My x-wing is being loaded from a 3ds file. Upon loading it, the texture files are listed on the command prompt. Is it supposed to load texture-mapped, or am I supposed to do something else.
The 2-part wings, on Egon's suggestion, were loaded separately, and I've even tried getting the instance to Texture Manager and adding the wings' top texture. The following code is what I tried. Am I doing something wrong? Or am I supposed to call something during the rendering process?
TextureManager manager = TextureManager.getInstance();
Texture wingTop = new Texture("./WolfXWing/WINGTOP.JPG");
manager.addTexture("WINGTOP", wingTop);
The texture's name (i.e. the name you give it in the TextureManager) has to match the name that is used in the 3DS-file. That's the name that's being printed out during load. It's best practice to determine the names once and load them before loading the model to save some overhead.
Do you mean that instead of naming it "WINGTOP" I would have to name it "WINGTOP.JPG?" It worked, now, which I'm taking to mean that the textures have to be added before loading the mesh. Or is there another way? Thanks a lot for all your help so far.
If you don't load them before the loading of the model happens, you have to replace them afterwards (TextureManager.replace(...)). But that involves the creation of a dummy texture as a place holder during load, which isn't needed when loading them before.
Some parts of the model aren't coming out textured. I went so far as to load the file as an instance of awt/Image, drawing the image to the screen (which worked), and insantiating Texture from the Image instance. But the texture still won't load.
Well, the textures should be correctly apllied if you have all of them, the no textured parts appears white?
Be sure that they are JPG images.
Checkiew the console messages and check if they are being applied well. cometimes when filenames of textures are very long, some programs like 3d studio max rename the texture on the 3ds file.
No, it's not the file names. And the texture coordinates are all right. And I'm not getting any out-of-the-ordinary messages (just the usual "resizing to 256 pixels ones, but that's for all of the textures and most of them work).
And the untextured parts render as flat and grey.
Are u using sw rendering or opengl, can you please give us the 3d model and the textures on a zip file to test.
Software renderer.
And who's "us?"
Egon, me and anyone that wants to help!
Done. Any insights would be appreciated.
The texture names used in the file are displayed while loading the model, if the texture can't be found by the manager. Like in this line:
"Texture named XWBACK.JPG added to TextureManager!"
What this means is, that the loader is looking for a texture named "XWBACK.JPG" in the TextureManager. If it doesn't find one, it creates one. So, before loading the model, you should add this texture like so:
TextureManager.getInstance().addTexture("XWBACK.JPG", <your texture>);
Do this for all of the textures that are printed out that way during load. If the texture is named "BLAHBLAH.TGA", use that name even if your actual texture is a jpg or has a completely different name. With the naming of the textures when adding them, you provide a mapping between the names in the 3ds file and the file names of your textures. The names are case sensitive, so if it prints out "XWBACK.JPG", name it "XWBACK.JPG" when adding....not "xwback.jpg" or so.
I hope this makes it a bit clearer.
No, I got it the first time around. Did you manage to texture map all of it?
I did the whole thing step by step, including reassigning the JPEGs on MAX, so I'll find it very strange if you managed to do it by that line alone.
Hello,
Is it possible that your textures are just applied on the wrong side of your model (displayed "inside" the xWing instead of outside). I had such a problem one time but it was just because i created my own model using the JPCT primitives... Not sure if it can be reproduced with 3ds file... that s just a guess...
Manu
It is possible that the Loader class would flip some faces upon importing them, but there are no flipped faces on the file itself. I even tried flipping them wrong in an attempt to get them right, but it didn't work. I don't think this is the problem, but thanks for the suggestion.
I haven't got the time to try to texture it correctly. I just did a quick load without any display...i'll try that later.
I gave it a try. It looks fine me. Granted, there are some parts that aren't textured (like the front of the lasers), but those don't seem to have a texture assigned at all (judging from what my viewer/converter software (DeepExploration) tells me). Here's the code:
import com.threed.jpct.*;
import org.lwjgl.opengl.*;
import org.lwjgl.input.*;
public class XWingTest {
public static void main(String[] args) throws Exception {
Config.maxPolysVisible=60000;
World w=new World();
TextureManager tm=TextureManager.getInstance();
tm.addTexture("ENGINE2.TGA", new Texture("WolfXWing/ENGINE2.JPG"));
tm.addTexture("WINGFRON.JPG", new Texture("WolfXWing/WINGFRON.jpg"));
tm.addTexture("WINGBACK.TGA", new Texture("WolfXWing/WINGBACK.jpg"));
tm.addTexture("WINGDOWN.JPG", new Texture("WolfXWing/WINGDOWN.jpg"));
tm.addTexture("WINGTOP.JPG", new Texture("WolfXWing/WINGTOP.jpg"));
tm.addTexture("LASER.TGA", new Texture("WolfXWing/LASER.jpg"));
tm.addTexture("ENGINE.TGA", new Texture("WolfXWing/ENGINE.JPG"));
tm.addTexture("XSIDE.JPG", new Texture("WolfXWing/XSIDE.jpg"));
tm.addTexture("XWBACK.JPG", new Texture("WolfXWing/XWBACK.jpg"));
tm.addTexture("XWTOP.JPG", new Texture("WolfXWing/XWTOP.JPG"));
tm.addTexture("XWDOWN.JPG", new Texture("WolfXWing/XWDOWN.jpg"));
tm.addTexture("PLATEOX2.TGA", new Texture("WolfXWing/PLATEOX2.JPG"));
tm.addTexture("FRC.JPG", new Texture("WolfXWing/FRC.JPG"));
Object3D xwing=Object3D.createDummyObj();
Object3D windows=Object3D.createDummyObj();
Object3D[] objs=Loader.load3DS("WolfXWing/XWing.3DS",1f);
for (int i=0; i<objs.length; i++) {
if (objs[i].getName().startsWith("windows")) {
windows=Object3D.mergeObjects(windows, objs[i]);
} else {
xwing=Object3D.mergeObjects(xwing, objs[i]);
}
}
w.addObject(windows);
w.addObject(xwing);
xwing.addChild(windows);
windows.setTransparency(0);
FrameBuffer fb=new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
fb.enableRenderer(IRenderer.RENDERER_OPENGL);
w.buildAllObjects();
w.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 500);
w.getCamera().lookAt(xwing.getTransformedCenter());
w.setAmbientLight(255,255,255);
Mouse.create();
while (!Display.isCloseRequested()) {
fb.clear(java.awt.Color.BLUE);
w.renderScene(fb);
w.draw(fb);
fb.displayGLOnly();
xwing.rotateX(Mouse.getDY()/100f);
xwing.rotateY(Mouse.getDX()/100f);
}
Mouse.destroy();
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
}
}
And this is how it looks like:
(http://www.jpct.net/pics/xwing.jpg)
Wow. Thanks a lot.
Now, why was the cockpit a separate object? Just for the transparency setting? And why the dummy objects? Those I don't get.
Yes, for the transparency. Transparency is object, not polygon based. The dummy objects are for having something to merge with in the first run. Any empty object would do or you may also merge 1....x with objs[0] instead...it doesn't matter.
Well, I just arrived home and when going to check the model it was already answered the question. Anyway
The thing is that it's not totally answered: the software renderer (really, the part that interests me the most in this engine), still fails to map all parts of it.
Can you post a screen shot? Have you called build() on the model after loading it?
Yeah, I can post a screenshot. And yes, I called World.buildAllObjects(). Give me a couple of hours to get back home. Again, thanks for your time.
Sorry, my very newbie mistake. The screenshot follows and it looks exactly as it should. Thanks a lot for a very cool and straightforward engine. By the way, I expect partial transparency is not possible on the software renderer. Is that right?
(http://66.160.166.159/xWing.jpg)
Quote from: "AGP"By the way, I expect partial transparency is not possible on the software renderer. Is that right?
What do you mean with "partial"? Some parts are transparent and some not or that you can choose different levels of transparency up to almost opaque?
I mean levels of transparency.
Yes, you can do that in software like you would do it the hardware renderer (Object3D.setTransparency(<int>)). The formula for the transparency is different in software, so the result will most likely look different when compared to hardware, but not too much in the lower levels of transparency. If your texture is too dark (below 0f0f0f), it will be totally transparent but that's true for hardware too.
Oh, you know what it was? Another rookie mistake: since I was adding the cockpit as child to the x-wing, I wasn't adding it to the world, so the cockpit appeared completely transparent because it wasn't being rendered!
Quote from: "manumoi"Hello,
Is it possible that your textures are just applied on the wrong side of your model (displayed "inside" the xWing instead of outside). I had such a problem one time but it was just because i created my own model using the JPCT primitives... Not sure if it can be reproduced with 3ds file... that s just a guess...
Manu
Hi
I am also facing similar kind of problem, could you let me know how to i change the side...of texture. I am also not geting texture to my wall of 3ds.
What do you mean by "side of texture"? Maybe you can post a screen shot to illustrate the problem?