Java Code Examples for com.badlogic.gdx.graphics.g3d.utils.ModelBuilder#node()
The following examples show how to use
com.badlogic.gdx.graphics.g3d.utils.ModelBuilder#node() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelManager.java From gdx-proto with Apache License 2.0 | 6 votes |
/** players are represented by cubes, with another cube marking the direction it is facing */ public void createPlayerModel() { ModelBuilder mb = new ModelBuilder(); ModelBuilder mb2 = new ModelBuilder(); long attr = Usage.Position | Usage.Normal; float r = 0.5f; float g = 1f; float b = 0.75f; Material material = new Material(ColorAttribute.createDiffuse(new Color(r, g, b, 1f))); Material faceMaterial = new Material(ColorAttribute.createDiffuse(Color.BLUE)); float w = 1f; float d = w; float h = 2f; mb.begin(); //playerModel = mb.createBox(w, h, d, material, attr); Node node = mb.node("box", mb2.createBox(w, h, d, material, attr)); // the face is just a box to show which direction the player is facing Node faceNode = mb.node("face", mb2.createBox(w/2, h/2, d/2, faceMaterial, attr)); faceNode.translation.set(0f, 0f, d/2); playerModel = mb.end(); }
Example 2
Source File: LevelBuilder.java From gdx-proto with Apache License 2.0 | 6 votes |
/** client builds statics, probably based on info from server */ public static void buildStatics(LevelStatic[] statics) { if (staticGeometry == null) { staticGeometry = new Array<>(); } Log.debug("client building statics received from server: " + statics.length); ModelBuilder mb = new ModelBuilder(); mb.begin(); for (LevelStatic stat : statics) { Model model = Assets.manager.get(stat.modelName, Model.class); setupStaticModel(model.meshParts, stat.mtx, true); Node node = mb.node("piece", model); stat.mtx.getTranslation(tmp); node.translation.set(tmp); node.rotation.set(stat.mtx.getRotation(q)); } Model finalModel = mb.end(); ModelInstance instance = new ModelInstance(finalModel); staticGeometry.add(instance); }
Example 3
Source File: UsefulMeshs.java From Mundus with Apache License 2.0 | 5 votes |
public static Model createArrowStub(Material mat, Vector3 from, Vector3 to) { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder meshBuilder; // line meshBuilder = modelBuilder.part("line", GL20.GL_LINES, VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, mat); meshBuilder.line(from.x, from.y, from.z, to.x, to.y, to.z); // stub Node node = modelBuilder.node(); node.translation.set(to.x, to.y, to.z); meshBuilder = modelBuilder.part("stub", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, mat); BoxShapeBuilder.build(meshBuilder, 2, 2, 2); return modelBuilder.end(); }
Example 4
Source File: ModelFactory.java From GdxDemo3D with Apache License 2.0 | 5 votes |
public static Model buildCompassModel() { float compassScale = 5; ModelBuilder modelBuilder = new ModelBuilder(); Model arrow = modelBuilder.createArrow(Vector3.Zero, Vector3.Y.cpy().scl(compassScale), null, VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal); modelBuilder.begin(); Mesh zArrow = arrow.meshes.first().copy(false); zArrow.transform(new Matrix4().rotate(Vector3.X, 90)); modelBuilder.part("part1", zArrow, GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(Color.BLUE))); modelBuilder.node(); Mesh yArrow = arrow.meshes.first().copy(false); modelBuilder.part("part2", yArrow, GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(Color.GREEN))); modelBuilder.node(); Mesh xArrow = arrow.meshes.first().copy(false); xArrow.transform(new Matrix4().rotate(Vector3.Z, -90)); modelBuilder.part("part3", xArrow, GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(Color.RED))); arrow.dispose(); return modelBuilder.end(); }
Example 5
Source File: Box.java From gdx-proto with Apache License 2.0 | 5 votes |
/** create some boxes to fill the level with some test geometry */ public static void createBoxes(int count) { ModelBuilder main = new ModelBuilder(); ModelBuilder mb = new ModelBuilder(); Material material = new Material(); if (Main.isClient()) { material.set(TextureAttribute.createDiffuse(Assets.manager.get("textures/marble.jpg", Texture.class))); } main.begin(); //float x = GameWorld.WORLD_WIDTH; //float y = GameWorld.WORLD_DEPTH; for (int i = 0; i < count; i++) { //float w = MathUtils.random(minW, maxW); float w = 8f; float d = 8f; float h = (i+1)*5f; tmp.set(10f + (w+2) * i, 0f, 10f + (d+2) * i); if (Main.isClient()) { mb.begin(); MeshPartBuilder mpb = mb.part("part-" + i, GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates, material); mpb.box(w, h, d); Model boxModel = mb.end(); Node node = main.node("box-" + i, boxModel); node.translation.set(tmp); q.idt(); node.rotation.set(q); } //node.translation.set(MathUtils.random(x), 0f, MathUtils.random(y)); //q.set(Vector3.X, -90); mtx.set(q); mtx.setTranslation(tmp); btCollisionObject obj = Physics.inst.createBoxObject(tmp.set(w/2, h/2, d/2)); obj.setWorldTransform(mtx); Physics.applyStaticGeometryCollisionFlags(obj); Physics.inst.addStaticGeometryToWorld(obj); } Model finalModel = main.end(); instance = new ModelInstance(finalModel); }