# x file material with more components

This topic is 3801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hihi! I want to write more components to an x form ( x from exported from max or blender script, nvm), and want to read that plus components under directx. I can't fint out how the hack can i do it. Does DX SDK have a function to read that stuffs (plus uv-coord,texture name for spec/bumpmap)? I'm really sure that at least one of u guys has/had the same problem. In a few games I saw the materials have more than one map, however I cant find out how does it work. Thx ahead for ur help and ur spend time. And sorr. EnglishSpeaker v0.01 is under construction :D

##### Share on other sites
Most non-trivial renderers will ahve custom model formats so they can have more specialised embedded.

##### Share on other sites
So, I can't use x files. In that fact i have to use ( after I write one ) an exporter script in blender? If on the net there is at least one special exporter, can u tell me its name?

##### Share on other sites
In Max I use the kW X-porter that lets me specify a lot of "components" (multiple UVs, tangents, normals, colors...).

In my engine I load the model with D3DXLoadMeshFromX as usual and then change its vertex declaration.

For example, if the model has position, normal and 2 UVs:
const D3DVERTEXELEMENT9 g_VertexDecl_Simple_AO[5] ={    { 0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },	{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },    { 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,  0 },	{ 0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,  1 },    D3DDECL_END()};

And then I use the secondary UV channel in the pixel shader to read from a lightmap (for example) .

Hope this helps :)

##### Share on other sites
And how can I get a plus texture name from x-file? I need two plus texturename and plus two UVs. The problem with UVs is solved by u, but I dunno, how to get these strings.

And yep, u was very helpfull.

##### Share on other sites
as far I know, you cannot get the secondary texture name, you can have only one texture per material.

To solve this I use a small convention: for example if I have a texture named "brick.png" and I want its normal map, I have "brick_N.xxx"(insert image file format here).

The same way, if you have for instance an ambient occlusion texture that covers an entire model (named "tiny.x") I rename the texture "tiny_ao.xxx". This way I know that if the texture exists I can use it :)

Just my two cents :)

##### Share on other sites
I got that idia, but i realized it isn't useful. Two material should have tha same texture(tex.jpg), however, one of them shouldn't need (for example) specular map(tex_spec.jpg).I really hope you get what i write with my bad EnglishSpeaker v0.01

##### Share on other sites
Use an external file that defines all the materials applied on a model.

Give each material an unique id and write its properties (number and type of textures, specular power and so on) in a custom structure. It will be a bit redundant, but the best option would be to use a custom file format for the whole model.

You could use XML to easily build a quick test.

Hope this helps :)

##### Share on other sites
Well,well... so, u tell 'xml'? Other ones told me that, too.
And you think I should write a new file format???? It is that what I'd not like to read, never-never. :'( However u'r right. Can u tel me a link with exporter and string using tutorial?

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633665
• Total Posts
3013247
×