UV coordinates


Can anyone tell me how jme is attaching a texture to a mesh that has no UV’s defined?

What algrithm is used there to determine how to put the texture on the model in such case.

Is there any UV coordinate generator??

No, theres generally no way this can happen :slight_smile: A mesh needs texture coordinates and all base meshes come with it.

You need UV coordinates for any textured mesh. You can however generate them at runtime if you need to

I’d love to do that :slight_smile:

The question is - what algorithm should I use ?

When you apply generated texture in blender you do not need to define UV coordinates by yourself.

Blender does that for you during rendering.

I have some ideas but if anyone knows how to do it please let me know.

It’s always faster to use an existing algorithm than inventing a new one :wink:

You can always specify how the texture should be applied in blender (e.g. projection).

Generating the UVs at runtime won’t work … Well, it will work, but for low resolution meshes like boxes it might not work correctly in some cases

You may need to use shader injection which hasn’t been invented yet

Momoko_Fan said:
You may need to use shader injection which hasn't been invented yet

Really? I could have bet that I already heard about it... :D

OK I’ve made a simple implementation.

But it will require improvements.

At the moment the algorith is as follows:

  • the bounding sphere is created for each loaded mesh
  • every vertex is projected on the sphere along its normal vector
  • the sphere is unwrapped so that it creates 2D plane (just like a texture taken from the planet globe :slight_smile: )
  • UV coords are being calculated from the unwrapped plane and applied for the vertices

    As I said this is not yet perfect. I would love to see the algorithm used by blender to do that. But I cannot find it in the source code.

Blender has many TexCoord modes … You may need to implement all of them somehow

Yeah I know.

But I’ve focused on UV-mapping at the moment.

I’ll take care of the rest later :wink: