How to use materials on my mesh?

Started by
13 comments, last by johnnyBravo 20 years, 8 months ago
Hey I want to use materials on my mesh. Like the materials that you use with lighting to colour a surface. It just won''t work with meshes. I heard something about setting the right texture stages?
Advertisement
I think it''s

D3DTSS_COLOROP, D3DTOP_MODULATE // combine 1 & 2
D3DTSS_COLORARG1, D3DTA_TEXTURE // 1 texture
D3DTSS_COLORARG2, D3DTA_DIFFUSE // 2 material

.lick
it didnt seem to do anything..

Would you be able to tell me where you found out on how to do that?
Do you have normals? Link

.lick
quote:Original post by Pipo DeClown
I think it''s

D3DTSS_COLOROP, D3DTOP_MODULATE // combine 1 & 2
D3DTSS_COLORARG1, D3DTA_TEXTURE // 1 texture
D3DTSS_COLORARG2, D3DTA_DIFFUSE // 2 material



I see.. somehow you need to add D3DTA_CURRENT to it I''m not very smart:

1) What does this do?
D3DTSS_COLOROP, D3DTOP_MODULATE // combine 1 & 2
D3DTSS_COLORARG1, D3DTA_TEXTURE // 1 texture
D3DTSS_COLORARG2, D3DTA_CURRENT // 2 light

2) This won''t work, will it?
0, D3DTSS_COLOROP, D3DTOP_MODULATE // combine 1 & 2
0, D3DTSS_COLORARG1, D3DTA_TEXTURE // 1 texture
0, D3DTSS_COLORARG2, D3DTA_CURRENT // 2 light
1, D3DTSS_COLOROP, D3DTOP_SELECTARG1
1, D3DTSS_COLORARG1, D3DTA_DIFFUSE // 3 diffuse

I really don''t have a clue..

.lick
first this is what i use on my loaded mesh so my point light works on it. Sets the normals or something
DWORD fvf = ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_SPECULAR | D3DFVF_TEX1 );myMesh[index]->CloneMeshFVF( D3DXMESH_MANAGED, fvf, myDevice, &myMesh[index]);D3DXComputeNormals( myMesh[index], 0);

and about "2) This won''t work, will it?"

it sent all my meshes white. Which had nothing to do with the materials i had on it.
hmmm i just realised that the materials i was setting on my normal surfaces could only set a max of red blue or green.

like no 200,10,200

only 1,1,1

etc

i wanted to be able to set the diffuse colour.....
Soooo??

.lick
then what are materials actually for?

I heard theres a way to set the diffuse colour somehow..... eg colour of my triangle
You can specify the diffuse colour for each vertex by adding a colour variable e.g. D3DXCOLOR Colour(255,255,255,255) to your vertex structure and then adding D3DFVF_DIFFUSE to your FVF decleration.

This topic is closed to new replies.

Advertisement