public void tick(float delta, GameScreen screen) { if (!started && screen.isPaused()) { started = true; prevTime = System.currentTimeMillis(); } if (spawns != null && enemyIndex < spawns.size() && System.currentTimeMillis() > prevTime + spawns.get(enemyIndex).getDelay()) { prevTime = System.currentTimeMillis(); String name = spawns.get(enemyIndex).getName(); ModelInstance instance; try { Class<?> c = enemyClasses.get(name); Constructor constructor = c.getConstructor(Matrix4.class, Map.class, btCollisionWorld.class, IntMap.class, List.class, Map.class); enemies.add((Enemy) constructor.newInstance(new Matrix4().setToTranslation(pos), models, world, entity, path, sounds)); } catch (Exception e) { Gdx.app.log("EnemySpawner spawn enemy", e.toString()); } enemyIndex++; } //for (Enemy enemy : enemies) // enemy.tick(delta, path); }
public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) { super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds); ((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90))); //System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id); listener = new AnimationController.AnimationListener() { @Override public void onEnd(AnimationController.AnimationDesc animationDesc) { } @Override public void onLoop(AnimationController.AnimationDesc animationDesc) { } }; //animation.setAnimation("Spider_Armature|walk_ani_vor"); //animation.animate("Spider_Armature|walk_ani_vor", -1); //animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0); //animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0); //animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0); }
private void addBackground(){ decalBackground = Decal.newDecal(new TextureRegion(managerAssets.getAssetsCrafting().getTexture(NameFiles.backgroundCrafting))); decalBackground.setDimensions(100,200); decalBackground.setPosition(0,0,0); environment = new Environment(); // environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f)); environment.set(new ColorAttribute(ColorAttribute.Diffuse)); environment.set(new ColorAttribute(ColorAttribute.Specular)); environment.set(new ColorAttribute(ColorAttribute.Reflection)); environment.add(new DirectionalLight().set(0.51f, 0.5f, 0.5f, 0f, -2f, -30f)); Model model = managerAssets.getAssetsRaider().getModel(NameFiles.raiderFull); model.nodes.get(2).translation.set(-12,28.6f,-5.5f); // model.nodes.get(0).translation.set(0,28f,29.2f); // model.nodes.get(2).translation.set(0,13,-1); instance = new ModelInstance(model); instance.transform.trn(0,-20,25).rotate(0,1,0,-25); instance.transform.scale(1.5f,1.5f,1.5f); }
public ScreenCrafting(GameManager game) { this.gameManager = game; informationProfile = InformationProfile.getInstance(); managerAssets = ManagerAssets.getInstance(); queue = QueueBuildCraft.getInstance(); intances = new Array<ModelInstance>(); camera = new PerspectiveCamera(45,WIDTH,HEIGHT); camera.position.set(0,0,1020); camera.lookAt(0, 0, 0); camera.near = 1; camera.far = 1500; camera.update(); nameRes.add("SCRAP"); nameRes.add("BRICK"); nameRes.add("CELL"); arrayDecal = new Array<Decal>(); }
public GameObject getObject (int screenX, int screenY) { Ray ray = camera.getPickRay(screenX, screenY); GameObject result = null; float distance = -1; for (ModelInstance item : instances) { if(item instanceof GameObject){ GameObject gameObject = (GameObject) item; if(gameObject.enabled){ Vector3 position = gameObject.transform.getTranslation(new Vector3()); gameObject.updateBox(); position.add(gameObject.center); float dist2 = ray.origin.dst2(position); if (distance >= 0f && dist2 > distance) continue; if (Intersector.intersectRayBoundsFast(ray, gameObject.bounds)) { result = gameObject; distance = dist2; } } } } return result; }
public void alphaToAnimation(float alpha, float time, final GameObject.OnAnimationComplete onAnimationComplete) { final GameObject object = this; Tween.registerAccessor(ModelInstance.class, new GameObjectAccessor()); if(alpha > 1) alpha = 1; if(alpha < 0) alpha = 0; context.tweenManager.killTarget(this, GameObjectAccessor.ALPHA); Tween.to(this, GameObjectAccessor.ALPHA, time) .target(alpha) .ease(TweenEquations.easeNone) .start(context.tweenManager) .setCallback(new TweenCallback() { @Override public void onEvent(int arg0, BaseTween<?> arg1) { if(onAnimationComplete != null) onAnimationComplete.run(object); } }); }
@Deprecated //Only for creating the first one private void createEntity(float f, float g, float h) { Vector3 position=new Vector3(f,g,h); List<EntityStatic> collidingEntities=space.getWithin(position, 0.03); if(collidingEntities.size() == 0) { EntityStatic entity=new EntityStatic(new ModelInstance( Assets.modelBuilder.createBox(0.03f, 0.03f, 0.06f, new Material(StrategyGame.blueAttr), Usage.Normal | Usage.Position)), position); space.addEntity(entity); } else { for(EntityStatic e:collidingEntities){ e.damage(2); } } }
/** Инициализация и загрузка ресурсов */ @Override public void create () { // Размеры экрана scrHalfWidth = Gdx.graphics.getWidth() / 2; scrHeight = Gdx.graphics.getHeight(); // Загрузка модели из файла modelBatch = new ModelBatch(); assets = new AssetManager(); assets.load("room.g3db", Model.class); assets.finishLoading(); Model roomModel = assets.get("room.g3db"); roomInstance = new ModelInstance(roomModel); // Создание камеры (fov, parallax, near, far) и установка позиции vrCamera = new VRCamera(90, 0.4f, 0.1f, 30f); vrCamera.setPosition(-1.7f, 3f, 3f); // Разрешаем коррекцию дрифта при помощи компаса vrSensorManager.useDriftCorrection(true); }
public Shark() { hasPhysics = true; vitesse = (float) (4f+Math.random()*6f); if(animations==null) { animations = new Hashtable<String, Shark.Animation>(); for(Animation anim : anims) { animations.put(anim.id, anim); } } targetDir.setToRandomDirection(); targetDir.y=0; targetDir.nor(); size.set(0.016f, 0.016f, 0.016f); model = new ModelInstance(Assets.requin); transform = model.transform; animation = new AnimationController(model); animation.allowSameAnimation=true; animation.setAnimation( getNomAnimation(), -1); }
@Override public void render(float delta) { dynamicsWorld.setGravity(new Vector3(0, -100, 0)); // Restricts physics update to a maximum of 5 per frame. // Should only do 1 though, but will do more to maintain physics simulation independent of frame rate dynamicsWorld.stepSimulation(delta, 5, 1/60f); for (T obj : instances) { btRigidBody body = renderer.getBulletBody(obj); ModelInstance inst = renderer.getRenderable(obj); if(body != null) { body.getWorldTransform(inst.transform); } } super.render(delta); debugRenderer.update(renderer().camera()); }
public void constructCells() { builder.begin(); int vertAttrs = Position | Normal | TextureCoordinates; for(int x = 0; x < cells.length; x++) { for (int z = 0; z < cells[x].length; z++) { MeshPartBuilder partBuilder = builder.part("cell"+x+","+z, GL30.GL_TRIANGLES, vertAttrs, Reference.Defaults.Models.material()); partBuilder.rect(getPoint("D", x, z), getPoint("C", x, z), getPoint("B", x, z), getPoint("A", x, z), Vector3.Y); cells[x][z].setCellPart(partBuilder.getMeshPart()); cells[x][z].init(); } } model = builder.end(); instance = new ModelInstance(model); }
@Override public GLFrameBuffer draw(List<ModelInstance> renderables) { applyToShader(shaderProgram); if(fbo == null) buildFBO(); fbo.begin(); while(((FrameBufferCubemap)fbo).nextSide()) { camera().direction.set( ((FrameBufferCubemap) fbo) .getSide() .direction); Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); batch.begin(camera()); batch.render(renderables); batch.end(); if (Gdx.input.isKeyJustPressed(Input.Keys.F3)) ScreenshotFactory.saveScreenshot(DEPTHMAPSIZE, DEPTHMAPSIZE, "PointLight"); } fbo.end(); return fbo; }
@Override protected AbstractPanel select(T obj) { super.select(obj); if(obj == null) { matList.clearItems(); selectMtl(null); return this; } ModelInstance inst = gameWorld.renderer().getRenderable(obj); matList.clearItems(); inst.nodes.forEach(n -> n.parts.forEach(p -> { ArgentList.ArgentListElement<Material> e = new ArgentList.ArgentListElement<>(p.material, this::selectMtl); e.getString = () -> String.format("[%s] %s", n.id, e.obj.id); matList.addItem(e); })); // inst.materials.forEach(m -> { // ArgentList.ArgentListElement<Material> e = new ArgentList.ArgentListElement<>(m, this::selectMtl); // e.getString = () -> e.obj.id; // matList.addItem(e); // }); selectMtl(null); return this; }
public void shift_row(Array<ModelInstance> level, Array<ModelInstance> addRow, boolean wire){ try { for (ModelInstance part : level) { Vector3 v = new Vector3(); part.transform.getTranslation(v); int x = Math.round(v.x); int z = Math.round(v.z); int y = Math.round(v.y); part.transform.translate(0f, -1f, 0f); if (!wire) { matrix[x][y][z] = false; matrix[x][y - 1][z] = true; } addRow.add(part); } level.clear(); }catch (Exception e){ return; } }
public BoxThree(PerspectiveCamera cam, boolean[][][] collision) { super(cam,collision); for(float x = 2f; x < 5f; ++x){ for(float z = 2f; z < 5f; ++z){ for(float y = 10f; y < 13f; ++y){ ModelInstance p = new ModelInstance(white,x,y,z); ModelInstance s = new ModelInstance(gray,x,y,z); ModelInstance f = new ModelInstance(wire,x,y,z); parts.add(p); shadow.add(s); frame.add(f); } } } traceShadow(); }
public GameModel(PerspectiveCamera cam, boolean [][][] collision){ //setup the model instances parts = new Array<ModelInstance>(); frame = new Array<ModelInstance>(); shadow = new Array<ModelInstance>(); //setup environment environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f)); //setup collision matrix matrix = collision; //setup camera camera = cam; }
public Column(PerspectiveCamera cam, boolean[][][] collision) { super(cam, collision); x = X.FRONT; y = Y.UP; for(float y = 10f; y < 12f; ++y){ ModelInstance p = new ModelInstance(white,2f,y,2f); ModelInstance s = new ModelInstance(gray,2f,y,2f); ModelInstance f = new ModelInstance(wire,2f,y,2f); parts.add(p); shadow.add(s); frame.add(f); } traceShadow(); }
public BoxTwo(PerspectiveCamera cam, boolean[][][] collision) { super(cam, collision); for(float x = 2f; x < 4f; ++x){ for(float z = 2f; z < 4f; ++z){ for(float y = 10f; y < 12f; ++y){ ModelInstance p = new ModelInstance(white,x,y,z); ModelInstance s = new ModelInstance(gray,x,y,z); ModelInstance f = new ModelInstance(wire,x,y,z); parts.add(p); shadow.add(s); frame.add(f); } } } traceShadow(); }
public ColumnTwo(PerspectiveCamera cam, boolean[][][] collision) { super(cam, collision); x = X.FRONT; y = Y.UP; for(float y = 10f; y < 13f; ++y){ ModelInstance p = new ModelInstance(white,2f,y,2f); ModelInstance s = new ModelInstance(gray,2f,y,2f); ModelInstance f = new ModelInstance(wire,2f,y,2f); parts.add(p); shadow.add(s); frame.add(f); } traceShadow(); }
public WorldEntity(String name, ModelInstance instance, btRigidBody btRigidBody, boolean disableDeactivation) { this.name = name; this.instance = instance; this.btRigidBody = btRigidBody; btRigidBody.userData = this; motionState = new MotionState(instance.transform); btRigidBody.setMotionState(motionState); logger.debug("Creating object '{}'", name); if (disableDeactivation) { logger.debug("Disabling deactivation for '{}'", name); btRigidBody.setActivationState(Collision.DISABLE_DEACTIVATION); } getDefaultColors(); }
@Override public btRigidBody createRigidBody (boolean isDynamic, float mass, Matrix4 startTransform, btCollisionShape shape, String bodyName) { Vector3 localInertia = new Vector3(); if (mass > 0f) shape.calculateLocalInertia(mass, localInertia); btRigidBody result = new btRigidBody(mass, null, shape, localInertia); String nodeName = bodyName.split("_", 2)[0] + "_model"; ModelInstance instance = new ModelInstance(model, nodeName, true, true); instance.transform.set(startTransform); BulletEntity entity = new BulletEntity(instance, result); ImportTest.this.world.add(entity); return result; }
public void init() { final int numVertices = this.vertexResolution * vertexResolution; final int numIndices = (this.vertexResolution - 1) * (vertexResolution - 1) * 6; mesh = new Mesh(true, numVertices, numIndices, attribs); this.vertices = new float[numVertices * stride]; mesh.setIndices(buildIndices()); buildVertices(); mesh.setVertices(vertices); MeshPart meshPart = new MeshPart(null, mesh, 0, numIndices, GL20.GL_TRIANGLES); meshPart.update(); ModelBuilder mb = new ModelBuilder(); mb.begin(); mb.part(meshPart, material); model = mb.end(); modelInstance = new ModelInstance(model); modelInstance.transform = transform; }
public RotateHandle(int id, Color color) { super(id); model = UsefulMeshs.torus(new Material(ColorAttribute.createDiffuse(color)), 20, 1f, 50, 50); modelInstance = new ModelInstance(model); modelInstance.materials.first().set(getIdAttribute()); switch (id) { case X_HANDLE_ID: this.getRotationEuler().y = 90; this.getScale().x = 0.9f; this.getScale().y = 0.9f; this.getScale().z = 0.9f; break; case Y_HANDLE_ID: this.getRotationEuler().x = 90; break; case Z_HANDLE_ID: this.getRotationEuler().z = 90; this.getScale().x = 1.1f; this.getScale().y = 1.1f; this.getScale().z = 1.1f; break; } // mi.transform.translate(0, 100, 0); }
/** * Holds a an instance of the model. * * @param name Name of model * @param model Model to instantiate * @param location World position at which to place the model instance * @param rotation The rotation of the model instance in degrees * @param scale Scale of the model instance */ public GameModel(Model model, String name, Vector3 location, Vector3 rotation, Vector3 scale) { super(name); modelInstance = new ModelInstance(model); applyTransform(location, rotation, scale, modelInstance); try { modelInstance.calculateBoundingBox(boundingBox); } catch (Exception e) { Gdx.app.debug(TAG, "Error when calculating bounding box.", e); } boundingBox.getCenter(center); boundingBox.getDimensions(dimensions); boundingBoxRadius = dimensions.len() / 2f; modelTransform = modelInstance.transform; halfExtents.set(dimensions).scl(0.5f); }
public Model6Easy(){ super(); shift(b(), v().x + 1f, v().y, v().z); shift(c(),v().x,v().y+1f,v().z); shift(d(),v().x+1f,v().y+1f,v().z); b2 = new ModelInstance(this.getModel()); a2 = new ModelInstance(this.getModel()); c2 = new ModelInstance(this.getModel()); d2 = new ModelInstance(this.getModel()); shift(b2,v().x + 1f, v().y, v().z-1f); shift(c2,v().x,v().y+1f,v().z-1f); shift(d2,v().x+1f,v().y+1f,v().z); d2.transform.translate(0, 0, -1f); shift(a2, v().x, v().y, v().z - 1f); addInstance(a2); addInstance(b2); addInstance(c2); addInstance(d2); e2 = new ModelInstance(this.getShadowModel()); f2 = new ModelInstance(this.getShadowModel()); g2 = new ModelInstance(this.getShadowModel()); h2 = new ModelInstance(this.getShadowModel()); }
public Model6(){ super(); shift(b(), v().x + 1f, v().y, v().z); shift(c(),v().x,v().y+1f,v().z); shift(d(),v().x+1f,v().y+1f,v().z); b2 = new ModelInstance(this.getModel()); a2 = new ModelInstance(this.getModel()); c2 = new ModelInstance(this.getModel()); d2 = new ModelInstance(this.getModel()); shift(b2,v().x + 1f, v().y, v().z-1f); shift(c2,v().x,v().y+1f,v().z-1f); shift(d2,v().x+1f,v().y+1f,v().z); d2.transform.translate(0, 0, -1f); shift(a2, v().x, v().y, v().z - 1f); addInstance(a2); addInstance(b2); addInstance(c2); addInstance(d2); e2 = new ModelInstance(this.getShadowModel()); f2 = new ModelInstance(this.getShadowModel()); g2 = new ModelInstance(this.getShadowModel()); h2 = new ModelInstance(this.getShadowModel()); }
public PlanetPortal() { // initialize PlanetPortal planetPortal = new ModelInstance(Models.PLANET_PORTAL); planetPortalTorus01 = new ModelInstance(Models.PLANET_PORTAL_TORUS); planetPortalTorus02 = new ModelInstance(Models.PLANET_PORTAL_TORUS); planetPortalTorus03 = new ModelInstance(Models.PLANET_PORTAL_TORUS); planetPortalTorus04 = new ModelInstance(Models.PLANET_PORTAL_TORUS); addRigidBody(Models.PORTAL_TUBE_COLLISION, 0, 0, CollisionTypes.GROUND.mask, new StandardMotionState(new Matrix4())); addRigidBody(Models.PORTAL_STAND_COLLISION, 0, 0, CollisionTypes.GROUND.mask, new StandardMotionState(new Matrix4())); btCollisionObject triggerObject = new btCollisionObject(); triggerObject.setCollisionShape(Models.PORTAL_TRIGGER_COLLISION); triggerObject.setWorldTransform(new Matrix4()); triggerObject.setUserValue(CollisionTypes.PORTAL_EXIT.mask); int collisionFlags = triggerObject.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_NO_CONTACT_RESPONSE; triggerObject.setCollisionFlags(collisionFlags); addCollisionObject(triggerObject); }
@Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { final float delta = Gdx.graphics.getDeltaTime(); dirLight.direction.rotate(Vector3.X, delta * 45f); dirLight.direction.rotate(Vector3.Y, delta * 25f); dirLight.direction.rotate(Vector3.Z, delta * 33f); pointLight.position.sub(transformedCenter); pointLight.position.rotate(Vector3.X, delta * 50f); pointLight.position.rotate(Vector3.Y, delta * 13f); pointLight.position.rotate(Vector3.Z, delta * 3f); pointLight.position.add(transformedCenter.set(center).mul(transform)); pLight.worldTransform.setTranslation(pointLight.position); batch.render(pLight); super.render(batch, instances); }
@Override public void create () { ObjLoader objLoader = new ObjLoader(); sphere = objLoader.loadObj(Gdx.files.internal("data/sphere.obj")); sphere.materials.get(0).set(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)); cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.far = 200; Random rand = new Random(); for (int i = 0; i < instances.length; i++) { instances[i] = new ModelInstance(sphere, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * -100 - 3); } batch = new SpriteBatch(); font = new BitmapFont(); logo = new TextureRegion(new Texture(Gdx.files.internal("data/badlogicsmall.jpg"))); modelBatch = new ModelBatch(); }
@Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { if(emitters.size > 0){ //Update float delta = Gdx.graphics.getDeltaTime(); builder.delete(0, builder.length()); builder.append(Gdx.graphics.getFramesPerSecond()); fpsLabel.setText(builder); ui.act(delta); billboardParticleBatch.begin(); for (ParticleController controller : emitters){ controller.update(); controller.draw(); } billboardParticleBatch.end(); batch.render(billboardParticleBatch, environment); } batch.render(instances, environment); ui.draw(); }
protected void switchAnimation () { for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) { int animIndex = 0; if (e.value.current != null) { for (int i = 0; i < e.key.animations.size; i++) { final Animation animation = e.key.animations.get(i); if (e.value.current.animation == animation) { animIndex = i; break; } } } animIndex = (animIndex + 1) % e.key.animations.size; e.value.animate(e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f); } }
@Override protected void onLoaded () { if (currentlyLoading == null || currentlyLoading.length() == 0) return; instances.clear(); animationControllers.clear(); final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class)); instance.transform = transform; instances.add(instance); if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance)); currentlyLoading = null; instance.calculateBoundingBox(bounds); cam.position.set(1, 1, 1).nor().scl(bounds.getDimensions().len() * 0.75f + bounds.getCenter().len()); cam.up.set(0, 1, 0); cam.lookAt(0, 0, 0); cam.far = 50f + bounds.getDimensions().len() * 2.0f; cam.update(); }
protected void switchAnimation () { for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) { int animIndex = 0; if (e.value.current != null) { for (int i = 0; i < e.key.animations.size; i++) { final Animation animation = e.key.animations.get(i); if (e.value.current.animation == animation) { animIndex = i; break; } } } animIndex = (animIndex + 1) % (e.key.animations.size + 1); e.value.animate((animIndex == e.key.animations.size) ? null : e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f); } }
@Override public void create () { modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 1f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f)); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(30f, 10f, 30f); cam.lookAt(0, 0, 0); cam.near = 0.1f; cam.far = 45f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); instance = new ModelInstance(model); Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam))); }
public static void createSkyBox (Texture xpos, Texture xneg, Texture ypos, Texture yneg, Texture zpos, Texture zneg) { modelInstance = new ModelInstance(model, "Skycube"); // Set material textures modelInstance.materials.get(0).set(TextureAttribute.createDiffuse(xpos)); modelInstance.materials.get(1).set(TextureAttribute.createDiffuse(xneg)); modelInstance.materials.get(2).set(TextureAttribute.createDiffuse(ypos)); modelInstance.materials.get(3).set(TextureAttribute.createDiffuse(yneg)); modelInstance.materials.get(5).set(TextureAttribute.createDiffuse(zpos)); modelInstance.materials.get(4).set(TextureAttribute.createDiffuse(zneg)); //Disable depth test modelInstance.materials.get(0).set(new DepthTestAttribute(0)); modelInstance.materials.get(1).set(new DepthTestAttribute(0)); modelInstance.materials.get(2).set(new DepthTestAttribute(0)); modelInstance.materials.get(3).set(new DepthTestAttribute(0)); modelInstance.materials.get(4).set(new DepthTestAttribute(0)); modelInstance.materials.get(5).set(new DepthTestAttribute(0)); enabled = true; }
@Override public void create () { texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true); texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); ObjLoader objLoader = new ObjLoader(); mesh = objLoader.loadObj(Gdx.files.internal("data/cube.obj")); mesh.materials.get(0).set(new TextureAttribute(TextureAttribute.Diffuse, texture)); modelInstance = new ModelInstance(mesh); modelBatch = new ModelBatch(); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(3, 3, 3); cam.direction.set(-1, -1, -1); batch = new SpriteBatch(); font = new BitmapFont(); }
@Override public void create () { ModelBuilder builder = new ModelBuilder(); sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)), Usage.Position | Usage.Normal); // cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight())); cam.near = 1; cam.far = 200; Random rand = new Random(); for (int i = 0; i < instances.length; i++) { pos.set(rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * -100 - 3); instances[i] = new ModelInstance(sphere, pos); } modelBatch = new ModelBatch(); batch = new SpriteBatch(); font = new BitmapFont(); // Gdx.graphics.setVSync(true); // Gdx.app.log("CullTest", "" + Gdx.graphics.getBufferFormat().toString()); }