Multiple Textures per Object

Started by Albareth, January 02, 2004, 05:49:47 PM

Previous topic - Next topic

Albareth

I have an object carrierh.3ds, and it requires multiple textures (TipMap.jpg, DreadHull.jpg & DreadHullSpec.jpg) on some of it's parts (the runways, the control centers, the bulkheads, the hull and the engines).  How is this done?

EgonOlsen

The 3ds-loader can do this for you. Taken from the Javadocs:

QuoteThe loader will read the textures' names out of the 3DS-file and will add dummy textures with these names to the texture-manager (If the name is already in use, no new dummy texture will be added). So one may load some textures and add them to the manager with the appropiate names before loading the 3DS-file or replace the ones generated by the loader after loading is finished. If the materials used in the file are not using textures, no textures will be generated.

What this means is: If the texture in the 3ds-file is named "Plonk.jpg", the loader will create a texture with this name or use an existing texture with this name. Have a look at the fps-example, which uses this method.
Another solution would be to split the object into seperate ones based on the used textures but i don't think that's a good one.

BTW: This documented behaviour will change slightly in the next version in a way that the loader will create textures for material without texture too to simulate material colors.

Albareth


Albareth

As well, this code (taken from JPCTDemo) doesn't seem to work with my project...  No object is being found.
Object3D[] bttlParts=Loader.load3DS("d:/13th/SESD/com/resources/carrierh.3ds", 1);
     Object3D battlecruiser=new Object3D(0);

     for (int i=0; i<bttlParts.length; i++) {
       Object3D part = bttlParts[i];

       part.setCenter(SimpleVector.ORIGIN);
       part.rotateX( (float) - Math.PI / 2);
       part.rotateMesh();
       part.setRotationMatrix(new Matrix());

       battlecruiser = Object3D.mergeObjects(battlecruiser, part);
     }

EgonOlsen

Quote from: "Albareth"Does jPCT utilise UV maps?
It reads the UV-coordinates from the file and maps the textures accordingly..if that's what you mean!?

EgonOlsen

Quote from: "Albareth"As well, this code (taken from JPCTDemo) doesn't seem to work with my project...  No object is being found.
Is bttlParts.length==0 or can't the file be found at all? Any output to the console available?

Albareth

I guess I wasn't really clear enough with my statement...  My object is being loaded, but it is not showing up in window...  The model exists, its not a blank file, it's just that the model isn't being loaded from the *.3ds

EgonOlsen

Quote from: "Albareth"I guess I wasn't really clear enough with my statement...  My object is being loaded, but it is not showing up in window...  The model exists, its not a blank file, it's just that the model isn't being loaded from the *.3ds
Make sure that you've added "battlecruiser" to your world and check for it's position in objectspace (the model's center in objectspace is not always (0,0,0)...it depends on the model). Maybe the camera is placed inside the model or even before it.

BTW: The rotations before the merge may not be necessary in your case.

Albareth

Now that my previous problem has been fixed, I am struck with a few more... 1) The textures are not appearing on my model, and 2) I have set the model creation to a key, but during the loading process of the model, the program window dies...  this may be a bug...

EgonOlsen

As mentioned, the naming of the textures in the 3DS-material and in the TextureManager has to match. Have a look at the console output: If a texture with the appropiate name can't be found by the TextureManager when loading the model, a new (plain white) texture with this name will be created. Check the output for a message like "Texture named blahblah.jpg has been created!" (or similar). If this happens, your texture is not present or at least not named correctly. You may add a texture with this name before loading the model or replace the white dummy texture afterwards (i prefer the first solution).
About your loading problem: Don't know...maybe your listener reports the key as pressed all the time and you are starting a gazillion of loading threads this way? Just a guess...
What do you mean exactly by "the program window dies"? Does it close or does it just hang?
And make sure that the loading doesn't interfere with the rendering. jPCT is not thread-save. I suggest to let the keylistener set a flag only and to do the actual loading in the thread that runs the main loop. You'll have to do this anyway when using OpenGL, because you can't access the OpenGL context via different threads.

Albareth

Can I send you the code?  I can't find anything wrong with my code, maybe, you, as the creator of jPCT, might be able to find something...

EgonOlsen

Quote from: "Albareth"Can I send you the code?  I can't find anything wrong with my code, maybe, you, as the creator of jPCT, might be able to find something...
Sure, feel free to send it to me.