Skip to main content
GameDev.net gamedev.net
🔒 Locked

.x Textures

Started by wforl Apr 3, 2009 at 12:42 PM 6 replies 700+ views
Original Post
wforl
wforl
So does the .x file only support 1 texture? Ive been using obj up until now. So how would i also use spec maps, normal maps etc etc with the .x file?
MJP
MJP
If you're using the old fixed-function "Material" declaration, then yes you can only have one texture. If you use the newer EffectInstances stuff, then you can store any amount of arbitrary integer, float, or string properties. These usually correspond to default values for effect parameters, but you can also use them to to store the names of textures that should be bound to the Effect.
wforl
wforl
hmm, i was referring to the .xfile, and how the materials store textures names in that, and then how to read those back.

such as the D3DXMATERIAL only seems to have one texture string. And Exporters such pandasofts dont seem to export others textures than the diffuse
glaeken
glaeken
You usually apply one material/texture per sub model, so you can have multiple materials/sub-models for an entire model.

To load these materials/textures you want to do something like:

//load the mesh, get pointer to the mtrl bufferD3DXLoadMeshFromX(filename.c_str(), D3DXMESH_SYSTEMMEM, device,		&adjBuffer, &mtrlBuffer, 0, &numMtrls, &mesh));//load the materialsif( mtrlBuffer != 0 && numMtrls != 0 ){	D3DXMATERIAL* d3dxmtrls = (D3DXMATERIAL*)mtrlBuffer->GetBufferPointer();	for(DWORD i = 0; i < numMtrls; ++i)	{		D3DMATERIAL9 m;		m.Ambient   = d3dxmtrls.MatD3D.Diffuse;		m.Diffuse   = d3dxmtrls.MatD3D.Diffuse;		m.Specular  = d3dxmtrls.MatD3D.Specular;		m.Power	    = d3dxmtrls.MatD3D.Power;		// Check if the ith material has an associative texture		if( d3dxmtrls.pTextureFilename != 0 )		{			//load the texture		}		else		{			// No texture for the ith subset			//load a default texture		}		//store the material		//store the texture	}}
wforl
wforl
I think you're missing my question. With the obj file, im able to export multiple maps with each material, such

# Max2Mtl Version 4.0 Mar 10th, 2001#newmtl 01_-_DefaultKa  0.6 0.6 0.6Kd  0.6 0.6 0.6Ks  0.9 0.9 0.9d  1.0Ns  0.0illum 2map_Kd Autumn_Leaves.jpgmap_Ks Dock.jpgmap_d Tree.jpgbump Green_Sea_Turtle.jpg## EOF


Im wondering how i can get the same functionality with the .xfile, from my understanding it only exports/imports one texture file path
glaeken
glaeken
Sorry about that, I really should pay more attention when I read.

AFAIK you're correct, the X file format only supports one texture per material, and only one material per face (someone correct me if I'm wrong).

If you want to use the .X format, you'll have to have some sort of naming convention that when you load the diffuse texture from the d3d material, you'll search for textures of the same name but with different suffixes (_spec, _normal, _0, _1, etc..).
wforl
wforl
Thats the point though, i want to have more than one texture per material.

hmmm, i dont think it can be done.
MJP
MJP
Quote:
Original post by wforl
hmm, i was referring to the .xfile, and how the materials store textures names in that, and then how to read those back.


Yes, this is what I'm talking about when I said "fixed-function 'Material' declaration". This is a legacy feature of x files that was meant to provide a simple mechanism for feeding the fixed-function pipeline.

However you don't need to use that...like I said you can embed Effect Instances in an x file. These allow you to specify a name of an Effect for each subset, as well as default values for effect parameters. If these are present in the x file, they come out of D3DXLoadMeshFromX as an array of D3DXEFFECTINSTANCE. Each of these contains an array of D3DXEFFECTDEFAULT.

You'll have to check with your .X exporter documentation to see whether it supports using Effect Instances.


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.