Hole in a wall

Hello,

can anybody help me with some coding ?
I want to cut a hole (e.g. cylinder) in a wall (cuboid). How can I do this ?

Thanks

Oliver

Do you want to generate a new geometry with the hole in the cube or just the visual effect?

The first needs a lot of math and intersection calculations. You’ll probalbly find some bits and pieces on most of the math pages like http://mathworld.wolfram.com/.

For the latter, look at “csg.c” in the GLUT distrubution. It shows how to display Constructive Solid Geometry in realtime with some help of the stencil buffer.

Thank you very much, I think the “csg-hint” is the right way :slight_smile:

The “csg” is not working in my case, perhaps it is I am using Delphi and I do not init via glut, I use my own init-routines. I loose the colors and get stripes, it looks like something is working but not in the right way. An other thing I translated the code to Delphi with the following details and I am not sure if this is write:
In C:
void inside(void(*a)(void), void(b)(void), GLenum face, GLenum test)
{
/
draw A into depth buffer, but not into color buffer */
glEnable(GL_DEPTH_TEST);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glCullFace(face);
a();

In Delphi I “translated” :
procedure inside(a, b : Integer;face,test : GLEnum);
begin
glEnable(GL_DEPTH_TEST);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE,
GL_FALSE);
glCullFace(face);
callList(a);

Before I made a cube by using glutSolidCube with the name a (glLoadName(a)) and the Displaylist with the number a. a is in my case a variable. Is there something wrong ?

But I have an other idea, could I use nurbs ?
How can I “generate” a flat nurb-surface (e.g. a surface with 4 edge-points) ?
Is there a good description about nurbs on the net ?
How do I generate a nurb-surface with the following parameters :

lets say I have 5 points in the x direction (0…4) and 5 points in the y direction (0…4) and I have different “heights” for the z direction in every point, how can I describe this by using nurbs ?

Thanks
Oliver

[This message has been edited by Oliver (edited 12-11-2000).]

[This message has been edited by Oliver (edited 12-12-2000).]

[This message has been edited by Oliver (edited 12-12-2000).]

Originally posted by Oliver:
void inside(void(*a)(void), void(*b)(void), GLenum face, GLenum test)
procedure inside(a, b : Integer;face,test : GLEnum);

These two are far from equivalent. void(*a)(void) translates to procedure in Pascal. So your prototype would be procedure Inside(a, b: procedure; face, test: GLenum);

I don’t know what this code is supposed to do, of course, but you’re not supposed to be passing it display list names - you should pass it function pointers.

  • Tom

procedure Inside(a, b: procedure; face, test: GLenum);

Procedure is a reserved name in Delphi (Pascal) so I can only use Types like Integer, Float, String, Pointers…

So I do not know how to handle this :frowning:

Can you tell me what does the a(); in the C-Code ?

[This message has been edited by Oliver (edited 12-12-2000).]

I think the inside-function is a general function, where you pass two functions that draws two objects (function a and b). You can remove these two arguments, and replace a() and b() in the code with something that draws an object.

procedure inside(face,test : GLEnum);
begin
glEnable(GL_DEPTH_TEST);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glCullFace(face);
DrawSomeObjectHere();

… for example. Or…

procedure inside(face,test : GLEnum);
begin
glEnable(GL_DEPTH_TEST);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glCullFace(face);
glBegin(whatever);

glEnd();

So it should also be possible to use a displaylist or ?

Oliver

Yepp, a() and b() is, probably, just two functions you use to draw the two objects. You can use whatever functions/method you like in your code.

Why can I not replace then
a(); (C++)
with
callList(a); (Pascal)

Um, well… you can…

If you put the two arguments back into the function (the a and b parameter defined as integers), you can. But then you have to pass the id of two displaylists to the function.

You must also change more things in your code if you want to do this. In the C-code you got, a and b are two functions. Instead, you must use their code to build a displaylist (a and b) in the initializationpart of your code.

Originally posted by Oliver:
[b]procedure Inside(a, b: procedure; face, test: GLenum);

Procedure is a reserved name in Delphi (Pascal) so I can only use Types like Integer, Float, String, Pointers…

So I do not know how to handle this :-([/b]

Actually it’s perfectly possible.

procedure MyProc;
begin
  // ...
end;

// Write some other procedures here...

procedure Test;
var
  a, b: procedure;
  test, face: GLenum;
begin

  @theProc := MyProc;
  // Similarly initialize b.
  // Also initialize face and test...

  Inside(a, b, face, test);

end;

You most definitely can declare a variable that is of type procedure. You should look up ‘procedural types’ in Delphi’s online help - it’s all there.

The call to a() does just that - it executes the procedure you passed as an argument to inside(). You can write the exact same thing in Delphi.

Note that this doesn’t even remotely have anything to do with display lists, so I don’t know where you got the idea that you could write glCallList(a)?

  • Tom

This with the glCallList(a) wasw my idea, because I had no idea what is done with a(), so I decided it could be something like callist :slight_smile:

I have now a quistion again, what is done in MyProc and what is done in C with the a(); ?
There is a definition of a() outside the function “Inside”, a is declared as:

void (*A)(void);
void (*B)(void);

but never someting else like what is done there. Here are some parts of the code csg.c


/* defines */
#define SPHERE 1
#define CONE 2
#define CUBE 3

A = cube;
B = sphere;

As fas as I know is the result A=2 (definition as constant) and then is somewhere a(); with some predeclared function void (*A)(void);, what is done with this code ?

Thanks

Oliver

Originally posted by Oliver:
/* defines */
#define SPHERE 1
#define CONE 2
#define CUBE 3

A = cube;
B = sphere;

C/C++ is case sensitive, so cube does not equal CUBE. You need to look for the definition of the functions cube and sphere, which should look somewhat like void cube() or void cube(void).

  • Tom

I have not found something like this, but
could I send you the source code csg.c, perhaps we you can see better what I mean.

Oliver

Originally posted by Oliver:
I have not found something like this, but
could I send you the source code csg.c, perhaps we you can see better what I mean.

Don’t bother:

void sphere(void)
{
  glPushMatrix();
  glTranslatef(sphereX, sphereY, sphereZ);
  glCallList(SPHERE);
  glPopMatrix();
}

The file I have (csg.c from Glut 3.7) doesn’t have any references to cubes, just spheres and cones. However, the functions are there. I can port this demo to Delphi if you want, it’s quite short… In the long run, you’d probably be better off digging a little deeper into C and Pascal, though

  • Tom

Thank you very much if this could be possible for you :slight_smile: :slight_smile: :slight_smile:

Oliver

Originally posted by Oliver:
Thank you very much if this could be possible for you :slight_smile: :slight_smile: :slight_smile:

Damn, this thread got way too far off-topic
There’s no e-mail address in your profile, so keep an eye out for the demo on http://www.gamedeveloper.org/delphi3d
It’ll probably be there later tonight (GMT+1).

  • Tom

[This message has been edited by Tom Nuydens (edited 12-12-2000).]

Sorry, the Emailadress should be there now
:frowning:

Thank you very, very, very much,

this is the one I was looking for :slight_smile:

Oliver