CollisionSurface index

Blitz3D Forums/Blitz3D Programming/CollisionSurface index

orion one(Posted 2003) [#1]
hi,

i seem to have a problem when i try to get (and copy) the surface of a mesh that collides with, let's say, a simple cube
a
If EntityCollided (mesh,cubetype) Then
ctype=CollisionEntity(cube,1)
csurf=CollisionSurface(ctype,1)

;getcsurf=GetSurface(mesh,csurf)
ClearSurface(csurf)


orion one(Posted 2003) [#2]
yeah right orion one, post it correctly or do not lol

so : when the cube collides with the mesh i have
If EntityCollided (mesh,cubetype) Then
ctype=CollisionEntity(cube,1)
csurf=CollisionSurface(ctype,1)

and i get the two indexes ctype and csurf

the questions are :
1° why are those indexes so high ? i expected them, especially the surface index, to be less than the max number of surfaces i do have put in the mesh
2° why is the clearsurface(csurf) command working, and not the getcsurf=GetSurface(mesh,csurf) command (that gives me an 'surface index out of range' error ... as expected) ?
3° what should i do to get the csurf index loewr or equal to the max number of surfaces of my mesh ? i wish to copy the collided surfaces and the surrounding ones to make a new mesh

thanks to all

orion one


DJWoodgate(Posted 2003) [#3]
1. They are not indexes they are handles to memory locations.
2. clearsurface expects the surface handle, Getsurface wants an index number (so you can iterate through all the suraces in a mesh). It returns the surface handle (or memory pointer if you like).
3. In principle iterate through all the surfaces of the mesh until getsurface returns csurf. Then you have the index number of csurf. In practice though it might be easier for you to work directly with the handles rather than the index numbers.


orion one(Posted 2003) [#4]
thank you very much David!