Jump to content

  • Log In with Google      Sign In   
  • Create Account

p_ooya

Member Since 07 Oct 2011
Offline Last Active Jan 19 2012 08:47 AM

Topics I've Started

JOGL: Strange behaviour with color material for an obj model

15 January 2012 - 01:59 PM

For a project with a 3d model I was given an Autocad file. I imported the file in 3ds max and exported it as .obj file. So far so good. But when I load this file into my Jogl application, I have a strange problem with color material. Te be more precise, look at the images below. The first one is an screenshot from my application and the second one, is a screenshot of the exactly the same file loaded into a 3d manipulation software.

How it looks like:

Posted Image

How it should look like (exactly the same file loaded in milkshape3d)

Posted Image

Moreover, when I add the classical teapot to the scene, it is shown very good without any problem (I mean the light and material are ok). Here is part of my code:

gl.glNewList(1, gl.GL_COMPILE);
		for (int i = 0; i < len; i=i+3) {

			gl.glBegin(GL.GL_TRIANGLES);

			gl.glTexCoord2f(body.body_textCoords[i][0], body.body_textCoords[i][1]);
			gl.glNormal3f(body.body_normal[i][0], body.body_normal[i][1], body.body_normal[i][2]);
			gl.glVertex3f(body.body_vertex[i][0], body.body_vertex[i][1], body.body_vertex[i][2]);

			gl.glTexCoord2f(body.body_textCoords[i+1][0], body.body_textCoords[i+1][1]);
			gl.glNormal3f(body.body_normal[i+1][0], body.body_normal[i+1][1], body.body_normal[i+1][2]);
			gl.glVertex3f(body.body_vertex[i+1][0], body.body_vertex[i+1][1], body.body_vertex[i+1][2]);

			gl.glTexCoord2f(body.body_textCoords[i+2][0], body.body_textCoords[i+2][1]);
			gl.glNormal3f(body.body_normal[i+2][0], body.body_normal[i+2][1], body.body_normal[i+2][2]);
			gl.glVertex3f(body.body_vertex[i+2][0], body.body_vertex[i+2][1], body.body_vertex[i+2][2]);
			gl.glEnd();
		}
gl.glEndList();

Any ideas?

[java] Java3D: Texture is not applied to OBJ model properly

08 October 2011 - 12:21 AM

Hello everyone. Hope this is the right place for this question.
I'm relatively new to java3d and I'm having a problem. I want to assign a texture (an image) to an obj 3d model. The problem is, when I run the code the model is loaded correctly but the texture is not assigned correctly. More accurately, the whole 3d model has a single color instead of an image as texture. Mentioned color, is the color of the pixel at bottom-left of the image. Here is the code:

Shape3D torus=null;
Scene t1 = getSceneFromFile("Some local path\torus.obj");

\*Grabbing the model from the scene*\

BranchGroup branchGroup = t1.getSceneGroup();
torus = (Shape3D) branchGroup.getChild(0);

\*loading the image, generating the texture and making the 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);
How to solve this issue?

PARTNERS