[Solved] Models are bad textured

'Ello! The problem is that models in a game, that I just started doing, are bad textured. Namely, after rendering it looks like this:



http://dl.dropbox.com/u/24150633/screenshot.png



Which is, of course, not what I want to get, as the texture is:



http://dl.dropbox.com/u/24150633/Crate.png



To clarify things a bit:

  • I tried to use models in the following formats: .obj, .j3o, and also .blend.
  • I tried to apply the texture using “ColorMap” (gives error, as the model material is set to “Common/MatDefs/Light/Lighting.j3md”, but I also tried “Common/MatDefs/Misc/Unshaded.j3md” with no success), “DiffuseMap”, “m_DiffuseMap” (don’t really know what’s the difference).



    And I know – by the way – what some of you are going to say - “Create a geometry instead of importing an object from a file. It’s faster.” Yes, I know it would be faster and simplier, but let’s be honest, creating models right in the code for more complex figures is a torment. So, it’s just putting problems off.



    The current code which is responsible for setting up the object and applying a material and which I stuck with :



    [java]

    Spatial block = assetManager.loadModel(“Models/Block.blend”);

    block.setLocalScale(1.0f);

    Material crateMaterial = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

    crateMaterial.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/Blocks/Crate.png”));

    crateMaterial.setFloat(“Shininess”, 5f);

    block.setMaterial(crateMaterial);

    rootNode.attachChild(block);

    [/java]



    I really don’t know what causes it not to work. I don’t think the texture is invalid (isn’t it?). Maybe something wrong with the above code or with the model itself. But I am almost sure it is something very trivial that needs a few clicks of a mouse.



    I’m not a lawyer and neither a pro game maker, but a beginner that just started playing around with jME, so all I know comes from tutorials (and a bit from documentation). Thus, please, don’t judge me…



    P.S. Sorry for my English. :slight_smile:



    Thanks in advance,

    Lucas

The texture is being set correctly but the texture coordinates are wrong. I don’t know why they are wrong but that’s what that image looks like.



So it’s something in the source Block file.



Are you using this as a test or do you really intend to create a block in blender to use in JME? …because you could just create a Box.

@pspeed said:
Are you using this as a test or do you really intend to create a block in blender to use in JME? ...because you could just create a Box.


Yes, it's somehow for testing purposes, but I will have the same problem with setting texture for, for example, a human model.

BTW, anyone knows how can I set coordinates for the model texture in Blender?

Does the block have normal maps or bump maps in blender? Maybe it just needs tangents generated… though I’d expect the badness to look differently.



And by the way, while it’s a good test maybe to load the .blend file in code. Really the JME way is to convert it to a j3o file and load that. Normally the application won’t be able to load .blend files I think except in development mode.

@pspeed said:
Does the block have normal maps or bump maps in blender?

No, it doesn't.
@Edit: At least, I don't think so. Meself no pro in Blender. ;) Just kidding... I know I don't need to be a pro to know how to create normal or bump maps but I do not know. Really.

@pspeed said:
And by the way, while it's a good test maybe to load the .blend file in code. Really the JME way is to convert it to a j3o file and load that. Normally the application won't be able to load .blend files I think except in development mode.

Well, I've already tried converting it to j3o with jME SDK and loading it in the code but I get the same result.
BTW, anyone knows how can I set coordinates for the model texture in Blender?


http://www.blender.org/development/release-logs/blender-234/uv-unwrapping/
@glaucomardano said:
http://www.blender.org/development/release-logs/blender-234/uv-unwrapping/

Oh, thanks.

Of course that tutorial is for blender 2.34, but there are a lot of nice video tutorials for blender 2.5 here : http://cgcookie.com/blender/

@lucaseasedup said:
Well, I've already tried converting it to j3o with jME SDK and loading it in the code but I get the same result.


Yeah... when you fix your model then it will work in both places. But the j3o way is the one that will also work in all deployments.

Recently, I had some problems importing and texturing Blender models.



The guys helped me a lot here: http://hub.jmonkeyengine.org/groups/import-assets/forum/topic/problem-applying-texture-in-model-imported-from-blender/



See if it helps.

OK, guys, sorry for my absence but the case is closed. I did as in the link dvsantos gave and it’s working now exactly how I wanted. Thanks.