Author Topic: Problem with 3ds load  (Read 2566 times)

Offline bobson

  • byte
  • *
  • Posts: 6
  • Some text must goes here
    • View Profile
Problem with 3ds load
« on: November 09, 2012, 08:43:51 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Problem with 3ds load
« Reply #1 on: November 09, 2012, 08:59:34 am »
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.

Offline bobson

  • byte
  • *
  • Posts: 6
  • Some text must goes here
    • View Profile
Re: Problem with 3ds load
« Reply #2 on: November 09, 2012, 12:46:20 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Problem with 3ds load
« Reply #3 on: November 09, 2012, 12:58:18 pm »
I'll do a quick test, stand by...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Problem with 3ds load
« Reply #4 on: November 09, 2012, 01:13:08 pm »
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...


Code: [Select]
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);
}
}


Offline bobson

  • byte
  • *
  • Posts: 6
  • Some text must goes here
    • View Profile
Re: Problem with 3ds load
« Reply #5 on: November 12, 2012, 04:11:27 am »
Thanks, it is really work. One more question, I add this code before FrameBuffer create, but no texture is loaded:

Code: [Select]
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?
« Last Edit: November 12, 2012, 05:02:01 am by bobson »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Problem with 3ds load
« Reply #6 on: November 12, 2012, 11:03:40 am »
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.

Offline bobson

  • byte
  • *
  • Posts: 6
  • Some text must goes here
    • View Profile
Re: Problem with 3ds load
« Reply #7 on: November 12, 2012, 11:47:59 am »
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()?
« Last Edit: November 13, 2012, 04:35:52 am by bobson »