Sign in to follow this  
Plasmarobo

Universal FVF

Recommended Posts

I thought this too simple a question to put in the directX section, but is this a "Universal" FVF? By Universal can I pretty much do anything 3d with this? Or does it have conflicting members? I don't want to have a flexible FVF, I would rather just hard code one FVF that can do anything. Even at the cost of some memory ineffiency. Anyway, here is my FVF:
struct gVertex
{
	Vertex() {}
	Vertex(float x, float y, float z)
	{
		x = x;
		y = y;
		z = z;
	}

	D3DCOLOR Diffuse;
	D3DCOLOR Specular;
	float x, y, z;
	float nx, ny, nz;
	float u, v;
}

#define FVF_GVERTEX (D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )

Share this post


Link to post
Share on other sites
It depends on what your planning on doing, graphically. That FVF will not support multi-texturing or binormal and tangent information (for bump-mapping in tangent space), but should be sufficient for a basic 3D game.

Edit: There are also time when you may want to supply x, y, z, and w coords for your objects. You appear to be set on just using one FVF, but I would really recommend having multiple FVFs, since different objects may need very different sets of information.

Share this post


Link to post
Share on other sites
Yes it is basic, but let us say that I plan to add the other number of texture variables (8 right?) Would it be good enough then? What do I need to add?

Edit: Two more things,
a) What would you recomend for Multipul FVF's
b) Can a D3DVECTOR3 be substituted for the three float x, y, z and normals values?

Share this post


Link to post
Share on other sites
Quote:
Original post by Plasmarobo
Edit: Two more things,
a) What would you recomend for Multipul FVF's
b) Can a D3DVECTOR3 be substituted for the three float x, y, z and normals values?


a) It's tough to make recommendations without knowing what you're trying to do. As an example, though, in my most recent project, I use 3 FVFs: my GUI objects have x, y, z, and w componants, along with a color and 1 set of texture coords. My models have x, y, and z coords, color, normal, and 1 set of texture coords, and my map has x, y, and z coords, color, normal, and 2 sets of texture coords.
b) Not sure, sorry. I've always done it with separate x, y, z, etc floats.

Share this post


Link to post
Share on other sites
Thanks, that gives a little direction.

Oh, if I use the D3DX mesh functions, do I really need to work with Vertex/Index buffers? (I will include them just cause they are good to have)

I know they are the particle and effect thingies, but that is different from Meshes.

Share this post


Link to post
Share on other sites
I only use vert buffers for my GUI objects. For mesh's, you can just call mesh->DrawSubset(i) for each material contained in it.

Share this post


Link to post
Share on other sites
If your still interestead, you can most definatly use D3DXVECTOR3 or D3DXVECTOR4 (if your going to be using the w val.), to store position, and normals, you could even use D3DXVECTOR2 for tex coords.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this