2011-10-04 5 views
3

Java3d : 텍스처가 OBJ 모델에 제대로 적용되지 않습니다.

다음 코드는 다음 코드를 사용하여 장면에서 모델을 가져옵니다. 코드는 이미지를 텍스처로 설정 한 다음 해당 텍스처를 Appearance 객체에 적용합니다.

TextureLoader textureLoader=new TextureLoader("Another local path\myImage.jpg",null); 
ImageComponent2D image=textureLoader.getImage(); 
Texture2D texture=new Texture2D(Texture.BASE_LEVEL,Texture.RGBA,image.getWidth(),image.getHeight()); 
texture.setImage(0, image); 

Appearance app = new Appearance(); 
app.setTexture(texture); 

torus.setAppearance(app); 

코드를 실행하면 토러스 모델이 올바르게로드되지만 텍스처가 올바르게 지정되지 않습니다. 보다 정확하게 말하자면, 전체 3D 모델은 텍스처 대신 이미지 대신 단일 색상을 사용합니다. 언급 된 색상은 이미지의 왼쪽 하단에있는 픽셀의 색상입니다.

솔루션은 무엇입니까? 미리 감사드립니다.

+0

모양을 사용할 때 텍스처 좌표를 설정해야합니까? 그렇다면 문제가 될 수 있습니다. –

+0

그것에 대해 생각했지만 질문은 "어떻게?"입니다. QuadArray 또는 TriangleArray 일 때 텍스처 좌표를 설정할 수 있습니다. 하지만 가져온 복잡한 3D 모델의 텍스처 좌표를 설정하는 방법은 무엇입니까? – Pouya

답변

0

Mudbox obj 파일을 만드는 데 사용하는 프로그램을 사용하면 UV 모델 이미지를 할당 할 수도 있습니다. 페인트 레이어를 올바른 형식으로 내보내는 것보다 할당하십시오. 이 텍스처를로드 할 수 있다고 생각하면 obj에 가장 좋은 세부 사항이 없습니다. 대신이 텍스쳐 로더 코드를 사용해보십시오.

static TextureLoader loader = new TextureLoader("C:\\Users\\Sawyera\\Desktop\\Paint Layer 1.jpg", 
    "RGP", new Container()); 
static Texture texture = loader.getTexture(); 

    texture.setBoundaryModeS(Texture.WRAP); 
texture.setBoundaryModeT(Texture.WRAP); 
texture.setBoundaryColor(new Color4f(0.0f, 1.0f, 0.0f, 0.0f)); 
TextureAttributes texAttr = new TextureAttributes(); 
texAttr.setTextureMode(TextureAttributes.MODULATE); 
Appearance ap = new Appearance(); 
ap.setTexture(texture); 
ap.setTextureAttributes(texAttr); 

다음 예 광산은 독창적 인 모델 이름, 그리고 AP에 겉 모양을 설정하거나 origanly을 가지고 있었다

model.setAppearance(ap); 

이 그것을 거의 100 %로드, 당신의 3D 모델 이름을. 해부 텍스처를로드하는 것은 원하는 코리 덤에 텍스처를로드하지 않습니다.

관련 문제