Hi I'm trying to make a solid with Indexed FaceSet on VRML. The problem is 2 faces aren't showing up and I really don't know why.
The code is:
Shape {
geometry IndexedFaceSet {
coord Coordinate {
point [0 0 0, #0
0.3 0 0, #1
0 1.2 0, #2
0.3 1.2 0, #3
0 0 -1, #4
0.3 0 -1, #5
0 1.2 -1, #6
0.3 1.2 -1, #7
0.6 1.2 -0.3, #8
0.6 1.2 -0.7] #9
}
coordIndex [6 7 9 8 3 2 -1,
0 1 5 4 -1,
1 5 9 8 -1,
0 1 3 2 -1,
4 5 7 6 -1,
0 4 6 2 -1,
3 1 8 -1,
7 5 9 -1
]
}
appearance Appearance { material Material { diffuseColor 0 0 0.8 }}
}
The 2 sides not appearing are the last ones. Any thoughts?
First, each side has to be defined in counter-clockwise order to be visible because
IndexedFaceSet
objects are one-sided unless you usesolid FALSE
, that's why some faces in your model look like they're missing, but they're actually visible from the other side instead.Solution 1: solid FALSE
Faces are visible from both sides, so it doesn't matter if they were defined clockwise or counter-clockwise. That's the easy hack, but it doubles the number of polygons that the viewer renders internally.
Solution 2: flip the faulty faces
Reverse the order of the vertexes for the specific faces that should be flipped.