Texture Mapping

Started by AGP, August 08, 2006, 07:33:12 PM

Previous topic - Next topic

AGP

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.

EgonOlsen

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.

EgonOlsen

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:


AGP

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.

EgonOlsen

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.

Melssj5

Well, I just arrived home and when going to check the model it was already answered the question. Anyway
Nada por ahora

AGP

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.

EgonOlsen

Can you post a screen shot? Have you called build() on the model after loading it?

AGP

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.

AGP

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?


EgonOlsen

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?

AGP

I mean levels of transparency.

EgonOlsen

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.

AGP

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!

san14

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.
San14