TextureAtlas - a working example?

Normally, I’d use vertex colors to color my faces and not a texture… as a texture is a bit overkill in this case.



I don’t really know if the batch node properly detects and rebatches in the case of color buffer changes or if there is some way to trigger it. Are you using Lighting.j3md or Unshaded.j3md?

Lighting.j3md but I can change it

I think lighting.j3md doesn’t support vertex colors. Unshaded doesn’t support lighting, though.



Now we are to the point where I’d just tweak a shader but that’s probably not a good idea in this case.



You should similarly be able to change the texture coordinates of your sub-geometries. I’d hope the batch node would rebatch properly. You don’t really need any of the atlas classes for that you just need to properly set your own texture coordinates. If it were me, I’d just create the atlas texture in a paint program and then give my geometry the right texture coordinates. Maybe that’s not so easy if you are loading models but it is doable using the same approach the texture atlas stuff does.



All of that code is available online if you wanted to look at it.

1 Like
I’d just create the atlas texture in a paint program


done :) just created a 1024 x 1024 files containing all the possible colors I'd use.

and then give my geometry the right texture coordinates


how do i do that? example please :S I think that's what I am struggling with now.

All of that code is available online if you wanted to look at it.


can you please point it out?

thanks:)

http://code.google.com/p/jmonkeyengine/source/browse/

1 Like

there is no code about that… there’s only a code about batching atlas in the TestTextureAtlas.java



can anyone post a working code example (like 3 or 4 lines) of using an already created atlas.png to map textures through it??

[java] FloatBuffer buf = (FloatBuffer)geom.getMesh().getBuffer(Type.TexCoord).getData();

buf.put(new float[]{0,0,0,0.5f,0.5f,0.5f,0.5f,0}, 0, 0);

[/java]

1 Like
@normen said:
[java] FloatBuffer buf = (FloatBuffer)geom.getMesh().getBuffer(Type.TexCoord).getData();
buf.put(new float[]{0,0,0,0.5f,0.5f,0.5f,0.5f,0}, 0, 0);
[/java]

For some reason I don't think that'll help him.
@madjack said:
For some reason I don't think that'll help him.

Exactly. But it is what he wants to do. I told him its necessary to actually know what you're doing but he won't listen ^^
1 Like

Well, @homsi, there you have it. You’ve got all your answers. I’d suggest you now do your homework and get it working on your own. This is relatively simple stuff.



Don’t forget to Thumb up, because we deserve it. :wink:

First i’m a “she” ! :slight_smile:



and thanks guys, i’m not sleeping tonight till I get it working.



plan of action:



1- create an atlas.png file

2- create material

3- map to the desired color

4- give the guys thumbs up for suffering with me

5- If my account got deactivated that means I killed myself from feeling stupid and not being able to get it working :slight_smile:

@homsi said:
First i'm a "she" ! :)


Good to know, but that won't make us be easier on you. It will not work in your favor. :P ;)
@homsi said:
and thanks guys, i'm not sleeping tonight till I get it working.

Bah! How many times have I said that... I lost count. :|


plan of action:

4- give the guys thumbs up for suffering with me
1- create an atlas.png file
2- create material
3- map to the desired color
5- If my account got deactivated that means I killed myself from feeling stupid and not being able to get it working :)


There. Your priorities were wrong, I fixed it.

Just one more quick question and I won’t bug you guys for LIFE, the code does not point to any atlas.png (or atlas file) :((((

:brainsout:

http://www.youtube.com/watch?v=Qj7WyfceJ58

1 Like

If that doesn’t help you, I’m with @normen


@pspeed said:
You should similarly be able to change the texture coordinates of your sub-geometries.


@normen said:
[java] FloatBuffer buf = (FloatBuffer)geom.getMesh().getBuffer(Type.TexCoord).getData();
buf.put(new float[]{0,0,0,0.5f,0.5f,0.5f,0.5f,0}, 0, 0);
[/java]