• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
tcige

where can i find the D3DFVF format

21 posts in this topic

there's only float on msdn, but no variable name and what float means, where can i find the detail of all kinds of D3DFVF format

 

yes, directx books have the info, but how do they get it, did sb reverse the detail format?

0

Share this post


Link to post
Share on other sites

What float variable name, I am not sure I understand your question actually.

 

Generally you do something like this

 

struct CustomVertex
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    float u, v; //texture coordinates
};

DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0 |
              D3DFVF_TEXCOORDSIZE2(0);
Edited by NightCreature83
0

Share this post


Link to post
Share on other sites

What float variable name, I am not sure I understand your question actually.

 

Generally you do something like this

 

struct CustomVertex
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    float u, v; //texture coordinates
}

DWORD CustomVertexFVF |= D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0 |
              D3DFVF_TEXCOORDSIZE2(0);

 

the float variable name is x, y, z in this structure

 

where does this structure come from, i can not find it on msdn

 

you know, when i program, i only go msdn

0

Share this post


Link to post
Share on other sites

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

 

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

 

struct CustomVertexColor
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    DWORD diffuse; //Diffuse color
    float u, v; //texture coordinates
};
 
DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);

 

The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

 

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

Edited by NightCreature83
2

Share this post


Link to post
Share on other sites

You create that structure. And you choose what you put there because you (should) know what data you need for each verticle.

For example in tcige's code, his structure says that he wants position of each vertex (x, y, z), normal vector of each vertex (nx, ny, nz) and one set of texture coordinates of each vertex (u, v).

The FVF value must correspond to this, so it this case it is D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0.

On the msdn page that NightCreature83 linked to, you can see what number and data types of variables does each of the FVF types need, for example "float,float,float" for  D3DFVF_XYZ. So, your structure must contain three float values (names are up to you, something like x, y, z is common).

 

Of course this is just the definition of the structure of your vertices. Next step is to fill them with actual data. But that's another story.

Edited by Tom KQT
1

Share this post


Link to post
Share on other sites

where can i find the detail of all kinds of D3DFVF format

 

directx 8 docs.

 

i've got a copy of the chart you need, but gamedev.net's editor can't paste it into this post, i'll try uploading it to my gallery or journal.

Edited by Norman Barrows
0

Share this post


Link to post
Share on other sites

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

 

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

 

struct CustomVertexColor
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    DWORD diffuse; //Diffuse color
    float u, v; //texture coordinates
};
 
DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);

 

The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

 

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

 

 

thanks a lot

 

i do not mean that, for example, the texture

 

how can i known what addictional info needs in the structure except xyz

0

Share this post


Link to post
Share on other sites

You create that structure. And you choose what you put there because you (should) know what data you need for each verticle.

For example in tcige's code, his structure says that he wants position of each vertex (x, y, z), normal vector of each vertex (nx, ny, nz) and one set of texture coordinates of each vertex (u, v).

The FVF value must correspond to this, so it this case it is D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX0.

On the msdn page that NightCreature83 linked to, you can see what number and data types of variables does each of the FVF types need, for example "float,float,float" for  D3DFVF_XYZ. So, your structure must contain three float values (names are up to you, something like x, y, z is common).

 

Of course this is just the definition of the structure of your vertices. Next step is to fill them with actual data. But that's another story.

 

yeah, why needs u,v for texture, that's what i want to know

0

Share this post


Link to post
Share on other sites

where can i find the detail of all kinds of D3DFVF format

 

directx 8 docs.

 

i've got a copy of the chart you need, but gamedev.net's editor can't paste it into this post, i'll try uploading it to my gallery or journal.

 

thanks for the info

 

where can i download the directx 8 sdk

0

Share this post


Link to post
Share on other sites

>>   where can i download the directx 8 sdk

 

its still out there on a few sites, but that image is all you need out of it. the june 2010 sdk docs cover everything else RE:  fixed function and FVF codes.

 

if you're just starting out, you might just want to learn the newer way. its forward compatible, FVF is not.

 

i'll check my code and see if i can explain what's up with fvf's.

0

Share this post


Link to post
Share on other sites

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

 

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

 

struct CustomVertexColor
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    DWORD diffuse; //Diffuse color
    float u, v; //texture coordinates
};
 
DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);

 

The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

 

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

 

 

thanks a lot

 

i do not mean that, for example, the texture

 

how can i known what addictional info needs in the structure except xyz

That's completely up to you to be honest, but there are a few things that are needed to do certain things, like:

  • Wanna do lighting you need to provide a normal
  • Wanna do texture mapping you need to provide at least one set of texture coordinates.

This link should give you more information on when to use what in a vertex buffer, it also relates this information to certain features you can turn on in the Fixed Function pipeline in D3D9.

 

ok I found a link to the order of the structure related to the FVF again: http://p.blog.csdn.net/images/p_blog_csdn_net/yanonsoftware/fvf_order.gif

 

Again I advice you to start looking at the programmable pipeline instead as the Fixed Function pipeline isn't used anymore in anything but legacy code.
 

1

Share this post


Link to post
Share on other sites

i posted the chart from the directx8 docs in my gallery:

 

http://www.gamedev.net/gallery/image/3560-fvfcodes/

 

lemme check my code, and i'll see if i can explain what's up in my next post. i use fvf too.

 

the chart is great

 

maybe the directx 8 header file contains the detail info of every structure

 

thanks for the info and advise

0

Share this post


Link to post
Share on other sites

 

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

 

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure

 

struct CustomVertexColor
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    DWORD diffuse; //Diffuse color
    float u, v; //texture coordinates
};
 
DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);

 

The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

 

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

 

 

thanks a lot

 

i do not mean that, for example, the texture

 

how can i known what addictional info needs in the structure except xyz

That's completely up to you to be honest, but there are a few things that are needed to do certain things, like:

  • Wanna do lighting you need to provide a normal
  • Wanna do texture mapping you need to provide at least one set of texture coordinates.

This link should give you more information on when to use what in a vertex buffer, it also relates this information to certain features you can turn on in the Fixed Function pipeline in D3D9.

 

ok I found a link to the order of the structure related to the FVF again: http://p.blog.csdn.net/images/p_blog_csdn_net/yanonsoftware/fvf_order.gif

 

Again I advice you to start looking at the programmable pipeline instead as the Fixed Function pipeline isn't used anymore in anything but legacy code.
 

 

thanks for the info and advise
 

0

Share this post


Link to post
Share on other sites

ok, i'm only using fvf's for a test of drawing dynamically height mapped ground quads, and for drawing meshes.

 

for the ground quad test, i'm using this vertex format:

 

 

const DWORD ZFVF=(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0)  );
 
struct Zvertexrec
{
float x,y,z;
float nx,ny,nz;
float tu,tv;  
DWORD diffuse,specular;
};
 
 
so these have position for drawing, normals for lighting, texture coords for texturing, and diffuse and specular lighting components.
 
but that was just a test.
 
in my actual code, i just call mesh.getfvf, and then call set_fvf. then i set my vertex and index buffers and call drawprimitive.
 
the meshes are made in truespace, and use its built-in .x export capability to save them as .x files. the .x files are loaded at program start, and are a convenient way for me to store vertex and index buffers for drawing.
 
as i recall, their vertex format is x,y,z,normal,u,v.
 
as i recall, diffuse and specular are only used when you're not texture mapping.
 
 
so here's the process:
 
1. figure out what you need.   xyz, normal, u,v   etc...     xyz normal and uv might be enough for basic texturermapping and lighting.
 
2. declare your struct.
 
3. declare your fvf code dword (like my ZFVF above)
 
4. call set_fvf(myfvf_dword)
0

Share this post


Link to post
Share on other sites

> maybe the directx 8 header file contains the detail info of every structure

 

dude, you don't get it, there ARE no structures. 

 

you make them yourself, then use fvf codes to tell directx what you put in them.

 

all the possible combos would be a nightmare to deal with, so microsoft left it up to the user to declare the struct in a certain order, then uses fvf codes to tell directx how to read it.

 

so there isn't a "xyz,normal,uv" struct in directx at all. or any of the other possible struct declarations you could get from all possible fvf code combos.

 

you make the struct.  the order in the chart and the fvf codes allow directx to read it correctly.

 

 

the fvf codes  define what fields you can include. the docs about the fvf flags tell what they do, but they don't explain about the order of appearance in the struct very well or at all.

 

i've never checked to see if the flags are listed in the docs in the order that the fields must appear or not.

Edited by Norman Barrows
1

Share this post


Link to post
Share on other sites

That depends on your render states that are setup on the device and on the material settings. If D3DRS_VERTEXCOLOR is set and lighting is also enabled it will use the per vertex color values in this calculation. By default it's set to true.

0

Share this post


Link to post
Share on other sites

That depends on your render states that are setup on the device and on the material settings.

 

yes, i suspected that material was involved.   when you export just a mesh by itself from truespace with uv and normals only, it does not include lighting in the vertices, so directx just uses the material (i'm pretty sure). i use global materials to control specular and diffuse when drawing scenes.

0

Share this post


Link to post
Share on other sites
The helper function D3DXDeclaratorFromFVF will give you an array of vertex elements (which you can use to create a matching vertex declaration) from any FVF you can think of. These elements tell you the exactly how your struct has to look. For C++ there's also the offsetof macro to check if your offsets really match with your declaration/FVF.

You can also look at the SDK samples (or any other working sample) that still uses FVF to learn how a such a struct looks and works.

As an aside: Without the fixed function pipeline (shaders) you rather go the other way round: You first define your struct and then define a matching vertex declaration (since FVF isn't really, well, flexible).
1

Share this post


Link to post
Share on other sites

The helper function D3DXDeclaratorFromFVF will give you an array of vertex elements (which you can use to create a matching vertex declaration) from any FVF you can think of. These elements tell you the exactly how your struct has to look. For C++ there's also the offsetof macro to check if your offsets really match with your declaration/FVF.

You can also look at the SDK samples (or any other working sample) that still uses FVF to learn how a such a struct looks and works.

As an aside: Without the fixed function pipeline (shaders) you rather go the other way round: You first define your struct and then define a matching vertex declaration (since FVF isn't really, well, flexible).

 

this function is awesome and really what i want

 

thanks a lot

0

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  
Followers 0