当前位置: 首页>>代码示例>>Java>>正文


Java ModelBuilder.createFromMesh方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.utils.ModelBuilder.createFromMesh方法的典型用法代码示例。如果您正苦于以下问题:Java ModelBuilder.createFromMesh方法的具体用法?Java ModelBuilder.createFromMesh怎么用?Java ModelBuilder.createFromMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.g3d.utils.ModelBuilder的用法示例。


在下文中一共展示了ModelBuilder.createFromMesh方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFrustumModel

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public static Model createFrustumModel (final Vector3... p) {
	return ModelBuilder.createFromMesh(new float[] {p[0].x, p[0].y, p[0].z, 0, 0, 1, p[1].x, p[1].y, p[1].z, 0, 0, 1, p[2].x,
		p[2].y, p[2].z, 0, 0, 1, p[3].x, p[3].y, p[3].z, 0, 0,
		1, // near
		p[4].x, p[4].y, p[4].z, 0, 0, -1, p[5].x, p[5].y, p[5].z, 0, 0, -1, p[6].x, p[6].y, p[6].z, 0, 0, -1, p[7].x, p[7].y,
		p[7].z, 0, 0, -1},// far
		new VertexAttribute[] {new VertexAttribute(Usage.Position, 3, "a_position"),
			new VertexAttribute(Usage.Normal, 3, "a_normal")}, new short[] {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4,
			1, 5, 2, 6, 3, 7}, GL20.GL_LINES, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)));
}
 
开发者ID:Matsemann,项目名称:eamaster,代码行数:11,代码来源:FrustumCullingTest.java

示例2: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
	public void create () {
		super.create();

		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);

		float x0 = -2f, y0 = 6f, z0 = -2f;
		float x1 = 8f, y1 = 6f, z1 = 8f;
		Vector3 patch00 = new Vector3(x0, y0, z0);
		Vector3 patch10 = new Vector3(x1, y1, z0);
		Vector3 patch01 = new Vector3(x0, y0, z1);
		Vector3 patch11 = new Vector3(x1, y1, z1);
		softBody = btSoftBodyHelpers.CreatePatch(worldInfo, patch00, patch10, patch01, patch11, 15, 15, 15, false);
		softBody.takeOwnership();
		softBody.setTotalMass(100f);
//        softBody.setConfig_kDP(0.2f);
//        softBody.setConfig_kCHR(0.99f);
//        softBody.setConfig_kKHR(0.99f);
//        softBody.setConfig_kSHR(0.99f);
		((btSoftRigidDynamicsWorld)(world.collisionWorld)).addSoftBody(softBody);

		final int vertCount = softBody.getNodeCount();
		final int faceCount = softBody.getFaceCount();
		mesh = new Mesh(false, vertCount, faceCount * 3, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
			new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2,
				ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
		final int vertSize = mesh.getVertexSize() / 4;
		mesh.getVerticesBuffer().position(0);
		mesh.getVerticesBuffer().limit(vertCount * vertSize);
		mesh.getIndicesBuffer().position(0);
		mesh.getIndicesBuffer().limit(faceCount * 3);
		softBody.getVertices(mesh.getVerticesBuffer(), vertCount, mesh.getVertexSize(), 0);
		softBody.getIndices(mesh.getIndicesBuffer(), faceCount);

		final float[] verts = new float[vertCount * vertSize];
		final int uvOffset = mesh.getVertexAttribute(Usage.TextureCoordinates).offset / 4;
		final int normalOffset = mesh.getVertexAttribute(Usage.Normal).offset / 4;
		mesh.getVertices(verts);
		for (int i = 0; i < vertCount; i++) {
			verts[i * vertSize + normalOffset] = 0f;
			verts[i * vertSize + normalOffset + 1] = 1f;
			verts[i * vertSize + normalOffset + 2] = 0f;
			verts[i * vertSize + uvOffset] = (verts[i * vertSize] - x0) / (x1 - x0);
			verts[i * vertSize + uvOffset + 1] = (verts[i * vertSize + 2] - z0) / (z1 - z0);
		}
		mesh.setVertices(verts);
		texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));

		model = ModelBuilder.createFromMesh(mesh, GL20.GL_TRIANGLES, new Material(TextureAttribute.createDiffuse(texture),
			ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f), IntAttribute.createCullFace(0)));
		instance = new ModelInstance(model);
		world.add(new BulletEntity(instance, null));

        shoot(320f, 240f, 20f);
    }
 
开发者ID:Matsemann,项目名称:eamaster,代码行数:57,代码来源:SoftBodyTest.java

示例3: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	super.create();

	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);

	float x0 = -2f, y0 = 6f, z0 = -2f;
	float x1 = 8f, y1 = 6f, z1 = 8f;
	Vector3 patch00 = new Vector3(x0, y0, z0);
	Vector3 patch10 = new Vector3(x1, y1, z0);
	Vector3 patch01 = new Vector3(x0, y0, z1);
	Vector3 patch11 = new Vector3(x1, y1, z1);
	softBody = btSoftBodyHelpers.CreatePatch(worldInfo, patch00, patch10, patch01, patch11, 15, 15, 15, false);
	softBody.takeOwnership();
	softBody.setTotalMass(100f);
	((btSoftRigidDynamicsWorld)(world.collisionWorld)).addSoftBody(softBody);

	final int vertCount = softBody.getNodeCount();
	final int faceCount = softBody.getFaceCount();
	mesh = new Mesh(false, vertCount, faceCount * 3, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
		new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2,
			ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
	final int vertSize = mesh.getVertexSize() / 4;
	mesh.getVerticesBuffer().position(0);
	mesh.getVerticesBuffer().limit(vertCount * vertSize);
	mesh.getIndicesBuffer().position(0);
	mesh.getIndicesBuffer().limit(faceCount * 3);
	softBody.getVertices(mesh.getVerticesBuffer(), vertCount, mesh.getVertexSize(), 0);
	softBody.getIndices(mesh.getIndicesBuffer(), faceCount);

	final float[] verts = new float[vertCount * vertSize];
	final int uvOffset = mesh.getVertexAttribute(Usage.TextureCoordinates).offset / 4;
	final int normalOffset = mesh.getVertexAttribute(Usage.Normal).offset / 4;
	mesh.getVertices(verts);
	for (int i = 0; i < vertCount; i++) {
		verts[i * vertSize + normalOffset] = 0f;
		verts[i * vertSize + normalOffset + 1] = 1f;
		verts[i * vertSize + normalOffset + 2] = 0f;
		verts[i * vertSize + uvOffset] = (verts[i * vertSize] - x0) / (x1 - x0);
		verts[i * vertSize + uvOffset + 1] = (verts[i * vertSize + 2] - z0) / (z1 - z0);
	}
	mesh.setVertices(verts);
	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));

	model = ModelBuilder.createFromMesh(mesh, GL20.GL_TRIANGLES, new Material(TextureAttribute.createDiffuse(texture),
		ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f), IntAttribute.createCullFace(0)));
	instance = new ModelInstance(model);
	world.add(new BulletEntity(instance, null));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:51,代码来源:SoftBodyTest.java


注:本文中的com.badlogic.gdx.graphics.g3d.utils.ModelBuilder.createFromMesh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。