2014-02-22 2 views
2

LibGDX로 안드로이드 애플리케이션에서 중공 실린더를 생성하려고합니다. 그것을 만들 수있는 방법이없는 것처럼 보입니다. 나는 두 개의 실린더를 꺼내야했다. 하나는 더 크고 작은 하나는 중공의 실린더를 만드는 더 큰 하나의 내부를 "제거"할 수있는 것입니다. 이제 내가 원하는 것은 더 좋은 방법이 있을까요?LibGDX로 중공 실린더 생성

감사합니다.

답변

1

대답 # 1

거기에 꽤 좋은 예를 찾을 수 있습니다 [에만 나이틀리에 포함]

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/ModelLoader.html 이 작업을 수행하는 두 가지 방법이 있습니다. 첫 번째는 createCylinder() convenience method of ModelBuilder을 사용하여 단일 실린더 메쉬가있는 모델을 만듭니다.

대답 # 2

메쉬를 만든 다음 나중에 모델이 포장하는 MeshBuilder 클래스의 createCylinder() 방법을 사용.

예 (방법 2)

다음 예제 코드 this에서 적응되었다

MeshBuilder meb = new MeshBuilder(); 
    final long atr = Usage.Position | Usage.Color; //Add Usage.TextureCoordinates or similar here if you need it 

    //Create mesh #1 
    meb.begin(atr); 
    meb.cylinder(4f, 6f, 4f, 16); 
    Mesh cyl1 = meb.end(); 

    //Create mesh #2 
    meb.begin(atr); 
    meb.cylinder(4f, 6f, 4f, 16); 
    Mesh cyl2 = meb.end(); 

    //Combine the two meshes into one model using ModelBuilder 
    ModelBuilder mob = new ModelBuilder(); 
    mob.begin(); 
    mob.part("cylinder1", cyl1, Usage.Position | Usage.Normal | Usage.TextureCoordinates, new Material(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(1, 1, 1, 1), FloatAttribute.createShininess(8f))); 
    mob.part("cylinder2", cyl2, Usage.Position | Usage.Normal | Usage.TextureCoordinates, new Material(ColorAttribute.createDiffuse(Color.GREEN), ColorAttribute.createSpecular(1, 1, 1, 1), FloatAttribute.createShininess(8f))).mesh.transform(new Matrix4().translate(0, 0, -2f)); 
    Model cyl = mob.end();