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


Java ModelBuilder.part方法代码示例

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


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

示例1: init

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
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;
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:20,代码来源:Terrain.java

示例2: init

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
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;
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:20,代码来源:Terrain.java

示例3: createAxes

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public static Model createAxes() {
    final float GRID_MIN = -10f;
    final float GRID_MAX = 10f;
    final float GRID_STEP = 1f;
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.LIGHT_GRAY);
    for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
        builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
        builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
    }
    builder = modelBuilder.part("axes", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.RED);
    builder.line(0, 0, 0, 100, 0, 0);
    builder.setColor(Color.GREEN);
    builder.line(0, 0, 0, 0, 100, 0);
    builder.setColor(Color.BLUE);
    builder.line(0, 0, 0, 0, 0, 100);
    return modelBuilder.end();
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:24,代码来源:UsefulMeshs.java

示例4: buildPlaneModel

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public static Model buildPlaneModel(final float width,
									final float height, final Material material, final float u1,
									final float v1, final float u2, final float v2) {

	ModelBuilder modelBuilder = new ModelBuilder();
	modelBuilder.begin();
	MeshPartBuilder bPartBuilder = modelBuilder.part("rect", GL20.GL_TRIANGLES,
			VertexAttributes.Usage.Position
					| VertexAttributes.Usage.Normal
					| VertexAttributes.Usage.TextureCoordinates, material);
	bPartBuilder.setUVRange(u1, v1, u2, v2);
	bPartBuilder.rect(-(width * 0.5f), -(height * 0.5f), 0, (width * 0.5f),
			-(height * 0.5f), 0, (width * 0.5f), (height * 0.5f), 0,
			-(width * 0.5f), (height * 0.5f), 0, 0, 0, -1);

	return (modelBuilder.end());
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:18,代码来源:ModelFactory.java

示例5: createInfiniteWaterPart

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public static Model createInfiniteWaterPart(TypeInterpreter interpreter, int landscapeIndex, PlanetConfig planetConfig) {
	ModelBuilder modelBuilder = new ModelBuilder();
	MeshBuilder builder = new MeshBuilder();
	float waterHeight = interpreter.it.get(landscapeIndex).endValue;
	builder.begin(PlanetPart.VERTEX_ATTRIBUTES, GL20.GL_TRIANGLES);
	infiniteWaterHeight = waterHeight * planetConfig.landscapeHeight - 1;
	Vector3 corner01 = new Vector3(-INFINITE_WATER_SIZE, -INFINITE_WATER_SIZE, infiniteWaterHeight);
	Vector3 corner02 = new Vector3(INFINITE_WATER_SIZE, -INFINITE_WATER_SIZE, infiniteWaterHeight);
	Vector3 corner03 = new Vector3(INFINITE_WATER_SIZE, INFINITE_WATER_SIZE, infiniteWaterHeight);
	Vector3 corner04 = new Vector3(-INFINITE_WATER_SIZE, INFINITE_WATER_SIZE, infiniteWaterHeight);
	builder.rect(corner01, corner02, corner03, corner04, new Vector3(0, 0, 1));
	Material waterMaterial = planetConfig.layerConfigs.get(landscapeIndex).material;
	Mesh mesh = builder.end();
	modelBuilder.begin();
	modelBuilder.part(PlanetPart.LANDSCAPE_PART_NAME + landscapeIndex, mesh, GL20.GL_TRIANGLES, waterMaterial);
	return modelBuilder.end();
}
 
开发者ID:aphex-,项目名称:Alien-Ark,代码行数:18,代码来源:ControllerPlanet.java

示例6: createAxes

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
private void createAxes () {
	ModelBuilder modelBuilder = new ModelBuilder();
	modelBuilder.begin();
	MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES, Usage.Position | Usage.Color, new Material());
	builder.setColor(Color.LIGHT_GRAY);
	for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
		builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
		builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
	}
	builder = modelBuilder.part("axes", GL20.GL_LINES, Usage.Position | Usage.Color, new Material());
	builder.setColor(Color.RED);
	builder.line(0, 0, 0, 100, 0, 0);
	builder.setColor(Color.GREEN);
	builder.line(0, 0, 0, 0, 100, 0);
	builder.setColor(Color.BLUE);
	builder.line(0, 0, 0, 0, 0, 100);
	axesModel = modelBuilder.end();
	axesInstance = new ModelInstance(axesModel);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:BaseG3dTest.java

示例7: Game3d

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public Game3d(){
   ship = Asset.loadModelObj("ship");//loads an obj model
   ship.scale(3f);
   skydome = Asset.loadModel("skydome"); //loads a g3db model
   builder = new ModelBuilder();
   builder.begin();
   MeshPartBuilder part = builder.part("floor", GL20.GL_TRIANGLES, Usage.Position | 
        Usage.TextureCoordinates | Usage.Normal, new Material());
   for (float x = -200f; x < 200f; x += 10f) {
       for (float z = -200f; z < 200f; z += 10f) {
           part.rect(x, 0, z + 10f, x + 10f, 0, z + 10f, x + 10f, 0, z, x, 0, z, 0, 1, 0);
       }
   }
   floor = new Actor3d(builder.end());
   floor.materials.get(0).set(TextureAttribute.createDiffuse(Asset.tex("concrete").getTexture()));
   knight = Asset.loadModel("knight");
   knight.setPosition(-20f, 18f, 0f);
   knight.setPitch(-90f);
   addActor3d(floor);
   addActor3d(skydome);
   addActor3d(ship);
   addActor3d(knight);
   stage3d.getCamera().position.set(knight.getX()+ 13f, knight.getY() + 24f, knight.getZ() + 45f);
   //Camera3d.followOffset(20f, 20f, -20f);
  // Camera3d.followActor3d(knight, false);
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:27,代码来源:Game3d.java

示例8: createFloor

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

		ModelBuilder modelBuilder = new ModelBuilder();
		modelBuilder.begin();
		MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES,
				Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(
						ColorAttribute.createDiffuse(Color.WHITE)));
		mpb.setColor(1f, 1f, 1f, 1f);
//		mpb.box(0, -0.1f, 0, 10, .2f, 10);
		mpb.rect(-10, 0, -10, 
				-10, 0, 10,
				10, 0, 10,
				10, 0, -10, 0, 1, 0);
		floorModel = modelBuilder.end();
		floorInstance = new ModelInstance(floorModel);
		
		// TODO Set only when FBO is active
		floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
	}
 
开发者ID:bladecoder,项目名称:bladecoder-adventure-engine,代码行数:20,代码来源:Utils3D.java

示例9: createAxes

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
private static void createAxes() {
	ModelBuilder modelBuilder = new ModelBuilder();
	modelBuilder.begin();
	MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material());
	builder.setColor(Color.LIGHT_GRAY);
	for (float t = GRID_MIN; t <= GRID_MAX; t+=GRID_STEP) {
		builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
		builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
	}
	builder = modelBuilder.part("axes", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material());
	builder.setColor(Color.RED);
	builder.line(0, 0, 0, 10, 0, 0);
	builder.setColor(Color.GREEN);
	builder.line(0, 0, 0, 0, 10, 0);
	builder.setColor(Color.BLUE);
	builder.line(0, 0, 0, 0, 0, 10);
	axesModel = modelBuilder.end();
	axesInstance = new ModelInstance(axesModel);
}
 
开发者ID:bladecoder,项目名称:bladecoder-adventure-engine,代码行数:20,代码来源:Utils3D.java

示例10: createBillboardTest

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public void createBillboardTest() {
	ModelBuilder mb = new ModelBuilder();
	mb.begin();

	long attr = Usage.TextureCoordinates | Usage.Position | Usage.Normal;
	TextureRegion region = Assets.getAtlas().findRegion("sprites/test-guy");
	Material mat = new Material(TextureAttribute.createDiffuse(region.getTexture()));
	boolean blended = true;
	float opacity = 1f;
	mat.set(new BlendingAttribute(blended, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, opacity));
	MeshPartBuilder mpb = mb.part("rect", GL20.GL_TRIANGLES, attr, mat);
	mpb.setUVRange(region);
	// the coordinates are offset so that we can easily set the center position to align with the entity's body
	float sz = 2f; // size
	float b = -sz/2; // base
	float max = sz/2; // max
	Vector3 bl = new Vector3(b, b, 0f);
	Vector3 br = new Vector3(b, max, 0f);
	Vector3 tr = new Vector3(max, max, 0f);
	Vector3 tl = new Vector3(max, b, 0f);
	Vector3 norm = new Vector3(0f, 0f, 1f);
	mpb.rect(bl, tl, tr, br, norm);
	billboardTestModel = mb.end();
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:25,代码来源:ModelManager.java

示例11: createAxes

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
public ModelInstance createAxes () {
	ModelBuilder modelBuilder = new ModelBuilder();
	modelBuilder.begin();
	MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES, Usage.Position | Usage.Color, new Material());
	builder.setColor(Color.LIGHT_GRAY);
	for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
		builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
		builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
	}
	builder = modelBuilder.part("axes", GL20.GL_LINES, Usage.Position | Usage.Color, new Material());
	builder.setColor(Color.RED);
	builder.line(0, 0, 0, 100, 0, 0);
	builder.setColor(Color.GREEN);
	builder.line(0, 0, 0, 0, 100, 0);
	builder.setColor(Color.BLUE);
	builder.line(0, 0, 0, 0, 0, 100);
	Model axesModel = modelBuilder.end();
	ModelInstance axesInstance = new ModelInstance(axesModel);
	return axesInstance;
}
 
开发者ID:if1live,项目名称:amatsukaze,代码行数:21,代码来源:AxisModelGenerator.java

示例12: createArrowStub

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
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();
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:16,代码来源:UsefulMeshs.java

示例13: buildCompassModel

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
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();
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:28,代码来源:ModelFactory.java

示例14: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);

	// Create material attributes. Each material can contain x-number of attributes.
	textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture);
	colorAttribute = new ColorAttribute(ColorAttribute.Diffuse, Color.ORANGE);
	blendingAttribute = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

	ModelBuilder builder = new ModelBuilder();
	model = builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
	model.manageDisposable(texture);
	modelInstance = new ModelInstance(model);
	modelInstance.transform.rotate(Vector3.X, 45);

	material = modelInstance.materials.get(0);

	builder.begin();
	MeshPartBuilder mpb = builder.part("back", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates, new Material(
		textureAttribute));
	mpb.rect(-2, -2, -2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 0, 0, 1);
	backModel = builder.end();
	background = new ModelInstance(backModel);

	modelBatch = new ModelBatch();

	camera = new PerspectiveCamera(45, 4, 4);
	camera.position.set(0, 0, 3);
	camera.direction.set(0, 0, -1);
	camera.update();

	Gdx.input.setInputProcessor(this);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:34,代码来源:MaterialTest.java

示例15: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	modelBatch = new ModelBatch();
	environment = new Environment();
	environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
	environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
	environment.add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)).set(0.8f, 0.8f, 0.8f, -1f, -.8f,
		-.2f));
	environment.shadowMap = shadowLight;

	cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	cam.position.set(0f, 7f, 10f);
	cam.lookAt(0, 0, 0);
	cam.near = 1f;
	cam.far = 50f;
	cam.update();

	ModelBuilder modelBuilder = new ModelBuilder();
	modelBuilder.begin();
	MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.Color,
		new Material(ColorAttribute.createDiffuse(Color.WHITE)));
	mpb.setColor(1f, 1f, 1f, 1f);
	mpb.box(0, -1.5f, 0, 10, 1, 10);
	mpb.setColor(1f, 0f, 1f, 1f);
	mpb.sphere(2f, 2f, 2f, 10, 10);
	model = modelBuilder.end();
	instance = new ModelInstance(model);

	shadowBatch = new ModelBatch(new DepthShaderProvider());

	Gdx.input.setInputProcessor(camController = new CameraInputController(cam));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:33,代码来源:ShadowMappingTest.java


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