• 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
Medo Mex

Sparks Effect

37 posts in this topic

Great!

 

The transformation issue is now resolved, now I'm trying to draw all the lines with only a single draw call, so I tried changing the following code:

 

 

// The following code draw line per draw call (I don't want that)
TVertex vrts[4];
vrts[0].pos = v0; vrts[0].otherPos = v1;
vrts[1].pos = v1; vrts[1].otherPos = v0;
vrts[2].pos = v0; vrts[2].otherPos = v1;
vrts[3].pos = v1; vrts[3].otherPos = v0;

vrts[0].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[1].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[2].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[3].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );

vrts[0].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[1].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[2].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[3].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );

d3ddev->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, vrts, sizeof( TVertex ) );

 

 

To:

// In this code, I'm trying to draw multiple lines with one single draw call
TVertex vrts[8]; // 8 instead of 4 (8 = 2 lines)

// Line 1
D3DXVECTOR3 v0(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 v1(0.0f, 100.0f, 0.0f);

vrts[0].pos = v0; vrts[0].otherPos = v1;
vrts[1].pos = v1; vrts[1].otherPos = v0;
vrts[2].pos = v0; vrts[2].otherPos = v1;
vrts[3].pos = v1; vrts[3].otherPos = v0;
vrts[0].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[1].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[2].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[3].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[0].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[1].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[2].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[3].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );

// Line 2
D3DXVECTOR3 pV0(200.0f, 0.0f, 0.0f);
D3DXVECTOR3 pV1(200.0f, 100.0f, 0.0f);

vrts[4].pos = pV0; vrts[4].otherPos = pV1;
vrts[5].pos = pV1; vrts[5].otherPos = pV0;
vrts[6].pos = pV0; vrts[6].otherPos = pV1;
vrts[7].pos = pV1; vrts[7].otherPos = pV0;
vrts[4].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[5].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[6].thickness = D3DXVECTOR3(  g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[7].thickness = D3DXVECTOR3( -g_fThickness, 0.f, g_fThickness * 0.5f );
vrts[4].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.f );
vrts[5].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.f );
vrts[6].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.f, 0.25f );
vrts[7].texOffset = D3DXVECTOR4( g_fThickness, g_fThickness, 0.25f, 0.25f );

// Draw all lines
d3ddev->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 4, vrts, sizeof( TVertex ) );

 

Now, the two lines are connected with each others, which of course undesired since I want to draw multiple separate lines with one draw call.

 

Do I have to set index buffer to draw multiple lines with one draw call? If yes, how do I fill the index buffer?

1

Share this post


Link to post
Share on other sites
 
I tried the following code, but it's not working as expected:
// Create index buffer
DWORD* index = new DWORD[indicesCount];
DWORD j = 0;
indexBuffer->Lock(0, sizeof(index), (void**)&index, 0);
for(USHORT i = 0; i < indicesCount; i += 6)
{
    index[0+i] = 0+j;
    index[1+i] = 2+j;
    index[2+i] = 1+j;
    index[3+i] = 0+j;
    index[4+i] = 3+j;
    index[5+i] = 2+j;
    j += 4;
}
indexBuffer->Unlock();

 

// Draw
device->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, 4, 2, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );

 

What's wrong?

Edited by Medo3337
0

Share this post


Link to post
Share on other sites

it's not working as expected:

 

I'll assume you don't know how to describe the problem. No, errors, it just looks funny, right?


1. The first issue I see is, to account for every line-segment you batch, make sure you do something like this (notice *lineNum):

device->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, 0, 4*lineNum, 2*lineNum, indexBuffer, D3DFMT_INDEX32, vrts, sizeof( TVertex ) );

 

Or you can increment a variable to use for the arguments, just as you probably do with 'vrts'.

 

2. Why are you making an allocation for the buffer? The following code you have written is unnecessary and bad: DWORD* index = new DWORD[indicesCount];

 

The Lock() function will modify your pointer to point somewhere used in the write-combining process. Not only is this memory allocation unnecessary, but you're creating a memory leak.

3. How do you determine "indicesCount" ?
4. My suggestions:

Construct your index layer in explicit terms of line segments. e.g.

 

uint i = 0;
uint vI = 0;
for (uint lineI = 0; lineI != lineQ; ++lineI)
{
	index[i++] = vI;
	index[i++] = vI + 2;
	index[i++] = vI + 1;
	index[i++] = vI + 1;
	index[i++] = vI + 2;
	index[i++] = vI + 3;
	vI += 4;
}

 

indicesCount can be determined just like this: lineQ * 6;

Notation info: I have a personal habit of appending a capital letter i to denote an index and Q to denote a quantity.

Hopefully these tips get you somewhere. biggrin.png

Edited by Reflexus
1

Share this post


Link to post
Share on other sites

if you can't get what you're working on going, check out the point sprite demo mentioned in one of the previous posts. its in the directx 8 sdk (and perhaps later ones). it REALLY looks nice! JUST what you want. <g>

 

not sure how they do it. they may be lines, or thin tri's with gradient texture and lots of emissive on the material. never looked at the code. but the demo is killer.

 

and if dx8 will do, dx9 will do it for sure.

0

Share this post


Link to post
Share on other sites

It's not working.

 

How so? Please explain the problem, as I asked before. I just left you with tips and example code to get you pointed in the right direction -- but it was a guess nevertheless -- because you have not explained the debugging results.

Edited by Reflexus
0

Share this post


Link to post
Share on other sites

So it doesn't have any crashing issues? (edit: Hey, I'm just expecting the worse laugh.png)

Edited by Reflexus
0

Share this post


Link to post
Share on other sites

No, nothing more than just deformed lines, you might want to look at the effect file to see how the indices should be like.

0

Share this post


Link to post
Share on other sites

you might want to look at the effect file to see how the indices should be like.


Really... If you're not sure how to get them right yourself, just try different combinations. Really. There aren't too many to try. You could have fixed it by now.

Edit: Oh, sorry. I sound sour. I am not able to help you further. My time!

Edited by Reflexus
0

Share this post


Link to post
Share on other sites

Yes, I have been trying to use different indices but couldn't get it to work.

 

Anyway, consider the question closed, I'll look for a way to resolve the issue.

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