I would like an algorithm to "point" a surface of an object toward the camera. I know the position of the camera, and I know the centerpoint of the surface. Would anyone here know how to accomplish this?
Printable View
I would like an algorithm to "point" a surface of an object toward the camera. I know the position of the camera, and I know the centerpoint of the surface. Would anyone here know how to accomplish this?
I know the maths behind it and should be able to come up with an algorithm, but I'd need to know more about how you're storing your surface. And other parts of your object.
It's just a simple quad in OGL that has two sides, mapped with a texture. It's located in variables stars(i).x,stars(i).y,stars(i).z, and the camera is cam.x, cam.y, cam.z. After translation, the points are
-1.0,-1.0, 0.0
-1.0, 1.0, 0.0
1.0, 1.0, 0.0
1.0,-1.0, 0.0
If you use OGL you will know what I mean. It means that the center point of translation is now 0. This makes it easy to make coordinate systems for each polygon.
There are two surfaces, and obviously I would just do a Y rotation of 180 degrees to get the opposite side. I am running a particle engine and the stars must be visible at all times.
Unfortunately I cannot understand it, HarryW. I need VB CODE to do this, PLEASE! Don't refer me to a website, I will get confused. I need CODE!!!
Hey, that was just a geometry tutorial, I already said I'll let Sam handle this since I don't understand it too well. The geometry tutorial was something you might want to look at if you want to learn some more geometry.
I'm afraid I've never used OGL so that doesn't help much.
Can you get the coordinates of 2 other points on the surface
? I could do it off that. You'll also need the coords of the point you wish to rotate the object about. (If you want to rotate about the centre of the surface then it's much easier, so tell me if that's what you want to do)
I'll have to refresh my memory on the maths first but I'll put the algo up when I work it out.
I sent you a private msg Sastraxi.
Check out some of these:
http://www.opengl.org
http://www.flipcode.com
http://www.gamedev.net
http://amir.cfxweb.net
http://www.cfxweb.net
http://nehe.gamedev.net
http://glvelocity.gamedev.net
you could get the cross product of 2 offsetvectors of the surface, divide it by it's length and multiply with distance to camera.
mebbe some code would be more helpful..