Hi Frederik,

In the polygon attributes, you should also set the "flip backface normal"
attribute. That should solve your problem on OpenGL implementation. On
DirectX, this attribute is not supported.

Cheers,

Florin

-----Ursprüngliche Nachricht-----
Von: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED] Auftrag von Fredrik Andersson
Gesendet: Freitag, 28. Januar 2005 16:32
An: JAVA3D-INTEREST@JAVA.SUN.COM
Betreff: [JAVA3D] Shouldn't a object be all in the samt color?


Hello!

I got a Canvas3D with some light, DirectionalLight. I do not think there is
any strange with that.

But when I add an Shape3D and set the Appearance something like this:

appearance = createMaterialAppearance(new Color3f(colors[0], colors[1],
colors[2]));

GeometryInfo gi = null;
NormalGenerator ng = new NormalGenerator();
Stripifier st = new Stripifier();
gi = new GeometryInfo( GeometryInfo.POLYGON_ARRAY );

gi.setCoordinates(cordinates3D[i]);
int[] stripCount = { cordinates3D[i].length/3 };
gi.setStripCounts(stripCount);

shapes3Ds[i] = new Shape3D();
shapes3Ds[i].setAppearance( appearance );

ng.generateNormals(gi);
gi.recomputeIndices();

st.stripify(gi);
gi.recomputeIndices();

shapes3Ds[i].setGeometry(gi.getGeometryArray());

and below is how I create the apperance:


    public Appearance createMaterialAppearance(Color3f color)
    {
        Appearance materialAppear = new Appearance();
        PolygonAttributes polyAttrib = new PolygonAttributes();
        polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
        materialAppear.setPolygonAttributes(polyAttrib);

        Material material = new Material();
        material.setDiffuseColor(color);
        materialAppear.setMaterial(material);

        return materialAppear;
    }

How ever when I rotate the Shape3D the object is black on the backside. I
thought that when the other side is exposed for the light it would reflect
the same color as the front side.

So if any one could explain why and how to solve it it would be great. I
hope you got all the info you need. My guess is that the problem is in how i
create the appearance.

Best regards
Fredrik

_________________________________________________________________
Chatt: Träffa nya nätkompisar på Habbo Hotel
http://habbohotel.msn.se/habbo/sv/channelizer

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

Reply via email to