General YPN >> Conversions
Posted by dxprog on 02:01:00 03-11-2002
I was wondering if anyone could give me a formula to convert world coords to screen coords.

[ This Message was edited by: dxprog on 2002-03-11 02:02 ]
Posted by robost86 on 06:14:00 03-11-2002
World coordinates? Huh?
Posted by KaGez on 08:19:00 03-11-2002
dxprog:
What do you need that for? I think DX can do that automatically (OpenGL does).
Anyways, if you really think that you need it, check:
http://www.flipcode.com
and
http://www.gamedev.net
I'm sure they have something about it, and if not, just post on their message board
[addsig]
Posted by dxprog on 18:21:00 03-11-2002
Yes DX does do that automatically but I'm trying to make a "simple" (if you could call this simple ) 3D designer so I can make 3D games. Plotting individual vertices in notepad is a pain.
Posted by KaGez on 02:00:00 03-12-2002
ahhhh, ok
anyways, check the above URLs. They should have some informations for ya
[addsig]
Posted by robost86 on 06:33:00 03-12-2002
I still don't get what he's talking about...
Posted by KaGez on 09:21:00 03-12-2002
only 3d freaks/game programmers can get what he means
I wants to convert the coordiates of something from the world coordinate system (the entire coordinate system) to those of the coordinate system. So, as far as I got it he wants to make 3D ---> 2D .
btw

dxprog:
What you try to do is called "Projection". It's somewhat difficult.... if you manage that you could almost write a 3d library like DX or OGL
Anyways, as said above, it's a lot to code, and you also need high school maths to manage it, which I'm trying to learn atm... But I still don't really get what you need it for... maybe explain the problem a bit more precise and I could maybe help you out
[addsig]
Posted by dxprog on 15:20:00 03-12-2002
OK. I am trying to make a 3D CAD Designer to easily make 3D objects for my game. But I would like to view the object before I put it into DX. To do this I use the Line command to draw the object in the view window. But I need to convert the world coordinate to screen coordinates to display it properly. That's the best I can explain it in words. I may be stuck until I learn trig or something.
Posted by KaGez on 06:19:00 03-13-2002
using trig for such stuff isn't too good, since the C/C++ (or whatever lang you use, dunno) are really slow. You should use linear algebra everywhere you can, even if it's a little bit more to code... if you use trig only you'll probably won't be able to use it for interactive stuff like CAD or games or whatever.
Anyways, I still don't get why you want to view the object before handing it over to DX :/
If you want to get the points on the 2d surface (the projected coordinates) for example for draggin them around with the mouse, I'd say you should use GLut. It's for OpenGL, but I know that it has such functions . Dunno if SX has, but it should have some sort of that too.
[addsig]
Posted by dxprog on 12:27:00 03-13-2002
I want to see the model before the actual program because loading Dx on machine takes a bit. Though I haven't done any Dx since I got my new processor.

[ This Message was edited by: dxprog on 2002-03-13 12:27 ]
Posted by KaGez on 12:36:00 03-13-2002
I think it'd be faster to let DX do the work than coding it yourself. No because you can't code or something... DX is hardware accelerated, which you own libs most probably won't be.
[addsig]
Posted by dxprog on 12:49:00 03-13-2002
Like I have hardware to accelerate stuff like that. [addsig]
Posted by nonama on 17:40:00 03-14-2002
im interested in this stuff to. i mean i want to program 3d in asm. i dont want to use libraries. moto wanna do everything myself ( ).

where could i find algorithms for that. i mean simple cube moving in the screen. what algos does it use.
Posted by KaGez on 08:50:00 03-15-2002
nonama:
Now, first get that cube out of your head. When you've done that, try to think of 3d graphics as a projection or 3d coordinates on a 2d plane. It's like if you have a room where you have all your polygons and vertices placed. At one end of the room you've got a white wall, where the stuff will be "projected" on, which in this case is our screen. On the other end you've got a flashlight and point it towards the white wall, and switch it on. Now, what do you see on the wall on the other side of the flashlight?
Exactly, that is what we interpret as 3d graphics. There are a few things more you'd need to do for software rendering, but that's the basic concept. You need at least High-School maths (as also mentioned above).
Do you now know why I said that you should forget that cube?
The cube is just one of the easiest things to program with most 3d libraries, for example OpenGL, because it has not so many vertices as 3d-game models have.

Anyways, back to the topic:
I _highly_ advise you to get a book about 3d programming first, that covers the maths and stuff, and then start to play around with those maths, and try to build up a 3d lib. Ok, you could use code that other programmed, but that won't help you understanding the maths And maths are the _most_ important part for 3d progaming
[addsig]
Posted by nonama on 12:34:00 03-15-2002
tell me something i dont know. i know that maths is very iomportant. but even if you know math in that level. you still need to understand some algos. i mean. drawing a cube and moving it would give me little bit of knowing what the heck im doing.

openGL. what is it? is it some super-duper talk between 3dcard and program or it just does lots of calculations to turn 3d world to 2d world in wanted mode?
Posted by KaGez on 00:54:00 03-16-2002
nonama:
maybe you should return to this topic after you know what 3d graphics on computers really are... go look up what OpenGL is, and do the same for Direct3D ... then you maybe also know the meaning of the term "Hardware acceleration" (for 3d graphics), which you don't seem to understand now.
Have a nice day
[addsig]
Posted by nonama on 10:24:00 03-16-2002
damit. you are so smart in here. i realy know nothing of 3d.
Posted by dxprog on 13:00:00 03-16-2002
If you want it plain and simple Direct3D and OpenGL are librarys of alogorithms. They do the projection, translation, etc. OpenGL is faster though. And I found the formula I was looking for. In case any one wants it:

X = (X / Z) + Scale + (ScreenWidth / 2)
Y = (Y / Z) + Scale + (ScreenHeight / 2)

Scale is basically just a zoom factor. Just make sure Z is a non-zero value or you'll get an error .
Posted by KaGez on 13:05:00 03-16-2002
I'm not smart or anything, I'm just interested in 3d graphics on PCs, and nothing more ...
[addsig]
Posted by dxprog on 13:15:00 03-16-2002
I'm with you...
Posted by nonama on 21:43:00 03-16-2002
X = (X_real / Z_real) + Scale + (ScreenWidth / 2)
Y = (Y_real / Z_real) + Scale + (ScreenHeight / 2)

does this mean:
X_real Y_real Z_real are in X Y on screen?

Posted by nonama on 21:51:00 03-16-2002
any ideas how to manage 3d world?

3d array of pixels looks evil. =)
Posted by KaGez on 00:44:00 03-17-2002
hhmmmm...
/me looks at the algo again ...
I'll have to try later what it does
[addsig]
Posted by dxprog on 01:18:00 03-17-2002
nonama: The way you rewrote it is correct. X Y is the Screen Coords and X_Real Y_Real Z_Real are the real world coords. I found a great book today called Graphics in VisualBasic or something like that. Has every algorithm for 2D and 3D stuff you could imagine. I NEED IT.