Textures For .x Files

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
pse11
Posts: 3
Joined: Mon Apr 10, 2006 9:54 pm

Textures For .x Files

Post by pse11 »

I am using Blender and have been able to export the .blend files to .x files. I have also been able to use them with the Irrlicht engine. The problem is, they only show up as black shapes when I run my program. How can I use the textures/materials that I used in Blender?
hybrid

Post by hybrid »

Try to disable Lighting, or add a dynamic light source. And check the console messages whether the textures are loaded correctly (sometimes the path is wrong).
pse11
Posts: 3
Joined: Mon Apr 10, 2006 9:54 pm

Post by pse11 »

I disabled the lighting and now the meshes show up white. I don't know how to tell Irrlicht to use the texture/materials that are already in the .x file. Can I do that? Or do I have to create the texture like in the Hello World example, using a bmp, jpeg, etc?
Guest

Post by Guest »

to help you more you should tell at least what is the flag of material on the mesh. called by setMaterialType(), if you have an exporter from blender, make sure the .X mesh is realy valid, you can do that by loading it in DXmeshviewer, and saving it in there, that is a good validation process.

or you can send me the X files with their textures and I will gladly take a look what they are


and I have just find out I have not logged in again :x , it is me needforhint
hybrid

Post by hybrid »

Oh yes, I really forgot this funny DXMeshViewer conversion. Some strange specification ambiguities many tools don't handle correctly. Maybe would be good to fix the Meshloader to become more failsafe...
pse11
Posts: 3
Joined: Mon Apr 10, 2006 9:54 pm

Post by pse11 »

What is this DXMeshViewer and how can I get it?
23yrold3yrold
Posts: 11
Joined: Wed Apr 19, 2006 6:23 am

Post by 23yrold3yrold »

I'm having the same problem; model and texture load according to console, but I get a simple black shape when I try to open them in the "Hello, World" example. Exporting a .X file from Blender like the OP. Latest version of Blender. File looks fine when I open it in a text editor. Do I need to use the Blender export script that comes with Irrlicht?

Here's the model and texture:
http://members.gamedev.net/23yrold3yrol ... htTest.zip

I dream one day of a 3D file format as easy to use as a .bmp, I really do. It's enough to drive me back to 2D games. :twisted:
finger007

Post by finger007 »

23yrold3yrold, pse11,

in most cases it's the setup in blender that is wrong. you have to uv-map textures and not just texture it "blender-style" :)
if you have not done that before:
http://mediawiki.blender.org/index.php/ ... UV_Mapping
not really complecated. you will get it fast! only drawback no-one tells you on blender: create a new material for each new texture you use! otherwise the exporter seems to get kinda confused ;) you will be able to map everything without creating a new material, but then you end up like before...
at least that is how it worked for me.

as to your question regarding exporter:
with the current version of blender, use this one by ben omari:
http://xoomer.virgilio.it/glabro1/
finally, make sure the .x-file and the textures end up in the same directory. then it should load fine in irrlicht.
it works for me.

hope this helped,
finger007
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

Using that script my .x comes out blue. It should be green. Also some triangles are either missing or back facing. :-(
23yrold3yrold
Posts: 11
Joined: Wed Apr 19, 2006 6:23 am

Post by 23yrold3yrold »

That script seems to work for me; at least it's the right shape now, near as I can tell since it's still a black mass. :) The image is UV mapped fine in Blender, unless I'm missing something (and I guess I must be) ... I have a material for the texture and everything. Hmm.

EDIT: Aha! The console is reporting a syntax error in the .x file in regards to the texture name. Not sure why it should matter, since I'm explicitly setting it in the code (slightly modified version of the Hello, World example) but that must be it. Now, how to fix it ...

Error is "Unknown syntax while reading texture filename string in x file". The zip file I posted above has been updated to contain the .x file exported with the posted Python script.

EDIT2: Commented out the texture file in the .x file; I seem to have a nasty problem with backfaces and distortion but the shape and texture is there. Huzzah! :D

EDIT3: And now it crashes horribly if that texture bit is commented out. :cry: I'll poke at this later; I need a break ... what would the ideal Irrlicht settings for that DirectXExporter241 be? Maybe that's my problem ...
finger007

Post by finger007 »

hi again!

23yrold3yrold,
i just spent a minute with your files. look at the two screenies here:
http://rapidshare.de/files/18473436/irr ... n.zip.html

what i did was the following: i opened the .x in mview (screenie 1) and resaved it. after that i loaded it into irrlicht. it seems distorted when you get near to it but from further away everything is fine...as you said: backfaces.

as for the settings for export...hmm, terribly hard to tell from an .x for me... but it doesnt have that much to set after all. if you cannot figure it out, send your .blend and i'll have a look at the weekend.

cheers,
finger007
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

i think that syntax error with the texture is probably due to having spaces in the texture file name? I had an error like that before and it was due to spaces.
Image Image Image
23yrold3yrold
Posts: 11
Joined: Wed Apr 19, 2006 6:23 am

Post by 23yrold3yrold »

I tried removing the space; didn't help.

I'll try that mview or MeshView, if I can find it. I see a MeshViewer in bin/Win32-VisualStudio but it looks completely different when running and doesn't load the mesh well ... thanks for your help so far; I just wish Blender would export right on it's own ...
finger007

Post by finger007 »

23yrold3yrold,

mview is part of directx-sdk.
I just wish Blender would export right on it's own
don't we all? ;)

in worst case go back to version 2.37(a) and use jox's exporter (here on the forum somewhere). that seemed to be less of a hassle...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

JP wrote:i think that syntax error with the texture is probably due to having spaces in the texture file name? I had an error like that before and it was due to spaces.
Indeed there's a major bug in the .x loader which reads only one token (word enclosed by whitespace) and requires it to be of the form "..."; In all other cases it throws the syntax error. Can be easily fixed, though, by reading until next quotes are found. The patch has been uploaded to the patch page. Yet untested, though, as I don't have examples or a compiler at hand.
Post Reply