public SimulationRunner() { logger.info("Loading models"); ModelBuilder builder = new ModelBuilder(); models.put("box", builder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal)); G3dModelLoader loader = new G3dModelLoader(new JsonReader()); models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj"))); models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj"))); models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj"))); Bullet.init(); logger.info("Initialized Bullet"); }
@Override public void create () { super.create(); ModelLoader g3djLoader = new G3dModelLoader(new JsonReader()); model = g3djLoader.loadModel(Gdx.files.internal("data/g3d/btscene1.g3dj")); disposables.add(model); importer = new MyImporter((btDynamicsWorld)world.collisionWorld); importer.loadFile(Gdx.files.internal("data/g3d/btscene1.bullet")); camera.position.set(10f, 15f, 20f); camera.up.set(0, 1, 0); camera.lookAt(-10, 8, 0); camera.update(); }
/** 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); }
private void createMeshes() { ModelBuilder mb = new ModelBuilder(); cubeModel = mb.createBox(1, 1, 1, new Material(), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates); cubeMesh = cubeModel.meshes.first(); G3dModelLoader modelLoader = new G3dModelLoader(new UBJsonReader()); quadModel = modelLoader.loadModel(Gdx.files.internal("models/quad.g3db")); quadMesh = quadModel.meshes.first(); }
@Override protected void onInitialize() { this.levelEnv = new LevelEnv(); this.camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.near = 0.1f; camera.position.set(5, 5, 5); camera.lookAt(0.1f, 0.1f, 0.1f); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f)); this.modelBatch = new ModelBatch(); //this.voxelBatch = new VoxelBatch(new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED))); ModelLoader g3djLoader = new G3dModelLoader(new UBJsonReader()); model = g3djLoader.loadModel(ForgE.files.internal("raw/models/test.g3db")); modelInstance = new ModelInstance(model); modelInstance.calculateBoundingBox(bounds); camera.position.set(1, 1, 1).nor().scl(bounds.getDimensions(tmpV1).len() * 1.75f + bounds.getCenter(tmpV2).len()); camera.up.set(0, 1, 0); camera.lookAt(0, 0, 0); camera.far = 50f + bounds.getDimensions(tmpV1).len() * 3.0f; camera.update(true); }
public ModelManager() { G3dModelLoader modelLoader = new G3dModelLoader(new UBJsonReader()); this.robotModel = modelLoader.loadModel(Gdx.files.getFileHandle("models/bot.g3db", Files.FileType.Internal)); //TextureAttribute attr = (TextureAttribute) robotModel.materials.first().get(TextureAttribute.Diffuse); //attr.textureDescription.minFilter = Texture.TextureFilter.Nearest; //attr.textureDescription.magFilter = Texture.TextureFilter.Nearest; this.ledModel = modelLoader.loadModel(Gdx.files.getFileHandle("models/led.g3db", Files.FileType.Internal)); }
private AssetRepository() { repository = new HashMap<String, Object>(); jsonReader = new UBJsonReader(); modelLoader = new G3dModelLoader(jsonReader); }
@Override public void create () { pbrShader=new PBRShader(); pbrShader.init(); pbrSadherTexture=new PBRSadherTexture(); pbrSadherTexture.init(); materials.put("Generic", null); materials.put("Rough Rock", createMaterial("roughrockface4")); materials.put("Bricks", createMaterial("mybricks3")); materials.put("Rusted Iron", createMaterial("rustediron-streaks")); materials.put("Carved Stone", createMaterial("carvedlimestoneground1")); materials.put("Grass", createMaterial("grass1")); materials.put("Floor", createMaterial("cavefloor1")); matNames = new ArrayList<String>(materials.keySet()); actMaterial=matNames.indexOf("Generic"); modelBatch = new ModelBatch(); spriteBatch=new SpriteBatch(); float w=Gdx.graphics.getWidth(); float h=Gdx.graphics.getHeight(); float scale=w/1600; cam=new PerspectiveCamera(30,w, h); cam.position.set(12,14,0); cam.lookAt(0,2,0); cam.up.set(0,1,0); cam.update(); camController = new CameraInputController(cam); font = new BitmapFont(Gdx.files.internal("font/my_font.fnt"), Gdx.files.internal("font/my_font.png"), false); skin = new Skin(Gdx.files.internal("skin/uiskin.json")); CreateStage(w, h, scale); G3dModelLoader loader = new G3dModelLoader(new UBJsonReader()); obj=createRenderableFromMesh(loader.loadModel(Gdx.files.internal("Mesh/teapot.g3db")).meshParts.get(0).mesh, new Material(ColorAttribute.createDiffuse(Color.BLUE)), pbrShader, null); obj.worldTransform.scl(5); }
@Override public void create() { logger.info("Setting up camera"); camera = new PerspectiveCamera(40, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // camera.position.set(40f, 30f, 40f); camera.position.set(45f, 29f, 73f); // camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // camera.position.set(4f, 3f, 4f); camera.lookAt(0, 2f, 0); camera.near = 1f; camera.far = 500f; camera.update(); cameraInputController = new CameraInputController(camera); Gdx.input.setInputProcessor(cameraInputController); // Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this))); logger.info("Loading models"); models = new HashMap<>(); ModelBuilder builder = new ModelBuilder(); models.put("box", builder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal)); G3dModelLoader loader = new G3dModelLoader(new JsonReader()); models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj"))); models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj"))); models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj"))); logger.info("Let there be light"); batch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.6f, 0.6f, 0.6f, 1f)); environment.add(new DirectionalLight().set(0.3f, 0.3f, 0.3f, -5f, -3f, -1f)); environment.add(new DirectionalLight().set(0.2f, 0.2f, 0.2f, 5f, 8f, 0f)); environment.add(new DirectionalLight().set(0.7f, 0.7f, 0.7f, -3f, -2f, -5f)); logger.info("Initializing Bullet"); Bullet.init(); logger.info("Creating simulation"); // create world & stuff? spokeAngles = new SpokeAngles(); // spokeAngles.create2l2t(); // spokeAngles.createCrowFoot(); // spokeAngles.createNx(3); // spokeAngles.createPer3mutation(new int[]{3, 14, 5, 0, 7, 2, 9, 4, 11, 6, 13, 8, 15, 10, 1, 12}); // 3x as well! // spokeAngles.createPermutation(new int[]{14, 2, 3, 15, 7, 5, 6, 10, 4, 9, 8, 11, 12, 0, 1, 13}); // spokeAngles.createPermutation(new int[]{2, 0, 1, 5, 3, 8, 10, 4, 12, 6, 11, 7, 9, 15, 13, 14}); // spokeAngles.createPermutation(new int[]{0, 15, 3, 2, 4, 9, 6, 7, 8, 5, 10, 11, 12, 13, 14, 1}); spokeAngles.createRandom(); // spokeAngles.createBack(); // spokeAngles.createSingel(); simulation = new Simulation("sim1", models, spokeAngles, true); rayResultCallback = new ClosestRayResultCallback(new Vector3(), new Vector3()); rayResultCallback.setCollisionFilterGroup(SimulationConstants.RAY_GROUP); logger.info("Setup complete"); }