GraphicsCode1 Flashcards Preview

Graphics > GraphicsCode1 > Flashcards

Flashcards in GraphicsCode1 Deck (14)
Loading flashcards...
1

Step One

Create Variables/Handles/Meshes/Etc

Create Variables/Handles/Meshes/Etc

IDirect3DDevice9* Device = 0;//declare interface
ID3DXMesh* Objects[3] = { 0,0,0 };//create an array of meshes)
D3DXMATRIX ObjectWorldMatrices[3];//create an array of matrices
HINSTANCE hinstance_app;//create a handle

bool red = true, clockwise = false, teapot = true;

int choice = 0; //location in array
int x = 1; //direction of rotation

2

Step Two


Set up

In the Setup() function

Create the objects
example:
D3DXCreateTeapot(Device, Objects[0], 0);

Set object positions
example:
D3DXMatrixTranslation(&ObjectWorldMatrices[0], 0, 0, 0);

Set render state(so you can see the rotation)
Device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);

3

Step Three

Clean up

for (int i = 0; i (Objects[i]);

4

Step Four

Display()

pass in timeDelta

bool Display(float timeDelta)

5

Step Five

in the if(Device) statement

Local Variables

Create Local Variables (a lot of the variables you will need are in the starter)

D3DXVECTOR3 right(0, 0, 1); //x axis vector
D3DXMATRIX V, localRotate;

change the position variable to look like:
D3DXVECTOR3 position(0.0f, cameraHeight, -10.0f);

6

Step Six

in the if(Device) statement
Clockwise

if (clockwise)
{
//computer pos for next frame
angle += 2 * timeDelta * x;
if (angle >= 6.28) // 2 * pi; 2 * 3.14159
angle = 0;
else if (angle

7

Step Seven

in the if(Device) statement
Counter Clockwise

if (clockwise)
{
//computer pos for next frame
angle += 2 * timeDelta * x;
if (angle >= 6.28) // 2 * pi; 2 * 3.14159
angle = 0;
else if (angle

8

Step Eight

in the if(Device) statement

Set Colors

//the colors are bool variables
//placed after Device->BeginScene();
example:

if (red)
{
Device->SetMaterial(&d3d::RED_MTRL);
}

9

Step Nine

in the if(Device) statement

Set the Local Object Matrices

Device->SetTransform(D3DTS_WORLD, &ObjLocalMatrices[choice]);

10

Step Ten

in the if(Device) statement

Draw the objects

Objects[choice]->DrawSubset(0);

11

Step Eleven

in the CALLBACK function

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case MENU_COLOR_RED:
red = true;
yellow = false, green = false, blue = false;
break;

case MENU_TEAPOT:
choice = 0;
break;

case MENU_CLOCKWISE:
clockwise = true, counterclockwise = false;
x=-1;
break;

default:
break;
}
}break;

12

Step Twelve

WINAPI

set show cursor to true

ShowCursor(true);

13

Step Thirteen

Resource.rc

#include "resource.h"

MainMenu MENU DISCARDABLE
{
POPUP "&Color"
{
MENUITEM"&Red", MENU_COLOR_RED
MENUITEM"&Blue", MENU_COLOR_BLUE
}
}
follow the same format for shape and rotation

14

Step Fourteen

Resource.h

#define MENU_COLOR_RED 3100

follow the same format for all menu items