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.
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)?
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
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).
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.
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.
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.
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.