volume coloring

i have a cube in a 3d space. when i zoom into it, i can c only the walls when im within the cube. is there ne way to fill the interiors of a cube? i mean the whole volume contained inside the cube should be colored as its walls. or is there ne other way that when im inside the cube i dont c the walls.
thank u

It is not possible to directly fill the cube, but there may be a workaround.

What exactly do you expect to see when the camera is inside the cube?

i dont want to c ne empty spaces inside. i just want it to be filled. i wanted it to be filled with the same color as its walls. it should give a solid feeling. not a hollow feel. the reason im doin this is cause when i move around in the 3d space and zoom into some of my objects, and when i get inside them, i can c only the polygon walls. i dont want that to happen.

Originally posted by Overmind:
[b]It is not possible to directly fill the cube, but there may be a workaround.

What exactly do you expect to see when the camera is inside the cube?[/b]

Is your cube textured?

If no, and cube has one solid color, you can always disable lighting for back-facing polygons.

It sounds like you’re wanting some sort of volume rendering thing going on (or something.)

Let’s get this straight:

You move around, and when you pass through a polygon on the outside of a cube, you can see inside (and all the inside polys of the cube.) Now… what you say you want sounds like…
Let’s say the cube is red.
As soon as you move inside of the cube, you want the viewport to be completely red…

-Or- the cube is red.
When you move inside of the cube, you want the cube to be “bored out” in the area/point the viewer is looking from.

Unfortunately, openGL isn’t made to do this automatically… I remember when I got into 3d stuff and it was such a let down to see that the stuff that looked so concrete was just a paper-wall looking structure internally. I wanted to know how to make solid objects.

What you probably want as a solution, is to just not let the user enter into the 3d “solid” (how could they anyway if it’s a solid?)
This is how all the 3d shooters and games out there generally take care of this problem.

You’ll want to read up on collision detection. There are actually some libraries out there that will do what (it sounds like) you want. Some are very fully featured and calculate the physics in a dynamic environment. Others are more “bare-bones” and only do stuff like clipping a camera’s position to be outside of an object.

If you want to calculate it yourself, you’ll probably want to search for infomation on… nm, actually flipcode.com (www.flipcode.com) has a “code of the day” (right hand side of front page, below image of the day) that calculates the point of intersection between a sphere and a “polygon soup” (any weird old polygons - doesn’t require special cases.)

You’d want to use the camera as a sphere (so not to get too close to objects - hey, even my nose gets in the way once I’m and inch away from whatever I’m looking at… right?)

Hope this helps,
-Michael

ps. If you’re really trying to see inside the object (and want it solid) check into volume rendering, voxels, and medical imaging with voxels (www.google.com)

You dont need volume rendering I think.

You can always do the cap rendering trick (I dont know the official name).

Basically, you render back faces by incrementing the stencil, then render front faces by decrementing the stencil.
For the final pass, you render a fullscreen quad and use stencil testing to reject fragments when stencil=1 and pass if stencil is 0.

Some CAD programs do this by rendering the cut face all red, but you can always texture it.

Stencil capping is illustrated by the Rage128 Stencil Cap sample (assuming that’s what you’re after). Of course, this uses a user clip plane rather than the front plane, which you seem to be clipping your object against. I’m sure you could make it work that way too.

-Jason

IIRC there’s an nVidia only depth clamp extension which could be used when the viewpoint is outside the box, but the near clipping plane intersects the box. If the viewpoint is inside the box then you can just use a full screen quad.

Originally posted by V-man:

You can always do the cap rendering trick (I dont know the official name).

Some CAD programs do this by rendering the cut face all red, but you can always texture it.

Hi,

I do this trick for CAD rendering, but its very slow for complex models. You could do it much faster, depending on the structure of your 3d models in background. I have a BSP here, so it is very easy to throw my actual camera position into the BSP and get returned if I’m inside or outside. Then I would simply color the whole screen in the color of this object (like somebody said before).

Kilam.

Originally posted by Kilam Malik:
[b] Hi,

I do this trick for CAD rendering, but its very slow for complex models. You could do it much faster, depending on the structure of your 3d models in background. I have a BSP here, so it is very easy to throw my actual camera position into the BSP and get returned if I’m inside or outside. Then I would simply color the whole screen in the color of this object (like somebody said before).
[/b]

If rendering twice is slow, then you could use that extension (double sided stencil?) plus make use of whatever else there is (like VBO).

But since this is a per fragment operation, you have no choice but to render ALL front and back faces.