Physics, toggle the collision mesh preview with F2, collision is hella buggy
1736
LastSession.t4jlog
|
Before Width: | Height: | Size: 3.6 MiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 286 KiB |
|
Before Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 266 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 225 KiB |
|
Before Width: | Height: | Size: 559 KiB |
|
Before Width: | Height: | Size: 884 KiB |
|
Before Width: | Height: | Size: 596 KiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 350 KiB |
|
Before Width: | Height: | Size: 481 KiB |
|
Before Width: | Height: | Size: 787 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 1 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 312 KiB |
|
Before Width: | Height: | Size: 855 KiB |
|
Before Width: | Height: | Size: 999 KiB |
|
Before Width: | Height: | Size: 1,022 KiB |
|
Before Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 288 KiB |
|
Before Width: | Height: | Size: 343 KiB |
|
Before Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 167 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 657 KiB |
|
Before Width: | Height: | Size: 519 KiB |
|
Before Width: | Height: | Size: 12 MiB |
|
Before Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 18 MiB |
|
Before Width: | Height: | Size: 490 KiB |
|
Before Width: | Height: | Size: 689 KiB |
|
Before Width: | Height: | Size: 664 KiB |
|
Before Width: | Height: | Size: 139 KiB |
|
Before Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 322 KiB |
|
Before Width: | Height: | Size: 383 KiB |
|
Before Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 690 KiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 2 MiB |
|
Before Width: | Height: | Size: 679 KiB |
|
Before Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 640 KiB |
|
Before Width: | Height: | Size: 642 KiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 604 KiB |
|
Before Width: | Height: | Size: 2.7 MiB |
|
|
@ -1,215 +0,0 @@
|
|||
{
|
||||
"ID": "forest",
|
||||
"Meshes": [
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.001_Background_Tree_Atlas_0_0",
|
||||
"MaterialID": "forest-mat-0",
|
||||
"OffsetVertex": 0,
|
||||
"VertexSize": 5860960,
|
||||
"OffsetIndex": 0,
|
||||
"IndexSize": 1125636
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.002_Metal_Fence_0_1",
|
||||
"MaterialID": "forest-mat-1",
|
||||
"OffsetVertex": 5860960,
|
||||
"VertexSize": 9184,
|
||||
"OffsetIndex": 1125636,
|
||||
"IndexSize": 984
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.003_Dirt_Road_Bare_0_2",
|
||||
"MaterialID": "forest-mat-2",
|
||||
"OffsetVertex": 5870144,
|
||||
"VertexSize": 13160,
|
||||
"OffsetIndex": 1126620,
|
||||
"IndexSize": 4740
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.004_Trunk_Birch_0_3",
|
||||
"MaterialID": "forest-mat-3",
|
||||
"OffsetVertex": 5883304,
|
||||
"VertexSize": 674016,
|
||||
"OffsetIndex": 1131360,
|
||||
"IndexSize": 155052
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.005_Wood_Log_0_4",
|
||||
"MaterialID": "forest-mat-4",
|
||||
"OffsetVertex": 6557320,
|
||||
"VertexSize": 56448,
|
||||
"OffsetIndex": 1286412,
|
||||
"IndexSize": 10584
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.006_Trunk_Oak_0_5",
|
||||
"MaterialID": "forest-mat-5",
|
||||
"OffsetVertex": 6613768,
|
||||
"VertexSize": 3659488,
|
||||
"OffsetIndex": 1296996,
|
||||
"IndexSize": 841836
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.007_Fallen_Generic_Leaves_0_6",
|
||||
"MaterialID": "forest-mat-6",
|
||||
"OffsetVertex": 10273256,
|
||||
"VertexSize": 379400,
|
||||
"OffsetIndex": 2138832,
|
||||
"IndexSize": 91788
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.008_Ground_Dirt_0_7",
|
||||
"MaterialID": "forest-mat-7",
|
||||
"OffsetVertex": 10652656,
|
||||
"VertexSize": 452032,
|
||||
"OffsetIndex": 2230620,
|
||||
"IndexSize": 41844
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.009_Forest_Bush_0_8",
|
||||
"MaterialID": "forest-mat-8",
|
||||
"OffsetVertex": 11104688,
|
||||
"VertexSize": 726992,
|
||||
"OffsetIndex": 2272464,
|
||||
"IndexSize": 102840
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.010_Grass_Vegetation_Dry_0_9",
|
||||
"MaterialID": "forest-mat-9",
|
||||
"OffsetVertex": 11831680,
|
||||
"VertexSize": 1873312,
|
||||
"OffsetIndex": 2375304,
|
||||
"IndexSize": 200712
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.011_Grass_Vegetation_Green_0_10",
|
||||
"MaterialID": "forest-mat-10",
|
||||
"OffsetVertex": 13704992,
|
||||
"VertexSize": 2930144,
|
||||
"OffsetIndex": 2576016,
|
||||
"IndexSize": 313512
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.012_Fallen_Maple_Leaves_0_11",
|
||||
"MaterialID": "forest-mat-11",
|
||||
"OffsetVertex": 16635136,
|
||||
"VertexSize": 583520,
|
||||
"OffsetIndex": 2889528,
|
||||
"IndexSize": 138060
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.013_Rock_Decal_0_12",
|
||||
"MaterialID": "forest-mat-12",
|
||||
"OffsetVertex": 17218656,
|
||||
"VertexSize": 861896,
|
||||
"OffsetIndex": 3027588,
|
||||
"IndexSize": 246348
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.014_Mud_Pile_0_13",
|
||||
"MaterialID": "forest-mat-13",
|
||||
"OffsetVertex": 18080552,
|
||||
"VertexSize": 48720,
|
||||
"OffsetIndex": 3273936,
|
||||
"IndexSize": 18108
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.015_Dirt_Road_Trails_0_14",
|
||||
"MaterialID": "forest-mat-14",
|
||||
"OffsetVertex": 18129272,
|
||||
"VertexSize": 169792,
|
||||
"OffsetIndex": 3292044,
|
||||
"IndexSize": 63504
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.016_Road_Edge_Gravel_Dusty_0_15",
|
||||
"MaterialID": "forest-mat-15",
|
||||
"OffsetVertex": 18299064,
|
||||
"VertexSize": 102368,
|
||||
"OffsetIndex": 3355548,
|
||||
"IndexSize": 37512
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.017_Puddle_Streaks_0_16",
|
||||
"MaterialID": "forest-mat-16",
|
||||
"OffsetVertex": 18401432,
|
||||
"VertexSize": 113848,
|
||||
"OffsetIndex": 3393060,
|
||||
"IndexSize": 44316
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.018_Wood_Fence_0_17",
|
||||
"MaterialID": "forest-mat-17",
|
||||
"OffsetVertex": 18515280,
|
||||
"VertexSize": 63280,
|
||||
"OffsetIndex": 3437376,
|
||||
"IndexSize": 8016
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.019_Sloped_Rock_0_18",
|
||||
"MaterialID": "forest-mat-18",
|
||||
"OffsetVertex": 18578560,
|
||||
"VertexSize": 1375640,
|
||||
"OffsetIndex": 3445392,
|
||||
"IndexSize": 123444
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.020_Terrain_Far_0_19",
|
||||
"MaterialID": "forest-mat-19",
|
||||
"OffsetVertex": 19954200,
|
||||
"VertexSize": 156184,
|
||||
"OffsetIndex": 3568836,
|
||||
"IndexSize": 31728
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.021_Aerial_Grass_0_20",
|
||||
"MaterialID": "forest-mat-20",
|
||||
"OffsetVertex": 20110384,
|
||||
"VertexSize": 1072624,
|
||||
"OffsetIndex": 3600564,
|
||||
"IndexSize": 128748
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.022_Tall_Cliff_0_21",
|
||||
"MaterialID": "forest-mat-21",
|
||||
"OffsetVertex": 21183008,
|
||||
"VertexSize": 1084664,
|
||||
"OffsetIndex": 3729312,
|
||||
"IndexSize": 93840
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.023_Cobblestone_0_22",
|
||||
"MaterialID": "forest-mat-22",
|
||||
"OffsetVertex": 22267672,
|
||||
"VertexSize": 114016,
|
||||
"OffsetIndex": 3823152,
|
||||
"IndexSize": 10860
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.024_Grass_Close_0_23",
|
||||
"MaterialID": "forest-mat-23",
|
||||
"OffsetVertex": 22381688,
|
||||
"VertexSize": 471184,
|
||||
"OffsetIndex": 3834012,
|
||||
"IndexSize": 87936
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.025_Dirt_Road_0_24",
|
||||
"MaterialID": "forest-mat-24",
|
||||
"OffsetVertex": 22852872,
|
||||
"VertexSize": 305928,
|
||||
"OffsetIndex": 3921948,
|
||||
"IndexSize": 120624
|
||||
},
|
||||
{
|
||||
"ID": "Background_Tree_Atlas.026_Broken_Rocks_0_25",
|
||||
"MaterialID": "forest-mat-25",
|
||||
"OffsetVertex": 23158800,
|
||||
"VertexSize": 632744,
|
||||
"OffsetIndex": 4042572,
|
||||
"IndexSize": 50736
|
||||
}
|
||||
],
|
||||
"VertexPath": "resources/models/Forest/forest.vtx",
|
||||
"IndexPath": "resources/models/Forest/forest.idx"
|
||||
}
|
||||
|
|
@ -1,380 +0,0 @@
|
|||
[
|
||||
{
|
||||
"ID": "forest-mat-0",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture0.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture2.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture1.png",
|
||||
"DiffuseColour": {
|
||||
"X": 0.3347269,
|
||||
"Y": 0.3347269,
|
||||
"Z": 0.3347269,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-1",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture4.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture6.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture5.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-2",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture7.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture9.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture8.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-3",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture10.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture12.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture11.png",
|
||||
"DiffuseColour": {
|
||||
"X": 0.8147891,
|
||||
"Y": 0.8147891,
|
||||
"Z": 0.8147891,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-4",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture13.png",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 0.9849378,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-5",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture14.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture16.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture15.png",
|
||||
"DiffuseColour": {
|
||||
"X": 0.9180937,
|
||||
"Y": 0.9180937,
|
||||
"Z": 0.9180937,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-6",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture17.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture19.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture18.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-7",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture20.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture22.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture21.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-8",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture23.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture24.png",
|
||||
"MetalRoughnessMap": "",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-9",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture25.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture27.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture26.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-10",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture28.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture27.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture26.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-11",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture29.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture31.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture30.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-12",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture32.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture34.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture33.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-13",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture35.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture37.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture36.png",
|
||||
"DiffuseColour": {
|
||||
"X": 0.79048216,
|
||||
"Y": 0.79048216,
|
||||
"Z": 0.79048216,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-14",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture38.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture40.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture39.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-15",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture41.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture43.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture42.png",
|
||||
"DiffuseColour": {
|
||||
"X": 0.6446405,
|
||||
"Y": 0.6446405,
|
||||
"Z": 0.6446405,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-16",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture44.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture46.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture45.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 0.7783287,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-17",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture47.png",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 0.9484773,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-18",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture48.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture50.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture49.png",
|
||||
"DiffuseColour": {
|
||||
"X": 0.74186826,
|
||||
"Y": 0.74186826,
|
||||
"Z": 0.74186826,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-19",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture51.png",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-20",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture52.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture54.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture53.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-21",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture55.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture57.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture56.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-22",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture58.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture60.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture59.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-23",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture61.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture63.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture62.png",
|
||||
"DiffuseColour": {
|
||||
"X": 0.8998634,
|
||||
"Y": 0.8998634,
|
||||
"Z": 0.8998634,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-24",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture64.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture66.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture65.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-25",
|
||||
"TexturePath": "resources\\models\\Forest\\ModelTexture67.png",
|
||||
"NormalTexturePath": "resources\\models\\Forest\\ModelTexture69.png",
|
||||
"MetalRoughnessMap": "resources\\models\\Forest\\ModelTexture68.png",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "forest-mat-26",
|
||||
"TexturePath": "",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 1.0
|
||||
}
|
||||
]
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
Dirt Road - 99.Miles on sketchfab
|
||||
https://sketchfab.com/3d-models/free-dirt-road-through-forest-c4676cdf7715484382400ff63faffd45
|
||||
|
||||
radio - TraianDumbrava on sketchfab
|
||||
https://sketchfab.com/3d-models/radio-d21d6bf783154170bfa6dc7ce0a208f1
|
||||
|
||||
Sponza - its self explanatory
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"ID": "MusicParticle",
|
||||
"Meshes": [
|
||||
{
|
||||
"ID": "plane_0",
|
||||
"MaterialID": "MusicParticle-mat-1",
|
||||
"OffsetVertex": 0,
|
||||
"VertexSize": 224,
|
||||
"OffsetIndex": 0,
|
||||
"IndexSize": 24
|
||||
}
|
||||
],
|
||||
"VertexPath": "resources/models/MusicParticle/MusicParticle.vtx",
|
||||
"IndexPath": "resources/models/MusicParticle/MusicParticle.idx"
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
# Made in Blockbench 5.1.4
|
||||
newmtl m_ce0c8b4a-552e-1f03-b22d-adf149492418
|
||||
map_Kd texture.png
|
||||
newmtl none
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# Made in Blockbench 5.1.4
|
||||
mtllib MusicParticle.mtl
|
||||
|
||||
o plane
|
||||
v 0.25 0.25 5.551115123125783e-17
|
||||
v 0.25 -0.25 -5.551115123125783e-17
|
||||
v -0.25 0.25 5.551115123125783e-17
|
||||
v -0.25 -0.25 -5.551115123125783e-17
|
||||
vt 1 0
|
||||
vt 1 1
|
||||
vt 0 1
|
||||
vt 0 0
|
||||
vn 0 2.220446049250313e-16 -1
|
||||
usemtl m_ce0c8b4a-552e-1f03-b22d-adf149492418
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
[
|
||||
{
|
||||
"ID": "MusicParticle-mat-0",
|
||||
"TexturePath": "",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"EmissiveMapPath": "",
|
||||
"DiffuseColour": {
|
||||
"X": 0.6,
|
||||
"Y": 0.6,
|
||||
"Z": 0.6,
|
||||
"W": 1.0
|
||||
},
|
||||
"EmissiveColour": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0,
|
||||
"Z": 0.0,
|
||||
"W": 0.0
|
||||
},
|
||||
"Roughness": 0.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "MusicParticle-mat-1",
|
||||
"TexturePath": "resources\\models\\MusicParticle\\texture.png",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"EmissiveMapPath": "",
|
||||
"DiffuseColour": {
|
||||
"X": 0.6,
|
||||
"Y": 0.6,
|
||||
"Z": 0.6,
|
||||
"W": 1.0
|
||||
},
|
||||
"EmissiveColour": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0,
|
||||
"Z": 0.0,
|
||||
"W": 0.0
|
||||
},
|
||||
"Roughness": 0.0,
|
||||
"Metallic": 0.0
|
||||
},
|
||||
{
|
||||
"ID": "MusicParticle-mat-2",
|
||||
"TexturePath": "",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"EmissiveMapPath": "",
|
||||
"DiffuseColour": {
|
||||
"X": 0.6,
|
||||
"Y": 0.6,
|
||||
"Z": 0.6,
|
||||
"W": 1.0
|
||||
},
|
||||
"EmissiveColour": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0,
|
||||
"Z": 0.0,
|
||||
"W": 0.0
|
||||
},
|
||||
"Roughness": 0.0,
|
||||
"Metallic": 0.0
|
||||
}
|
||||
]
|
||||
|
Before Width: | Height: | Size: 423 B |
|
Before Width: | Height: | Size: 325 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 497 KiB |
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"ID": "radio",
|
||||
"Meshes": [
|
||||
{
|
||||
"ID": "Radio_20 - Default_0_0",
|
||||
"MaterialID": "radio-mat-0",
|
||||
"OffsetVertex": 0,
|
||||
"VertexSize": 55776,
|
||||
"OffsetIndex": 0,
|
||||
"IndexSize": 10104
|
||||
}
|
||||
],
|
||||
"VertexPath": "resources/models/radio/radio.vtx",
|
||||
"IndexPath": "resources/models/radio/radio.idx"
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
[
|
||||
{
|
||||
"ID": "radio-mat-0",
|
||||
"TexturePath": "resources\\models\\radio\\ModelTexture0.png",
|
||||
"NormalTexturePath": "resources\\models\\radio\\ModelTexture2.png",
|
||||
"MetalRoughnessMap": "resources\\models\\radio\\ModelTexture1.png",
|
||||
"EmissiveMapPath": "",
|
||||
"DiffuseColour": {
|
||||
"X": 0.8042929,
|
||||
"Y": 0.8042929,
|
||||
"Z": 0.8042929,
|
||||
"W": 1.0
|
||||
},
|
||||
"EmissiveColour": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0,
|
||||
"Z": 0.0,
|
||||
"W": 0.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 1.0
|
||||
},
|
||||
{
|
||||
"ID": "radio-mat-1",
|
||||
"TexturePath": "",
|
||||
"NormalTexturePath": "",
|
||||
"MetalRoughnessMap": "",
|
||||
"EmissiveMapPath": "",
|
||||
"DiffuseColour": {
|
||||
"X": 1.0,
|
||||
"Y": 1.0,
|
||||
"Z": 1.0,
|
||||
"W": 1.0
|
||||
},
|
||||
"EmissiveColour": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0,
|
||||
"Z": 0.0,
|
||||
"W": 0.0
|
||||
},
|
||||
"Roughness": 1.0,
|
||||
"Metallic": 1.0
|
||||
}
|
||||
]
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Logic.Collision;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.primitives.AABBf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -10,41 +11,77 @@ import java.util.Map;
|
|||
public class CollisionManager {
|
||||
public static Map<String,CollisionMesh> CollisionMeshes = new HashMap<>();
|
||||
public static Map<String,List<String>> CollisionChunks = new HashMap<>();
|
||||
public static List<String> AlwaysCheckMeshes = new ArrayList<>();
|
||||
public static int ChunkWidth = 64;
|
||||
|
||||
public static void AddNewMesh(CollisionMesh mesh){
|
||||
CollisionMeshes.put(mesh.ID, mesh);
|
||||
Vector3f WorldPos = new Vector3f(mesh.WorldPosition).div(ChunkWidth);
|
||||
WorldPos.x = (int)Math.floor(WorldPos.x);
|
||||
WorldPos.y = (int)Math.floor(WorldPos.y);
|
||||
WorldPos.z = (int)Math.floor(WorldPos.z);
|
||||
String ChunkPosition = WorldPos.x + ":" + WorldPos.y + ":" + WorldPos.z;
|
||||
if(!CollisionChunks.containsKey(ChunkPosition)){
|
||||
AABBf Bounds = mesh.GetVoxelCollider();
|
||||
if(Bounds != null) {
|
||||
Vector3f LowestPoints = new Vector3f(Bounds.minX, Bounds.minY, Bounds.minZ).div(ChunkWidth);
|
||||
LowestPoints.x = (int) Math.floor(LowestPoints.x);
|
||||
LowestPoints.y = (int) Math.floor(LowestPoints.y);
|
||||
LowestPoints.z = (int) Math.floor(LowestPoints.z);
|
||||
Vector3f LargestPoints = new Vector3f(Bounds.maxX, Bounds.maxY, Bounds.maxZ).div(ChunkWidth);
|
||||
LargestPoints.x = (int) Math.ceil(LargestPoints.x);
|
||||
LargestPoints.y = (int) Math.ceil(LargestPoints.y);
|
||||
LargestPoints.z = (int) Math.ceil(LargestPoints.z);
|
||||
for (int x = (int) LowestPoints.x; x < LargestPoints.x + 1; x++) {
|
||||
for (int y = (int) LowestPoints.y; y < LargestPoints.y + 1; y++) {
|
||||
for (int z = (int) LowestPoints.z; z < LargestPoints.z + 1; z++) {
|
||||
String ChunkPosition = x + ":" + y + ":" + z;
|
||||
if (!CollisionChunks.containsKey(ChunkPosition)) {
|
||||
List<String> newStrList = new ArrayList<>();
|
||||
CollisionChunks.put(ChunkPosition, newStrList);
|
||||
}
|
||||
CollisionChunks.get(ChunkPosition).add(mesh.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else{
|
||||
AlwaysCheckMeshes.add(mesh.ID);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> GetCollisionMeshesAtChunk(String Chunk){
|
||||
return CollisionChunks.get(Chunk) == null ? new ArrayList<>() : CollisionChunks.get(Chunk);
|
||||
}
|
||||
|
||||
public static List<CollisionMesh> GetAllCollisionMeshes(){return CollisionMeshes.values().stream().toList();}
|
||||
|
||||
public static void UpdateCollisionChunks(){
|
||||
public static synchronized void UpdateCollisionChunks(){
|
||||
Map<String,List<String>> newMap = new HashMap<>();
|
||||
List<CollisionMesh> meshes = GetAllCollisionMeshes();
|
||||
List<String> AlwaysShowMesh = new ArrayList<>();
|
||||
for(int i = 0; i < meshes.size(); i++){
|
||||
Vector3f WorldPos = new Vector3f(meshes.get(i).WorldPosition).div(ChunkWidth);
|
||||
WorldPos.x = (int)Math.floor(WorldPos.x);
|
||||
WorldPos.y = (int)Math.floor(WorldPos.y);
|
||||
WorldPos.z = (int)Math.floor(WorldPos.z);
|
||||
String ChunkPosition = WorldPos.x + ":" + WorldPos.y + ":" + WorldPos.z;
|
||||
if(!newMap.containsKey(ChunkPosition)){
|
||||
CollisionMesh mesh = meshes.get(i);
|
||||
AABBf Bounds = mesh.GetVoxelCollider();
|
||||
if(Bounds != null) {
|
||||
Vector3f LowestPoints = new Vector3f(Bounds.minX, Bounds.minY, Bounds.minZ).div(ChunkWidth);
|
||||
LowestPoints.x = (int) Math.floor(LowestPoints.x);
|
||||
LowestPoints.y = (int) Math.floor(LowestPoints.y);
|
||||
LowestPoints.z = (int) Math.floor(LowestPoints.z);
|
||||
Vector3f LargestPoints = new Vector3f(Bounds.maxX, Bounds.maxY, Bounds.maxZ).div(ChunkWidth);
|
||||
LargestPoints.x = (int) Math.ceil(LargestPoints.x);
|
||||
LargestPoints.y = (int) Math.ceil(LargestPoints.y);
|
||||
LargestPoints.z = (int) Math.ceil(LargestPoints.z);
|
||||
for (int x = (int) LowestPoints.x; x < LargestPoints.x + 1; x++) {
|
||||
for (int y = (int) LowestPoints.y; y < LargestPoints.y + 1; y++) {
|
||||
for (int z = (int) LowestPoints.z; z < LargestPoints.z + 1; z++) {
|
||||
String ChunkPosition = x + ":" + y + ":" + z;
|
||||
if (!CollisionChunks.containsKey(ChunkPosition)) {
|
||||
List<String> newStrList = new ArrayList<>();
|
||||
newMap.put(ChunkPosition, newStrList);
|
||||
CollisionChunks.put(ChunkPosition, newStrList);
|
||||
}
|
||||
newMap.get(ChunkPosition).add(meshes.get(i).ID);
|
||||
|
||||
CollisionChunks.get(ChunkPosition).add(mesh.ID);
|
||||
}
|
||||
CollisionChunks.clear();
|
||||
CollisionChunks.putAll(newMap);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
AlwaysShowMesh.add(mesh.ID);
|
||||
}
|
||||
}
|
||||
AlwaysCheckMeshes = (AlwaysShowMesh);
|
||||
CollisionChunks = (newMap);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,57 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Logic.Collision;
|
||||
|
||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.Actor;
|
||||
import net.halbear.Terrain4J.EngineCore.Main.Util.Maths.T4Math;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.VertexBufferStructure;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.VkModel.MeshData;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.VkModel.ModelData;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.VkModel.VulkanMesh;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.VkModel.VulkanModel;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Util.VulkanUtils;
|
||||
import org.joml.Intersectionf;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
import org.joml.primitives.AABBf;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.LongBuffer;
|
||||
import java.util.*;
|
||||
|
||||
public class CollisionMesh {
|
||||
public final List<CollisionPoly> Polygons;
|
||||
public Vector3f TopLeftFront = new Vector3f(0,0,0);
|
||||
public Vector3f BottomRightBack = new Vector3f(0,0,0);
|
||||
public Vector3f TopRightFront = new Vector3f(0,0,0);
|
||||
public Vector3f BottomLeftBack = new Vector3f(0,0,0);
|
||||
public Vector3f WorldPosition = new Vector3f(0,0,0);
|
||||
public Quaternionf Rotation;
|
||||
public Vector3f Scale;
|
||||
public Quaternionf Rotation = new Quaternionf();
|
||||
public Vector3f Scale = new Vector3f(1f,1f,1f);
|
||||
public final String ID;
|
||||
public CollisionMesh(String ID){
|
||||
public final String ParentID;
|
||||
public AABBf Voxel;
|
||||
|
||||
public CollisionMesh(String ID, String ActorID){
|
||||
this.ID = ID;
|
||||
if(ActorID != "NULL") {
|
||||
Scale = new Vector3f(Actor.Actors.get(ActorID).GetScale());
|
||||
Rotation = new Quaternionf(Actor.Actors.get(ActorID).GetRotation());
|
||||
}
|
||||
ParentID = ActorID;
|
||||
Polygons = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void RegisterMesh(){
|
||||
CollisionManager.AddNewMesh(this);
|
||||
}
|
||||
|
||||
public AABBf GetVoxelCollider(){
|
||||
if(TopRightFront == null || BottomLeftBack == null) return null;
|
||||
if(Voxel == null){
|
||||
Vector3f TLF = new Vector3f(TopRightFront);
|
||||
Vector3f BRB = new Vector3f(BottomLeftBack);
|
||||
TLF = TLF.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
BRB = BRB.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
AABBf ThisVoxel = new AABBf(BRB,TLF);
|
||||
this.Voxel = ThisVoxel;
|
||||
}
|
||||
return Voxel;
|
||||
}
|
||||
|
||||
public CollisionMesh SetWorldPosition(Vector3f newPos){
|
||||
this.WorldPosition = new Vector3f(newPos);
|
||||
return this;
|
||||
|
|
@ -107,37 +127,71 @@ public class CollisionMesh {
|
|||
}
|
||||
|
||||
public void CheckAABbounds(Vector3f v1, Vector3f v2, Vector3f v3){
|
||||
float Bottom = Math.min(Math.min(v3.y, v1.y), Math.min(v3.y, v2.y));
|
||||
float Left = Math.min(Math.min(v3.x, v1.x), Math.min(v3.x, v2.x));
|
||||
float back = Math.min(Math.min(v3.z, v1.z), Math.min(v3.z, v2.z));
|
||||
float Top = Math.max(Math.max(v3.y, v1.y), Math.max(v3.y, v2.y));
|
||||
float Right = Math.max(Math.max(v3.x, v1.x), Math.max(v3.x, v2.x));
|
||||
float Front = Math.max(Math.max(v3.z, v1.z), Math.max(v3.z, v2.z));
|
||||
TopLeftFront.x = Math.min(TopLeftFront.x, Left);
|
||||
TopLeftFront.y = Math.max(TopLeftFront.y, Top);
|
||||
TopLeftFront.z = Math.max(TopLeftFront.z, Front);
|
||||
BottomRightBack.x = Math.max(BottomRightBack.x, Right);
|
||||
BottomRightBack.y = Math.min(BottomRightBack.y, Bottom);
|
||||
BottomRightBack.z = Math.min(BottomRightBack.z, back);
|
||||
float localMinX = Math.min(v1.x, Math.min(v2.x, v3.x));
|
||||
float localMinY = Math.min(v1.y, Math.min(v2.y, v3.y));
|
||||
float localMinZ = Math.min(v1.z, Math.min(v2.z, v3.z));
|
||||
float localMaxX = Math.max(v1.x, Math.max(v2.x, v3.x));
|
||||
float localMaxY = Math.max(v1.y, Math.max(v2.y, v3.y));
|
||||
float localMaxZ = Math.max(v1.z, Math.max(v2.z, v3.z));
|
||||
TopRightFront.x = Math.max(TopRightFront.x, localMaxX);
|
||||
TopRightFront.y = Math.max(TopRightFront.y, localMaxY);
|
||||
TopRightFront.z = Math.max(TopRightFront.z, localMaxZ);
|
||||
BottomLeftBack.x = Math.min(BottomLeftBack.x, localMinX);
|
||||
BottomLeftBack.y = Math.min(BottomLeftBack.y, localMinY);
|
||||
BottomLeftBack.z = Math.min(BottomLeftBack.z, localMinZ);
|
||||
}
|
||||
|
||||
public void AddNewCollisionPoly(Vector3f v1, Vector3f v2, Vector3f v3){
|
||||
// if(Actor.Actors.get(ParentID) != null) {
|
||||
// PhysicsController physicsController = Actor.Actors.get(ParentID).GetPhysicsController();
|
||||
// if (physicsController != null) {
|
||||
// physicsController.AddCollisionSensor(v1);
|
||||
// physicsController.AddCollisionSensor(v2);
|
||||
// physicsController.AddCollisionSensor(v3);
|
||||
// }
|
||||
// }
|
||||
CollisionPoly newPoly = new CollisionPoly(v1,v2,v3,new Vector3f(0,0,0));
|
||||
newPoly.CalculateCentre();
|
||||
Polygons.add(newPoly);
|
||||
CheckAABbounds(v1,v2,v3);
|
||||
}
|
||||
|
||||
public boolean CheckAABBCollisionAgainstAABB(Vector3f inTopLeftFront, Vector3f inBottomRightBack){
|
||||
AABBf OtherVoxel = new AABBf(inBottomRightBack,inTopLeftFront);
|
||||
Vector3f TLF = new Vector3f(TopRightFront);
|
||||
Vector3f BRB = new Vector3f(BottomLeftBack);
|
||||
TLF = TLF.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
BRB = BRB.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
AABBf ThisVoxel = new AABBf(BRB,TLF);
|
||||
this.Voxel = ThisVoxel;
|
||||
return ThisVoxel.intersectsAABB(OtherVoxel);
|
||||
}
|
||||
|
||||
public boolean CheckAABBCollisionAgainstAABB(AABBf OtherVoxel){
|
||||
Vector3f TLF = new Vector3f(TopRightFront);
|
||||
Vector3f BRB = new Vector3f(BottomLeftBack);
|
||||
TLF = TLF.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
BRB = BRB.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
AABBf ThisVoxel = new AABBf(BRB,TLF);
|
||||
this.Voxel = ThisVoxel;
|
||||
return ThisVoxel.intersectsAABB(OtherVoxel);
|
||||
}
|
||||
|
||||
public boolean CheckAABCollision(Vector3f Origin, Vector3f Sensor){
|
||||
Vector3f LineDirection = new Vector3f(Sensor).sub(Origin);
|
||||
Vector2f Result = new Vector2f();
|
||||
return Intersectionf.intersectRayAab(Origin, LineDirection,BottomRightBack,TopLeftFront,Result) && Result.x <= 1.0f && Result.y >= 0.0f;
|
||||
Vector3f TLF = new Vector3f(TopRightFront);
|
||||
Vector3f BRB = new Vector3f(BottomLeftBack);
|
||||
TLF = TLF.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
BRB = BRB.mul(Scale).rotate(Rotation).add(WorldPosition);
|
||||
AABBf ThisVoxel = new AABBf(BRB,TLF);
|
||||
return Intersectionf.intersectRayAab(Origin, LineDirection,BRB,TLF,Result) && Result.x <= 1.0f && Result.y >= 0.0f;
|
||||
}
|
||||
|
||||
public boolean SimpleCheckCollision(Vector3f Origin, Vector3f Sensor){
|
||||
Vector3f LineDirection = new Vector3f(Sensor).sub(Origin);
|
||||
Vector2f Result = new Vector2f(0,0);
|
||||
if(Intersectionf.intersectRayAab(Origin, LineDirection,BottomRightBack,TopLeftFront,Result) && Result.x <= 1.0f && Result.y >= 0.0f){
|
||||
if(Intersectionf.intersectRayAab(Origin, LineDirection, BottomLeftBack, TopRightFront,Result) && Result.x <= 1.0f && Result.y >= 0.0f){
|
||||
for(int i = 0; i < Polygons.size(); i++){
|
||||
CollisionPoly polygon = Polygons.get(i);
|
||||
if(T4Math.Math3D.DoesLineCollideWithPoly(Origin,Sensor,new Vector3f[]{polygon.v1(),polygon.v2(),polygon.v3()})){
|
||||
|
|
@ -151,18 +205,20 @@ public class CollisionMesh {
|
|||
public CollisionPoly[] GetAllPolygons(){
|
||||
int Rows = Polygons.size();
|
||||
CollisionPoly[] PolygonArr = new CollisionPoly[Rows * 3];
|
||||
Vector3f PivotOffset = Actor.Actors.get(ParentID) != null ? new Vector3f(Actor.Actors.get(ParentID).GetPivotOffset()).add(Actor.Actors.get(ParentID).GetAditionalPivotOffset()) : new Vector3f(0,0,0);
|
||||
for(int row = 0; row < Rows; row++){
|
||||
PolygonArr[row] = Polygons.get(row).TransformScale(Scale).TransformRotation(Rotation).TransformPosition(WorldPosition);
|
||||
PolygonArr[row] = Polygons.get(row).TransformScale(Scale).TransformPosition(PivotOffset).TransformRotation(Rotation).TransformPosition(PivotOffset.negate()).TransformPosition(WorldPosition);
|
||||
}
|
||||
return PolygonArr;
|
||||
}
|
||||
|
||||
public Vector3f[] GetAllVertices(){
|
||||
int Rows = Polygons.size();
|
||||
Vector3f PivotOffset = Actor.Actors.get(ParentID) != null ? new Vector3f(Actor.Actors.get(ParentID).GetPivotOffset()).add(Actor.Actors.get(ParentID).GetAditionalPivotOffset()) : new Vector3f(0,0,0);
|
||||
Vector3f[] Vertices = new Vector3f[Rows * 3];
|
||||
for(int row = 0; row < Rows; row++){
|
||||
int StartPos = row * 3;
|
||||
CollisionPoly poly = Polygons.get(row).TransformScale(Scale).TransformRotation(Rotation).TransformPosition(WorldPosition);
|
||||
CollisionPoly poly = Polygons.get(row).TransformScale(Scale).TransformPosition(PivotOffset).TransformRotation(Rotation).TransformPosition(PivotOffset.negate()).TransformPosition(WorldPosition);
|
||||
Vertices[StartPos] = new Vector3f(poly.v1().x,poly.v1().y,poly.v1().z);
|
||||
Vertices[StartPos + 1] = new Vector3f(poly.v2().x,poly.v2().y,poly.v2().z);
|
||||
Vertices[StartPos + 2] = new Vector3f(poly.v3().x,poly.v3().y,poly.v3().z);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Logic.Physics;
|
||||
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionPoly;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public record CollisionSensor(Vector3f Offset, String ActorID) {
|
||||
public CollisionSensor TransformRotation(Quaternionf quaternionf){
|
||||
if(quaternionf == null ) return this;
|
||||
Vector3f newV1 = new Vector3f(Offset);
|
||||
newV1.rotate(quaternionf);
|
||||
CollisionSensor newPoly = new CollisionSensor(newV1,ActorID);
|
||||
return newPoly;
|
||||
}
|
||||
public CollisionSensor TransformScale(Vector3f Scale){
|
||||
if(Scale == null ) return this;
|
||||
Vector3f newV1 = new Vector3f(Offset);
|
||||
newV1.mul(Scale);
|
||||
CollisionSensor newPoly = new CollisionSensor(newV1,ActorID);
|
||||
return newPoly;
|
||||
}
|
||||
public CollisionSensor TransformPosition(Vector3f Position){
|
||||
if(Position == null ) return this;
|
||||
Vector3f newV1 = new Vector3f(Offset);
|
||||
newV1.add(Position);
|
||||
CollisionSensor newPoly = new CollisionSensor(newV1,ActorID);
|
||||
return newPoly;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Logic.Physics;
|
||||
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionManager;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionMesh;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionPoly;
|
||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.Actor;
|
||||
import net.halbear.Terrain4J.EngineCore.Main.Util.Maths.T4Math;
|
||||
import org.joml.Vector3f;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionManager.ChunkWidth;
|
||||
|
||||
public class PhysicsController {
|
||||
|
||||
public List<CollisionSensor> collisionSensors;
|
||||
public Vector3f Velocities = new Vector3f(0,0,0);
|
||||
public Vector3f WeightBalance = new Vector3f(0,0,0);
|
||||
public float MassKG = 10.0f;
|
||||
public Vector3f TerminalVelocitiesMS = new Vector3f(36f,6.6f,36f);
|
||||
public Vector3f Drag = new Vector3f(0.2f,0.2f,0.2f);
|
||||
public Vector3f DragCoefficients = new Vector3f(0.1f,0.1f,0.1f);
|
||||
public Vector3f CrossSectionAreas = new Vector3f(1.8f * 0.9f, 0.6f * 0.9f, 1.8f * 0.6f);
|
||||
public Vector3f WeightDistribution = new Vector3f(2.0f,5.0f,7.0f);
|
||||
public float FallingAcceleration = 0.0f;
|
||||
public float Bounciness = 0.3f;
|
||||
String CurrentChunkPosition = "NULL";
|
||||
|
||||
public void CalculateDragCoefficients(){
|
||||
Vector3f dragCoefficients = WorldPhysicsManager.CalculateDragFromTerminalVelocities(TerminalVelocitiesMS,MassKG,CrossSectionAreas);
|
||||
this.DragCoefficients = new Vector3f(dragCoefficients);
|
||||
}
|
||||
public void CalculateDrag(){
|
||||
Vector3f drag = WorldPhysicsManager.CalculateRealDrag(Velocities,DragCoefficients,CrossSectionAreas);
|
||||
this.Drag = new Vector3f(drag);
|
||||
}
|
||||
public void CalculateFallSpeed(){
|
||||
FallingAcceleration = WorldPhysicsManager.CalculateGravityForce(MassKG, Drag);
|
||||
}
|
||||
|
||||
public final String ID;
|
||||
public final String ParentID;
|
||||
|
||||
public PhysicsController(String ActorID){
|
||||
collisionSensors = new ArrayList<>();
|
||||
ID = ActorID + "_PHYSICS_CONTROLLER";
|
||||
ParentID = ActorID;
|
||||
WorldPhysicsManager.PhysicsObjects.put(ID, this);
|
||||
WorldPhysicsManager.ActiveControllers.add(ID);
|
||||
Actor actor = Actor.Actors.get(ParentID);
|
||||
Vector3f WorldPos = new Vector3f(actor.GetPosition()).div(ChunkWidth);
|
||||
WorldPos.x = (int)Math.floor(WorldPos.x);
|
||||
WorldPos.y = (int)Math.floor(WorldPos.y);
|
||||
WorldPos.z = (int)Math.floor(WorldPos.z);
|
||||
CurrentChunkPosition = WorldPos.x + ":" + WorldPos.y + ":" + WorldPos.z;
|
||||
CalculateDragCoefficients();
|
||||
}
|
||||
|
||||
public PhysicsController AddCollisionSensor(Vector3f RelativeOffset){
|
||||
collisionSensors.add(new CollisionSensor(RelativeOffset, ParentID));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void PhysicsTick(float DeltaTime, float TargetFrameRate){
|
||||
Actor actor = Actor.Actors.get(ParentID);
|
||||
Vector3f Position = new Vector3f(actor.GetPosition());
|
||||
Vector3f NextPosition = new Vector3f(Position);
|
||||
Vector3f Velocity = new Vector3f(Velocities);
|
||||
Velocity = Velocity.mul(DeltaTime);
|
||||
NextPosition.add(Velocity);
|
||||
boolean ValidMovement = true;
|
||||
CalculateDrag();
|
||||
CalculateFallSpeed();
|
||||
Velocities.y -= (FallingAcceleration/(TargetFrameRate*2)) * DeltaTime;
|
||||
Velocities = Velocities.mul((1f - (WorldPhysicsManager.Drag * (DeltaTime))),1f,(1f - (WorldPhysicsManager.Drag * (DeltaTime))));
|
||||
if(collisionSensors != null && !collisionSensors.isEmpty()) {
|
||||
// Vector3f WorldPos = new Vector3f(NextPosition).div(ChunkWidth);
|
||||
// WorldPos.x = (int) Math.floor(WorldPos.x);
|
||||
// WorldPos.y = (int) Math.floor(WorldPos.y);
|
||||
// WorldPos.z = (int) Math.floor(WorldPos.z);
|
||||
// String NextChunkPosition = WorldPos.x + ":" + WorldPos.y + ":" + WorldPos.z;
|
||||
// List<String> CollisionMeshesToCycleThrough = new ArrayList<>(CollisionManager.AlwaysCheckMeshes);
|
||||
// CollisionMeshesToCycleThrough.addAll(CollisionManager.GetCollisionMeshesAtChunk(NextChunkPosition));
|
||||
// if (!NextChunkPosition.equals(CurrentChunkPosition)) {
|
||||
// CollisionMeshesToCycleThrough.addAll(CollisionManager.GetCollisionMeshesAtChunk(CurrentChunkPosition));
|
||||
// CurrentChunkPosition = NextChunkPosition;
|
||||
// }
|
||||
// Logger.debug(CollisionMeshesToCycleThrough.size());
|
||||
List<CollisionMesh> CollisionMeshesToCycleThrough = CollisionManager.GetAllCollisionMeshes();
|
||||
//Logger.debug("Collision Mesh Count [{}]",CollisionMeshesToCycleThrough.size());
|
||||
Vector3f PivotOffset = Actor.Actors.get(ParentID) != null ? new Vector3f(Actor.Actors.get(ParentID).GetPivotOffset()).add(Actor.Actors.get(ParentID).GetAditionalPivotOffset()) : new Vector3f(0,0,0);
|
||||
List<CollisionSensor> CollidingSensors = new ArrayList<>();
|
||||
for (int j = 0; j < collisionSensors.size(); j++) {
|
||||
CollidingSensors.add(collisionSensors.get(j).TransformScale(actor.GetScale()).TransformPosition(PivotOffset).TransformRotation(actor.GetRotation()).TransformPosition(PivotOffset.negate()).TransformPosition(NextPosition));
|
||||
}
|
||||
if(CollidingSensors.size() > 0){
|
||||
for(int i = 0; i < CollisionMeshesToCycleThrough.size(); i++){
|
||||
CollisionMesh collisionMesh = CollisionMeshesToCycleThrough.get(i);
|
||||
if(collisionMesh != null && !Objects.equals(collisionMesh.ID, actor.GetCollisionMesh().ID) && collisionMesh.CheckAABBCollisionAgainstAABB(collisionMesh.GetVoxelCollider())) {
|
||||
CollisionPoly[] polygons = collisionMesh.GetAllPolygons();
|
||||
for(int j = 0; j < polygons.length; j++){
|
||||
CollisionPoly poly = polygons[j];
|
||||
if(poly != null) {
|
||||
for (int k = 0; k < CollidingSensors.size(); k++) {
|
||||
Vector3f CollisionPoint = T4Math.Math3D.LineCollisionPointWithPoly(NextPosition, CollidingSensors.get(k).Offset(), new Vector3f[]{poly.v1(), poly.v2(), poly.v3()});
|
||||
if (CollisionPoint != null) {
|
||||
Vector3f subtraction = new Vector3f(NextPosition).sub(CollisionPoint);
|
||||
if(Math.abs(subtraction.x) > 0.1f && Math.abs(subtraction.z) > 0.1f) {
|
||||
NextPosition.sub(new Vector3f(NextPosition).sub(CollisionPoint));
|
||||
} else {
|
||||
NextPosition.sub(0,new Vector3f(NextPosition).sub(CollisionPoint).y,0);
|
||||
}
|
||||
Velocities.y = -Velocities.y * Bounciness;
|
||||
if(Math.abs(Velocities.y) < 0.05f) Velocities.y = 0;
|
||||
ValidMovement = false;
|
||||
}
|
||||
if(!ValidMovement)break;
|
||||
}
|
||||
}
|
||||
if(!ValidMovement)break;
|
||||
}
|
||||
}
|
||||
if(!ValidMovement)break;
|
||||
}
|
||||
}
|
||||
}
|
||||
actor.SetPosition(NextPosition);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Logic.Physics;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldPhysicsManager {
|
||||
public static float GravityMS = 9.8f;
|
||||
public static float AirResistance = 0.5f;
|
||||
public static float Drag = 0.02f;
|
||||
public static float AirDensityKGM3 = 1.225f;
|
||||
|
||||
public static Vector3f CalculateRealDrag(Vector3f Velocity, Vector3f DragCoefficients, Vector3f CrossSectionAreas){
|
||||
float XDrag = 0.5f * (AirDensityKGM3 * Velocity.x * Velocity.x * DragCoefficients.x * CrossSectionAreas.x);
|
||||
float YDrag = 0.5f * (AirDensityKGM3 * Velocity.y * Velocity.y * DragCoefficients.y * CrossSectionAreas.y);
|
||||
float ZDrag = 0.5f * (AirDensityKGM3 * Velocity.z * Velocity.z * DragCoefficients.z * CrossSectionAreas.z);
|
||||
return new Vector3f(XDrag,YDrag,ZDrag);
|
||||
}
|
||||
|
||||
public static float CalculateGravityForce(float Mass, Vector3f Drag){
|
||||
return ((Mass * GravityMS) - Drag.y)/Mass;
|
||||
}
|
||||
|
||||
public static Vector3f CalculateDragFromTerminalVelocities(Vector3f TerminalVelocities, float Mass, Vector3f CrossSectionAreas){
|
||||
float Cdx = (2 * Mass * GravityMS) / (AirDensityKGM3 * TerminalVelocities.x * TerminalVelocities.x * CrossSectionAreas.x);
|
||||
float Cdy = (2 * Mass * GravityMS) / (AirDensityKGM3 * TerminalVelocities.y * TerminalVelocities.y * CrossSectionAreas.y);
|
||||
float Cdz = (2 * Mass * GravityMS) / (AirDensityKGM3 * TerminalVelocities.z * TerminalVelocities.z * CrossSectionAreas.z);
|
||||
return new Vector3f(Cdx, Cdy, Cdz);
|
||||
}
|
||||
|
||||
public static final Map<String, PhysicsController> PhysicsObjects = new HashMap<>();
|
||||
public static List<String> ActiveControllers = new ArrayList<>();
|
||||
|
||||
public static void PhysicsTick(float DeltaTime, float TargetFrameTime){
|
||||
for(int i = 0; i < ActiveControllers.size(); i++){
|
||||
PhysicsObjects.get(ActiveControllers.get(i)).PhysicsTick(DeltaTime, TargetFrameTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,11 +12,13 @@ import net.halbear.Terrain4J.EngineCore.Audio.SoundListener;
|
|||
import net.halbear.Terrain4J.EngineCore.Display.Window;
|
||||
import net.halbear.Terrain4J.EngineCore.Input.KeyboardInput;
|
||||
import net.halbear.Terrain4J.EngineCore.Input.MouseListener;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionManager;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionMesh;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.EngineConfig;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.EngineInstance;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.GameLogic;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.InitData;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Physics.WorldPhysicsManager;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Rendering.ModelLoader;
|
||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.*;
|
||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.GUIs.Gimbal;
|
||||
|
|
@ -78,14 +80,32 @@ public class GameCore implements GameLogic {
|
|||
MelonaData = ModelLoader.LoadModel("resources/models/melona/melona.json");
|
||||
List<MaterialData> MelonaDataMat = ModelLoader.LoadMaterials("resources/models/melona/melona_mat.json");
|
||||
var Melona = new Actor("Melona", MelonaData.ID(), new Vector3f(0,0f,-5f)).SetRotation(0,(float)Math.toRadians(180),0);
|
||||
CollisionMesh mesh = new CollisionMesh("Super Collision Mesh");
|
||||
mesh.AddNewCollisionPoly(new Vector3f(-100,-5,0),new Vector3f(-100,-5,-100),new Vector3f(0,-5,-100));
|
||||
mesh.AddNewCollisionPoly(new Vector3f(0,-5,0),new Vector3f(0,-5,-100),new Vector3f(-100,-5,0));
|
||||
Melona.CreatePhysicsController();
|
||||
Melona.GetPhysicsController()
|
||||
.AddCollisionSensor(new Vector3f(0,0,0))
|
||||
.AddCollisionSensor(new Vector3f(0,1.8f,0))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,0,0))
|
||||
.AddCollisionSensor(new Vector3f(-0.5f,0,0))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,1.8f,0))
|
||||
.AddCollisionSensor(new Vector3f(-5f,1.8f,0))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,1.8f,0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0.5f,1.8f,0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0.5f,1.8f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,1.8f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(0f,1.8f,0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0f,1.8f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0f,0f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(0f,0f,0.5f));
|
||||
|
||||
CollisionMesh mesh = new CollisionMesh("Super Collision Mesh","NULL");
|
||||
mesh.AddNewCollisionPoly(new Vector3f(-100,-5,100),new Vector3f(-100,-5.5f,-100),new Vector3f(100,-6,-100));
|
||||
mesh.AddNewCollisionPoly(new Vector3f(100,-5.5f,100),new Vector3f(100,-6,-100),new Vector3f(-100,-5,100));
|
||||
try {
|
||||
Melona.GenerateCollisionMesh(MelonaData);
|
||||
} catch(IOException e){
|
||||
Logger.error("Could Not Generate Collison Mesh [{}]",e);
|
||||
}
|
||||
mesh.RegisterMesh();
|
||||
scene.AddActor(Melona);
|
||||
ActorEditorComponents.add(new EditorActorComponent(Melona,new Vector3f(0,0f,-5f),new Vector3f(1.0f,1.8f,1.0f)));
|
||||
CubeActors.forEach(scene::AddActor);
|
||||
|
|
@ -127,7 +147,26 @@ public class GameCore implements GameLogic {
|
|||
|
||||
public void SpawnNewActorEditorComponent(EngineInstance engineInstance){
|
||||
var scene = engineInstance.scene();
|
||||
var Melona = new Actor("Melona" + scene.GetActors().size(), MelonaData.ID(), new Vector3f(scene.GetCamera().GetPosition())).SetRotation(new Vector3f(scene.GetCamera().GetRotation()));
|
||||
Camera camera = scene.GetCamera().CloneCamera();
|
||||
camera.MoveForward(5);
|
||||
var Melona = new Actor("MelonaSpawned" + scene.GetActors().size(), MelonaData.ID(), new Vector3f(camera.GetPosition()));
|
||||
camera = null;
|
||||
Melona.CreatePhysicsController();
|
||||
Melona.GetPhysicsController()
|
||||
.AddCollisionSensor(new Vector3f(0,0,0))
|
||||
.AddCollisionSensor(new Vector3f(0,1.8f,0))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,0,0))
|
||||
.AddCollisionSensor(new Vector3f(-0.5f,0,0))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,1.8f,0))
|
||||
.AddCollisionSensor(new Vector3f(-5f,1.8f,0))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,1.8f,0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0.5f,1.8f,0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0.5f,1.8f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(0.5f,1.8f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(0f,1.8f,0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0f,1.8f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(-0f,0f,-0.5f))
|
||||
.AddCollisionSensor(new Vector3f(0f,0f,0.5f));
|
||||
try {
|
||||
Melona.GenerateCollisionMesh(MelonaData);
|
||||
} catch(IOException e){
|
||||
|
|
@ -196,7 +235,7 @@ public class GameCore implements GameLogic {
|
|||
KeyboardInput input = window.getKeyboardInput();
|
||||
float MovementDist = (float)(FrameDiffNanoSeconds / 1000000L) * MOVEMENT_SPEED;
|
||||
Camera camera = scene.GetCamera();
|
||||
if(input.keyPressed(GLFW_KEY_F3)){
|
||||
if(input.keySinglePress(GLFW_KEY_F3)){
|
||||
GUI_MODE = (GUI_MODE + 1) % 2;
|
||||
}
|
||||
if(input.keyPressed(GLFW_KEY_1)) {
|
||||
|
|
@ -208,6 +247,14 @@ public class GameCore implements GameLogic {
|
|||
if(input.keyPressed(GLFW_KEY_3)) {
|
||||
Gimbal.universalType = Gimbal.GimbalType.Rotate;
|
||||
}
|
||||
if(input.keyPressed(GLFW_KEY_TAB)){
|
||||
for(int i = 0; i < ActorEditorComponents.size(); i++){
|
||||
ActorEditorComponents.get(i).UpdateAll();
|
||||
}
|
||||
}
|
||||
if(input.keySinglePress(GLFW_KEY_F2)) {
|
||||
EngineConfig.getInstance().SetRenderCollisionMesh(!EngineConfig.getInstance().RenderCollisionMeshes());
|
||||
}
|
||||
if(input.keyPressed(GLFW_KEY_W)){
|
||||
camera.MoveForward(MovementDist);
|
||||
}
|
||||
|
|
@ -269,10 +316,18 @@ public class GameCore implements GameLogic {
|
|||
|
||||
@Override
|
||||
public void Update(EngineInstance engineInstance, long FrameDiffNanoSeconds) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateFastThread(EngineInstance engineInstance, long FrameDiffNanoSeconds) {
|
||||
float PhysicsFramerate = 24f;
|
||||
float PhysicsFrameTime = 1000f/PhysicsFramerate;
|
||||
float DeltaTime = (float)FrameDiffNanoSeconds/(PhysicsFrameTime*1000000f);
|
||||
if(PrimaryRuntime.GetFastThread().Ticks(20)==0){
|
||||
//CollisionManager.UpdateCollisionChunks();
|
||||
}
|
||||
WorldPhysicsManager.PhysicsTick(DeltaTime, PhysicsFramerate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Main.Scene;
|
||||
|
||||
import imgui.extension.imguizmo.flag.Mode;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Collision.CollisionMesh;
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.Physics.PhysicsController;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.VkModel.ModelData;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Actor{
|
||||
public static final Map<String, Actor> Actors = new HashMap<>();
|
||||
private final String ID;
|
||||
private final String ModelID;
|
||||
private final Matrix4f ModelMatrix;
|
||||
|
|
@ -16,6 +21,10 @@ public class Actor{
|
|||
private final Quaternionf Rotation;
|
||||
private CollisionMesh collisionMesh;
|
||||
private Vector3f Scale;
|
||||
private PhysicsController physicsController;
|
||||
private final Vector3f PivotOffset;
|
||||
private final Vector3f AdditionalPivotOffset;
|
||||
private final Vector3f TemporaryVector;
|
||||
|
||||
public CollisionMesh GetCollisionMesh(){
|
||||
return collisionMesh;
|
||||
|
|
@ -25,15 +34,41 @@ public class Actor{
|
|||
this.ID = ID;
|
||||
this.ModelID = ModelID;
|
||||
this.Position = Position;
|
||||
TemporaryVector = new Vector3f();
|
||||
PivotOffset = new Vector3f();
|
||||
AdditionalPivotOffset = new Vector3f();
|
||||
Scale = new Vector3f(1f,1f,1f);
|
||||
Rotation = new Quaternionf();
|
||||
ModelMatrix = new Matrix4f();
|
||||
UpdateModelMatrix();
|
||||
Actors.put(ID,this);
|
||||
}
|
||||
|
||||
public Vector3f GetAditionalPivotOffset(){return AdditionalPivotOffset;}
|
||||
|
||||
public Actor SetAditionalPivotOffset(Vector3f offset){
|
||||
AdditionalPivotOffset.set(offset);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3f GetPivotOffset(){return PivotOffset;}
|
||||
|
||||
public Actor SetPivotOffset(Vector3f offset){
|
||||
PivotOffset.set(offset);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PhysicsController GetPhysicsController(){return physicsController;}
|
||||
|
||||
public Actor CreatePhysicsController(){
|
||||
physicsController = new PhysicsController(ID);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Actor GenerateCollisionMesh(ModelData modelData) throws IOException {
|
||||
collisionMesh = new CollisionMesh(ID + "_COLLISION_MESH");
|
||||
collisionMesh = new CollisionMesh(ID + "_COLLISION_MESH", ID);
|
||||
collisionMesh.GenerateCollisionMeshFromVulkanModel(modelData);
|
||||
collisionMesh.RegisterMesh();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +94,12 @@ public class Actor{
|
|||
UpdateModelMatrix();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Actor SetPosition(Vector3f position){
|
||||
Position.set(position);
|
||||
UpdateModelMatrix();
|
||||
if(collisionMesh != null)collisionMesh.SetWorldPosition(Position);
|
||||
return this;
|
||||
}
|
||||
public Actor SetPosition(float x, float y, float z){
|
||||
Position.x = x;
|
||||
Position.y = y;
|
||||
|
|
@ -83,7 +123,10 @@ public class Actor{
|
|||
}
|
||||
|
||||
public void UpdateModelMatrix(){
|
||||
ModelMatrix.translateLocal(TemporaryVector.set(PivotOffset).add(AdditionalPivotOffset));
|
||||
ModelMatrix.translationRotateScale(Position, Rotation, Scale);
|
||||
ModelMatrix.translateLocal(TemporaryVector.negate());
|
||||
|
||||
}
|
||||
|
||||
public String GetID(){return ID;}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,18 @@ public class Camera {
|
|||
private final Matrix4f ViewMatrix;
|
||||
private float FOV = (float) (60 * EngineConfig.DegToRad);
|
||||
private boolean Sprint;
|
||||
int i = 0;
|
||||
|
||||
public Camera CloneCamera(){
|
||||
Camera NewCam = new Camera();
|
||||
NewCam.SetPosition(Position.x, Position.y, Position.z);
|
||||
NewCam.SetRotation(Rotation.x, Rotation.y, Rotation.z);
|
||||
NewCam.Right.set(new Vector3f(Right));
|
||||
NewCam.Up.set(new Vector3f(Up));
|
||||
NewCam.SetFOVrad(FOV);
|
||||
NewCam.Sprint = Sprint;
|
||||
NewCam.ViewMatrix.set(new Matrix4f(ViewMatrix));
|
||||
return NewCam;
|
||||
}
|
||||
|
||||
public Camera(){
|
||||
Direction = new Vector3f();
|
||||
|
|
@ -24,6 +35,12 @@ public class Camera {
|
|||
ViewMatrix = new Matrix4f();
|
||||
}
|
||||
|
||||
public Camera SetFOVrad(float FOVradians){
|
||||
FOV = FOVradians;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Camera SetFOV(float FOVdegrees){
|
||||
FOV = (float) (FOVdegrees * EngineConfig.DegToRad);
|
||||
return this;
|
||||
|
|
|
|||