Author Topic: Texture Mapping  (Read 13407 times)

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Texture Mapping
« Reply #15 on: August 10, 2006, 07:19:52 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #16 on: August 10, 2006, 07:32:30 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #17 on: August 10, 2006, 08:22:51 pm »
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:

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


Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Texture Mapping
« Reply #18 on: August 10, 2006, 09:28:49 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #19 on: August 10, 2006, 09:37:16 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Texture Mapping
« Reply #20 on: August 11, 2006, 02:08:16 am »
Well, I just arrived home and when going to check the model it was already answered the question. Anyway
Nada por ahora

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Texture Mapping
« Reply #21 on: August 11, 2006, 09:22:40 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #22 on: August 11, 2006, 10:34:03 pm »
Can you post a screen shot? Have you called build() on the model after loading it?

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Texture Mapping
« Reply #23 on: August 11, 2006, 11:20:20 pm »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Texture Mapping
« Reply #24 on: August 12, 2006, 03:06:03 am »
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?


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #25 on: August 12, 2006, 07:38:58 pm »
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?

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Texture Mapping
« Reply #26 on: August 12, 2006, 08:34:41 pm »
I mean levels of transparency.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Texture Mapping
« Reply #27 on: August 12, 2006, 09:34:26 pm »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Texture Mapping
« Reply #28 on: August 15, 2006, 12:35:57 am »
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!

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Texture Mapping
« Reply #29 on: February 08, 2007, 12:16:20 pm »
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