Results 1 to 10 of 10

Thread: Make a 2d image of a 3d world

  1. #1

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Make a 2d image of a 3d world

    Hi.

    I've tried some ways to calc the 2d image, but i didnt like any of those...they gave me alot of problems.

    I have a 3d array of "pixels" with a color integer.
    what i want is to sort those pixels by distance from the camera to draw them properly and then calculate the x and y coord in a 2d field.

    It would also be good to have a dynamic camera so i can rotate and move it using vectors.
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  2. #2

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    ok....Answer his instead:
    I have a camera holding x, y, z and horizontal angle and vertical angle. I also have a coordinate (x,y,z) where i want to draw a dot.
    How do i draw this dot on a 2d picturebox (how do i calculate where it should be drawn)?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I guess you have your reasons not to, but why not use DirectX?


    Also, this might be better posted in the maths forum.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  4. #4
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586
    I think this guy is having the same problem I had when trying to create a 3d world level editor.

    I never could figure out a way to convert the mouse's 2d picture box coordinate correctly in the 3d world coordinate that it was pointing at.

    I ended up using a technique from another level editor called a puck until I one day figure it out or see a post or code of someone else figuring out the problem.

    I think the only way to actually do it though would be to have the picturebox in directx and have directx take control of the mouse when it moves into the picture box. The only problem is this is you would have to have a release key to get the mouse back out of the picture box when you are done. At least this way though you should have the correct coordinates of the mouse by asking dx where its drawing the mouse (I'm not a dx expert so I'm not sure if even this would work).

  5. #5

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i dont want to use directx...i want to code my own 3d engine
    gonna create a particle system in it too...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  6. #6
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    You want to look up perspective maths.
    I have a sort of idea how it might be done but I couldn't be sure:
    If you imagine your 3D world, put a flat square in it and think of this as your screen(note I said square not point). Then put a dot in the center of the square and pull it back away from the screen in the direction of the normal to the screen. (You with me still, hope so). Now if you want to find where a point is on the screen you make a vector between the point and the dot and where it passes through the screen is the position on the screen that the dot should be drawn.
    This should work in theory and the problem will be how far to move the dot and whether the square should be a rectangle and what size.

    To do this you will need a good understanding of 3D Vectors, 3D Planes and how to find points of interception between vectors and planes.

    I wish you the best of luck with this as it seems a very hard task but I hope you do it, let me know how it goes.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  7. #7

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i know there is a formula for calcing the positions...
    the one i got is something like this:
    X2d = distance * (pointX + camx) / (pointZ + camz)
    Y2d = distance * (pointY + camy) / (pointZ + camz)

    the problem with this is that its not using any vectors.
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  8. #8

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    when a point gets further away from the camera it should get closer to the center of the screen...am i right?

    look at this illustration. if i understand your idea correct, this will not work.

    Attached Images Attached Images  
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  9. #9
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Sorry I meant for the objects(Points) not to be on the side which the dot is. That way they should get closer to the center if they are further away.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  10. #10
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Heres a pic:
    Attached Images Attached Images  
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width