Author
Topic: Two Textures On Single-Part Model (Read 2496 times)

Is there a way for me to assign two diffuse texture maps to a single-part model, much like 3ds max can do for object ids (say, a texture map just for the head, another one for the body)? I have some critical models that need this.

Either export them as separate models or as one model that uses two textures. You then have to let the loader to the assignment by adding the textures with the proper namens before loading the mesh. You can't do it with setTexture, as you will have noticed.

That's just the loading of the textures, not of the model. At least not using jPCT's loaders. If this is a Bones object, then i can't comment on that. What i said about this topic applies to jPCT's Loader class only.

It turns out that although the head and body are merged in Max, Bones is getting them as separate objects. The problem should be done with, except for the fact that the texture coordinates are broken. The original textures are 2048x2048 in size. But at that size, after calling setTexture on both the head and the body, all I get is black (clearly because only the black part of the texture is being textured on the model). When I edit the textures to rescale them to 1024x1024, I get some of the non-black texture parts (albeit the wrong parts in the wrong places). The following textures are producing the following model:

Just like raft mentioned in the other thread, a call to recreateTextureCoords() after assigning the new texture should actually help, given that the coordinates are correct. This is needed for the software renderer only, btw. The hardware ones don't need this call (it doesn't hurt though).

But just like I mentioned there, I tried that and nothing changed. Besides, I'm not scaling the textures at runtime. I edited the files. And I'd rather not HAVE to edit them, but when unedited I only get black.

And I'd rather not HAVE to edit them, but when unedited I only get black.

Texture coordinates are normalized. It actually doesn't matter if you are using a 4*4 or a 4096*4096 texture, the coordinates will be the same for each. That doesn't fully apply to the software renderer, because it doesn't work with normalized coordinates internally. Instead, it creates an additional data set with coordinates that match the texture size. It does that at load time (with the assumption that the texture will be 256*256 because it doesn't know any better), at build()-time (with the dimensions of the texture currently assigned) and if you call recreateTextureCoords() (also with the texture currently assigned). You might want to use a PolygonManager to print out the actual texture coordinates (the normalized ones...) to see how they look. Also make sure that clamping has been disabled (Texture.setClamping(true))Edit: (Texture.setClamping(false)).

If nothing else helps: Have you tried to render it with the hardware renderer instead? The software renderer has a limitation regarding repeating textures, which might apply to models with texture coordinates far outside of the [0..1] interval.