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

clockwise (CW) & counter-clockwise (CCW) definition of vertices.

5 posts in this topic

Windows 7 DirectX9 VS express 2013 I'm in a state of deep confusion!!! The default in DirectX( is clockwise definition of vertices. In my tut. the lesson building the code to draw a triangle starting w/ transformed vertices renders a triangle. The vertices are defined in a CW mode, if i change the definition to a CCW mode the triangle is not rendered: as expected. In the next lesson the vertices are untransformed and here is the root of my confusion. Because here the vertices are defined CCW. After quite a few tries my only conclusion is that i plugged the coordinates the wrong way. On a piece of paper i used a 2D cartesian coordinate system where X and Y are perpendicular to each other, intersecting at (0, 0). Right of (0, 0) X is >0 (<0 to the left) and Y is >0 above (0, 0) (<0 below). CW has not been changed to CCW in the code, in fact the tut. author states that CCW will not be used in the tut. Help!!! I've been obssessing over this!! Thanx. Oreste
0

Share this post


Link to post
Share on other sites

AFAIK since you use untransformed vertices one of the stage matrices might change the order direction. The culling is done once all vertices have been transformed through world, view and projection matrix.

 

In other words, is the vertex order CW after transformation?

0

Share this post


Link to post
Share on other sites
I don't see in the code a change of direction...........But being relatively new at this i think a good idea is to paste here the code that might be relevant:............................................................. //this is the funct 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->BeginScene(); //select which vertex format we are using d3ddev->SetFVF(CUSTOMFVF); //set up the pipeline D3DXMATRIX matRotateY; //a matrix to store the rotation info static float index = 0.0f; index += 0.01f; //an ever increasing float value, this determines the speed of the rotation //build a matrix to rotate the model based on the increasing float value D3DXMatrixRotationY(&matRotateY, index); //tell Direct3D about our matrix d3ddev->SetTransform(D3DTS_WORLD, &matRotateY); D3DXMATRIX matView; //the view transform matrix D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3{ 0.0f, 0.0f, 10.0f }, //the camera position &D3DXVECTOR3{ 0.0f, 0.0f, 0.0f }, //look-at position &D3DXVECTOR3{ 0.0f, 1.0f, 0.0f }); //the up direction d3ddev->SetTransform(D3DTS_VIEW, &matView); //set the view transform to matView 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 //select the vertex buffer to display d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); //copy the vertex buffer to the back buffer d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); d3ddev->EndScene(); d3ddev->Present(NULL, NULL, NULL, NULL); }...................................................................................... //this is the func that puts the 3D models into video RAM void init_graphics(void) { //create the vertices using the CUSTOMVERTEX struct CUSTOMVERTEX vertices[] = { { 3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 0.0f, 3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), }, { -3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; //CUSTOMVERTEX vertices[] = //{ //{} //} //create a vertex buffer interface called v_buffer d3ddev->CreateVertexBuffer(3 * sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; //a void pointer //lock v_buffer and load the vertices into it v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); v_buffer->Unlock(); }
0

Share this post


Link to post
Share on other sites
Sorry i am having a prob with the editor! The reply is a mess. By the way where must i go to present posts that are legible and not one big mass of text? Thankx Oreste
0

Share this post


Link to post
Share on other sites

Click 'more reply options' to open the full post editor.

There's a button for entering code.

Alternatively, you can just wrap it in BBCode style [ code ] [ /code ] tags.
 
The idea behind backface culling is that primitives whose vertices are CW/CCW (depending on the setting) from the point of view of the camera won't be drawn. You want the 'outward' facing primitives of an object's mesh to be in the correct order so that they'll be rendered when the face is pointing toward the viewer. If you have a simple triangle and you're rotating it steadily around one axis, then it should only be visible half the time.

  CUSTOMVERTEX vertices[] = {
    {  3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255) },
    {  0.0f,  3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0) },
    { -3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0) }
  };

 That's CCW. If you don't transform it, and if the camera is looking at it from the front, then you won't see it. However, the code you posted looks like it does transform it: it rotates the triangle around the y axis by 0.01f every frame, so you should be seeing it roughly half the time, since you're looking at 0,0,0, where it's centered. Specifically, you should start seeing it after rendering 158 or so frames.

 

Are you calling render_frame() repeatedly?

0

Share this post


Link to post
Share on other sites
Yes render_frame is called repeatedly. In an attempt to see clearer i stopped the rotation of the triangle. And w/ the code as it is the triangle is rendered, when i swap the coordinates (to CW) the triangle is not rendered!! My nrxt project is to look more in depth at the geometry pipeline it is very possible thta my solution lies there.
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