Migrating from JME1 to JME2: Mostly about TriangleBatch

Hi!



I have to convert a program from JME1 to JME2, that I haven't

written by myself. So unfortunately I don't have an in-depth

understanding of everything in the code.



When migrating, I ran into a couple of problems, mostly related to

Batches (TriangleBatch, getBatchCount, getBatch(n) etc.).

Right now I cannot compile my code under JME2. My first goal

is to make code that compiles.

Searching through the forum I found out that most of the TriangleBatch

were replaced by Geometry, but I still have some questions, where I

need to ask for your help.



Here we go. How do I replace sth like this:

  1. // JME1-Code

            for (int i = 0; i < mesh.getBatchCount(); i++) {

                mesh.getBatch(i).setEnabled(false);

                mesh.getBatch(i).setHasDirtyVertices(true);

            }

    My guess for JME2: mesh.getBatchCount() -> mesh.getTriangleCount?

    What about mesh.getBatch(i)?


  2. TriangleBatch batch = mesh.getBatch(0); // JME1

                batch.setTextureCombineMode(TextureState.OFF);

    My guess:

        Geometry batch = mesh; //JME2

        mesh.setTextureCombineMode(TextureCombineMode.Off);


  3. mesh.removeBatch(batchIndex); // JME1


  4. if (batch.getMode() != TriangleBatch.TRIANGLES) { … } //JME1


  5. com.jme.scene.Image image; // JME1

        texture = new Texture();

        texture.setImage(image);



        Question here: I found out, there is TextureManager.loadTexture(java.awt.Image image, …),

        is this what I'm supposed to use here? If so, is there a shortcut to convert from

        com.jme.scene.Image to java.awt.Image?





    Thanks a lot for any help,

    Bernhard

hey there. first off always put your code in code brackets for easy reading.


  1. you can delete the whole for loop, batches have been removed and all it does is set properties of said batches.


  2. this will suffice:


mesh.setTextureCombineMode(TextureCombineMode.Off);



3. just delete it.

4. dont know exactly but there should be something in the Geometry or TriMesh class that has fan and strip feature constants. look around

5. yes, use the TextureManager class to load textures from Image object or image files


mesh.setTextureCombineMode(TextureCombineMode.Off);