PDA

View Full Version : 256 cube help plz

rborob
11-05-2004, 01:30 AM
ok. im extremely new to openGL so please be as "layman" as possible when it comes to help. any help however is much appreciated

im creating a 16x16x16 cube filled with smaler cubes. ivew managed to do this. ive also implemented a zoom and rotate feature. my problem is this.
i need to be able to draw a plane through any point and set everything in front of that as either transparent or as background so it becomes invisible.
if need be i will show my code for the cube.
kind regards
rborob

Rawk
11-05-2004, 12:39 PM
Hi,

SOunds like you need a clip-plane. Basically, you can define a plane that will not allow anything drawn behind it (plane direction is defined by the normal vector).

FROM THE REDBOOK:

void glClipPlane(GLenum plane, const GLdouble *equation);

Defines a clipping plane. The equation argument points to the four coefficients of the plane equation, Ax+By+Cz+D = 0. All points with eye coordinates (xe, ye, ze, we) that satisfy (A B C D)M-1 (xe ye ze we)T >= 0 lie in the half-space defined by the plane, where M is the current modelview matrix at the time glClipPlane() is called. All points not in this half-space are clipped away. The plane argument is GL_CLIP_PLANEi, where i is an integer between 0 and 5, specifying which of the six clipping planes to define.

So, the trickiest part is determining the coefficients for the plane. A simple example would to clip fragments with a negative X would be:

GLdouble coefs[4] = { 1.0, 0.0, 0.0, 0.0 };

glClipPlane( GL_CLIP_PLANE0, coefs );
glEnable( GL_CLIP_PLANE0 );
// Draw geometry to clip
glDisable( GL_CLIP_PLANE0 );Hope that helps!
-Rawk

rborob
11-05-2004, 02:22 PM
ok ill try that during the weekend
thanks for help ill let you know how it goes

rborob
11-07-2004, 01:38 PM
ok so how would i go about setting an input in my interface to handle any arguments? would i have an x, y, z input and have it draw the normal at those coordinates then clip it? what sort of code would i be looking at to do that for me if thats the case?

rborob
11-08-2004, 02:04 AM
ok that methos wasn't so good since the view of the cube is changing with rotate etc. heres what i think should work..any ideas?

given 3 cubes in tesseral form, plot a plane through these and determine what is displayed. thats to say everything in front of it is displayed as background (black)

help plz

rborob
11-08-2004, 01:20 PM
bump

rborob
11-09-2004, 01:57 AM
please can someone help..ive found some info on other posts but cant tell if its relevant or not. i just want my interface to be able to input 3 sets of coordinates, draw a plane through all of them and set all in front as background. please help

rborob
11-09-2004, 02:19 PM
bumpety bump

rborob
11-10-2004, 12:33 AM

ZbuffeR
11-10-2004, 03:22 AM
Stop bumping with silly posts.

1) You have been answered correctly : use clip planes.
2) A problem with rotation/scaling ? Read the docs better.
3) ... and stop bumping with silly posts. If you don't show you make some work, why would one want to help you again ?