Homebrew Viewpoint Change libcaelina

Urbanshadow

Well-Known Member
OP
Member
Joined
Oct 16, 2015
Messages
1,578
Trophies
0
Age
33
XP
1,723
Country
Ok, so I'm trying to set up 3d effects for libcaelina in my custom helper library for c++ and I don't really get how I'm supposed to change the viewpoint.

We don't have gluLookAt so should I just glOrtho into the new position as in 2d?
I guess that because glFrustum is set up in the examples.

What is the "eye" separation advised to avoid headaches ?

Thanks in advance.

One more question: In a mid-complex scene how am I supposed to navigate? Moving the world instead of the viewpoint?
Different question but related: Can I use texture pointers from libsfil into libcaelina's texture matrix and expect to see something?
 
Last edited by Urbanshadow,

machinamentum

Well-Known Member
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
If by viewpoint you mean the conceptual 3D eye, then your view matrix is the inverse of your camera matrix. What this means if that if your camera is at XYZ(10,15,2) you need to apply the translation matrix of XYZ(-10,-15,-2) to your entire scene. To do this you can use set the modelview matrix to the inverse camera position then push the matrix whenever you need to set individual objects matrices. You should really avoid changing GL_PROJECTION as the matrix stack for it is very small and is only really meant to setup the projection transform.

Example:
Code:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslate(-camX,-camY,-camZ);

glPushMatrix();//save camera matrix onto the stack
glTranslate(objX,objY,objZ);
DrawMyObject();
glPopMatrix();//restore camera matrix from the stack

As for textures, Caelina is by design to work just like OpenGL 1.x textures so you can upload textures just as you would on a PC using image buffers (i.e. using stb_image or libpng).
 

Urbanshadow

Well-Known Member
OP
Member
Joined
Oct 16, 2015
Messages
1,578
Trophies
0
Age
33
XP
1,723
Country
If by viewpoint you mean the conceptual 3D eye, then your view matrix is the inverse of your camera matrix. What this means if that if your camera is at XYZ(10,15,2) you need to apply the translation matrix of XYZ(-10,-15,-2) to your entire scene. To do this you can use set the modelview matrix to the inverse camera position then push the matrix whenever you need to set individual objects matrices. You should really avoid changing GL_PROJECTION as the matrix stack for it is very small and is only really meant to setup the projection transform.
Example: -snip-

As for textures, Caelina is by design to work just like OpenGL 1.x textures so you can upload textures just as you would on a PC using image buffers (i.e. using stb_image or libpng).

Of course. I didn't actually think of moving into MODELVIEW for that. That's smart. kudos to you.
libsfil is uses libpng so I assume it's ok. Glad to hear that.

Thanks.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    HiradeGirl @ HiradeGirl: :discuss: