Skybox is garbling texture

the title says it all. When i attach my skybox to my rootNode or any other node for that matter, the texture covering my terrain model (i didn't use heightmaps, but an actual object) gets garbled up into a chunky mess. No exceptions or errors are being thrown, but the texture still comes out as explained. If a log or image is needed please tell. I would like to get this problem resolved not only for my own sake, but for anyone else who finds their skybox is messing with their level.

i suppose an image would help

okies. The first is with the skybox, the second is without. :slight_smile: i’ll post the code the code later if it is needed












Try updateRenderState() on the rootNode?

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;

import jmetest.TutorialGuide.HelloModelLoading;
import jmetest.flagrushtut.Lesson4;

import com.jme.animation.AnimationController;
import com.jme.animation.Bone;
import com.jme.animation.BoneAnimation;
import com.jme.animation.SkinNode;
import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.light.DirectionalLight;
import com.jme.light.LightNode;
import com.jme.light.PointLight;
import com.jme.light.SimpleLightNode;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Controller;
import com.jme.scene.Node;
import com.jme.scene.Skybox;
import com.jme.scene.Spatial;
import com.jme.scene.state.LightState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.XMLparser.JmeBinaryReader;
import com.jmex.model.XMLparser.XMLtoBinary;
import com.jmex.model.XMLparser.Converters.FormatConverter;
import com.jmex.model.XMLparser.Converters.MaxToJme;
import com.jmex.model.XMLparser.Converters.ObjToJme;
import com.jmex.model.collada.ColladaImporter;


public class HelloWorldLoader extends SimpleGame {
Skybox skybox;
AnimationController ac;

public void simpleUpdate(){

//skybox.setLocalTranslation(cam.getLocation());
}
public static void main(String args[]){
    HelloWorldLoader lvl = new HelloWorldLoader();
    lvl.setDialogBehaviour(AbstractGame.NEVER_SHOW_PROPS_DIALOG);
    lvl.start();
    }

public void simpleInitGame(){
//Node n =  get3ds("sample.3ds","mtllib","");
Node n =  getObj("sample.obj","mtllib","");

//lightState.detachAll();
lightState.setGlobalAmbient(ColorRGBA.green);
DirectionalLight amb = new DirectionalLight();
amb.setEnabled(true);
amb.setAmbient(ColorRGBA.white);
amb.setDiffuse(ColorRGBA.white);
amb.setDirection(new Vector3f(0,-1,0));

DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.5f, 0.5f,-0.5f));
dl.setDiffuse(ColorRGBA.white);
dl.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
dl.setEnabled(true);

n.setLocalTranslation(-10, -35, -10);
LightState ls;
ls = DisplaySystem.getDisplaySystem().getRenderer().createLightState();
ls.setEnabled(true);
LightNode light1 = new LightNode("light1",ls);
light1.setLocalTranslation(0, 30, 0);
light1.setLight(amb);
light1.setLight(dl);
light1.setTarget(rootNode);
n.setCullMode(n.CULL_DYNAMIC);


light1.attachChild(n);
rootNode.attachChild(light1);
rootNode.updateRenderState();
createSkybox();
rootNode.attachChild(skybox);
rootNode.updateRenderState();










}

//hard core terrain in using terrain blocks
//adjust and implement
//hopefully fixes skybox texture problem

//implement 3rd person handler
public void createSkybox(){


skybox = new Skybox("skybox", 100, 100, 100);

Texture north = TextureManager.loadTexture(
            Lesson4.class.getClassLoader().getResource(
            "jmetest/data/texture/north.jpg"),
            Texture.MM_LINEAR,
            Texture.FM_LINEAR);
Texture south = TextureManager.loadTexture(
            Lesson4.class.getClassLoader().getResource(
            "jmetest/data/texture/south.jpg"),
            Texture.MM_LINEAR,
            Texture.FM_LINEAR);
Texture east = TextureManager.loadTexture(
            Lesson4.class.getClassLoader().getResource(
            "jmetest/data/texture/east.jpg"),
            Texture.MM_LINEAR,
            Texture.FM_LINEAR);
Texture west = TextureManager.loadTexture(
            Lesson4.class.getClassLoader().getResource(
            "jmetest/data/texture/west.jpg"),
            Texture.MM_LINEAR,
            Texture.FM_LINEAR);
Texture up = TextureManager.loadTexture(
            Lesson4.class.getClassLoader().getResource(
            "jmetest/data/texture/top.jpg"),
            Texture.MM_LINEAR,
            Texture.FM_LINEAR);
Texture down = TextureManager.loadTexture(
            Lesson4.class.getClassLoader().getResource(
            "jmetest/data/texture/bottom.jpg"),
            Texture.MM_LINEAR,
            Texture.FM_LINEAR);

skybox.setTexture(Skybox.NORTH, north);
skybox.setTexture(Skybox.WEST, west);
skybox.setTexture(Skybox.SOUTH, south);
skybox.setTexture(Skybox.EAST, east);
skybox.setTexture(Skybox.UP, up);
skybox.setTexture(Skybox.DOWN, down);

}
public Node getXML(String name, String path){
URL model = null;
    model=HelloModelLoading.class.getClassLoader().getResource("repository//" +path+name);
    System.out.println(model.toString());
    XMLtoBinary converter = new XMLtoBinary();
    ByteArrayOutputStream BO = new ByteArrayOutputStream();
    JmeBinaryReader jbr = new JmeBinaryReader();
    jbr.setProperty("bound", "box");
    Node modelNode = null;
    try {
        converter.sendXMLtoBinary(model.openStream(), BO);
        modelNode = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    return modelNode;
   
   
}
public Node getCollada(String mdlName, String animation, String folder){
URL model = null;
        model=HelloModelLoading.class.getClassLoader().getResource("repository//"+folder+mdlName);
        InputStream figure = HelloWorldLoader.class.getClassLoader().getResourceAsStream(folder+mdlName);
        InputStream anim = HelloWorldLoader.class.getClassLoader()
        .getResourceAsStream(folder+animation);
        if (figure == null) {
            System.out
                    .println("Unable to find file, did you include jme-test.jar in classpath?");
            return null;
        }
//      tell the importer to load the mob boss
        ColladaImporter.load(figure, model, mdlName);
        //we can then retrieve the skin from the importer as well as the skeleton
        SkinNode sn = ColladaImporter.getSkinNode(ColladaImporter.getSkinNodeNames().get(0));
        Bone skel = ColladaImporter.getSkeleton(ColladaImporter.getSkeletonNames().get(0));
        //clean up the importer as we are about to use it again.
        ColladaImporter.cleanUp();
       
        ColladaImporter.load(anim, model, "anim");
        //this file might contain multiple animations, (in our case it's one)
        ArrayList<String> animations = ColladaImporter.getControllerNames();
        if(animations != null) {
        System.out.println("Number of animations: " + animations.size());
        for(int i = 0; i < animations.size(); i++) {
            System.out.println(animations.get(i));
        }
        //Obtain the animation from the file by name
        BoneAnimation anim1 = ColladaImporter.getAnimationController(animations.get(0));
        anim1.toString();
        //set up a new animation controller with our BoneAnimation
        ac = new AnimationController();
        ac.addAnimation(anim1);
        ac.setRepeatType(Controller.RT_WRAP);
        ac.setActive(true);
        ac.setActiveAnimation(anim1);
       
        //assign the animation controller to our skeleton
        skel.addController(ac);
        Node lol = null;
      lol.attachChild(sn);
        lol.attachChild(skel);
        lol.updateGeometricState(0, true);
      ColladaImporter.cleanUp();
      return lol;
     
        }
return null;
       
       
}
public Node get3ds(String mdlName, String mtlName, String folder){
        URL model = null;
        model=HelloModelLoading.class.getClassLoader().getResource("repository//"+folder+mdlName);
        model.toString();
        FormatConverter f = new MaxToJme();

        f.setProperty("mtlllib", model);
        ByteArrayOutputStream output=new ByteArrayOutputStream();
        try {
            f.convert(model.openStream(), output);
            Node modelnode =(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(output.toByteArray()));
            modelnode.setModelBound(new BoundingBox());
            modelnode.updateModelBound();
            System.out.println("got past loader....");
            return modelnode;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;
        }
    }
    public Node getObj(String mdlName, String mtlName, String folder){
        URL model = null;
        model=HelloModelLoading.class.getClassLoader().getResource("repository//"+folder+mdlName);
        model.toString();
        FormatConverter f = new ObjToJme();
        f.setProperty(mtlName, model);
        ByteArrayOutputStream output=new ByteArrayOutputStream();
        try {
            f.convert(model.openStream(), output);
            Node modelnode =(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(output.toByteArray()));
            modelnode.setModelBound(new BoundingBox());
            modelnode.updateModelBound();
            System.out.println("got past loader....");
            return modelnode;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;
        }
    }


}



still didn't help ;) here's the code, if that helps. Maybe i just did something dumb lol.

i don't see the terrain creation code.

are you using clod terrain? that would explain why the texture coords get messed up and the terrain triangles are defined that way.



i don't think this has anything to do with the skybox.

i'm using a model as the terrain :stuck_out_tongue: Really, i guess it is more practical to create my terrain from a heightmap. :stuck_out_tongue:


Node n =  getObj("sample.obj","mtllib","");


this is where i got my my model, including my houses, clock, terrain ect :) not sure if it helps.. i think i might just generate a heightmap from the terrain, use that, and be done with it...

i have to admit i don't know what the problem is.

i wasn't even aware that there's a class called LightNode  :expressionless:

i just waited for someone else to provide a helpful answer.