/** Creates a new AssetManager with all default loaders. */ public AssetManager (FileHandleResolver resolver) { setLoader(BitmapFont.class, new BitmapFontLoader(resolver)); setLoader(Music.class, new MusicLoader(resolver)); setLoader(Pixmap.class, new PixmapLoader(resolver)); setLoader(Sound.class, new SoundLoader(resolver)); setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver)); setLoader(Texture.class, new TextureLoader(resolver)); setLoader(Skin.class, new SkinLoader(resolver)); setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver)); setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver)); setLoader(I18NBundle.class, new I18NBundleLoader(resolver)); setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver)); setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver)); setLoader(Model.class, ".obj", new ObjLoader(resolver)); executor = new AsyncExecutor(1); }
@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 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(); }
private static ModelInstance getInstance(String objPath, String texturePath) { Model model = loader.loadModel(Gdx.files.internal(objPath), new ObjLoader.ObjLoaderParameters(true)); ModelInstance instance = new ModelInstance(model); Texture texture = new Texture(Gdx.files.internal(texturePath)); instance.materials.get(0).set(TextureAttribute.createDiffuse(texture)); return instance; }
private void loadSphere(String planetId) { ModelLoader loader = new ObjLoader(); sphereModel = loader.loadModel(Gdx.files.internal("models/sphere01.obj"), new SphereTextureProvider(planetId)); environmentSphere = new ModelInstance(sphereModel); Attribute attribute = environmentSphere.materials.get(0).get( ColorAttribute.getAttributeType(ColorAttribute.DiffuseAlias)); ((ColorAttribute) attribute).color.r = 1; ((ColorAttribute) attribute).color.g = 1; ((ColorAttribute) attribute).color.b = 1; }
public void create () { ShaderProgram.pedantic = false; /* * shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal( * "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", * "couldn't compile scene shader: " + shader.getLog()); } */ batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal( "data/shaders/convolution.frag").readString()); if (!batchShader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog()); } ObjLoader objLoader = new ObjLoader(); scene = objLoader.loadObj(Gdx.files.internal("data/scene.obj")); sceneInstance = new ModelInstance(scene); modelBatch = new ModelBatch(); fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0, 0, 10); cam.lookAt(0, 0, 0); cam.far = 30; batch = new SpriteBatch(); batch.setShader(batchShader); fboRegion = new TextureRegion(fbo.getColorBufferTexture()); fboRegion.flip(false, true); logger = new FPSLogger(); calculateOffsets(); }
private static Model getModel(String objPath) { return loader.loadModel(Gdx.files.internal(objPath), new ObjLoader.ObjLoaderParameters(true)); }
/** * Needs an initialized com.badlogic.gdx.physics.bullet.Bullet. */ public static void init() { loader = new ObjLoader(); param = new ObjLoader.ObjLoaderParameters(true); BoundingBox boundingBox = new BoundingBox(); FUEL = load("models/fuel.obj"); FUEL.calculateBoundingBox(boundingBox); FUEL_SHAPE = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.8f)); SHIELD = load("models/shield.obj"); SHIELD.calculateBoundingBox(boundingBox); SHIELD_SHAPE = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.8f)); ARTIFACT_MODELS.put(ATTRIBUTE_SPEED, load("models/artifact_speed.obj")); ARTIFACT_MODELS.put(ATTRIBUTE_INERTIA, load("models/artifact_inertia.obj")); ARTIFACT_MODELS.put(ATTRIBUTE_LANDSLIDE, load("models/artifact_landslide.obj")); ARTIFACT_MODELS.put(ATTRIBUTE_FUEL_CAPACITY, load("models/artifact_fuel.obj")); ARTIFACT_MODELS.put(ATTRIBUTE_SHIELD_CAPACITY, load("models/artifact_shield.obj")); ARTIFACT_MODELS.put(ATTRIBUTE_SCAN_RADIUS, load("models/artifact_radius.obj")); ARTIFACT_MODELS.put(ATTRIBUTE_LUCK, load("models/artifact_luck.obj")); ARTIFACT_MODELS.put(OPERATOR_PLUS, load("models/artifact_plus.obj")); ARTIFACT_MODELS.put(OPERATOR_MINUS, load("models/artifact_minus.obj")); ARTIFACT_MODELS.put(OPERATOR_MULTIPLY, load("models/artifact_multiply.obj")); ARTIFACT_MODELS.put(OPERATOR_DIVIDE, load("models/artifact_divide.obj")); ARTIFACT_MODELS.put(VALUE_100, load("models/artifact_100.obj")); ARTIFACT_MODELS.put(VALUE_200, load("models/artifact_200.obj")); ARTIFACT_MODELS.put(VALUE_500, load("models/artifact_500.obj")); ARTIFACT_MODELS.put(VALUE_1000, load("models/artifact_1000.obj")); ARTIFACT_MODELS.put(VALUE_2000, load("models/artifact_2000.obj")); PLANET_PORTAL = load("models/planetPortal.obj"); PLANET_PORTAL_TORUS = load("models/portalTorus.obj"); PORTAL_STAND_COLLISION = Bullet.obtainStaticNodeShape(PLANET_PORTAL.nodes); Model portalTorusCollisionModel = load("models/planetPortalCollisionTube.obj"); PORTAL_TUBE_COLLISION = Bullet.obtainStaticNodeShape(portalTorusCollisionModel.nodes); Model portalTriggerModel = load("models/portalTrigger.obj"); PORTAL_TRIGGER_COLLISION = Bullet.obtainStaticNodeShape(portalTriggerModel.nodes); RACE_WAY_POINT = load("models/race_waypoint.obj"); RACE_WAY_POINT.calculateBoundingBox(boundingBox); //Model raceWayPointTrigger = load("models/race_waypoint_trigger.obj"); RACE_WAY_POINT_COLLISION = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.5f)); }
public Rocket() { // init graphic ModelLoader loader = new ObjLoader(); model = loader.loadModel(Gdx.files.internal("models/rocket.obj"), new ObjLoader.ObjLoaderParameters(true)); rocketModelInstance = new ModelInstance(model); ModelBuilder modelBuilder = new ModelBuilder(); final long attributes = VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal; // damage shield Material shieldMaterial = new Material(); shieldMaterial.set(ColorAttribute.createDiffuse(0, 0.3f, 1, 0.5f)); shieldMaterial.set(ColorAttribute.createSpecular(1, 1, 1, 1f)); shieldMaterial.set(new BlendingAttribute(1f)); Model shieldModel = modelBuilder.createSphere(4, 4, 4, 32, 32, shieldMaterial, attributes); shieldModelInstance = new ModelInstance(shieldModel); Material tractorBeamMaterial = new Material(); tractorBeamMaterial.set(ColorAttribute.createDiffuse(0, 0, 1, 1)); tractorBeamMaterial.set(ColorAttribute.createSpecular(1, 1, 1, 1f)); tractorBeamMaterial.set(new BlendingAttribute(0.1f)); Model tractorBeamModel = modelBuilder.createSphere(5, 5, 5, 32, 32, tractorBeamMaterial, attributes); tractorBeamModelInstance = new ModelInstance(tractorBeamModel); // init physic //BoundingBox boundingBox = new BoundingBox(); //model.calculateBoundingBox(boundingBox); //btCollisionShape shape = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.5f)); btCollisionShape shape = new btBoxShape(new Vector3(1, 1, 1)); rocketModelInstance.transform.setToRotation(0, 0, 1, 0); rocketModelInstance.transform.trn(START_POSITION); float mass = 1; addRigidBody(shape, mass, SpaceShipProperties.properties.getLandslide(), CollisionTypes.ROCKET.mask, new RocketMotionState(rocketModelInstance.transform)); rigidBodyList.get(0).setActivationState(4); // disable deactivation rigidBodyList.get(0).setLinearVelocity(tmpMovement.set(getDirection()).nor().scl( SpaceShipProperties.properties.getEnginePower())); thrustSound = App.audioController.getSound("thrust.wav"); if (App.config.playAudio) { thrustSound.loop(); thrustSound.play(); } }
@Override public void create() { debrisInstance = new ArrayList<ModelInstance>(); casketInstance = new ArrayList<ModelInstance>(); debris = Main.getDebris(); casket = debris.subList(0, 100); light = new DirectionalLight().set(222f, 222f, 222f, 300f, 300f, 300f); enviroment = new Environment(); enviroment.set(new ColorAttribute(ColorAttribute.AmbientLight, 2.4f, 3.4f, 2.4f, 3f)); enviroment.add(light); modelBatch = new ModelBatch(); cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // cam.rotate(90, 0, 0, 1); cam.position.set(50f, 50f,50f); cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 4000f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); ObjLoader loader = new ObjLoader(); model = loader.loadModel(Gdx.files.internal("textures/Earth.obj")); // // model = modelBuilder.createSphere(128f, 128f, 128f, 20, 20, // new Material(ColorAttribute.AmbientAlias), // VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates); instance = new ModelInstance(model); instance.transform.scale(128, 128, 128); instance.transform.rotate(1, 0, 0, 180); instance.transform.rotate(0, 0, 1, 90); space = loader.loadModel(Gdx.files.internal("textures/space/spacesphere.obj")); spaceInstance = new ModelInstance(space); spaceInstance.transform.scale(10,10,10); for (int i = 0; i < 100; i++) { debrisModel = loader.loadModel(Gdx.files.internal("textures/Nuka_Cola_Fridge.obj")); casketInstance.add(new ModelInstance(debrisModel)); } for (Placemark pm : debris) { Random rand = new Random(); debrisModel = modelBuilder.createSphere(3f, 3f, 3f, 4, 4, new Material(ColorAttribute.createDiffuse(rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat())), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates); ModelInstance mi = new ModelInstance(debrisModel); Coordinate coordinate = pm.getNextCoordinate(100f); mi.transform.translate((float) coordinate.x, (float) coordinate.y, (float) coordinate.z); debrisInstance.add(mi); } camController = new CameraInputController(cam); Gdx.input.setInputProcessor(camController); }