Model not moving/resizing

I'm having a problem moving and resizing a model i've loaded into my program.  Here is the init game code:


protected void initGame() {
        scene = new Node("Scene graph node");
        wireState = display.getRenderer().createWireframeState();
        wireState.setEnabled(false);
        scene.setRenderState(wireState);
       
       
        try {
            URL battlefieldmodel = Main.class.getClassLoader().getResource("BF.obj");
            FormatConverter converter = new ObjToJme();
            // Point the converter to where it will find the .mtl file from
            converter.setProperty("mtllib", battlefieldmodel);
           
            //load model
            ByteArrayOutputStream BO = new ByteArrayOutputStream();
            // Use the format converter to convert .obj to .jme
            converter.convert(battlefieldmodel.openStream(), BO);
            TriMesh battlefield = (TriMesh) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
           
            // shrink this baby down some
            battlefield.setLocalScale(5.0f);
            battlefield.setModelBound(new BoundingSphere());
            battlefield.setLocalTranslation(-10.0f,-110.0f,0.0f);
            battlefield.updateModelBound();
           
            // Put her on the scene graph
            scene.attachChild(battlefield);
        } catch (IOException e) {   // Just in case anything happens
           
            System.out.println("Damn exceptions!" + e);
            e.printStackTrace();
            System.exit(0);
        }
       
        try {
            URL diskModel = Main.class.getClassLoader().getResource("disk000.obj");
            FormatConverter converter = new ObjToJme();
            // Point the converter to where it will find the .mtl file from
            converter.setProperty("mtllib", diskModel);
           
            //load model
            ByteArrayOutputStream BO = new ByteArrayOutputStream();
            // Use the format converter to convert .obj to .jme
            converter.convert(diskModel.openStream(), BO);
            Node disk1 = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
            // shrink this baby down some
            disk1.setLocalScale(0.5f);
            disk1.setModelBound(new BoundingSphere());
            disk1.updateModelBound();
            disk1.setLocalTranslation(100.0f,100.0f,100.0f);
            // Put her on the scene graph
            scene.attachChild(disk1);
        } catch (IOException e) {   // Just in case anything happens
           
            System.out.println("Damn exceptions!" + e);
            e.printStackTrace();
            System.exit(0);
        }
       
       
        PointLight light = new PointLight();
        light.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) );
        light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) );
        light.setLocation( new Vector3f( 100, 100, 100 ) );
        light.setEnabled( true );
        lightState = display.getRenderer().createLightState();
        lightState.setEnabled( true );
        lightState.attach( light );
        ZBufferState buf = display.getRenderer().createZBufferState();
        buf.setEnabled( true );
        buf.setFunction( ZBufferState.CF_LEQUAL );
        scene.setRenderState( buf );
       
        scene.setRenderState( lightState );
        //scene.updateGeometricState(0.0f, true);
        scene.updateRenderState();
       
       
    }



I am having problems with the disk1 node.  The battlefield trimesh moves and resizes fine.  the disk node will neither move nor resize.  I also do not understand why one of the models was loaded as a trimesh and the other as a node  (a runtime error occured when I tried to make disk1 a trimesh).

perhaps I am not using the correct methods on the node, or there is something I am missing?  Or is it possible something is wrong with the exported obj or mtl file for the disk?  But it loads fine so I don't think there is.

Any help or insight is greatly appreciated.

Malcolm

Why do you have updateGeometricState commented out?  Also, models load in as a subclass of Spatial.  Node if it has multiple parts and TriMesh if there is just one part.  You can just refer to it as a Spatial though if you don't need special access to Node of TriMesh methods.

thanks, having them all as spatial and uncommenting that line seems to have worked :slight_smile: