3D Theory - Geometry Arrays

This section demonstrates how a geometry is built using an Indexed Face Set (IFS). We dont normally build shapes from scratch like this, there are quicker ways, for instance, we could draw a 2 dimentional shape and then use an 'extrude tool' to turn it into a 3D shape. Or we can build it up from simple pre-built shapes. However building a simple box from scratch will be a good way to understand the underlienig principles of 3D geometrys.

So to begin, start up the program. Then use insert to add a TransformGroup, under this add a Shape3D, under this add an IFS and uder this add Coordinate node.

The left hand panel shows this tree structure you have just created.

First add the vertex coordiates, these are the coordinates of the corners of the box, there are 8 coordinated (the 4 corners of the front face and the four corners of the back face).

Select the coordinate node, in the left hand tree panel, in the middle panel click on insert 8 times to give verticies, you should see somthing like this:

Entering vertexes

Now we need to enter the values into the vertex coordinates. Each vertex is a point in space with x,y and z coordinates.

Currenty these are all set to default vaues of zero so we need to enter the numbers.
the vertexes on the front face are:
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, 1.0,
the vertexes on the back face are
-1.0, -1.0, -1.0,
-1.0, 1.0, -1.0,
1.0, 1.0, -1.0,
1.0, -1.0, -1.0,



Enter Vertex coords

The shape (in this case a box) can be made up of triangles or quads (four points in the same plane). As we are building a box, it is probably easier to use quads. So we need six rectangles to make up the box. Six rectangular faces are needed, top, bottom, left, right, front and back. Each of which is defined by its four corners.


0,1,2,3, // front face
4,5,6,7, // back face
7,6,1,0, // right face
3,2,5,4, // left face
1,6,5,2, // top face
3,4,7,0, // bottom face

 

 

 



new sfvec3f( 0.0f, 0.0f, 1.0f), // front face
new sfvec3f( 0.0f, 0.0f, -1.0f), // back face
new sfvec3f( 1.0f, 0.0f, 0.0f), // right face
new sfvec3f(-1.0f, 0.0f, 0.0f), // left face
new sfvec3f( 0.0f, 1.0f, 0.0f), // top face
new sfvec3f( 0.0f, -1.0f, 0.0f), // bottom face


metadata block
see also:

 

Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.