0

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++.

  • 1
    Well, you win the award for being the first I've seen to make a video of your problem. – chris Jul 24 '12 at 05:23
  • I posted a problem 3days ago at stack overflow and NO ONE WILL GIVE ME AN ANSWER. If some will give an answer, people will just give the most ambiguous answers possible. I hope someone will solve it here. – Joey Arnold Andres Jul 24 '12 at 05:25
  • How about posting some code and describing your problem? It's too much trouble for me to go watch your video. – Wernsey Jul 24 '12 at 05:38
  • I edited the top as you requested, I included a just a single line of code I think enough to show my problem. – Joey Arnold Andres Jul 24 '12 at 06:04
  • It's not enough. Definitely, something wrong with vertexes and their indexes. Can you show the full listing? – flamingo Jul 24 '12 at 06:22
  • full listing of what?? I used D3DXCreateTeapot(Device, &Teapot, 0); to create the mesh. What I need is how do you acess the vertex buffers and index buffers. For the vertex buffers I need to add color. – Joey Arnold Andres Jul 24 '12 at 06:34

1 Answers1

1

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.

DrYap
  • 6,525
  • 2
  • 31
  • 54
  • I almost got it, and as predicted I hit a big road bump again at the "get the vertex decleration" part. So here are what I've done: 1.)did the D3DVERTEXELEMENT9, to corresput with my vertex struct. 2.)Declared that using the device->CreateVertexDeclaration(D3DVERTEXELEMENT9* ve, IDirect3DVertexDeclaration9** ppDecl). 3.) And then device->setvetexdecleration.
    but after that, there is simply no trail leading to semantic, I feel like I need to know something. I and really do. Can you show me a band aid solution for that right now if its hard to explain? pls
    – Joey Arnold Andres Jul 24 '12 at 11:23