我是新来LibGDX 3D设备,我想知道我怎么可以合并使用创建的模型构建器#createCylinder class.I有两个ModelInstances:
I'm a new to LibGDX 3D facilities and I'm wondering how I can merge two cylinders created using the ModelBuilder#createCylinder class.I have two ModelInstances :
第一种方法是一种白色气缸, 第二个红色的圆柱体具有相同属性如何获得的只有一个气缸来呈现(例如/模型/对象/任何可以呈现)以上的白某(反之亦然)的红色组成。
How can get only one cylinder to render (instance / model / object / whatever can be rendered) composed of the red above the white one (or vice versa).
Pixmap pixmap1 = new Pixmap(1, 1, Format.RGBA8888);
pixmap1.setColor(Color.WHITE);
pixmap1.fill();
Texture white = new Texture(pixmap1);
//...
Texture red = new Texture(pixmap2);
model1 = modelBuilder.createCylinder(4f, 6f, 4f, 16,
new Material(
TextureAttribute.createDiffuse(white),
ColorAttribute.createSpecular(1,1,1,1),
FloatAttribute.createShininess(8f))
, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
model1I_white = new ModelInstance(model1, 0, 0, 0);
//...
model2I_red = new ModelInstance(model2, 0, 0, -2f);
然后,我使ModelInstance与 ModelBatch#呈现。
而不是使用createCylinder(),你可以创建2个气瓶与MeshBuilder类,并与部分()撰写最终的圆筒。
Instead of using createCylinder(), you can create 2 cylinders with the MeshBuilder class, and compose your final cylinder with part().
meshBuilder.begin();
meshBuilder.cylinder(4f, 6f, 4f, 16);
Mesh cylinder1 = meshBuilder.end();
meshBuilder.begin();
meshBuilder.cylinder(4f, 6f, 4f, 16);
Mesh cylinder2 = meshBuilder.end();
modelBuilder.begin();
modelBuilder.part("cylinder1",
cylinder1,
Usage.Position | Usage.Normal | Usage.TextureCoordinates,
new Material(
TextureAttribute.createDiffuse(white),
ColorAttribute.createSpecular(1,1,1,1),
FloatAttribute.createShininess(8f)));
modelBuilder.part("cylinder2",
cylinder2,
Usage.Position | Usage.Normal | Usage.TextureCoordinates,
new Material(
TextureAttribute.createDiffuse(red),
ColorAttribute.createSpecular(1,1,1,1),
FloatAttribute.createShininess(8f)))
.mesh.transform(new Matrix4().translate(0, 0, -2f));
Model finalCylinder = modelBuilder.end();