Giant Model? o_o

Okay, i have imported a model from blender, but when imported, it gets hugeeeeeeee!



So, what's the problem?

try this

model.setLocalScale(0.5f);  //or any other number less than 1f

model.updateGeometricState(0, false);

Netbeans says that he can't find symbols (setLocalScale and updateGeometricState)  :?

thats weird … post some code to try to see the problem

Here is my simpleInitGame:


protected void simpleInitGame() {
        Box rF = new Box("Room Floor.", new Vector3f(0, 0, 30), 16, 1, 16);
       
        URL floor = Main.class.getClassLoader().getResource("floor2.png");

        TextureState ts = display.getRenderer().createTextureState();
        ts.setTexture(TextureManager.loadTexture(floor,
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear));
        rF.setRenderState(ts);

        Box rW1 = new Box("Room Wall 1.", new Vector3f(0, 4, 15), 16, 3, 1);
        Box rW12 = new Box("Room Wall 1-2.", new Vector3f(0, 17, 15), 16, 3, 1);
        Box rW13 = new Box("Room Wall 1-3.", new Vector3f(11, 11, 15), 5, 4, 1);
        Box rW14 = new Box("Room Wall 1-4.", new Vector3f(-10, 11, 15), 5, 4, 1);
        Box rW2 = new Box("Room Wall 2.", new Vector3f(-15, 10, 30), 1, 10, 16);
       
        URL wall = Main.class.getClassLoader().getResource("wall.png");

        TextureState ts2 = display.getRenderer().createTextureState();
        ts2.setTexture(TextureManager.loadTexture(wall,
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear));
        rW1.setRenderState(ts2);
        rW12.setRenderState(ts2);
        rW13.setRenderState(ts2);
        rW14.setRenderState(ts2);
        rW2.setRenderState(ts2);

        Box rWV = new Box("Room - Window View.", new Vector3f(0, 10, 13), 8, 4, 1);

        URL sky = Main.class.getClassLoader().getResource("sky.png");

        TextureState ts3 = display.getRenderer().createTextureState();
        ts3.setTexture(TextureManager.loadTexture(sky,
                Texture.MinificationFilter.BilinearNearestMipMap,
                Texture.MagnificationFilter.Bilinear));
        rWV.setRenderState(ts3);

        rootNode.attachChild(rF);
        rootNode.attachChild(rW1);
        rootNode.attachChild(rW12);
        rootNode.attachChild(rW13);
        rootNode.attachChild(rW14);
        rootNode.attachChild(rW2);
        rootNode.attachChild(rWV);

        URL model = Main.class.getClassLoader().getResource("unknown_trinity_obj.obj");

        FormatConverter converter = new ObjToJme();

        converter.setProperty("mtllib",model);
        converter.setProperty("texdir",model);

        ByteArrayOutputStream mode = new ByteArrayOutputStream();
        try {
          
            converter.convert(model.openStream(), mode);

            rootNode.attachChild((Spatial)BinaryImporter.getInstance().load(new ByteArrayInputStream(mode.toByteArray())));
        } catch (IOException e) {   // Just in case anything happens
            System.out.println("Could not find the model." + e);
            e.printStackTrace();
            System.exit(0);
        }
    }

here is the problem:


rootNode.attachChild((Spatial)BinaryImporter.getInstance().load(new ByteArrayInputStream(mode.toByteArray())));



replace it with:


Spatial spatialModel = (Spatial)BinaryImporter.getInstance().load(new ByteArrayInputStream(mode.toByteArray()));
spatialModel.setLocalScale(0.5f); //as I said earlier: any number < 1f will decrease the model size
rootNode.attachChild(spatialModel);
spatialModel.updateGeometricState(0, false);



hope this helps!

Thank you! It worked percfect! But now, a noobie question… I know we have to use Vector3f to move the node, but how to implement it on a model? '-'

your model is a node, if you want, attach your model to a node and move the node around.



node.getLocalTranslation().set(location);