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

dx9 tutorial help

21 posts in this topic

I am able to draw a triangular pyramid to the screen, I am working with the directxtutorial.com web site. I really like this tutorial. I want to draw 20 triangular pyramids to the screen. Here is the code I am working with.
        { -1.0f, -1.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
        { -1.0f, 1.0f,-1.0f, D3DCOLOR_XRGB(0, 0, 255), },
        { 1.0f, 1.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
        { 1.0f, -1.0f, -1.0f, D3DCOLOR_XRGB(0, 0, 255), },
2

Share this post


Link to post
Share on other sites

Is this a thread for the 'Announcements' section? Or are you asking us how you might go about drawing 20 pyramids to the screen?

 

Stitchs.

1

Share this post


Link to post
Share on other sites

I want to know how to draw 20 triangular pyramids to the screen

Repeat the code for 1 pyramids 20 times, but of set each one by x (otherwise they will be drawn on top of each other)?

2

Share this post


Link to post
Share on other sites

Use a for-loop where for each increment, you change the coordinates so that each pyramid is drawn at a certain distance away from the last. This will put them into a single row or column of pyrmaids.

 

If you wanted a pattern, try using a second for-loop nested in your first. The first can move the pyramids along the X-axis, then the second moves them on the Y-axis. This results in, for example. five triangles being drawn in a column, inner loop exits to outer loop, column start moves to the right. This is repeated until you have 20 drawn on the screen, in 4 columns of 5 pyramids.

 

Regards,

 

Stitchs.

1

Share this post


Link to post
Share on other sites
am I on the right track with this code
        { x, -x, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
        { -x, x,-1.0f, D3DCOLOR_XRGB(0, 0, 255), },
        { x, x, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
        { x, -x, -1.0f, D3DCOLOR_XRGB(0, 0, 255), },
0

Share this post


Link to post
Share on other sites

am I on the right track with this code

        { x, -x, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
        { -x, x,-1.0f, D3DCOLOR_XRGB(0, 0, 255), },
        { x, x, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
        { x, -x, -1.0f, D3DCOLOR_XRGB(0, 0, 255), },

Well,yes and no, the first 3 floats are X,Y and Z (i assume, sorry), this (im pretty sure) will create them in a diagonal pattern

 

for(float i; i <= (20*32); i+=32.0f){

...[code]
{ -i, -1.0f, 0.0f,d3dcolor_xrgb(0,255,0),}
[code]
....

}

the loop increases by 32 each itteration, thus, the spacing between the pyramid will be 32px on the x axis

bare in mind its only an example :)

 

hopw that helps

1

Share this post


Link to post
Share on other sites

You'll want to create a static model of your pyramid. That means no variables in the pyramid declaration. Once that's done you use a transform to place the pyramid where you want to render it in the world.

 

This process is described in lesson 5 on the site you're using.

1

Share this post


Link to post
Share on other sites




Posted 13 April 2013 - 04:03 PM


You'll want to create a static model of your pyramid. That means no variables in the pyramid declaration. Once that's done you use a transform to place the pyramid where you want to render it in the world.

well I  have read the lesson 5 several times, I understand how to scale and rotate an object but don't understand of how to transform an object. what I want to do is draw several objects to the screen. I am able to draw a single object to the center of the screen. let me know if  you need more explanation. I am trying to ask more intelligent questions.

0

Share this post


Link to post
Share on other sites

To draw it more than once you just change the transform and then draw it again.

 

D3DXMatrixTranslation()

 

should be what you're looking for.

 

You have to reset the world matrix for every time you render the model. That means set the matrix to the identity, then do your scaling, rotation and translation -> every time. Once the matrix is set just do your draw call.

1

Share this post


Link to post
Share on other sites

ok here  is the code I am working with

// this is the function used to render a single frame
void
 
 
render_frame(void)
{
d3ddev->Clear(0, 
 
NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->Clear(0, 
 
NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
d3ddev->SetFVF(
 
CUSTOMFVF);
 
 
// set the view transform
 
 
D3DXMATRIX matView; // the view transform matrix
D3DXMatrixLookAtLH(&matView,
&
 
D3DXVECTOR3 (0.0f, 8.0f, 25.0f), // the camera position
&
 
D3DXVECTOR3 (0.0f, 0.0f, 0.0f), // the look-at position
&
 
D3DXVECTOR3 (0.0f, 1.0f, 0.0f)); // the up direction
d3ddev->SetTransform(
 
D3DTS_VIEW, &matView); // set the view transform to matView 
 
 
// set the projection transform
 
 
D3DXMATRIX matProjection; // the projection transform matrix
D3DXMatrixPerspectiveFovLH(&matProjection,
 
 
D3DXToRadian(45), // the horizontal field of view
(
 
FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // aspect ratio
1.0f, 
 
// the near view-plane
100.0f); 
 
// the far view-plane
d3ddev->SetTransform(
 
D3DTS_PROJECTION, &matProjection); // set the projection
 
 
// set the world transform
 
 
static float index = 0.0f; index+=0.03f; // an ever-increasing float value
 
 
D3DXMATRIX matRotateY; // a matrix to store the rotation for each triangle
D3DXMatrixRotationY(&matRotateY, index); 
 
// the rotation matrix
d3ddev->SetTransform(
 
D3DTS_WORLD, &(matRotateY)); // set the world transform
 
 
// select the vertex buffer to display
d3ddev->SetStreamSource(0, v_buffer, 0, 
 
sizeof(CUSTOMVERTEX));
d3ddev->SetIndices(i_buffer);
 
 
// draw the Hypercraft
d3ddev->DrawIndexedPrimitive(
 
D3DPT_TRIANGLELIST, 0, 0, 10, 0, 6);
d3ddev->EndScene(); 
d3ddev->Present(
 
NULL, NULL, NULL, NULL);
}

 

 

0

Share this post


Link to post
Share on other sites
D3DXMATRIX matRotateY, matTranslate, matWorld;

//generate the rotation
D3DXMatrixRotationY(&matRotateY, index); 

//generate the translation
D3DXMatrixTranslation(&matTranslate, x, y, z); 

//concatenate them into the world matrix - if you add scaling then it comes first (world = scale * rot * trans)
matWorld = matRotate * matTranslate;

d3ddev->SetTransform(D3DTS_WORLD, &matWorld);
1

Share this post


Link to post
Share on other sites

I am able to draw the triangular pyramid in the upper left corner of the screen. I just want to draw two pyramids to the screen. Thanks for all the help khatharr.

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