Advertisement

How to view a cube from inside ?

Started by October 10, 2001 05:56 PM
7 comments, last by Ineluki 23 years, 4 months ago
Aloa I just started opengl coding yesterday. I wanted to write a 360° picture viewer using 6 textures (front, right, top ....) projected to the 6 sides of a cube. This works already fine, but only when viewing from outside the cube. If my position is inside the total screen remains black. I tried to use glPolygonMode to draw front and backside, I tried to use glDisable(GL_CULL_FACE) and lots more, but nothing worked. So please help my if you can. Thanx a lot Ineluki
Disabling face culling should have worked. Try rotating the vertices for each side. For example, instead of:
-1.0, 1.0, 0.0
1.0, 1.0, 0.0
1.0, -1.0, 0.0
-1.0, -1.0, 0.0
Try:
-1.0, 1.0, 0.0
-1.0, -1.0, 0.0
1.0, -1.0, 0.0
1.0, 1.0, 0.0

Good luck .

[Resist Windows XP''s Invasive Production Activation Technology!]
Advertisement
Maybe your near clip plane is out too far. You could try either making the cube larger so it is beyond the clip plane, or, decrease the distance to the near plane.

jw
This might not be what you''re looking for, but just in case ...

If you want to render both sides of a polygon you can set (in your initialization):

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

Then, when you declare your material properties specify GL_FRONT_AND_BACK, instead of just GL_FRONT as so:

GLfloat array[4] = {1.0f, 0.0f, 0.0f, 1.0f);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, array);
etc.

Of course, you can always declare GL_FRONT and GL_BACK to be different things, and that will be correctly rendered, too. Depends on what you want to do.

I''m not sure if this is the most effective way to do it. I''ve actually only used this to render some models that were not consistent with their CW/CCW orientation. I wasn''t trying to view inside a box or anything. Can''t hurt to try.

Also, if you only want to view the inside (instead of wanting to view both sides) you can either rotate the vertices, as was mentioned above, or else simply change the normal orientation between GL_CW and GL_CCW using glFrontFace(). If you do either of these, nothing else ought to have to change.

Hope I''ve been helpful ,

eriol
I already tried glFrontFace using GL_CW and GL_CCW but nothing changes.
I do not use materials nor lighteffects.
First I''ll try to move around some points.
By the way how do I change the distance to the near plane ?

Thanx so far

Ineluki
glDisable(GL_CULL_FACE);

That should turn it off completely. Enable it when you''re ready to draw culled polygons (with no back faces).
Advertisement
Try inverting all the normals,
i.e. glNormal3f(1,0,0)
should be
glNormal3f(-1,0,0)

-David-
the distance is changed in the glProjection function.....
(i think...correct me if i am wrong! )!!

Just change the last parameter to something big.......

Take Care!

- -- ---[XaOs]--- -- -

[ project fy ]
- -- ---[XaOs]--- -- -[ Project fy ||| CyberTux ]
I solved my problem.
I simply forgot to switch back to Modelview by glMatrixMode(GL_MODELVIEW)

Thanx to all who helped me


This topic is closed to new replies.

Advertisement