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


Java ModelBuilder.node方法代码示例

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


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

示例1: createPlayerModel

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

示例2: buildStatics

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

示例3: 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

示例4: 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

示例5: createBoxes

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

示例6: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	super.create();
	environment = new Environment();
	environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
	environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));
	
	modelsWindow.setVisible(false);
	
	Texture texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
	
	Material material = new Material(TextureAttribute.createDiffuse(texture));
	
	ModelBuilder mb = new ModelBuilder();
	mb.begin();
	mb.manage(texture);
	
	mb.node().id = "box";
	MeshPartBuilder mpb = mb.part("box", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
	mpb.setColor(Color.RED);
	mpb.box(1f, 1f, 1f);
	
	mb.node().id = "sphere";
	mpb = mb.part("sphere", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
	mpb.sphere(2f, 2f, 2f, 10, 5);
	
	mb.node().id = "cone";
	mpb = mb.part("cone", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
	mpb.setVertexTransform(new Matrix4().rotate(Vector3.X, -45f));
	mpb.cone(2f, 3f, 1f, 8);
	
	mb.node().id = "cylinder";
	mpb = mb.part("cylinder", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates | Usage.ColorPacked, material);
	mpb.cylinder(2f, 4f, 3f, 15);
	
	model = mb.end();
	
	instances.add(new ModelInstance(model, new Matrix4().trn(-5f, 0f, -5f), "box", true));
	instances.add(new ModelInstance(model, new Matrix4().trn(5f, 0f, -5f), "sphere", true));
	instances.add(new ModelInstance(model, new Matrix4().trn(-5f, 0f, 5f), "cone", true));
	instances.add(new ModelInstance(model, new Matrix4().trn(5f, 0f, 5f), "cylinder", true));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:43,代码来源:MeshBuilderTest.java

示例7: create

import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入方法依赖的package包/类
@Override
public void create () {
	super.create();
	lights = new Environment();
	lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
	lights.add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f))
		.set(0.8f, 0.8f, 0.8f, -.4f, -.4f, -.4f));
	lights.shadowMap = shadowLight;
	inputController.rotateLeftKey = inputController.rotateRightKey = inputController.forwardKey = inputController.backwardKey = 0;
	cam.position.set(25, 25, 25);
	cam.lookAt(0, 0, 0);
	cam.update();
	modelsWindow.setVisible(false);
	assets.load("data/g3d/skydome.g3db", Model.class);
	assets.load("data/g3d/concrete.png", Texture.class);
	assets.load("data/tree.png", Texture.class);
	loading = true;
	trForward.translation.set(0, 0, 8f);
	trBackward.translation.set(0, 0, -8f);
	trLeft.rotation.setFromAxis(Vector3.Y, 90);
	trRight.rotation.setFromAxis(Vector3.Y, -90);

	ModelBuilder builder = new ModelBuilder();
	builder.begin();
	builder.node().id = "floor";
	MeshPartBuilder part = builder.part("floor", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates | Usage.Normal,
		new Material("concrete"));
	((MeshBuilder)part).ensureRectangles(1600);
	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);
		}
	}
	builder.node().id = "tree";
	part = builder.part("tree", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates | Usage.Normal,
		new Material("tree"));
	part.rect( 0f, 0f, -10f, 10f, 0f, -10f, 10f, 10f, -10f,  0f, 10f, -10f, 0, 0, 1f);
	part.setUVRange(1, 0, 0, 1);
	part.rect(10f, 0f, -10f,  0f, 0f, -10f,  0f, 10f, -10f, 10f, 10f, -10f, 0, 0, -1f);
	floorModel = builder.end();

	shadowBatch = new ModelBatch(new DepthShaderProvider());
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:44,代码来源:Animation3DTest.java


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