As well as VR - I want 3D physics in my game. So I thought I'd start slowly and just set my FPSC level up as the static body, before I start adding all the dynamic and kinematic objects for the user to play with.
But as soon as I use Create3DPhysicsStaticBody( ObjID ) the exe crashes.
So as part of my exe initialisation, I create the physics world like thus:
Quote: "//load objects
Create3DPhysicsWorld()
Set3DPhysicsGravity(0,-1,0)
LoadFPSCLevel( "level-1" )"
Then as part of "LoadFPSCLevel()" I load the objects created by FPSC-2-AGK and attempt to set them as 3D Physics Static Bodies, but at that point the exe crashes. As soon as i comment out the 2 physics commands the exe runs. Here's where I load the *.x files and set them as static physics objects:
Quote: "if Lower( Right( filename$, 1 ) )="x"
ObjID = LoadObject( filename$ )
//SetObjectCollisionMode( ObjID, 1 )
Create3DPhysicsStaticBody( ObjID )
SetObjectShapeStaticPolygon( ObjID )
ObjStatic.insert( ObjID )
endif"
Here's my complete FPSC level loading code:
function LoadFPSCLevel( LevelFolderName as string )
//loads all elements for FPSC Level
EntityToLoad as string[]
pixel$ = ""
vertex$ = ""
SetFolder( LevelFolderName )
readfolder$ = GetFolder()
filename$ = GetFirstFile()
while filename$<>""
if Lower( Right( filename$, 3 ) )="lst"
//objects
FileID = OpenToRead( filename$ )
repeat
wholeline$ = ReadLine( FileID )
param$ = Lower( GetStringToken( wholeline$, ":", 1 ) )
value$ = GetStringToken( wholeline$, ":", 2 )
select param$
case "camera"
camStartX = ValFloat( GetStringToken( value$, ",", 1 ) )
camStartY = ValFloat( GetStringToken( value$, ",", 2 ) )
camStartZ = ValFloat( GetStringToken( value$, ",", 3 ) )
endcase
case "entity"
EntityToLoad.insert( value$ )
endcase
case "light"
lx# = ValFloat( GetStringToken( value$, ",", 1 ) )
ly# = ValFloat( GetStringToken( value$, ",", 2 ) )
lz# = ValFloat( GetStringToken( value$, ",", 3 ) )
rad# = ValFloat( GetStringToken( value$, ",", 4 ) )
red = Val( GetStringToken( value$, ",", 5 ) )
grn = Val( GetStringToken( value$, ",", 6 ) )
blu = Val( GetStringToken( value$, ",", 7 ) )
if LgtLight.length<0
lID = 1
else
lID = LgtLight.length+1
endif
LgtLight.insert( lID )
CreatePointLight(lID, lx#, ly#, lz#, rad#, red, grn, blu)
SetPointLightMode( lID, 1 )
endcase
case "player"
plrStartX = ValFloat( GetStringToken( value$, ",", 1 ) )
plrStartY = ValFloat( GetStringToken( value$, ",", 2 ) )
plrStartZ = ValFloat( GetStringToken( value$, ",", 3 ) )
endcase
endselect
until FileEOF( FileID )
CloseFile( FileID )
endif
if Lower( Right( filename$, 3 ) )="png"
if Lower( Left( filename$, 3 ) )="tex"
//texture
texname$ = Left(filename$, Len(filename$) - 4)
lm$ = Right(texname$, 1)
If lm$ = "-" Then lm$ = "0"
LightMapID.insert( Val(lm$) )
ImgID = LoadImage(filename$)
ImgTexture.insert( ImgID )
if GetImagePowerOfTwo( ImgID )>0
SetImageWrapU(ImgID, 1)
SetImageWrapV(ImgID, 1)
endif
else
//light map
ImgID = LoadImage( filename$ )
ImgLightMap.insert( ImgID )
SetImageWrapU( ImgID, 1 )
SetImageWrapV( ImgID, 1 )
endif
endif
if Lower( Right( filename$, 2 ) )="ps"
pixel$ = filename$
endif
if Lower( Right( filename$, 2 ) )="vs"
vertex$ = filename$
endif
if Lower( Right( filename$, 1 ) )="x"
ObjID = LoadObject( filename$ )
//SetObjectCollisionMode( ObjID, 1 )
Create3DPhysicsStaticBody( ObjID )
SetObjectShapeStaticPolygon( ObjID )
ObjStatic.insert( ObjID )
endif
filename$ = GetNextFile()
endwhile
//set up elements
LevelShaderID = LoadShader( vertex$, pixel$ )
for o=0 to ObjStatic.length
//set textures
//base texture
SetObjectImage(ObjStatic[o], ImgTexture[o], 0)
//light map
SetObjectImage(ObjStatic[o], ImgLightMap[ LightMapID[o] ], 1)
//SetObjectLightMap( ObjStatic[o], ImgLightMap[ LightMapID[o] ] )
SetObjectLightMode( ObjStatic[o], 1 )
//shader
SetObjectShader(ObjStatic[o], LevelShaderID)
perc# = o
perc# = perc# / ObjStatic.length
perc = perc# * 100
//SetTextString(1, "Loading - " + Str(perc) + "%")
//Sync()
next o
//load entities
SetFolder( "/media" )
for e=0 to EntityToLoad.length
value$ = EntityToLoad[e]
posx# = ValFloat( GetStringToken( value$, ",", 1 ) )
posy# = ValFloat( GetStringToken( value$, ",", 2 ) )
posz# = ValFloat( GetStringToken( value$, ",", 3 ) )
rotx# = ValFloat( GetStringToken( value$, ",", 4 ) )
roty# = ValFloat( GetStringToken( value$, ",", 5 ) )
rotz# = ValFloat( GetStringToken( value$, ",", 6 ) )
FilePath$ = GetStringToken( value$, ",", 7 )
EntID = LoadFPEObject( FilePath$ )
SetObjectPosition( Entity[EntID].ObjectID, posx#, posy#, posz# )
SetObjectRotation( Entity[EntID].ObjectID, rotx#, roty#, rotz# )
next e
endfunction
Any help would be appreciated.