Reputation: 368
code is here as requested:
void MakeTeapotRed()
{
D3DXCreateTeapot(Device, &Teapot, 0);
}
so how do I change the vertex color of the teapot? If your thinking material, i already know that, I just need to know the color vertex which is supposed to be a much simpler thing than material. I can do this with a geometry mannually layed out with Vertex Buffers and Index Buffers, how do you apply this to a mesh with those VB and IB info filled out already?
class ColorVertex
{
public:
ColorVertex(){}
ColorVertex(float x, float y, float z, D3DCOLOR color)
{
m_x = x;
m_y = y;
m_z = z;
m_color = color;
}
float m_x, m_y, m_z; // 3d coordinates
D3DCOLOR m_color;
static const DWORD FVF;
};
const DWORD ColorVertex::FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
The code I just posted is the class for the Vertex information called ColorVertex. As you can see, the code is setup for vertex color, color that doesnt required or must NOT have a light to work properly, as shown in FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE.
Again, people seems to have a hard time understanding the problem, I need to update the color of the vertex to include color, for objects like teapot, sphere, mesh that can be created through D3DCreate[objects] eg. D3DCreateTeapot(arguments stuff). Pls layout the code line by line, I'm a noob in directx, not in c++.
Upvotes: 0
Views: 2858
Reputation: 6647
Look at the section on accessing the vertex buffer. You have to get the vertex declaration end examine it to find how the data for each vertex is laid out.
Once you have identified how the colour is stored you loop through each vertex and changed the value. When you finish and unlock the vertex buffer of the mesh, you will be done.
I just need to know the color vertex which is supposed to be a much simpler thing than material
I would have to disagree, a material looks like it would be a lot easier.
Upvotes: 1