Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3508 Members - Latest Member: NevilleKemp

26. May 2012, 03:03:26 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)MultiTexture
Pages: [1]
Print
Author Topic: MultiTexture  (Read 318 times)
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« on: 26. August 2010, 06:14:48 pm »

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 ?

Code:
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;
}
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 26. August 2010, 08:58:48 pm »

You're calling Sphere.createGeometryConstructITSA(), but create a TriangleStripArray from that (not indexed). This should be wrong.

You appearance looks good. But you could have problems with the cull mode on a sphere. Transparent spheres have to be rendered in CullMode.SWITCH.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic