local coords ...

Blitz3D Forums/Blitz3D Programming/local coords ...

necky(Posted 2003) [#1]
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


cyberseth(Posted 2003) [#2]
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



Sunteam Software(Posted 2003) [#3]
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 :)


cyberseth(Posted 2003) [#4]
If you need to transform the coordinates to global (world) coordinates, then:

TFormPoint x,y,z, entity, 0

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



Koriolis(Posted 2003) [#5]
Hem cyberseth:
If there is a command in Blitz3D for this that, unfortunately, won't be any use



cyberseth(Posted 2003) [#6]
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?


Koriolis(Posted 2003) [#7]
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.


Sunteam Software(Posted 2003) [#8]
Also he wants the local coords (see above) ;)