public void setEnvironmentLights(Array<BaseLight<?>> lights, Vector3 sunDirection) { environment = new Environment(); environment.add( (shadowLight = new DirectionalShadowLight( GameSettings.SHADOW_MAP_WIDTH, GameSettings.SHADOW_MAP_HEIGHT, GameSettings.SHADOW_VIEWPORT_WIDTH, GameSettings.SHADOW_VIEWPORT_HEIGHT, GameSettings.SHADOW_NEAR, GameSettings.SHADOW_FAR)) .set( GameSettings.SHADOW_INTENSITY, GameSettings.SHADOW_INTENSITY, GameSettings.SHADOW_INTENSITY, sunDirection.nor())); environment.shadowMap = shadowLight; float ambientLight = GameSettings.SCENE_AMBIENT_LIGHT; environment.set( new ColorAttribute( ColorAttribute.AmbientLight, ambientLight, ambientLight, ambientLight, 1)); for (BaseLight<?> light : lights) { environment.add(light); } }
@Override public void create() { modelBatch = new ModelBatch(); 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)); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(2f, 2f, 2f); cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 300f; cam.update(); camController = new CameraInputController(cam); Gdx.input.setInputProcessor(camController); ModelLoader modelLoader = new G3dModelLoader(new JsonReader()); ModelData modelData = modelLoader.loadModelData(Gdx.files.internal(data + "/invaderscene.g3dj")); model = new Model(modelData, new TextureProvider.FileTextureProvider()); NodePart blockPart = model.getNode("ship").parts.get(0); renderable = new Renderable(); renderable.mesh = blockPart.meshPart.mesh; renderable.meshPartOffset = blockPart.meshPart.indexOffset; renderable.meshPartSize = blockPart.meshPart.numVertices; renderable.primitiveType = blockPart.meshPart.primitiveType; renderable.material = blockPart.material; renderable.environment = environment; renderable.worldTransform.idt(); }
@Override public void create() { // Create ModelBatch that will render all models using a camera modelBatch = new ModelBatch(); // Create a camera and point it to our model camera = new PerspectiveCamera(85, 0, 0); camera.position.set(1, 1, 1150); camera.lookAt(0, 0, 0); camera.near = 100f; camera.far = 2000f; camera.update(); // Create the generic camera input controller to make the app interactive cameraController = new CameraInputController(camera); Gdx.input.setInputProcessor(cameraController); /// Create an asset manager that lets us dispose all assets at once for (int i = 0; i < listing.size(); i++) { assets.load("data/obj_" + listing.get(i).getId() + ".g3db", Model.class); } assets.finishLoading(); // Create an instance of our crate model and put it in an array for (int i = 0; i < listing.size(); i++) { Model model = assets.get("data/obj_" + listing.get(i).getId() + ".g3db", Model.class); ModelInstance inst = new ModelInstance(model); instances.add(inst); } // Set up environment with simple lighting 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)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 1f, 0.8f, -0.2f)); }
@Override public void create() { Bullet.init(); modelBatch = new ModelBatch(); 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)); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(3f, 7f, 10f); cam.lookAt(0, 4f, 0); cam.update(); camController = new CameraInputController(cam); Gdx.input.setInputProcessor(camController); ModelBuilder mb = new ModelBuilder(); mb.begin(); mb.node().id = "ground"; mb.part( "box", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(Color.RED))) .box(5f, 1f, 5f); mb.node().id = "ball"; mb.part( "sphere", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(Color.GREEN))) .sphere(1f, 1f, 1f, 10, 10); model = mb.end(); ground = new ModelInstance(model, "ground"); ball = new ModelInstance(model, "ball"); ball.transform.setToTranslation(0, 9f, 0); instances = new Array<ModelInstance>(); instances.add(ground); instances.add(ball); ballShape = new btSphereShape(0.5f); groundShape = new btBoxShape(new Vector3(2.5f, 0.5f, 2.5f)); groundObject = new btCollisionObject(); groundObject.setCollisionShape(groundShape); groundObject.setWorldTransform(ground.transform); ballObject = new btCollisionObject(); ballObject.setCollisionShape(ballShape); ballObject.setWorldTransform(ball.transform); collisionConfig = new btDefaultCollisionConfiguration(); dispatcher = new btCollisionDispatcher(collisionConfig); }
@Override public void dispose() { // Release all resources environment.clear(); assets.dispose(); modelBatch.dispose(); instances.clear(); }
@Override public void create() { modelBatch = new ModelBatch(); lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); lights.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(0f, 7f, 10f); cam.lookAt(0, 0, 0); cam.near = 0.1f; cam.far = 300f; cam.update(); camController = new CameraInputController(cam); Gdx.input.setInputProcessor(camController); assets = new AssetManager(); assets.load("data/g3d/invaders.g3dj", Model.class); loading = true; }
@Override public void create() { modelBatch = new ModelBatch(); 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)); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0f, 7f, 10f); cam.lookAt(0, 0, 0); cam.near = 0.1f; cam.far = 300f; cam.update(); camController = new CameraInputController(cam); Gdx.input.setInputProcessor(camController); ModelLoader modelLoader = new G3dModelLoader(new JsonReader()); ModelData modelData = modelLoader.loadModelData(Gdx.files.internal(data + "/invaderscene.g3dj")); model = new Model(modelData, new TextureProvider.FileTextureProvider()); doneLoading(); }
@Override public void create() { Gdx.app.setLogLevel(Application.LOG_DEBUG); modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 254f, 254f, 65f, 1.f)); environment.add(new DirectionalLight().set(254f, 254f, 65f, -1f, -0.8f, -0.2f)); // environment.add(new SpotLight().set(0.8f, 0.8f, 0.8f, new Vector3())); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0f, 20f, 20f); cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 1300f; cam.update(); camController = new CameraInputController(cam); Gdx.input.setInputProcessor(new InputMultiplexer(this, camController)); loadTexture(); assets = new AssetManager(); assets.load(Config.Model.PLAYER_MODEL_NAME, Model.class); assets.load("models//pitch.g3db", Model.class); loading = true; }
@Override public void create() { modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f)); environment.add( (shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)) .set(0.8f, 0.8f, 0.8f, -1f, -.8f, -.2f)); environment.shadowMap = shadowLight; cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0f, 7f, 10f); cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 50f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder mpb = modelBuilder.part( "parts", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(ColorAttribute.createDiffuse(Color.WHITE))); mpb.setColor(1f, 1f, 1f, 1f); mpb.box(0, -1.5f, 0, 10, 1, 10); mpb.setColor(1f, 0f, 1f, 1f); mpb.sphere(2f, 2f, 2f, 10, 10); model = modelBuilder.end(); instance = new ModelInstance(model); shadowBatch = new ModelBatch(new DepthShaderProvider()); Gdx.input.setInputProcessor(camController = new CameraInputController(cam)); }