/** Method to transform the positions in the mesh. Normals will be kept as is. This is a potentially slow operation, use with * care. It will also create a temporary float[] which will be garbage collected. * * @param matrix the transformation matrix */ public void transform (final Matrix4 matrix) { transform(matrix, 0, getNumVertices()); }
/** Method to transform the positions in the mesh. Normals will be kept as is. This is a potentially slow operation, use with * care. It will also create a temporary float[] which will be garbage collected. * * @param matrix the transformation matrix */ public void transform (final Matrix4 matrix) { transform(matrix, 0, getNumVertices()); }
public void transform (final Matrix4 matrix, final int start, final int count) { final VertexAttribute posAttr = getVertexAttribute(Usage.Position); final int posOffset = posAttr.offset / 4; final int stride = getVertexSize() / 4; final int numComponents = posAttr.numComponents; final int numVertices = getNumVertices(); final float[] vertices = new float[count * stride]; getVertices(start * stride, count * stride, vertices); // getVertices(0, vertices.length, vertices); transform(matrix, vertices, stride, posOffset, numComponents, 0, count); // setVertices(vertices, 0, vertices.length); updateVertices(start * stride, vertices); }
public void transform (final Matrix4 matrix, final int start, final int count) { final VertexAttribute posAttr = getVertexAttribute(Usage.Position); final int posOffset = posAttr.offset / 4; final int stride = getVertexSize() / 4; final int numComponents = posAttr.numComponents; final int numVertices = getNumVertices(); final float[] vertices = new float[count * stride]; getVertices(start * stride, count * stride, vertices); // getVertices(0, vertices.length, vertices); transform(matrix, vertices, stride, posOffset, numComponents, 0, count); // setVertices(vertices, 0, vertices.length); updateVertices(start * stride, vertices); }
/** Method to transform the positions in the mesh. Normals will be kept as is. This is a potentially slow operation, use with * care. It will also create a temporary float[] which will be garbage collected. * * @param matrix the transformation matrix */ public void transform (final Matrix4 matrix) { transform(matrix, 0, getNumVertices()); }
public void transform (final Matrix4 matrix, final int start, final int count) { final VertexAttribute posAttr = getVertexAttribute(Usage.Position); final int posOffset = posAttr.offset / 4; final int stride = getVertexSize() / 4; final int numComponents = posAttr.numComponents; final int numVertices = getNumVertices(); final float[] vertices = new float[count * stride]; getVertices(start * stride, count * stride, vertices); // getVertices(0, vertices.length, vertices); transform(matrix, vertices, stride, posOffset, numComponents, 0, count); // setVertices(vertices, 0, vertices.length); updateVertices(start * stride, vertices); }
/** * Creates and adds the navmesh to this scene. */ private void setNavmesh(GameObjectBlueprint bp) { // We need to set the node transforms before calculating the navmesh shape GameModel gameModel = new GameModel(bp.model, bp.name, bp.position, bp.rotation, bp.scale); Array<NodePart> nodes = gameModel.modelInstance.model.getNode("navmesh").parts; // Sort the model meshParts array according to material name nodes.sort(new NavMeshNodeSorter()); // The model transform must be applied to the meshparts for shape generation to work correctly. gameModel.modelInstance.calculateTransforms(); Matrix4 transform = new Matrix4(); for (Node node : gameModel.modelInstance.nodes) { transform.set(node.globalTransform).inv(); for (NodePart nodePart : node.parts) { nodePart.meshPart.mesh.transform(transform); } } navMesh = new NavMesh(gameModel.modelInstance.model); btCollisionShape shape = navMesh.getShape(); navmeshBody = new InvisibleBody("navmesh", shape, 0, gameModel.modelInstance.transform, GameEngine.NAVMESH_FLAG, GameEngine.NAVMESH_FLAG, false, false); worldBounds.set(gameModel.boundingBox); gameModel.dispose(); }
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(); } }