3D to 2D coords....

This is a discussion on 3D to 2D coords.... within the Game Programming forums, part of the General Programming Boards category; I'm working on a simple demo app. What i need to do is convert a point in 3D space to ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    7

    3D to 2D coords....

    I'm working on a simple demo app. What i need to do is convert a point in 3D space to a point in 2D space (in this case my screen).

    I was thinking of creating a vector from the point where the 4 viewport edges meets behind the camera, to the point in 3D, and detect the intersection point in the nearclipping plane. But from there, im lost. I also know that the nearclipping plane can be both infront of the camera and behind.

    Any one got any good ideas ?

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,209
    Check this thread: Moving objects with mouse in 3D.
    Might find some ideas there.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    7
    thats not it... thats somthing diferent.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Can't you just use the projection matrix for that? That's what the graphics card does, after all, to map 3d points to the final 2d image.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    7
    humm... i se what you meen, but dont really have the maths for it =P
    gonna try and look it up.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    It's multiplying the vector with a single matrix. If you don't have the maths for that then, I'm sorry to say, you have no business in 3d graphics.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,597
    D3DX has a function called D3DXProject() which projects a 3D vector from 3D space to 2D screen space. To do a type of targeting system for a HUD you would project the corners of your bounding volume into 2D space and then when you finally have the 2D values, you can determine which ones are most appropriate for display.

  8. #8
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    The OpenGL equiv to D3DXProject would be gluProject, if you're using OpenGL.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    7
    Quote Originally Posted by CornedBee
    It's multiplying the vector with a single matrix. If you don't have the maths for that then, I'm sorry to say, you have no business in 3d graphics.
    I know how to do that... it was just that i had no idea about this matrix.
    Been studying 3d programming for 2 weeks now. Befor that, ive been studying Lin.Algebra and 3d maths for 4weeks (this is all in school).

    My maths is quite ok ( still working on it )

  10. #10
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    What are you using to render to the screen? OpenGL, DX, SDL, BananaCreamPie?

  11. #11
    Registered User
    Join Date
    Oct 2006
    Posts
    7
    I figured it all out.
    I use RenderWare as my middleware.
    I made one with both renderware functions and then also with the matrix mult.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I would like to Produce 2d and 3d plots
    By BobInNJ in forum Windows Programming
    Replies: 2
    Last Post: 03-04-2009, 10:16 PM
  2. Wiki FAQ
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 192
    Last Post: 04-29-2008, 02:17 PM
  3. 2d to 3d: Image processing
    By arjunajay in forum C++ Programming
    Replies: 2
    Last Post: 07-19-2006, 10:39 PM
  4. 3D to 2D
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 07-09-2003, 11:29 PM
  5. Initialising 2D and 3D arrays
    By fry in forum C++ Programming
    Replies: 5
    Last Post: 08-01-2002, 05:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21