Geometrybatch instance texturing

Hello!



I'm facing a problem using GeometryBatch to aggregate small meshes. These meshes are loaded from an external model and they have a texture attached.



So i've managed to build every mesh with


                    // Given the triangulation i build the relative Trimesh
                    polygonMesh.reconstruct(BufferUtils.createFloatBuffer(meshVertices),
                            BufferUtils.createFloatBuffer(meshNormals), BufferUtils
                                    .createFloatBuffer(meshColor), tCoords, BufferUtils
                                    .createIntBuffer(meshFaces));
                    polygonMesh.setRenderState(rs);


attaching the renderstate (texture one) and then building the instance with


                    // Box instance attributes
                    GeometryBatchInstanceAttributes attributes = new GeometryBatchInstanceAttributes(
                            Vector3f.ZERO, // TRANSLATION
                            Vector3f.UNIT_XYZ, // SCALE
                            new Quaternion(), // ROTATION
                            ColorRGBA.gray); // COLOR
                    // Box instance (batch and attributes)
                    GeometryBatchInstance instance = new GeometryBatchInstance(polygonMesh,
                            attributes);
                    geomBatchCreator.addInstance(instance);



After adding every mesh i do


            TriMesh mesh = new TriMesh("GeomBatch");
            mesh.setModelBound(new BoundingBox());
            // Create the batch's buffers
            mesh.setIndexBuffer(BufferUtils.createIntBuffer(geomBatchCreator.getNumIndices()));
            mesh
                    .setVertexBuffer(BufferUtils.createVector3Buffer(geomBatchCreator
                            .getNumVertices()));
            mesh
                    .setNormalBuffer(BufferUtils.createVector3Buffer(geomBatchCreator
                            .getNumVertices()));
            mesh.setTextureCoords(new TexCoords(BufferUtils.createVector2Buffer(geomBatchCreator
                    .getNumVertices())), 0);
            mesh.setColorBuffer(BufferUtils
                    .createFloatBuffer(geomBatchCreator.getNumVertices() * 4));
            geomBatchCreator.commit(mesh);
            retNode = new Node("Node");
            retNode.attachChild(mesh);



I get no texture on the model so something is wrong but cannot figure out. I've tried searching in this forum but I couldn't find anything fitting my need.

Hope someone can help me :)
Thank you in advance!

Eduard

Have you tried this?

retNode.setRenderState(rs);


I don't think GeometryBatchInstance automatically applies renderstates from the source to the target, so you'll have to do that yourself.