• 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
BSOD

Vertex format problem

8 posts in this topic

[color=#434343][font=helvetica, arial, verdana,]I read a memory block of [/font][/color][b]vertex positions[/b][color=#434343][font=helvetica, arial, verdana,] from an file but they're in this sequance [/font][/color][b]X Z Y[/b][color=#434343][font=helvetica, arial, verdana,] and the FVF format is D3DFVF_[/font][/color][b]XYZ[/b][color=#434343][font=helvetica, arial, verdana,] - what vertex format to use to fix this problem or maybe changing the coordinate axes?[/font][/color]
0

Share this post


Link to post
Share on other sites
Hi,

There is no such vertex format as XZY. Either change the component ordering at load time to XYZ or use a swizzle in the vertex shader.

Best regards!
0

Share this post


Link to post
Share on other sites
What is this [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]swizzle - I mean can you give me an [b]example[/b] with a [b]function call[/b]?[/background][/left][/size][/font][/color]

[quote name='kauna' timestamp='1335977908' post='4936817']
Best regards!
[/quote]

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Thanks![/background][/left][/size][/font][/color]
0

Share this post


Link to post
Share on other sites
Swizzling is used in any high level shading languages:

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb509634(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/bb509634(v=vs.85).aspx[/url] check here for details who swizzling works.

Or simply put in the vertex shader


float4 main(float4 pos : SV_POSITION) : SV_POSITION
{
float4 val = mul(pos.xzyw,World); //y and z components swizzled.

return val;
}

Best regards!
0

Share this post


Link to post
Share on other sites
Can't you just reprocess your vertex file to rearrange the vertices in the coordinate system expected by DX9? Most likely it only involves importing and exporting the file through any good 3D design package or you could even write your own script if the format isn't too complicated. Edited by Bacterius
0

Share this post


Link to post
Share on other sites
Lol here what I'll read this summer about -
[left][background=rgb(250, 251, 252)]shading. But for now here is what I do: I use a block of structures to store the vertex from the file and then I put it into the vertex buffer. Here is the code:[/background][/left]


[CODE]
//The structure where I store the vertex
struct CUSTOMVERTEX {
CUSTOMVERTEX();
FLOAT X, Z, Y; FLOAT U, V, U1, V1; DWORD COLOR, COLOR1, COLOR2;
};

//The vertex format declaration

D3DVERTEXELEMENT9 dwDecl3[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_TEXCOORD, 0},
{0, 20, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_TEXCOORD, 1},
{0, 28, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_FOG, 0},
{0, 32, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_COLOR, 1},
{0, 36, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_COLOR, 0},
D3DDECL_END()
};

//The function creating the vertex buffer
void Room::CreateBuffers(unsigned long ptr, Map* BaseClass) {
//Some code........

CUSTOMVERTEX* vertex;
vertex=new CUSTOMVERTEX[NumVertices];

GetF(0, ptr+56+BaseClass->MapOffset, sizeof(CUSTOMVERTEX)*NumVertices, &vertex[0]); //Load the vertex positions from the file

//Create the buffer


d3ddev->CreateVertexBuffer(NumVertices*sizeof(CUSTOMVERTEX),
0,
0,
D3DPOOL_MANAGED,
&v_buffer,
NULL);

VOID* pVoid; // a void pointer

// lock t_buffer and load the vertices into it
if(v_buffer) {
v_buffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, vertex, NumVertices*sizeof(CUSTOMVERTEX));
v_buffer->Unlock();
delete[] vertex;
}
else
vertex=NULL;

d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
}
[/CODE]



Any advice about this code. And I can't change the format because I don't made it - it's from a game. Edited by BSOD
0

Share this post


Link to post
Share on other sites
After the part

"GetF(0, ptr+56+BaseClass->MapOffset, sizeof(CUSTOMVERTEX)*NumVertices, &vertex[0]);"

Can't you just iterate through your vertices and swap the z and y components?

Such as

[CODE]for(int i=0;i<NumVertices;++i)
{
std::swap(vertex[i].z,vertex[i].y);
}[/CODE]
Best regards! Edited by kauna
1

Share this post


Link to post
Share on other sites
Hmm, actually this work and the program works fast. Because I was think such of loop will slow it down and that's way I was searching for some tricks. Anyway thanks for the advice.
0

Share this post


Link to post
Share on other sites
[quote name='BSOD' timestamp='1336047057' post='4937068']
Hmm, actually this work and the program works fast. Because I was think such of loop will slow it down and that's way I was searching for some tricks. Anyway thanks for the advice.
[/quote]

I assume that you run that loop only when you are loading your assets. Since the code isn't run while your main loop is executing, it doesn't affect the performance of your program at all.

You shouldn't be afraid of writing a piece of code which does the thing that you need it to do (especially if it is simple loop). After writing the code you may find out (by using facts from profilers and user experience etc) that the code needs to be improved performance wise.

Best regards!
1

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