I can help you with GeometryInfo problems.

I have some code that generates a 'rounded stick' like object I use for
creating molecular stick models. The GeometryInfo class interests me and
looks like it could save me a lot of work. That is if I could get it to
work.

Case 1:

def createNormals(self):
 gi = GeometryInfo(GeometryInfo.TRIANGLE_ARRAY| LineArray.COLOR_3)

The prmitive sent to GeometryInfo is one of the five primitives listed in the javadoc (POLYGON_ARRAY, QUAD_ARRAY, TRIANGLE_ARRAY, TRIANGLE_FAN_ARRAY, or TRIANGLE_STRIP_ARRAY). Why are you or'ring GeometryInfo.TRIANGLE_ARRAY with LineArray.COLOR_3? That's wrong.

GeometryInfo will know that you have colors when you set the colors
using setColors().  You do not need to send a flag to the constructor
to inform it that you will be using colors.  GeometryInfo was
designed to be more flexible than GeometryArray, and this is one
example of how I tried to achieve that.

 gi.setCoordinates(self.verts)
 nm = NormalGenerator()

NormalGenerator nm = new NormalGenerator();


 nm.generateNormals(gi)
 si = Stripifier()

Stripifier si = new Stripifier();


 si.stripify(gi)
 return gi.getGeometryArray(1,0,0)

return gi.getGeometryArray(true, false, false);



Result:


java.lang.IllegalArgumentException: StripCounts inconsistent with primitive
at com.sun.j3d.utils.geometry.GeometryInfo.checkForBadData

This error means that you have set stripCounts on a primitive that doesn't require it, or vice-versa. TRIANGLE_ARRAY and QUAD_ARRAY don't require stripCounts, the other three primitive types do.

GeometryInfo is confused about the primitive because you sent the
LineArray.COLOR_3 flag to the constructor.  LineArray.COLOR_3 is
4 and GeometryInfo.TRIANGLE_ARRAY is 1 so you are sending 1 | 4 = 5
to the constructor.  This corresponds to GeometryInfo.POLYGON_ARRAY
so GeometryInfo is expecting polygons.  This is why it needs a
stripCounts arry, which you didn't set, hence the error.  (To find
these values, in the javadoc, click on the constant and then click
on "See Also: Constant Field Values."  See here:

http://hendrix.lems.brown.edu/~arw/online-docs/java3d-1.3.0-docs/constant-values.html


Yet it works if I create a GeometryArray.TRIANGLE_ARRAY with the same data
it works.

Huh ?

The primitive type constants for GeometryInfo are separate from those for GeometryArray. You need to use the GeometryInfo primitive constants for GeometryInfos and the GeometryArray constants for GeometryArrays.

-Paul Pantera
 Chief Architect, PresidioLabs, Inc.
 1-650-766-1517

===========================================================================
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".

Reply via email to