Problem with 3ds load

Started by bobson, November 09, 2012, 08:43:51 AM

Previous topic - Next topic

bobson

Hi every-body, I am new in 3d, read tutorials and have a problem with load 3ds file, can ane-one help me?

I create a scene in 3ds max 2012, here is the source with 3ds and textures http://www.rcpp.ru/temp/Crane.zip

I ask some-body to try load this scene and write here is it possible to load all scene with jPCT?

EgonOlsen

Yes, that should be possible. What's the problem with it if you try to load it? "Have a problem" is a bit vague. Regarding 3ds format, there are some transformations that the file might contain that are not supported by the loader, but in most cases, it should work fine.

bobson

Where I can see a list with not supported transformations? I load my scene and nothing to see on my screen, I don't know why, I use example from http://www.jpct.net/wiki/index.php/Advanced_example but my scene didn't work with it, can you test or help me?

EgonOlsen

I'll do a quick test, stand by...

EgonOlsen

That thing has an insane scale, which is why it's way off from the origin after loading and it's HUGE, so that you would have to move out thousands of units to see something. But you can set a prescale factor when loading it, so i did that and voila...



import java.awt.*;

import org.lwjgl.opengl.*;

import com.threed.jpct.*;
import com.threed.jpct.util.*;

public class CraneTest {

public static void main(String[] args) throws Exception {
CraneTest mt = new CraneTest();
mt.doIt();
}

private void doIt() throws Exception {
FrameBuffer fb = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
fb.enableRenderer(IRenderer.RENDERER_OPENGL);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);

World w = new World();
w.setAmbientLight(50, 50, 50);
Light light=new Light(w);
light.setAttenuation(-1);
light.setIntensity(255, 0, 0);

Object3D[] crane = Loader.load3DS("3ds/Crane/Crane.3DS", 0.01f);

for (Object3D obj : crane) {
obj.build();
obj.compile();
w.addObject(obj);
}

w.getCamera().setPosition(crane[0].getTransformedCenter());
w.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 500);
w.getCamera().lookAt(crane[0].getTransformedCenter());

long s = System.currentTimeMillis();
int fps = 0;

while (!Display.isCloseRequested()) {
fb.clear(Color.BLUE);
w.renderScene(fb);
fps++;
w.draw(fb);
fb.displayGLOnly();
if (System.currentTimeMillis() - s > 1000) {
System.out.println("FPS: " + fps);
fps = 0;
s = System.currentTimeMillis();
}
}

fb.disableRenderer(IRenderer.RENDERER_OPENGL);
System.exit(0);
}
}


bobson

#5
Thanks, it is really work. One more question, I add this code before FrameBuffer create, but no texture is loaded:


TextureManager tm = TextureManager.getInstance();
tm.addTexture("brown.jpg", new Texture("example/brown.jpg"));
tm.addTexture("green.jpg", new Texture("example/green.jpg"));
tm.addTexture("steel.jpg", new Texture("example/steel.jpg"));
tm.addTexture("metal.jpg", new Texture("example/metal.jpg"));


May be I use texture with 256x256 px in jpg format, is it correct? And if I can found my error I want to add this example (with Crane.3ds) in wiki, do you give me agree to do it?

EgonOlsen

jpgs are fine. You have to make sure that the name with which you add the texture is EXACTLY the same that is used in the file. You'll see that in the log output. If it doesn't find a texture of that name, a new one will be created and added and you should see these messages in the log.

bobson

#7
I think some-thing with my max, because I try to import just exported scene and got no textures, tomorrow will post here decision of my problem. Yes, problem with export in 3ds max 2013, the scene lost all textures.

One more question, what is the easiest  way to work with some object in Object3D's array? If only one way to do it via for cycle and check currentIterationObject.getName()?