Hi,
I have just tried creating a TList then adding a list of floating point variables to it. When I came to compile, it gave an error saying 'Unable to convert from Float to Object'. Now, I know I could solve this by grouping some of my float variables into a type then adding the type objects, but this seems counter productive.
Is there another way of doing this, or do I have to jump through the hoop on this one?
Here is my code:
' this function builds a static tri mesh from an entity
' PARAMS:
' entity - the entity to build the tri mesh from
' ode_space - the ODE space to add this tri mesh to
Function BuildTriMesh:Int(entity:Int, ode_space:Int)
' locals
Local vert_list:TList = New TList ' this is a temp list to store vertices
Local tri_list:TList = New TList ' this is a temp list to store triangle vertex indices
Local vert_bank:TBank ' the actual vertex bank
Local tri_bank:TBank ' the actual index bank
Local vertex_index:Int ' this is used to hold vertex indices
Local Offset:Int = 0 ' the vertex offset
Local TriOffset:Int = 0 ' the triangle offset
' cycle through all of the surfaces
For Local surf:Int = 1 To bbCountSurfaces(entity)
' cycle through each triangle in this surface
For Local tri:Int = 1 To bbCountTriangles(surf)
' add all three vertices and indices to the list
For Local vert:Int = 0 To 2
vertex_index = bbTriangleVertex(surf, tri, vert)
vert_list.AddLast(bbVertexX(surf, vertex_index))
vert_list.AddLast(bbVertexY(surf, vertex_index))
vert_list.AddLast(bbVertexZ(surf, vertex_index))
vert_list.AddLast(Float(0.0))
TList
' add the vertex index to the list
tri_list.AddLast(vert_list.count() - 1)
Next
Next
Next
' now create the banks
vert_bank = CreateBank(vert_list.count() * 4 * 4)
tri_bank = CreateBank(tri_list.count() * 3 * 4)
' the vertex bank
For Local v:Int = 0 To vert_list.count() - 1
PokeFloat(vert_bank, Offset, vert_list[v] )
Offset:+4
Next
' the triangle bank
For Local t:Int = 0 To tri_list.count() - 1
PokeInt(tri_bank, TriOffset, tri_list[t] )
TriOffset:+4
Next
' now create the tri mesh in ODE
Local TriMeshData:Int = dGeomTriMeshDataCreate()
dGeomTriMeshDataBuildSimple(TriMeshData, BankBuf(vert_bank), vert_list.count(), BankBuf(tri_bank), tri_list.count())
' return the tri mesh
Return dCreateTriMesh(ode_space, TriMeshData)
End Function
Thanks in advance.
|