PDA

View Full Version : Calculate vertex 2d position?


xcx
08-16-2005, 10:02 AM
How I can calculate vertex 2d position or any 3d point 2d position?

xcx
08-16-2005, 11:59 AM
I found something like this in manuals and I modify that code. This should be return me objects postion in 2d space. Seen any bugs or errors?


(
local screen_width = 0
local screen_height = 0

screen_width=RenderWidth
screen_height=RenderHeight


theMesh = selection[1]
thePos = (theMesh.pos)* viewport.getTM()

screen_origin = mapScreenToView [0,0] (thePos.z) [screen_width,screen_height]
format "Screen origin %\n" screen_origin

end_screen = mapScreenToView [screen_width,screen_height] (thePos.z) [screen_width,screen_height]
format "Screen end %\n" end_screen

world_size = screen_origin-end_screen
format "World size %\n" world_size

x_aspect = screen_width/(abs world_size.x)
format "X aspect %\n" x_aspect

y_aspect = screen_height/(abs world_size.y)
format "Y aspect %\n" y_aspect

screen_coords = point2 (x_aspect*(thePos.x-screen_origin.x)) (-(y_aspect*(thePos.y-screen_origin.y)))
format "Screen coord %\n" screen_coords
)

Rivendale
08-16-2005, 01:27 PM
hey xcx, that's a bit too complicated.:) This should do it:

gw.setTransform(Matrix3 1)

gw.wTranspoint (polyop.getVert $.baseobject aVertex node:$)


cheers,
CML

xcx
08-17-2005, 05:59 AM
So simple! Darn :)
Thanks man. My code works too, but that is way more simpler.

CGTalk Moderation
08-17-2005, 05:59 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.