本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.utils.ModelBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ModelBuilder类的具体用法?Java ModelBuilder怎么用?Java ModelBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelBuilder类属于com.badlogic.gdx.graphics.g3d.utils包,在下文中一共展示了ModelBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入依赖的package包/类
@Override
public void create() {
super.create();
geometryPass = new ShaderProgram(
Gdx.files.internal("shaders/g_buffer.vert"),
Gdx.files.internal("shaders/g_buffer.frag"));
lightingPass = new ShaderProgram(
Gdx.files.internal("shaders/deferred_shader.vert"),
Gdx.files.internal("shaders/deferred_shader.frag"));
ModelBuilder mb = new ModelBuilder();
Model cube = mb.createBox(1, 1, 1, new Material(),
VertexAttributes.Usage.Position |
VertexAttributes.Usage.Normal |
VertexAttributes.Usage.TextureCoordinates);
cubeMesh = cube.meshes.first();
}
示例2: 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;
}
示例3: SimulationRunner
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入依赖的package包/类
public SimulationRunner() {
logger.info("Loading models");
ModelBuilder builder = new ModelBuilder();
models.put("box", builder.createBox(5f, 5f, 5f,
new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));
G3dModelLoader loader = new G3dModelLoader(new JsonReader());
models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));
Bullet.init();
logger.info("Initialized Bullet");
}
示例4: 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;
}
示例5: 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();
}
示例6: ScaleTool
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入依赖的package包/类
public ScaleTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker,
ShapeRenderer shapeRenderer, ModelBatch batch, CommandHistory history) {
super(projectManager, goPicker, handlePicker, batch, history);
this.shapeRenderer = shapeRenderer;
ModelBuilder modelBuilder = new ModelBuilder();
Model xPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_X)),
Vector3.Zero, new Vector3(15, 0, 0));
Model yPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Y)),
Vector3.Zero, new Vector3(0, 15, 0));
Model zPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Z)),
Vector3.Zero, new Vector3(0, 0, 15));
Model xyzPlaneHandleModel = modelBuilder.createBox(3, 3, 3,
new Material(ColorAttribute.createDiffuse(COLOR_XYZ)),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
xHandle = new ScaleHandle(X_HANDLE_ID, xPlaneHandleModel);
yHandle = new ScaleHandle(Y_HANDLE_ID, yPlaneHandleModel);
zHandle = new ScaleHandle(Z_HANDLE_ID, zPlaneHandleModel);
xyzHandle = new ScaleHandle(XYZ_HANDLE_ID, xyzPlaneHandleModel);
handles = new ScaleHandle[] { xHandle, yHandle, zHandle, xyzHandle };
}
示例7: 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());
}
示例8: 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();
}
示例9: create
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入依赖的package包/类
@Override
public void create () {
modelBatch = new ModelBatch(new BaseShaderProvider() {
@Override
protected Shader createShader (Renderable renderable) {
return new TestShader();
}
});
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
camController = new CameraInputController(cam);
Gdx.input.setInputProcessor(camController);
Material material = new Material(new TestAttribute(1f));
ModelBuilder builder = new ModelBuilder();
model = builder.createCone(5, 5, 5, 20, material, Usage.Position);
instance = new ModelInstance(model);
testAttribute = (TestAttribute)instance.materials.get(0).get(TestAttribute.ID);
}
示例10: 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, 0.4f, 0.4f, 0.4f, 1.f));
environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(30f, 10f, 30f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 45f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
| Usage.Normal);
instance = new ModelInstance(model);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
示例11: 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);
}
示例12: create
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入依赖的package包/类
@Override
public void create () {
modelBatch = new ModelBatch(new DefaultShaderProvider());
// 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));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position
| Usage.Normal);
instance = new ModelInstance(model);
// model = new G3dModelLoader(new UBJsonReader()).loadModel(Gdx.files.internal("data/g3d/knight.g3db"));
// instance = new ModelInstance(model);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
示例13: create
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入依赖的package包/类
@Override
public void create () {
ModelBuilder builder = new ModelBuilder();
sphere = builder.createSphere(2f, 2f, 2f, 16, 16, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)),
Usage.Position | Usage.Normal);
// cam = new PerspectiveCamera(45, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam = new OrthographicCamera(45, 45 * (Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight()));
cam.near = 1;
cam.far = 200;
Random rand = new Random();
for (int i = 0; i < instances.length; i++) {
pos.set(rand.nextFloat() * 100 - rand.nextFloat() * 100, rand.nextFloat() * 100 - rand.nextFloat() * 100,
rand.nextFloat() * -100 - 3);
instances[i] = new ModelInstance(sphere, pos);
}
modelBatch = new ModelBatch();
batch = new SpriteBatch();
font = new BitmapFont();
// Gdx.graphics.setVSync(true);
// Gdx.app.log("CullTest", "" + Gdx.graphics.getBufferFormat().toString());
}
示例14: TileHighlightDisplayable
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; //导入依赖的package包/类
public TileHighlightDisplayable() {
ModelBuilder modelBuilder = new ModelBuilder();
Model model
= modelBuilder.createRect(0, 0, Z_OFFSET,
1, 0, Z_OFFSET,
1, 1, Z_OFFSET,
0, 1, Z_OFFSET,
0, 0, 1,
GL20.GL_TRIANGLES,
new Material(
new ColorAttribute(
ColorAttribute.createDiffuse(color)),
new BlendingAttribute(
GL20.GL_SRC_ALPHA,
GL20.GL_ONE_MINUS_SRC_ALPHA)),
VertexAttributes.Usage.Position |
VertexAttributes.Usage.TextureCoordinates);
instance = new ModelInstance(model);
}
示例15: 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);
}