Java 类com.badlogic.gdx.graphics.g3d.model.MeshPart 实例源码
项目:Argent
文件:Terrain.java
public void init() {
final int numVertices = this.vertexResolution * this.vertexResolution;
final int numIndices = (this.vertexResolution-1) * (this.vertexResolution-1) * 6;
mesh = new Mesh(true, numVertices, numIndices, attribs);
this.vertices = new float[numVertices * stride];
mesh.setIndices(buildIndices());
buildVertices();
mesh.setVertices(vertices);
MeshPart meshPart = new MeshPart(null, mesh, 0, numIndices, GL30.GL_TRIANGLES);
meshPart.update();
ModelBuilder mb = new ModelBuilder();
mb.begin();
mb.part(meshPart, material);
model = mb.end();
modelInstance = new ModelInstance(model);
modelInstance.transform = transform;
}
项目:Argent
文件:VolumetricDepthShader.java
@Override
public void render(final Renderable renderable, final Attributes combinedAttributes) {
renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
final boolean[] firstCall = {true};
lights.forEach(l -> {
l.applyToShader(program);
if(Gdx.input.isKeyJustPressed(Input.Keys.L))
for (String s : program.getUniforms()) {
System.out.println(s);
}
if(true) {
context.setDepthTest(GL20.GL_LEQUAL);
context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
super.render(renderable, combinedAttributes);
firstCall[0] = false;
}else{
context.setDepthTest(GL20.GL_EQUAL);
context.setBlending(true, GL20.GL_ONE, GL20.GL_ONE);
MeshPart part = renderable.meshPart;
part.mesh.render(program, part.primitiveType, part.offset, part.size, false);
}
});
}
项目:Mundus
文件:Terrain.java
public void init() {
final int numVertices = this.vertexResolution * vertexResolution;
final int numIndices = (this.vertexResolution - 1) * (vertexResolution - 1) * 6;
mesh = new Mesh(true, numVertices, numIndices, attribs);
this.vertices = new float[numVertices * stride];
mesh.setIndices(buildIndices());
buildVertices();
mesh.setVertices(vertices);
MeshPart meshPart = new MeshPart(null, mesh, 0, numIndices, GL20.GL_TRIANGLES);
meshPart.update();
ModelBuilder mb = new ModelBuilder();
mb.begin();
mb.part(meshPart, material);
model = mb.end();
modelInstance = new ModelInstance(model);
modelInstance.transform = transform;
}
项目:libgdxcn
文件:ModelBuilder.java
@Deprecated
public static Model createFromMesh (final Mesh mesh, int indexOffset, int vertexCount, int primitiveType,
final Material material) {
Model result = new Model();
MeshPart meshPart = new MeshPart();
meshPart.id = "part1";
meshPart.indexOffset = indexOffset;
meshPart.numVertices = vertexCount;
meshPart.primitiveType = primitiveType;
meshPart.mesh = mesh;
NodePart partMaterial = new NodePart();
partMaterial.material = material;
partMaterial.meshPart = meshPart;
Node node = new Node();
node.id = "node1";
node.parts.add(partMaterial);
result.meshes.add(mesh);
result.materials.add(material);
result.nodes.add(node);
result.meshParts.add(meshPart);
result.manageDisposable(mesh);
return result;
}
项目:libgdxcn
文件:MeshBuilder.java
/** End building the mesh and returns the mesh */
public Mesh end () {
if (this.attributes == null) throw new RuntimeException("Call begin() first");
endpart();
final Mesh mesh = new Mesh(true, vertices.size / stride, indices.size, attributes);
mesh.setVertices(vertices.items, 0, vertices.size);
mesh.setIndices(indices.items, 0, indices.size);
for (MeshPart p : parts)
p.mesh = mesh;
parts.clear();
attributes = null;
vertices.clear();
indices.clear();
return mesh;
}
项目:libgdxcn
文件:ModelInstance.java
private NodePart copyNodePart (NodePart nodePart) {
NodePart copy = new NodePart();
copy.meshPart = new MeshPart();
copy.meshPart.id = nodePart.meshPart.id;
copy.meshPart.indexOffset = nodePart.meshPart.indexOffset;
copy.meshPart.numVertices = nodePart.meshPart.numVertices;
copy.meshPart.primitiveType = nodePart.meshPart.primitiveType;
copy.meshPart.mesh = nodePart.meshPart.mesh;
if (nodePart.invBoneBindTransforms != null) nodePartBones.put(copy, nodePart.invBoneBindTransforms);
final int index = materials.indexOf(nodePart.material, false);
if (index < 0)
materials.add(copy.material = nodePart.material.copy());
else
copy.material = materials.get(index);
return copy;
}
项目:gaiasky
文件:MeshBuilder2.java
/** End building the mesh and returns the mesh */
public Mesh end() {
if (this.attributes == null)
throw new RuntimeException("Call begin() first");
endpart();
final Mesh mesh = new Mesh(true, vertices.size / stride, indices.size, attributes);
mesh.setVertices(vertices.items, 0, vertices.size);
mesh.setIndices(indices.items, 0, indices.size);
for (MeshPart p : parts)
p.mesh = mesh;
parts.clear();
attributes = null;
vertices.clear();
indices.clear();
return mesh;
}
项目:gaiasky
文件:ModelBuilder2.java
@Deprecated
public static Model createFromMesh(final Mesh mesh, int indexOffset, int vertexCount, int primitiveType, final Material material) {
Model result = new Model();
MeshPart meshPart = new MeshPart();
meshPart.id = "part1";
meshPart.offset = indexOffset;
meshPart.size = vertexCount;
meshPart.primitiveType = primitiveType;
meshPart.mesh = mesh;
NodePart partMaterial = new NodePart();
partMaterial.material = material;
partMaterial.meshPart = meshPart;
Node node = new Node();
node.id = "node1";
node.parts.add(partMaterial);
result.meshes.add(mesh);
result.materials.add(material);
result.nodes.add(node);
result.meshParts.add(meshPart);
result.manageDisposable(mesh);
return result;
}
项目:vtm
文件:SharedModel.java
private NodePart copyNodePart (NodePart nodePart) {
NodePart copy = new NodePart();
copy.meshPart = new MeshPart();
copy.meshPart.id = nodePart.meshPart.id;
copy.meshPart.indexOffset = nodePart.meshPart.indexOffset;
copy.meshPart.numVertices = nodePart.meshPart.numVertices;
copy.meshPart.primitiveType = nodePart.meshPart.primitiveType;
copy.meshPart.mesh = nodePart.meshPart.mesh;
if (nodePart.invBoneBindTransforms != null)
nodePartBones.put(copy, nodePart.invBoneBindTransforms);
// final int index = materials.indexOf(nodePart.material, false);
// if (index < 0)
// materials.add(copy.material = nodePart.material.copy());
// else
// copy.material = materials.get(index);
//
copy.material = nodePart.material;
return copy;
}
项目:gdx-tilemap3d
文件:BaseModelTileMesh.java
protected void collectModelNodeVertexPositions(Node node, Array<Vector3> destVertices, Vector3 scaleFactor, Vector3 positionOffset) {
final Matrix4 transform = node.globalTransform;
for (int i = 0; i < node.parts.size; ++i) {
NodePart nodePart = node.parts.get(i);
MeshPart meshPart = nodePart.meshPart;
ShortBuffer indices = meshPart.mesh.getIndicesBuffer();
FloatBuffer vertices = meshPart.mesh.getVerticesBuffer();
final int strideInFloats = meshPart.mesh.getVertexSize() / (Float.SIZE / 8);
for (int j = 0; j < meshPart.numVertices; ++j) {
int index = indices.get(meshPart.indexOffset + j);
int offset = index * strideInFloats;
tmpPosition.set(vertices.get(offset), vertices.get(offset + 1), vertices.get(offset + 2))
.add(positionOffset)
.scl(scaleFactor)
.mul(transform);
destVertices.add(new Vector3(tmpPosition));
}
}
for (int i = 0; i < node.children.size; ++i)
collectModelNodeVertexPositions(node.children.get(i), destVertices, scaleFactor, positionOffset);
}
项目:Cubes_2
文件:AreaMesh.java
public AreaMesh(VertexAttributes vertexAttributes) {
mesh = new Mesh(true, MAX_VERTICES, MAX_INDICES, vertexAttributes);
meshPart = new MeshPart();
meshPart.mesh = mesh;
meshPart.primitiveType = GL20.GL_TRIANGLES;
meshPart.offset = 0;
mesh.setIndices(indices);
}
项目:Cubes
文件:AreaMesh.java
public AreaMesh(VertexAttributes vertexAttributes) {
mesh = new Mesh(true, MAX_VERTICES, MAX_INDICES, vertexAttributes);
meshPart = new MeshPart();
meshPart.mesh = mesh;
meshPart.primitiveType = GL20.GL_TRIANGLES;
meshPart.offset = 0;
mesh.setIndices(indices);
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
protected static <T extends MeshPart> btBvhTriangleMeshShape getInstance(final Array<T> meshParts) {
for (final btBvhTriangleMeshShape instance : instances) {
if (instance.meshInterface instanceof btTriangleIndexVertexArray &&
btTriangleIndexVertexArray.compare((btTriangleIndexVertexArray)(instance.meshInterface), meshParts))
return instance;
}
return null;
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
public static <T extends MeshPart> btBvhTriangleMeshShape obtain(final Array<T> meshParts) {
btBvhTriangleMeshShape result = getInstance(meshParts);
if (result == null) {
result = new btBvhTriangleMeshShape(btTriangleIndexVertexArray.obtain(meshParts), true);
instances.add(result);
}
result.obtain();
return result;
}
项目:gdx-bullet-gwt
文件:btTriangleIndexVertexArray.java
/** Create or reuse a btTriangleIndexVertexArray instance based on the specified {@link MeshPart} array.
* Use {@link #release()} to release the mesh when it's no longer needed. */
public static <T extends MeshPart> btTriangleIndexVertexArray obtain(final Array<T> meshParts) {
btTriangleIndexVertexArray result = getInstance(meshParts);
if (result == null) {
result = new btTriangleIndexVertexArray(meshParts);
instances.add(result);
}
result.obtain();
return result;
}
项目:gdx-bullet-gwt
文件:btTriangleIndexVertexArray.java
/** Add a {@link MeshPart} instance to this btTriangleIndexVertexArray.
* The specified mesh must be indexed and triangulated and must outlive this btTriangleIndexVertexArray.
* The buffers for the vertices and indices are shared amongst both. */
public btTriangleIndexVertexArray addMeshPart(final MeshPart meshPart) {
btIndexedMesh mesh = btIndexedMesh.obtain(meshPart);
addIndexedMesh(mesh, PHY_ScalarType.PHY_SHORT);
mesh.release();
return this;
}
项目:gdx-bullet-gwt
文件:btIndexedMesh.java
/** Create or reuse a btIndexedMesh instance based on the specified {@link MeshPart}.
* Use {@link #release()} to release the mesh when it's no longer needed. */
public static btIndexedMesh obtain(final MeshPart meshPart) {
if (meshPart == null)
throw new GdxRuntimeException("meshPart cannot be null");
btIndexedMesh result = getInstance(meshPart);
if (result == null) {
result = new btIndexedMesh(meshPart);
instances.add(result);
}
result.obtain();
return result;
}
项目:eamaster
文件:Rim.java
private btCollisionShape createShape(Model model) {
Array<MeshPart> meshParts = model.meshParts;
btTriangleIndexVertexArray btArray = new btTriangleIndexVertexArray(meshParts);
btGImpactMeshShape shape = new btGImpactMeshShape(btArray);
shape.setLocalScaling(new Vector3(1f, 1f, 1f));
shape.setMargin(0.05f);
shape.updateBound();
disposables.add(btArray);
disposables.add(shape);
return shape;
}
项目:eamaster
文件:SoftMeshTest.java
@Override
public void render () {
if (world.renderMeshes) {
MeshPart meshPart = model.nodes.get(0).parts.get(0).meshPart;
softBody.getVertices(meshPart.mesh.getVerticesBuffer(), meshPart.mesh.getVertexSize(), positionOffset, normalOffset,
meshPart.mesh.getIndicesBuffer(), meshPart.indexOffset, meshPart.numVertices, indexMap, 0);
softBody.getWorldTransform(entity.transform);
}
super.render();
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
protected static <T extends MeshPart> btBvhTriangleMeshShape getInstance(final Array<T> meshParts) {
for (final btBvhTriangleMeshShape instance : instances) {
if (instance.meshInterface instanceof btTriangleIndexVertexArray &&
btTriangleIndexVertexArray.compare((btTriangleIndexVertexArray)(instance.meshInterface), meshParts))
return instance;
}
return null;
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
public static <T extends MeshPart> btBvhTriangleMeshShape obtain(final Array<T> meshParts) {
btBvhTriangleMeshShape result = getInstance(meshParts);
if (result == null) {
result = new btBvhTriangleMeshShape(btTriangleIndexVertexArray.obtain(meshParts), true);
instances.add(result);
}
result.obtain();
return result;
}
项目:gdx-bullet-gwt
文件:btTriangleIndexVertexArray.java
/** Create or reuse a btTriangleIndexVertexArray instance based on the specified {@link MeshPart} array.
* Use {@link #release()} to release the mesh when it's no longer needed. */
public static <T extends MeshPart> btTriangleIndexVertexArray obtain(final Array<T> meshParts) {
btTriangleIndexVertexArray result = getInstance(meshParts);
if (result == null) {
result = new btTriangleIndexVertexArray(meshParts);
instances.add(result);
}
result.obtain();
return result;
}
项目:gdx-bullet-gwt
文件:btTriangleIndexVertexArray.java
/** Add a {@link MeshPart} instance to this btTriangleIndexVertexArray.
* The specified mesh must be indexed and triangulated and must outlive this btTriangleIndexVertexArray.
* The buffers for the vertices and indices are shared amongst both. */
public btTriangleIndexVertexArray addMeshPart(final MeshPart meshPart) {
btIndexedMesh mesh = btIndexedMesh.obtain(meshPart);
addIndexedMesh(mesh, PHY_ScalarType.PHY_SHORT);
mesh.release();
return this;
}
项目:gdx-bullet-gwt
文件:btIndexedMesh.java
/** Create or reuse a btIndexedMesh instance based on the specified {@link MeshPart}.
* Use {@link #release()} to release the mesh when it's no longer needed. */
public static btIndexedMesh obtain(final MeshPart meshPart) {
if (meshPart == null)
throw new GdxRuntimeException("meshPart cannot be null");
btIndexedMesh result = getInstance(meshPart);
if (result == null) {
result = new btIndexedMesh(meshPart);
instances.add(result);
}
result.obtain();
return result;
}
项目:libgdxcn
文件:ModelBuilder.java
/** Adds the specified mesh part to the current node. The Mesh will be managed by the model and disposed when the model is
* disposed. The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the
* model.
* @return The added MeshPart. */
public MeshPart part (final String id, final Mesh mesh, int primitiveType, int offset, int size, final Material material) {
final MeshPart meshPart = new MeshPart();
meshPart.id = id;
meshPart.primitiveType = primitiveType;
meshPart.mesh = mesh;
meshPart.indexOffset = offset;
meshPart.numVertices = size;
part(meshPart, material);
return meshPart;
}
项目:libgdxcn
文件:btBvhTriangleMeshShape.java
protected static <T extends MeshPart> btBvhTriangleMeshShape getInstance(final Array<T> meshParts) {
for (final btBvhTriangleMeshShape instance : instances) {
if (instance.meshInterface instanceof btTriangleIndexVertexArray &&
btTriangleIndexVertexArray.compare((btTriangleIndexVertexArray)(instance.meshInterface), meshParts))
return instance;
}
return null;
}
项目:libgdxcn
文件:btBvhTriangleMeshShape.java
/** Obtain an instance of btBvhTriangleMeshShape, made up of the specified {@link MeshPart} instances.
* Where possible previously obtained objects are reused. You must call {@link #release()},
* when you no longer need the shape. */
public static <T extends MeshPart> btBvhTriangleMeshShape obtain(final Array<T> meshParts) {
btBvhTriangleMeshShape result = getInstance(meshParts);
if (result == null) {
result = new btBvhTriangleMeshShape(btTriangleIndexVertexArray.obtain(meshParts), true);
instances.add(result);
}
result.obtain();
return result;
}
项目:libgdxcn
文件:btTriangleIndexVertexArray.java
/** Create or reuse a btTriangleIndexVertexArray instance based on the specified {@link MeshPart} array.
* Use {@link #release()} to release the mesh when it's no longer needed. */
public static <T extends MeshPart> btTriangleIndexVertexArray obtain(final Array<T> meshParts) {
btTriangleIndexVertexArray result = getInstance(meshParts);
if (result == null) {
result = new btTriangleIndexVertexArray(meshParts);
instances.add(result);
}
result.obtain();
return result;
}
项目:libgdxcn
文件:btTriangleIndexVertexArray.java
/** Add a {@link MeshPart} instance to this btTriangleIndexVertexArray.
* The specified mesh must be indexed and triangulated and must outlive this btTriangleIndexVertexArray.
* The buffers for the vertices and indices are shared amongst both. */
public btTriangleIndexVertexArray addMeshPart(final MeshPart meshPart) {
btIndexedMesh mesh = btIndexedMesh.obtain(meshPart);
addIndexedMesh(mesh, PHY_ScalarType.PHY_SHORT);
mesh.release();
return this;
}
项目:libgdxcn
文件:btIndexedMesh.java
/** Create or reuse a btIndexedMesh instance based on the specified {@link MeshPart}.
* Use {@link #release()} to release the mesh when it's no longer needed. */
public static btIndexedMesh obtain(final MeshPart meshPart) {
if (meshPart == null)
throw new GdxRuntimeException("meshPart cannot be null");
btIndexedMesh result = getInstance(meshPart);
if (result == null) {
result = new btIndexedMesh(meshPart);
instances.add(result);
}
result.obtain();
return result;
}
项目:libgdxcn
文件:SoftMeshTest.java
@Override
public void create () {
super.create();
world.maxSubSteps = 20;
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
// Note: not every model is suitable for a one on one translation with a soft body, a better model might be added later.
model = objLoader.loadModel(Gdx.files.internal("data/wheel.obj"));
MeshPart meshPart = model.nodes.get(0).parts.get(0).meshPart;
meshPart.mesh.scale(6, 6, 6);
indexMap = BufferUtils.newShortBuffer(meshPart.numVertices);
positionOffset = meshPart.mesh.getVertexAttribute(Usage.Position).offset;
normalOffset = meshPart.mesh.getVertexAttribute(Usage.Normal).offset;
softBody = new btSoftBody(worldInfo, meshPart.mesh.getVerticesBuffer(), meshPart.mesh.getVertexSize(), positionOffset,
normalOffset, meshPart.mesh.getIndicesBuffer(), meshPart.indexOffset, meshPart.numVertices, indexMap, 0);
// Set mass of the first vertex to zero so its unmovable, comment out this line to make it a fully dynamic body.
softBody.setMass(0, 0);
com.badlogic.gdx.physics.bullet.softbody.btSoftBody.Material pm = softBody.appendMaterial();
pm.setKLST(0.2f);
pm.setFlags(0);
softBody.generateBendingConstraints(2, pm);
// Be careful increasing iterations, it decreases performance (but increases accuracy).
softBody.setConfig_piterations(7);
softBody.setConfig_kDF(0.2f);
softBody.randomizeConstraints();
softBody.setTotalMass(1);
softBody.translate(tmpV.set(1, 5, 1));
((btSoftRigidDynamicsWorld)(world.collisionWorld)).addSoftBody(softBody);
world.add(entity = new BulletEntity(model, (btCollisionObject)null, 1, 5, 1));
}
项目:libgdxcn
文件:SoftMeshTest.java
@Override
public void render () {
if (world.renderMeshes) {
MeshPart meshPart = model.nodes.get(0).parts.get(0).meshPart;
softBody.getVertices(meshPart.mesh.getVerticesBuffer(), meshPart.mesh.getVertexSize(), positionOffset, normalOffset,
meshPart.mesh.getIndicesBuffer(), meshPart.indexOffset, meshPart.numVertices, indexMap, 0);
softBody.getWorldTransform(entity.transform);
}
super.render();
}
项目:gaiasky
文件:ModelBuilder2.java
/**
* Adds the specified mesh part to the current node. The Mesh will be
* managed by the model and disposed when the model is disposed. The
* resources the Material might contain are not managed, use
* {@link #manage(Disposable)} to add those to the model.
*
* @return The added MeshPart.
*/
public MeshPart part(final String id, final Mesh mesh, int primitiveType, int offset, int size, final Material material) {
final MeshPart meshPart = new MeshPart();
meshPart.id = id;
meshPart.primitiveType = primitiveType;
meshPart.mesh = mesh;
meshPart.offset = offset;
meshPart.size = size;
part(meshPart, material);
return meshPart;
}
项目:gdx-proto
文件:LevelBuilder.java
/** bullet bodies are offset from model instances by a 90 degree rotation on X axis, boolean set to true handles this */
private static void setupStaticModel(Array<MeshPart> meshParts, Matrix4 matrix, boolean performVisualToPhysicalRotation) {
//Log.debug("create static model at: " + matrix.getTranslation(tmp));
btCollisionObject obj = new btCollisionObject();
btCollisionShape shape = new btBvhTriangleMeshShape(meshParts);
obj.setCollisionShape(shape);
Physics.applyStaticGeometryCollisionFlags(obj);
mtx.set(matrix);
if (performVisualToPhysicalRotation) {
mtx.rotate(Vector3.X, -90);
}
obj.setWorldTransform(mtx);
Physics.inst.addStaticGeometryToWorld(obj);
}
项目:gdx-proto
文件:HeadlessModel.java
private Node loadNode (Node parent, ModelNode modelNode) {
Node node = new Node();
node.id = modelNode.id;
node.parent = parent;
if (modelNode.translation != null) node.translation.set(modelNode.translation);
if (modelNode.rotation != null) node.rotation.set(modelNode.rotation);
if (modelNode.scale != null) node.scale.set(modelNode.scale);
// FIXME create temporary maps for faster lookup?
if (modelNode.parts != null) {
for (ModelNodePart modelNodePart : modelNode.parts) {
MeshPart meshPart = null;
if (modelNodePart.meshPartId != null) {
for (MeshPart part : meshParts) {
if (modelNodePart.meshPartId.equals(part.id)) {
meshPart = part;
break;
}
}
}
if (meshPart == null) throw new GdxRuntimeException("Invalid node: " + node.id);
NodePart nodePart = new NodePart();
nodePart.meshPart = meshPart;
// nodePart.material = meshMaterial;
node.parts.add(nodePart);
if (modelNodePart.bones != null) nodePartBones.put(nodePart, modelNodePart.bones);
}
}
if (modelNode.children != null) {
for (ModelNode child : modelNode.children) {
node.children.add(loadNode(node, child));
}
}
return node;
}
项目:Tower-Defense-Galaxy
文件:VRContext.java
private Model loadRenderModel(String name) {
if (models.containsKey(name)) return models.get(name);
// FIXME we load the models synchronously cause we are lazy
int error = 0;
PointerBuffer modelPointer = PointerBuffer.allocateDirect(1);
while (true) {
error = VRRenderModels.VRRenderModels_LoadRenderModel_Async(name, modelPointer);
if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
}
if (error != VR.EVRRenderModelError_VRRenderModelError_None) return null;
RenderModel renderModel = new RenderModel(modelPointer.getByteBuffer(RenderModel.SIZEOF));
error = 0;
PointerBuffer texturePointer = PointerBuffer.allocateDirect(1);
while (true) {
error = VRRenderModels.VRRenderModels_LoadTexture_Async(renderModel.diffuseTextureId(), texturePointer);
if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
}
if (error != VR.EVRRenderModelError_VRRenderModelError_None) {
VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
return null;
}
RenderModelTextureMap renderModelTexture = new RenderModelTextureMap(texturePointer.getByteBuffer(RenderModelTextureMap.SIZEOF));
// convert to a Model
Mesh mesh = new Mesh(true, renderModel.unVertexCount(), renderModel.unTriangleCount() * 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0));
MeshPart meshPart = new MeshPart(name, mesh, 0, renderModel.unTriangleCount() * 3, GL20.GL_TRIANGLES);
RenderModelVertex.Buffer vertices = renderModel.rVertexData();
float[] packedVertices = new float[8 * renderModel.unVertexCount()];
int i = 0;
while(vertices.remaining() > 0) {
RenderModelVertex v = vertices.get();
packedVertices[i++] = v.vPosition().v(0);
packedVertices[i++] = v.vPosition().v(1);
packedVertices[i++] = v.vPosition().v(2);
packedVertices[i++] = v.vNormal().v(0);
packedVertices[i++] = v.vNormal().v(1);
packedVertices[i++] = v.vNormal().v(2);
packedVertices[i++] = v.rfTextureCoord().get(0);
packedVertices[i++] = v.rfTextureCoord().get(1);
}
mesh.setVertices(packedVertices);
short[] indices = new short[renderModel.unTriangleCount() * 3];
renderModel.IndexData().get(indices);
mesh.setIndices(indices);
Pixmap pixmap = new Pixmap(renderModelTexture.unWidth(), renderModelTexture.unHeight(), Format.RGBA8888);
byte[] pixels = new byte[renderModelTexture.unWidth() * renderModelTexture.unHeight() * 4];
renderModelTexture.rubTextureMapData(pixels.length).get(pixels);
pixmap.getPixels().put(pixels);
pixmap.getPixels().position(0);
Texture texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), true, true));
Material material = new Material(new TextureAttribute(TextureAttribute.Diffuse, texture));
Model model = new Model();
model.meshes.add(mesh);
model.meshParts.add(meshPart);
model.materials.add(material);
Node node = new Node();
node.id = name;
node.parts.add(new NodePart(meshPart, material));
model.nodes.add(node);
model.manageDisposable(mesh);
model.manageDisposable(texture);
VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
VRRenderModels.VRRenderModels_FreeTexture(renderModelTexture);
models.put(name, model);
return model;
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
public <T extends MeshPart> btBvhTriangleMeshShape(final Array<T> meshParts) {
this(meshParts, true);
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
public <T extends MeshPart> btBvhTriangleMeshShape(final Array<T> meshParts, boolean useQuantizedAabbCompression) {
this(1, btTriangleIndexVertexArray.obtain(meshParts), useQuantizedAabbCompression);
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
public <T extends MeshPart> btBvhTriangleMeshShape(final Array<T> meshParts, boolean useQuantizedAabbCompression, boolean buildBvh) {
this(1, btTriangleIndexVertexArray.obtain(meshParts), useQuantizedAabbCompression, buildBvh);
}
项目:gdx-bullet-gwt
文件:btBvhTriangleMeshShape.java
public <T extends MeshPart> btBvhTriangleMeshShape(final Array<T> meshParts, boolean useQuantizedAabbCompression, Vector3 bvhAabbMin, Vector3 bvhAabbMax) {
this(1, btTriangleIndexVertexArray.obtain(meshParts), useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax);
}