1 (edited by detvog 2008-06-10 04:12:49)

Topic: look for a little help.

Re: look for a little help.

greetings smile  the vertex system was revamped for v1.4 so the type Vertex no longer exists.  i translated but have not tested:

Function AnimatedMeshToNewtonCollisionTree:Byte Ptr(nWorld:Byte Ptr,g_map:IAnimatedMesh,g_newtonMap:Byte Ptr)
    NewtonTreeCollisionBeginBuild(g_newtonmap)
    Local cMeshBuffer:Int,j:Int
    Local v1i:Int,v2i:Int,v3i:Int
    Local mb:IMeshBuffer
    
    Local vArray:Float[9]    'vertex array (3*3 floats)
    
    Local tmpCount:Int = 0
    
    For cMeshBuffer=0 To g_map.getMesh(0).getMeshBufferCount() - 1
        
        mb = g_map.getMesh(0).getMeshBuffer(cMeshBuffer)
        
        Local verts:S3DVertex[] = mb.getVertices()
        
        Local mb_indices:Short[] = mb.getIndices()
        
        'add each triangle from the mesh
        For Local j = 0 To mb.getIndexCount() - 1 Step 3
            v1i = mb_indices[j]
            v2i = mb_indices[j+1]
            v3i = mb_indices[j+2]

            Local v1:S3DVertex = Null                            
            Local v2:S3DVertex = Null
            Local v3:S3DVertex = Null
            
            v1 = verts[v1i]
            v2 = verts[v2i]
            v3 = verts[v3i]
            
            vArray[0] = v1.getPos().getX()
            vArray[1] = v1.getPos().getY()
            vArray[2] = v1.getPos().getZ()
            vArray[3] = v2.getPos().getX()
            vArray[4] = v2.getPos().getY()
            vArray[5] = v2.getPos().getZ()
            vArray[6] = v3.getPos().getX()
            vArray[7] = v3.getPos().getY()
            vArray[8] = v3.getPos().getZ()
            
            NewtonTreeCollisionAddFace(g_newtonmap, 3,Varptr vArray[0], 12, j)
        Next    
    Next

    NewtonTreeCollisionEndBuild(g_newtonmap,0)
    Local g_newtonmapbody:Byte Ptr = NewtonCreateBody(nWorld,g_newtonmap)
EndFunction