|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
No color in a TriangleStripArrayCan anyone explain why the back strip (OctagonBottomStrip4) is showing the fill color and the front strip (OctagonBottomStrip1) is not, for the sample code I've provided below?
I've tried drawing and filling the bottom surface of this figure several ways, for instance as a single TriangleStripArray Shape3D objects with four strip segments and and as four seperate TriangleStripArray Shape3D objects (as provided in the sample code. In either case only the back strip is ever rendered correctly. Am I doing something wrong? BTW, Sorry about the code formating, this is not how I write my code :-). import java.applet.Applet; import java.awt.BorderLayout; import java.awt.GraphicsConfiguration; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; public class Java3DGeometryTesterAnimated extends Applet { public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the transform group node and initialize it to the // identity. Add it to the root of the subgraph. TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objSpin); // Create a simple shape leaf node, add it to the scene graph. // ColorCube is a Convenience Utility class //objSpin.addChild(new OctagonTop()); objSpin.addChild(new OctagonBottomStrip1()); //objSpin.addChild(new OctagonBottomStrip2()); //objSpin.addChild(new OctagonBottomStrip3()); objSpin.addChild(new OctagonBottomStrip4()); //objSpin.addChild(new OctagonWalls()); objSpin.addChild(new OctagonWireframeTop()); objSpin.addChild(new OctagonWireframeBottom()); objSpin.addChild(new OctagonWireframeWalls()); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Alpha rotationAlpha = new Alpha(-1, 100000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); // a bounding sphere specifies a region a behavior is active // create a sphere centered at the origin with radius of 100 BoundingSphere bounds = new BoundingSphere(); rotator.setSchedulingBounds(bounds); objSpin.addChild(rotator); return objRoot; } // end of CreateSceneGraph method public Java3DGeometryTesterAnimated() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas3D = new Canvas3D(config); add("Center", canvas3D); BranchGroup scene = createSceneGraph(); // SimpleUniverse is a Convenience Utility class SimpleUniverse simpleU = new SimpleUniverse(canvas3D); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); } // end of HelloJava3D (constructor) // The following allows this to be run as an application // as well as an applet public static void main(String[] args) { new MainFrame(new Java3DGeometryTesterAnimated(), 256, 256); } // end of main (method of HelloJava3D) } import javax.media.j3d.*; import javax.vecmath.*; public class OctagonBottomStrip1 extends Shape3D { private int vertCount [ ] = { 8 }; private float verts [ ] = { 0.6f, -0.3f, 0.3f, // First Triangle Strip 0.3f, -0.3f, 0.6f, 0.3f, -0.3f, 0.3f, 0.0f, -0.3f, 0.6f, 0.0f, -0.3f, 0.3f, -0.3f, -0.3f, 0.6f, -0.3f, -0.3f, 0.3f, -0.6f, -0.3f, 0.3f }; public OctagonBottomStrip1( ) { setGeometry(createGeometry()); } private Geometry createGeometry() { Color4f green = new Color4f(0.0f, 1.0f, 0.0f, 0.0f); TriangleStripArray bottomSurface = new TriangleStripArray(8, GeometryArray.COORDINATES | GeometryArray.COLOR_4, vertCount); bottomSurface.setCoordinates(0, verts); bottomSurface.setColor(0, green); bottomSurface.setColor(1, green); bottomSurface.setColor(2, green); bottomSurface.setColor(3, green); bottomSurface.setColor(4, green); bottomSurface.setColor(5, green); bottomSurface.setColor(6, green); bottomSurface.setColor(7, green); return bottomSurface; } } import javax.media.j3d.*; import javax.vecmath.*; public class OctagonBottomStrip4 extends Shape3D { private int vertCount [ ] = { 8 }; private float verts [ ] = { 0.6f, -0.3f, -0.3f, // Forth Triangle Strip 0.3f, -0.3f, -0.6f, 0.3f, -0.3f, -0.3f, 0.0f, -0.3f, -0.6f, 0.0f, -0.3f, -0.3f, -0.3f, -0.3f, -0.6f, -0.3f, -0.3f, -0.3f, -0.6f, -0.3f, -0.3f }; public OctagonBottomStrip4( ) { setGeometry(createGeometry()); } private Geometry createGeometry() { Color4f green = new Color4f(0.0f, 1.0f, 0.0f, 0.0f); TriangleStripArray bottomSurface = new TriangleStripArray(8, GeometryArray.COORDINATES | GeometryArray.COLOR_4, vertCount); bottomSurface.setCoordinates(0, verts); bottomSurface.setColor(0, green); bottomSurface.setColor(1, green); bottomSurface.setColor(2, green); bottomSurface.setColor(3, green); bottomSurface.setColor(4, green); bottomSurface.setColor(5, green); bottomSurface.setColor(6, green); bottomSurface.setColor(7, green); return bottomSurface; } } [Message sent by forum member 'mtarullo463' (mtarullo463@...)] http://forums.java.net/jive/thread.jspa?messageID=370062 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: No color in a TriangleStripArrayHi
I guess you have to set Normals to have working right. I thing you should create an Appearance, define a PolygonAttributes and play with face culling as CULL_NONE, CULL_BACK, CULL_FRONT. There is no need to create a extra geometry to paint the back side. Just set it as CULL_NONE. [Message sent by forum member 'zesharp' (zando.silva@...)] http://forums.java.net/jive/thread.jspa?messageID=370068 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
|
|
Re: No color in a TriangleStripArrayCULL_NONE did the trick!!!!
I was able to use an Apperaance object with ColoringAttributes and PolygonAttributes with just my original single Shape3D object. Thanks for the hint. [Message sent by forum member 'mtarullo' (mtarullo463@...)] http://forums.java.net/jive/thread.jspa?messageID=370073 --------------------------------------------------------------------- To unsubscribe, e-mail: interest-unsubscribe@... For additional commands, e-mail: interest-help@... |
| Free embeddable forum powered by Nabble | Forum Help |