local coords ...

Blitz3D Forums/Blitz3D Programming/local coords ...

Hi,
If I have an object consisting of one triangle and I rotate the object, is there a formula for extracting the local (x,y,z) coords for each of the vertices?

If there is a command in Blitz3D for this that, unfortunately, won't be any use (it's for an exporter), I actually need a formula or, ideally, a piece of a code that will work this out.

thanx,
Mike

surf = GetSurface(entity,1)
v1 = TriangleVertex(surf,0,0)  ; either that or (surf,1..)
v2 = TriangleVertex(surf,0,1)  ; I cant totally remember if
v3 = TriangleVertex(surf,0,2)  ; triangles start from 0 or 1

x = VertexX(surf,v1)
y = VertexY(surf,v1)
z = VertexZ(surf,v1)

; Repeat for v2 and v3


I don't know the math's off hand but I know that you probably need to be looking to applying matrix formula's to each vertex to transform it to local space. So you could do a search on that, I know there's been some talk about it around here somewhere :)

If you need to transform the coordinates to global (world) coordinates, then:

TFormPoint x,y,z, entity, 0

x = TFormedX()
y = TFOrmedY()
z = TFormedZ()


Hem cyberseth:
If there is a command in Blitz3D for this that, unfortunately, won't be any use


It's all about the grammar interpretation!

If there is a command in Blitz3D for this that, unfortunately, won't be any use (it's for an exporter), I actually need a formula or, ideally, a piece of a code that will work this out.


I read it to mean that: If there isn't a command in Blitz for this that will be any use...

Anyway, what is a function, if not an in-built formula? If it does the job then it does the job. If it doesn't do the job then I need to know why it doesn't do the job. Why be an Anti-Functionist?

He said it's for an exporter, so I guess he needs the formula because the exporter will obviously be coded in another language. It makes sense to me.

Also he wants the local coords (see above) ;)