List of usage examples for com.badlogic.gdx.graphics.glutils ImmediateModeRenderer10 ImmediateModeRenderer10
public ImmediateModeRenderer10()
From source file:com.badlogic.gdx.graphics.g3d.test.KeyframedModelViewer.java
License:Apache License
@Override public void create() { model = ModelLoaderRegistry.loadKeyframedModel(Gdx.files.internal(fileName)); if (textureFileName != null) texture = new Texture(Gdx.files.internal(textureFileName), Format.RGB565, true); model.setMaterial(new Material("default", new TextureAttribute(texture, 0, "skin"))); hasNormals = hasNormals();/*from www . jav a2 s. c om*/ anim = (KeyframedAnimation) model.getAnimations()[0]; model.getBoundingBox(bounds); float len = bounds.getDimensions().len(); System.out.println("bounds: " + bounds); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(bounds.getCenter().cpy().add(len, len, len)); cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z); cam.near = 1f; cam.far = 1000; renderer = new ImmediateModeRenderer10(); batch = new SpriteBatch(); font = new BitmapFont(); }
From source file:com.badlogic.gdx.graphics.g3d.test.SkeletonModelViewer.java
License:Apache License
@Override public void create() { if (fileName.endsWith(".xml")) { model = new OgreXmlLoader().load(Gdx.files.internal(fileName), Gdx.files.internal(fileName.replace("mesh.xml", "skeleton.xml"))); } else//from w w w . j av a 2 s .co m throw new GdxRuntimeException("Unknown file format '" + fileName + "'"); if (textureFileName != null) texture = new Texture(Gdx.files.internal(textureFileName)); hasNormals = hasNormals(); Material material = new Material("material", new TextureAttribute(texture, 0, "s_tex")); model.setMaterial(material); anim = (SkeletonAnimation) model.getAnimations()[0]; model.getBoundingBox(bounds); float len = bounds.getDimensions().len(); System.out.println("bounds: " + bounds); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(bounds.getCenter().cpy().add(len, len, len)); cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z); cam.near = 1f; cam.far = 1000; renderer = new ImmediateModeRenderer10(); batch = new SpriteBatch(); font = new BitmapFont(); }
From source file:com.badlogic.gdx.graphics.g3d.test.StillModelViewer.java
License:Apache License
@Override public void create() { long start = System.nanoTime(); model = ModelLoaderRegistry.loadStillModel(Gdx.files.internal(fileName)); Gdx.app.log("StillModelViewer", "loading took: " + (System.nanoTime() - start) / 1000000000.0f); for (StillSubMesh mesh : model.subMeshes) { mesh.mesh.scale(0.1f, 0.1f, 0.1f); }//from ww w . j a va2s . co m if (!fileName.endsWith(".g3d")) { G3dExporter.export(model, Gdx.files.absolute(fileName + ".g3d")); start = System.nanoTime(); model = G3dLoader.loadStillModel(Gdx.files.absolute(fileName + ".g3d")); Gdx.app.log("StillModelViewer", "loading binary took: " + (System.nanoTime() - start) / 1000000000.0f); } if (textureFileNames.length != 0) { textures = new Texture[textureFileNames.length]; for (int i = 0; i < textureFileNames.length; i++) { textures[i] = new Texture(Gdx.files.internal(textureFileNames[i]), i > 0 ? false : true); } } hasNormals = hasNormals(); model.getBoundingBox(bounds); float len = bounds.getDimensions().len(); System.out.println("bounds: " + bounds); cam = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(bounds.getCenter().cpy().add(len / 2, len / 2, len / 2)); cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z); cam.near = 0.1f; cam.far = 1000; renderer = new ImmediateModeRenderer10(); batch = new SpriteBatch(); font = new BitmapFont(); }
From source file:com.badlogic.gdx.graphics.g3d.test.Viewer.java
License:Apache License
@Override public void create() { Texture texture = new Texture(Gdx.files.internal("data/models/ninja.jpg")); Material mat = new Material("mat", new TextureAttribute(texture, 0, "s_tex"), new ColorAttribute(Color.CYAN, ColorAttribute.diffuse)); model = new OgreXmlLoader().load(Gdx.files.internal("data/models/ninja.mesh.xml"), Gdx.files.internal("data/models/ninja.skeleton.xml")); model.setMaterial(mat);// ww w . ja va 2 s .co m cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); BoundingBox bounds = model.subMeshes[0].mesh.calculateBoundingBox(); cam.position.set(bounds.getCenter().cpy().add(100, 100, 100)); cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z); cam.near = 0.1f; cam.far = 1000; renderer = new ImmediateModeRenderer10(); batch = new SpriteBatch(); font = new BitmapFont(); for (String name : model.skeleton.animations.keys()) animNames.add(name); animation = animNames.get(0); }