🔒 Locked
Texture Name
Advertisement
Original Post
struct Texture { IDirect3DTexture9* tex; std::wstring name;};Quote:
There's is absolutely no way to know texture name?
When you load a texture, you know its name. You can just make a wrapper class that stores the texture and its name together. Or you could map textures to their names with a map(dictionary) data structure. It depends on what you need.
I am trying to make rear light of a car glow when user press the down (break) button. Here's what I thought I would do, I have a material called "rearLight".
Texture of the rear light of the car is kept in "rearlight.jpg". Now when user presses the down button, I would change the Ambient, Diffuse and Emissive property of the "rearLight" to:
and when user releases the down button I change it back to previous property. And when rendering the car I would render the rear light subset with texture "rearlight.jpg" and material "rearLight". For knowing if the subset is of rear light, I would compare the name of texture with "rearlight.jpg".
Now that above method won't work, here's what I'll do:
Instead of keeping the texture name in a string, I am thinking about putting the subset id of the rear light in a integer variable and when I render that subset I will set the "rearLight" material. This method will work. But if you have better suggestion, please post it.
P.S. I finished writing the code and it works nicely. Thanks everyone but if you have better solution, please post it. :D
rearLight.Ambient = D3DXCOLOR(0.5f, 0, 0, 1.0f);rearLight.Diffuse = D3DXCOLOR(0.5f, 0, 0, 1.0f);rearLight.Specular = D3DXCOLOR(0, 0, 0, 1.0f);rearLight.Emmisive = D3DXCOLOR(0, 0, 0, 1.0f);rearLight.Power = 5.0f;Texture of the rear light of the car is kept in "rearlight.jpg". Now when user presses the down button, I would change the Ambient, Diffuse and Emissive property of the "rearLight" to:
rearLight.Ambient = D3DXCOLOR(1.0f, 0, 0, 1.0f);rearLight.Diffuse = D3DXCOLOR(1.0f, 0, 0, 1.0f);rearLight.Emmisive = D3DXCOLOR(1.0f, 0, 0, 1.0f);and when user releases the down button I change it back to previous property. And when rendering the car I would render the rear light subset with texture "rearlight.jpg" and material "rearLight". For knowing if the subset is of rear light, I would compare the name of texture with "rearlight.jpg".
Now that above method won't work, here's what I'll do:
Instead of keeping the texture name in a string, I am thinking about putting the subset id of the rear light in a integer variable and when I render that subset I will set the "rearLight" material. This method will work. But if you have better suggestion, please post it.
P.S. I finished writing the code and it works nicely. Thanks everyone but if you have better solution, please post it. :D
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement