mjbWorld program - ifsBean

This discribes how the VRML IndexedFaceSet parameters are converted into Java3D IndexedTriangleArray or IndexedQuadArray classes.

In VRML the IndexedFaceSet is used to define any arbitrary shape. Under this node there might be coordBean, colorBean, texcoordBean or normalBean to store vertex coordinates and other information about the vertexes, these arrays are all indexed.

In Java3D there are many geometry types, I have chosen to use IndexedTriangleArray or IndexedQuadArray classes as these apprear to be closer to the VRML IndexedFaceSet parameters. So a shape is made up of triangle or quad faces, these are defined by the 3 or 4 vertices at their corners. Because they are indexed, each vertex may be used in several triangles or quads. This indexing is a more efficient way to store the information in terms of requiring less data, however I'm not sure about the runtime efficiency once its passed to the Java3D classes such as IndexedTriangleArray.

So we need to take the VRML parameters and convert them into the arrays required by the Java3D IndexedTriangleArray and IndexedQuadArray nodes as follows.


Processing For Coords


Processing For Normals


Processing For Colors


Processing For TextureCoordinates

 


ifs_bean class

Classes written for this program Java3D classes (scene graph structure)

VRML2 definition:

IndexedFaceSet {

eventIn MFInt32 set_colorIndex
eventIn MFInt32 set_coordIndex
eventIn MFInt32 set_normalIndex
eventIn MFInt32 set_texCoordIndex
exposedField SFNode color NULL
exposedField SFNode coord NULL
exposedField SFNode normal NULL
exposedField SFNode texCoord NULL
field SFBool ccw TRUE
field MFInt32 colorIndex [] # [-1,∞)
field SFBool colorPerVertex TRUE
field SFBool convex TRUE
field MFInt32 coordIndex [] # [-1,∞)
field SFFloat creaseAngle 0 # [0,∞)
field MFInt32 normalIndex [] # [-1,∞)
field SFBool normalPerVertex TRUE
field SFBool solid TRUE
field MFInt32 texCoordIndex [] # [-1,∞)

}

 

Color {
exposedField MFColor color [] # [0,1]
}

Coordinate {
exposedField MFVec3f point [] # (-,)
}

Normal {
exposedField MFVec3f vector [] # (-∞,∞)
}

TextureCoordinate {
exposedField MFVec2f point [] # (-,)
}


VRML2 format

When an IFS is saved it looks like this:

#VRML V2.0 utf8
Transform {
children [
Shape
{
geometry IndexedFaceSet {
coord Coordinate {
point
[
0.5 -0.5 0.5,
0.5 0.5 0.5,
-0.5 0.5 0.5,
-0.5 -0.5 0.5,
-0.5 -0.5 -0.5,
-0.5 0.5 -0.5,
0.5 0.5 -0.5,
0.5 -0.5 -0.5,
]

}
coordIndex [
0, 1, 2, 3, -1,
4, 5, 6, 7, -1,
7, 6, 1, 0, -1,
3, 2, 5, 4, -1,
1, 6, 5, 2, -1,
3, 4, 7, 0, -1,
]

normal Normal {
vector
[
0.0 0.0 1.0,
0.0 0.0 -1.0,
1.0 0.0 0.0,
-1.0 0.0 0.0,
0.0 1.0 0.0,
0.0 -1.0 0.0,
]

}
normalIndex [
0, 0, 0, 0, -1,
1, 1, 1, 1, -1,
2, 2, 2, 2, -1,
3, 3, 3, 3, -1,
4, 4, 4, 4, -1,
5, 5, 5, 5, -1,
]

texCoord TextureCoordinate {
point
[
1.0 0.0,
1.0 1.0,
0.0 1.0,
0.0 0.0,
1.0 0.0,
1.0 1.0,
0.0 1.0,
0.0 0.0,
]

}
texCoordIndex [
0, 1, 2, 3, -1,
4, 5, 6, 7, -1,
7, 6, 1, 0, -1,
3, 2, 5, 4, -1,
1, 6, 5, 2, -1,
3, 4, 7, 0, -1,
]

}
}
]
}

metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Covers VRML 2 (but not the upcoming X3D standard). A good introduction to all VRML2 node types and how to build them.

cover This book introduces 3D concepts, VRML, Java3D, MPEG4/BIFS, and X3D. It is a very good introduction to the theory, The writers have an in depth knowledge due to their involvement in the standards making. This is a good book to help you choose which 3D open standards to use and to give you a good insight into these standards. It is probably not for those who want a basic introduction to 3D or for these who want a step-by-step programming in 3D book.

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

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

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