two small questions about textures

Started by manumoi, July 11, 2007, 07:42:15 PM

Previous topic - Next topic

manumoi

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

EgonOlsen

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.

manumoi

#2
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

  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)



EgonOlsen

Quote from: manumoi on July 11, 2007, 09:40:03 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.

Melssj5

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

manumoi

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.

EgonOlsen

Quote from: manumoi 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.
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.

manumoi

hehe ok no problem... so i will make my grid in white ;)

EgonOlsen

#8
Quote from: manumoi on July 11, 2007, 10:55:16 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.

manumoi

great egon, works perfectly. Thanks a lot