Advertisement

World Coordinate to Screen Pixel

Started by June 11, 2000 11:27 PM
4 comments, last by Darkening 24 years, 6 months ago
I''m starting to learn how to use D3DVERTEX to render a scene. When I was using D3DTLVERTEX, it was easy to know where the vertex would end up on the screen but D3DVERTEX uses a different coord. system. So, I have a question for you guys. How do I know where my vertex will end up on the screen ? Thanks, Darkening
---------------------------Unfortunately, no one can be told what a bug is.You have to see it for yourself...
Darkening,

You have to use a technique called raycasting in which you run a "ray" from your mouse point through 3d space and test intersection with your polygons. I''m not yet a real expert on the subject so I couldn''t walk you effectively through it. However several discussions have been posted in D3D/OpenGL section and the subject comes up quite a bit.

BTW, Darkening I never did send you that info in mouse to world I did with transformed vertices. Sorry about that, been a little busy! Send me a mail if you still want to go that route.

Sieggy
Advertisement
Isn''t world to screen a simple vector transformation with the matrix, and then a projection to screen?

Could you explain it more baskuenen, I would like to know how you do that. I''m no John Carmack, so please be simple...

Thanks,
Darkening
---------------------------Unfortunately, no one can be told what a bug is.You have to see it for yourself...
Taken from my software rendered 3D engine:

    // single vector transformation (object space 2 world)float sx = V->x * Matrix[ 0] + V->y * Matrix[ 1] + V->z * Matrix[ 2] + Matrix[ 3];float sy = V->x * Matrix[ 4] + V->y * Matrix[ 5] + V->z * Matrix[ 6] + Matrix[ 7];float sz = V->x * Matrix[ 8] + V->y * Matrix[ 9] + V->z * Matrix[10] + Matrix[11];// world 2 screen projectionsz = FOV/sz;V->sx = (int)(sz*sx) + SCREEN_WIDTH /2;V->sy = (int)(sz*sy) + SCREEN_HEIGHT/2;    


V is the vertex pointer. x/y/z is object space coords. sx/sy is screen coords. To change the aspect, you have to multiply the screen coords with an extra value.

I''m sorry, I only know OpenGL, less D3D. If you use OpenGL you have to setup the matrix a bit different (probably in D3D also).
If you don''t know exactly how to do this, I''ll explain (at the moment a bit lazy).

Thanks a lot baskuenen !!
I think that''s what I needed to get myself going again.

Darkening
---------------------------Unfortunately, no one can be told what a bug is.You have to see it for yourself...

This topic is closed to new replies.

Advertisement