Author Topic: two small questions about textures  (Read 7433 times)

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
two small questions about textures
« on: July 11, 2007, 07:42:15 pm »
Hello,

When using multi texturing, supposing that i have one base texture and an upper texture with transparent parts (a square that i could use for showing the borders of a tile), is it possible to replace only the visible parts of the upper texture? I didn t find any mode for this.

Also, looks dummy to me but is it possible to access texture names or IDs from an Object3D?

Thanks,

Manu

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: two small questions about textures
« Reply #1 on: July 11, 2007, 09:01:37 pm »
You may color the transparent parts in black and use MODE_ADD. So base texture+0 remains base texture while all others parts become base texture+second stage.
The textureIDs of single polygons can be obtained via the PolygonManager that each Object3D provides. However, it's currently not possible to get multi texturing information that way. You'll get the first stage only.

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Re: two small questions about textures
« Reply #2 on: July 11, 2007, 09:40:03 pm »
hello Egon, thanks for the quick answer...
I m a little bit surprised by the first answer given the fact that s what i have done first.

Here is my code
Code: [Select]
  public Object3D[][] generateSplittedGroundMap(){
Object3D [][] splittedMap = new Object3D[zSize][xSize];
for (int i =0; i<zSize; i++){
    for (int j = 0; j<xSize; j++){
MapElement me = mapData[i][j];
if (me.getGround()!=null){
    splittedMap[i][j] =elementFactory.getObject(me.getGround());
    TextureInfo ti = new TextureInfo(texMan.getTextureID("ground"));
    ti.add(texMan.getTextureID("blueGrid"),TextureInfo.MODE_ADD);
    splittedMap[i][j].setTexture(ti);
}
    }
}
return splitedMap;
    }

and here are ground texture

http://www.iro.umontreal.ca/~blanchae/images/screenshots/woodpanel5.gif

blueGrid texture,

http://www.iro.umontreal.ca/~blanchae/images/screenshots/blue_cell.GIF

and the final result

http://www.iro.umontreal.ca/~blanchae/images/screenshots/final.JPG

As you can see, the blue border appears to be violet.
Am I missing something? (i am using  AWTGLRenderer)


« Last Edit: July 11, 2007, 09:43:55 pm by manumoi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: two small questions about textures
« Reply #3 on: July 11, 2007, 09:53:37 pm »
As you can see, the blue border appears to be violet.
Am I missing something? (i am using  AWTGLRenderer)
No, you aren't. As said, the colors will be added...and blue + the brown of the wood gives something like violet.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: two small questions about textures
« Reply #4 on: July 11, 2007, 10:06:29 pm »
maybe you should draw black lines arround the base texture to be sure the added texture will be as exactly as you defined, the color are added not replaced.

BTW: It should be good the have something like that. to mount one texture over another without ading the colors but replacing the colored parts.
Nada por ahora

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Re: two small questions about textures
« Reply #5 on: July 11, 2007, 10:34:50 pm »
Sorry Egon, i didn t read correctly your answer but I wanted to replace, not to add. As Melssj said (and also because it would simplify my life ;)), i think it would be a nice option.

By the way, good trick melssj... But i think it will not work for my own case. I am making a tile-based map editor for an application... So for each tile, I will save the texture name... When loading in the app, the grid should not appear so if i modify the texture itself, i will have some kind of black grid... Maybe i can use pairs of textures (one with extruded borders for the editor and the full one for rendering into my application) but i don t think it s a beautiful solution... Anyway, thanks all for these answers.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: two small questions about textures
« Reply #6 on: July 11, 2007, 10:44:55 pm »
Sorry Egon, i didn t read correctly your answer but I wanted to replace, not to add. As Melssj said (and also because it would simplify my life ;)), i think it would be a nice option.
It would, but unfortunately, there is no such texture blending mode. Doing a custom multipass render with some alpha test may work, but that's a bit to heavy to add just for this single purpose.

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Re: two small questions about textures
« Reply #7 on: July 11, 2007, 10:55:16 pm »
hehe ok no problem... so i will make my grid in white ;)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: two small questions about textures
« Reply #8 on: July 11, 2007, 11:05:23 pm »
hehe ok no problem... so i will make my grid in white ;)
White...that's an idea! You may use three stages for this. One for the base texture, the second one for the white grid using MODE_ADD and the third one for a copy of the grid with the desired color instead of white and with all black sections (in the white grid) colored white. Use MODE_MODULATE for this and you'll get a grid in the desired color.
« Last Edit: July 11, 2007, 11:08:45 pm by EgonOlsen »

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Re: two small questions about textures
« Reply #9 on: July 11, 2007, 11:38:04 pm »
great egon, works perfectly. Thanks a lot