Ok I have to be more clear :) From 3dsmax I export a b3dmodel containing several objects named "ground_collision", "wall_collision", "trigger_1" that I use to build the level structure. I use getchild() to find "ground_collision" then pass it to PhysxBodyCreateMesh() function to create a static rigib body for the world collisions. Unfortunately this function doesn't work well with multisurfaces objects (I know I could export it, disabling textures from b3d exporter). The function is:
Function PhysxBodyCreateMesh(mesh%,mass=0)
nsurf = CountSurfaces(mesh)
nvert = 0
nface=0
For ns = 1 To nsurf
Local surf = GetSurface(mesh,ns)
nface = nface+CountTriangles(surf)
nvert = nvert +CountVertices(surf)
Next
fbank = CreateBank(nface*4*3)
nf = 0
vbank = CreateBank(nvert*4*3)
nv = 0
For ns = 1 To nsurf
surf = GetSurface(mesh,ns)
nfv = CountTriangles(surf)
For nfc = 0 To nfv -1
PokeInt fbank,(nf*12)+0,TriangleVertex(surf,nfc,0)
PokeInt fbank,(nf*12)+4,TriangleVertex(surf,nfc,1)
PokeInt fbank,(nf*12)+8,TriangleVertex(surf,nfc,2)
nf=nf+1
Next
nvv = CountVertices(surf)
For nvc = 0 To nvv - 1
vx#=VertexX(surf,nvc)
vy#=VertexY(surf,nvc)
vz#=VertexZ(surf,nvc)
TFormPoint vx#,vy#,vz#,mesh,0
PokeFloat vbank,(nv*12)+0,TFormedX()
PokeFloat vbank,(nv*12)+4,TFormedY()
PokeFloat vbank,(nv*12)+8,TFormedZ()
nv = nv+1
Next
Next
bbb%=pxCreateTriMesh (vbank, fbank, nvert, nface, mass)
FreeBank vbank
FreeBank fbank
Return bbb%
End Function
It is strange that it works only for a single surface object...with the two or more surfaces it creates random faces in the collisions. What's wrong??
|