How to get world coordinates of a vertex?

Blitz3D Forums/Blitz3D Programming/How to get world coordinates of a vertex?

JoeGr(Posted 2004) [#1]
Simple question (I hope). Is there a direct way to get the world x/y/z coordinates of a vertex?

Thanks,


N(Posted 2004) [#2]
VertexX(), VertexY(), VertexZ() ?


GfK(Posted 2004) [#3]
VertexX(), VertexY(), VertexZ() ?
Those give local coords.


Ice9(Posted 2004) [#4]
Look at TFormedPoint


N(Posted 2004) [#5]
GfK: Really? Peculiar. Wouldn't it then be EntityX()+VertexX()? Or am I missing something?


skidracer(Posted 2004) [#6]
No it would be TFormPoint(VertexX(),VertexY(),VertexZ(),entity,0)


jhocking(Posted 2004) [#7]
A couple days ago someone was asking what the TForm commands are useful for. I hope he reads this thread.


GfK(Posted 2004) [#8]
GfK: Really? Peculiar. Wouldn't it then be EntityX()+VertexX()? Or am I missing something?
No, because that doesn't take into account entity rotation.

What Skidracer said.


N(Posted 2004) [#9]
Ah, good point.


JoeGr(Posted 2004) [#10]
Thanks for the help. I'm not sure how I overlooked that TformPoint command. Seems to me that an optional 'global' flag for VertexX/Y/Z would be simpler but I'm sure Mark has his reasons.


_PJ_(Posted 2004) [#11]

A couple days ago someone was asking what the TForm commands are useful for. I hope he reads this thread.


That might've been me ! and yeah this is helpful :)


Stickman(Posted 2004) [#12]
[Edit] Im corecting my origanal post in saying that Vertex X/Y/Z is World coordinates to They are Local coords [Edit]
This demo will show why.

Graphics3D 640,480,16,2

Camera=CreateCamera()
PositionEntity Camera,0,0,-10

C=CreateCube()

While Not KeyHit(1)

Select KeyDown(57)
Case 1
If KeyDown(200) PositionMesh C,0,0,+1
If KeyDown(208) PositionMesh C,0,0,-1
Default
If KeyDown(200) MoveEntity C,0,0,+1
If KeyDown(208) MoveEntity C,0,0,-1
End Select

RenderWorld

Text 5,5,"Vertex Z :"+VertexZ(GetSurface(C,1),0)
Text 5,30," Use Up\Down Arrows to Move Cube "
Text 5,60," Hold Space Bar to Move Mesh "

Flip
Wend 
End




skidracer(Posted 2004) [#13]
You are mistaken, it would be preferred if you correct yourself.


AntonyWells(Posted 2004) [#14]
Skid's right.

for each vert
   tFormPoint vertexX(surface,vert),vertexY(surface,vert),vertexZ(surface,vert),surfaceMesh,0
   worldVertexX=tformedX()
   worldVertexY=tformedY()
   worldVertexZ=tformedZ()


surfaceMesh being the actual mesh you're scanning. (I.e got the surface from.)


JoeGr(Posted 2004) [#15]
Yep, Skidracer was right. I'm using TFormPoint exactly as he suggested it and it works. VertexX/Y/Z return local coordinates and (correct ME if I'm wrong too) do not take into account any rotation, movement or scaling unless it has been done using the -Mesh commands (RotateMesh, ScaleMesh, etc).


Stickman(Posted 2004) [#16]
You are wright,Im mistaken

I thought about that this morning after I got some sleep and was woundering my self what I was thinking.

Got my local \ Global stuff backwards or somthing honestly I don't know what I was thinking,I was tired is what I was.I do this to myself occasionaly when Im like that.Sorry

Ill fix my post above.


Stickman(Posted 2004) [#17]
Ok Corcted my mistake,

A better understand of my mistake is to look at how I understand 3D….

A model could have a set of Model vertices stored in a Vlist[ ] array. This would be the only “fresh” copy
of the model. When the model is transformed or moved the transformation is made on these coordinates then a copy of them could be stored in what could be called the transformed coordinate list tvlist [ ] array.
This is usually the best approach as for after lets say 10,000 or so transformations performed on the model the models coordinates could or will degrade due to numeric inaccuracies.

The best approach is to use a rotation/movement variable or state that tracks the current rotation angles and position of the object , and then for each frame use this variable to transform the local coordinates and store them into a transformed coordinates list for rendering.

The Vlist [ ] always uses 0,0,0 as a base in order to track the “fresh” list to the transformed list. Thus the Vlist [ ] array coords would be refered to as the Local coordinates of the Model, my mistake is I look at this list ( vlist [ ] array ) as if it were World Coordinates being transformed to the local entites space.

I just felt like I needed to explain my thoughts so you won't think Im a total Idiot,maby more like half of one.