Strange textures

Hello… i made a model in 3dsmax, then exported 3ds. From milkshake imported it and saved as a ms3d. I checked the the mapping coords imported from 3ds using the texture coordinate editor form milkshape and looks correct.

The model in milkshape looks like this







but in render doesnt look that good







heres the code i used:


 
protected void loadMilk() {
        MilkToJme converter=new MilkToJme();
        URL MSFile=GameStart.class.getClassLoader().getResource(
        "com/vlad/game/data/model/muelle.ms3d");
        ByteArrayOutputStream BO=new ByteArrayOutputStream();

        try {
            converter.convert(MSFile.openStream(),BO);
        } catch (Exception e) {
            System.out.println("IO problem writting the file!!!");
            System.out.println(e.getMessage());
            System.exit(0);
        }
        JmeBinaryReader jbr=new JmeBinaryReader();
        Node i=null;
        try {
            i=jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
        } catch (IOException e) {
            System.out.println("darn exceptions:" + e.getMessage());
        }
        i.setLocalScale(.1f);
        rootNode.attachChild(i);
}



What could this be??

Also tried the same model using the milkshape export to ascii and following the example in TestMilkshapeASCII and get the same wrong mapping.

AND finally used the TestMaxJmeWrite directly with the 3ds file



   protected void load3DS() {
        try {
            MaxToJme C1=new MaxToJme();
            ByteArrayOutputStream BO=new ByteArrayOutputStream();
            URL maxFile=GameStart.class.getClassLoader().getResource("com/vlad/game/data/model/muelle.3ds");
            C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
            JmeBinaryReader jbr=new JmeBinaryReader();
            jbr.setProperty("bound","box");
            Node r=jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
            r.setLocalScale(.1f);
            if (r.getChild(0).getControllers().size()!=0)
                r.getChild(0).getController(0).setSpeed(20);
            Quaternion temp=new Quaternion();
            temp.fromAngleAxis(FastMath.PI/2,new Vector3f(-1,0,0));
            rootNode.setLocalRotation(temp);
            rootNode.attachChild(r);
        } catch (IOException e) {
            System.out.println("Damn exceptions:"+e);
            e.printStackTrace();
        }
    }




and get this error (remember.. from milkshape it opens ok)


com.jme.system.JmeException: Logic error. Unknown parent ID for 4
at com.jme.scene.model.XMLparser.Converters.TDSChunkingFiles.TDSFile.getParentIndex(TDSFile.java:154)
at com.jme.scene.model.XMLparser.Converters.TDSChunkingFiles.TDSFile.putTranslations(TDSFile.java:113)
at com.jme.scene.model.XMLparser.Converters.TDSChunkingFiles.TDSFile.buildScene(TDSFile.java:74)
at com.jme.scene.model.XMLparser.Converters.MaxToJme.convert(MaxToJme.java:42)
at com.vlad.game.main.GameStart.load3DS(GameStart.java:106)
at com.vlad.game.main.GameStart.simpleInitGame(GameStart.java:54)
at com.jme.app.SimpleGame.initGame(SimpleGame.java:329)
at com.jme.app.BaseGame.start(BaseGame.java:63)
at com.vlad.game.main.GameStart.main(GameStart.java:43)
[/i][/code]

It appears that there is a repeat on your texture defined in milkshape, but the repeat is not being carried over in the jME texture state. Check the repeat of the texture (you might have to manipulate the state by hand). Do you see anything in the ASCII milkshape file that defines how to repeat the texture?

Load it with .ms3d not the .3ds loader. I’m working on the 3ds loader now, and it should releave most errors soon. The 3ds format is a nightmare. No official documentation, just people’s best guesses so mangled files can appear funky :?



-edit- Update from CVS and try again. The texture should now wrap correctly with the .ms3d file. If it doens’t let me know here.

"mojomonk" wrote:
It appears that there is a repeat on your texture defined in milkshape, but the repeat is not being carried over in the jME texture state. Check the repeat of the texture (you might have to manipulate the state by hand). Do you see anything in the ASCII milkshape file that defines how to repeat the texture?

Thats exactly what happens.. if i do a mapping like



the final texture in the java program goes wrong.. so i have to do something like this



(the wood tile repetead 4 fimes) but now, i have to use a 2048x2048 texture and the in the start it says


...
30-ago-2004 2:01:31 com.jme.scene.Node attachChild
INFO: Child (Milkshape Model) attached to this node (rootNode)
java.lang.OutOfMemoryError
30-ago-2004 2:01:32 com.jme.app.SimpleGame cleanup
INFO: Cleaning up resources.
30-ago-2004 2:01:32 com.jme.app.BaseGame start
INFO: Application ending.


and does not run. The final jpg is 260kb, and guess that the problem is the resoultion of the jpg, not the size in kb, isn´t?

I have no idea how to look in the ascii file to check out what are you saying :S

Did you update from CVS? Update from CVS and try again. Your original .ms3d should work.

dont use jpg, use TGA.

Its also possible to have multiple UV coordinates for the same XYZ coordinate.



Meaning that you can copy/paste those UV coordinates that are outside the single wood tile and put them ontop of the other UV coordinates that are already there.



This is good because you get to keep the same 512x512 texture.



DP

"Cep21" wrote:
Did you update from CVS? Update from CVS and try again. Your original .ms3d should work.

it doesnt :( i updated every single class and do the same ugly effect.
"DarkProphet" wrote:
dont use jpg, use TGA.
Its also possible to have multiple UV coordinates for the same XYZ coordinate.

Meaning that you can copy/paste those UV coordinates that are outside the single wood tile and put them ontop of the other UV coordinates that are already there.

This is good because you get to keep the same 512x512 texture.

DP

How do i do the UV copy/paste coordinates (in milkshape?). Also tried the TGA thing but it does the same. Besides the new tga file is 4 times the size of the jpg or png file :?

Email me the file you’re trying to use in its ms3d form, along with the texture.



cep221_at_gmail_dot_com

its true that the TGA is 3 times loader than the png/jpg but it loads 10 times faster.



Anyway, back to the subject; I dont know how to do it in milkshape, but in the “texture coordinate editor” window that you showed in the screenshots, isn’t there a move option? If there is, just selection a couple of vertices and move them to match the vertices that are on the texture properly.



DP

cep21: the mail is going out right now :slight_smile:

dark: milkshape texturing is very basic. Does not have anything something like "repeat UV map" or something. The same milkshape, in the mesh editor, repeats the texture as you expect (as i guess almost game does in that case) but the program running, only shows that part of the mesh mapped and dont repeat it along the model.



The other thing i thinked is to cut the selections of mesh to be the size the wood texture, and have 4 parts instead of one… but the repeating feature will be very handy instead. :slight_smile:

surely theres a "move" command for editing the texture coordinates.

"DarkProphet" wrote:
surely theres a "move" command for editing the texture coordinates.

yes it is! but when i move it, the part that is not mapped, is what shows wrong..

if you have milkshape try yourself.. is very hard to explain here :'(



Works for me. Probably didn't updated correctly from the CVS.


public class TestMilkJmeWrite extends SimpleGame{
    public static void main(String[] args) {
        SimpleGame app=new TestMilkJmeWrite();
        app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
        app.start();
    }

    protected void simpleInitGame() {

        MilkToJme converter=new MilkToJme();
//        URL MSFile=TestMilkJmeWrite.class.getClassLoader().getResource(
//        "jmetest/data/model/msascii/run.ms3d");
        ByteArrayOutputStream BO=new ByteArrayOutputStream();

        try {
            URL MSFile=new File("muelle.ms3d").toURL();
            converter.convert(MSFile.openStream(),BO);
        } catch (IOException e) {
            System.out.println("IO problem writting the file!!!");
            System.out.println(e.getMessage());
            System.exit(0);
        }
        JmeBinaryReader jbr=new JmeBinaryReader();
        Node i=null;
        try {
            URL TEXdir=new File(".").toURL();
            jbr.setProperty("texurl",TEXdir);
            i=jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
        } catch (IOException e) {
            System.out.println("darn exceptions:" + e.getMessage());
        }
        i.setLocalScale(.1f);
        rootNode.attachChild(i);
    }

    private void drawAxis() {
        rootNode.attachChild(new Box("axisX",new Vector3f(5,0,0),5f,.1f,.1f));
        rootNode.attachChild(new Box("axisY",new Vector3f(0,5,0),.1f,5f,.1f));
        rootNode.attachChild(new Box("axisZ",new Vector3f(0,0,5),.1f,.1f,5f));
    }
}

"Cep21" wrote:
Works for me. Probably didn't updated correctly from the CVS.


public class TestMilkJmeWrite extends SimpleGame{
    public static void main(String[] args) {
        SimpleGame app=new TestMilkJmeWrite();
        app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
        app.start();
    }

    protected void simpleInitGame() {

        MilkToJme converter=new MilkToJme();
//        URL MSFile=TestMilkJmeWrite.class.getClassLoader().getResource(
//        "jmetest/data/model/msascii/run.ms3d");
        ByteArrayOutputStream BO=new ByteArrayOutputStream();

        try {
            URL MSFile=new File("muelle.ms3d").toURL();
            converter.convert(MSFile.openStream(),BO);
        } catch (IOException e) {
            System.out.println("IO problem writting the file!!!");
            System.out.println(e.getMessage());
            System.exit(0);
        }
        JmeBinaryReader jbr=new JmeBinaryReader();
        Node i=null;
        try {
            URL TEXdir=new File(".").toURL();
            jbr.setProperty("texurl",TEXdir);
            i=jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
        } catch (IOException e) {
            System.out.println("darn exceptions:" + e.getMessage());
        }
        i.setLocalScale(.1f);
        rootNode.attachChild(i);
    }

    private void drawAxis() {
        rootNode.attachChild(new Box("axisX",new Vector3f(5,0,0),5f,.1f,.1f));
        rootNode.attachChild(new Box("axisY",new Vector3f(0,5,0),.1f,5f,.1f));
        rootNode.attachChild(new Box("axisZ",new Vector3f(0,0,5),.1f,.1f,5f));
    }
}


look.. i checked out again ALL the jme as a new proyect. Remember what classes changed so i can look for diferences?? Thank you very much..

JmeBinaryWriter, JmeBinaryReader, and MilkToJme were updated.

hi againg… i updated all from:



jme / src / com / jme / …



Its ok? I am having the same problem ://

Did you make sure the cvs update did not have any conflicts? That has happened to me in the past where I thought I had the latest but due to conflicts it wasn’t picking something up.

Your problem isn’t that it isn’t finding the texture, but that it’s not repeating the coordinates correctly right?



Look inside the file


com.jme.scene.model.XMLparser.Converters.MilkToJme




Inside the function

private void readMats() throws IOException



You should see

            if (texFile.length()!=0){
                texState=DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
                Texture tempTex=new Texture();
                tempTex.setImageLocation("file:/"+texFile);
                tempTex.setWrap(Texture.WM_WRAP_S_WRAP_T);
                texState.setTexture(tempTex);
            }




The important part is the line

tempTex.setWrap(Texture.WM_WRAP_S_WRAP_T);



Do you see that line?

Exact… the problem is that. Texture loads, but does not repeat in the parts thar aren’t mapped in the faces selected as group in milkshape.



Yes… that line is there :’( …that means i have the latest version?



What if i send the complete java code, the model and the textures? Cant be that is working for you and not for me :’( :’(



I know i am a pain in the ass, so take the time you need… ://



thanks