I'm getting that problem currently in my program. I'm loading a model from a file definition, so I'm not able (and don't want) to change the transforms provided within the model. Unfortunately (for me), some of the transforms are mirror transforms. The workaround I'm using in my case is as follows:
1. analyze the transform matrix (provided as a 16 float array) and determine if it is a mirror transform (it is a mirror if the determinant of the matrix is negative) 2. clone the affected subgraph, then traverse it and negate all the normals. For that subgraph I'm setting the polygon attributes CULL_NONE and Back-face normal flip is set to true. In your case, since you already know it's a mirror transform, you can directly go to step 2. BTW, Back-face normal flip attribute of the PolygonAttributes is ignored by the DirectX implementation of java3d, so it works only under opengl. Cheers, Florin -----Ursprüngliche Nachricht----- Von: Nick Stark [mailto:[EMAIL PROTECTED] Gesendet: Montag, 9. Juni 2003 22:53 An: [EMAIL PROTECTED] Betreff: Re: [JAVA3D] Inverted Normals Question Thanks for your response, Alessandro. I am actually mirroring a coordinate system change transform. Here is one of the transforms I am trying to mirror. 0.997564, -0.069755, -0.000462, -0.000000, 0.067070, 0.957300, 0.281208, -0.006913, -0.019174, -0.280554, 0.959647, -0.04314, 0.000000, 0.000000, 0.000000, 1.000000 And I multiplied this transform by the following (a scale of -1.0 applied to the x coordinates): -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 I'm not applying this transform to a shape, though...it is a bit more complex. To summarize, I need to mirror a coordinate system change (similar to one shown above), and use this transform in a series of transforms that are multiplied together. The product of this series of transforms is then used to transform a shape. Any ideas on how to mirror the transform without screwing up the normals? Thanks for your help, Nick Maybe this is a bug. How do you do this mirroring ?? transform3D.setScale(-1) ? ( I guess the Java3D develop. team never imagined a negative scaling hehehehe ) If so, may you can try another way as reverting X axis of the shapes, as below : private void mirrorShapeXAxis(Shape3D sh) { Appearance app = sh.getAppearance(); if (app != null) { PolygonAttributes polyA = new PolygonAttributes(); polyA.setCullFace(polyA.CULL_FRONT); app.setPolygonAttributes(polyA); } GeometryInfo gi = new GeometryInfo((GeometryArray)sh.getGeometry()); Point3f[] coords = gi.getCoordinates(); // mirror in X axis for(int i=0; i<coords.length;i++) { coords[i].x = - coords[i].x; } gi.setCoordinates(coords); // it reverse the normals - not mirror like //NormalGenerator ng = new NormalGenerator(); //ng.generateNormals(gi); //gi.recomputeIndices(); sh.setGeometry(gi.getGeometryArray()); } Please report if it works or not. Alessandro ----- Original Message ----- From: "Nick Stark" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, June 09, 2003 10:09 AM Subject: [JAVA3D] Inverted Normals Question > Hi - > > I have a set of objects, all of whose normals are initially correct (all > lighting looks as it should). > > However, I apply a mirror transform to some of the objects, and when > viewing the new objects, it appears that the normals have been inverted on > the geometry. The lights still look correct for the objects that were not > mirrored, but the objects that are mirrored have dark faces and bright > backsides. The objects have not moved to such a position where this should > be the case, though. Is there some issue with the 3D API or is this a > problem that any of you have encountered before? > > Thanks for any help. > > Nick > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA3D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". ==========================================================================To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".