Skip to main content

.mtl with .obj

2 replies [Last post]
Joined: 2007-06-07

I'm still very new to J3D so forgive me for asking so many questions but anyway, I gave up on the Lightwave Loader because my office cannot export models to .lws... ok fine, so now I'm trying to work with the .obj loader that Sun also created for J3D, and with minimal success.

At the very least, I'm not getting any compile or runtime errors. But I don't see anything. And everything else with my program as far as the scene graph is concerned is working correctly because when I add a simple ColorCube to the scenegraph it shows up with no problem.

One peculiarity is that when I use the cube.obj which came with J3D, part of the ColorCube is obscured by what seems to be a smaller, completely black cube. But no other .obj file that I've loaded does that, or anything else at all.

My first question is.. why is this happening? That I can't see anything at all, or only a small black obscuration.

I'm wondering if it's a lighting issue, so I've been trying to manually edit the .obj file to include a .mtl file that colors it anything other than black. But when I do that, and run the program, nothing happens. My .obj code:

mtllib mymtl.mtl

g cube
usemtl flatwhite
v 0 0 0
v 1 0 0
v 1 1 0
v 0 1 0
v 0 0 1
v 1 0 1
v 1 1 1
v 0 1 1
f 1 2 7 8
f 3 4 5 6
l 1 2
l 3 4
l 5 6
l 7 8


.mtl code:

newmtl flatwhite
Ka 0.5000 0.5000 0.5000
Kd 1.0000 1.0000 1.0000
illum 1

Thanks for any help, and if I can provide more info or clarification just let me know! I'm off to lunch...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-12-21

Try to turn lights on:

// mediun to strong ambient light
Color3f ambientLightColor = new Color3f(0.7f, 0.7f, 0.7f);

AmbientLight ambientLight = new AmbientLight(ambientLightColor);
// 1000 meters of light ;)
ambientLight.setInfluencingBounds(new BoundingSphere(new Point3d(), 1000.0d));
// add it toscene

ColorCobe doesn´t need lights. It has per vertex colors.
But other objects looks better with some light ;)

Joined: 2007-06-07

THANK YOU! I knew it was lighting, but here I was trying to add it to the actual model! Ugh... thank you, that is 100% exactly what I needed... it's been a few years since I last fooled around with scene graphs!