I have look at the examples on the MultiTextureTest. I tried to used it for the Sphere using TriangleStripArray, TriangelArray and TriangleFanArray but I'm getting the wrong results. I expected the stone with the cross over the Sphere. I'm getting some transparent shape with some stone texture. Can anybody help me on this ?
private void CreateSphere() {
Transform3D t3d;
GeometryConstruct gc;
TriangleStripArray geom;
final int features = Geometry.COORDINATES | Geometry.TEXTURE_COORDINATES ;
gc = Sphere.createGeometryConstructITSA( 0.0f, 0.0f, 0.0f, 1.0f, 30, 30, features, false, 3 );
geom = new TriangleStripArray( gc.numVertices() );
geom.setCoordinates( 0, gc.getCoordinates() );
geom.setTextureCoordinates( 0, 0, gc.getTextureCoordinates3f() );
geom.setTexCoordData( 1, geom.getTexCoordsData( 0 ) );
SPHERE = new Shape3D( geom, CreateAppearance2D() );
t3d = new Transform3D();
t3d.setIdentity();
t3d.setTranslation(-8f, HEIGHT, 0.0f);
RotatableGroup testRotateYGroup = new RotatableGroup(new TransformationDirectives(0f, 0.1f, 0f));
testRotateYGroup.addChild(SPHERE);
testRotateYGroup.setTransform(t3d);
OBJECT_ROOT_2D.addChild(testRotateYGroup);
ANIMATOR.addAnimatableObject(testRotateYGroup);
}
protected Appearance CreateAppearance2D(){
Appearance ap;
TextureAttributes ta;
Texture tex, tex1;
TextureUnit tu0, tu1;
ta = new TextureAttributes( TextureAttributes.MODULATE, null, null, TextureAttributes.NICEST );
tex = TextureLoader.getInstance().getTexture( "stone.jpg", FlipMode.NOT_FLIPPED, TextureFormat.DEPTH, MipmapMode.MULTI_LEVEL_MIPMAP, false );
tex1 = TextureLoader.getInstance().getTexture( "cross.jpg", FlipMode.NOT_FLIPPED, TextureFormat.DEPTH, MipmapMode.MULTI_LEVEL_MIPMAP, false );
tu0 = new TextureUnit( tex, ta, null );
tu1 = new TextureUnit( tex1, ta, null );
ap = new Appearance();
ap.setPolygonAttributes( new PolygonAttributes( PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_BACK ) );
ap.getColoringAttributes(true).setColor( Colorf.YELLOW );
ap.setMaterial(MATERIAL);
ap.setTextureUnit( 0, tu0);
ap.setTextureUnit( 1, tu1);
return ap;
}