Jump to content

  • Log In with Google      Sign In   
  • Create Account

TransformedBG

Member Since 24 Apr 2007
Offline Last Active Apr 25 2012 09:32 PM

Topics I've Started

Need a little help.. think my lighting is messed up...

24 April 2012 - 10:58 PM

So programming calls go like so:
IDirect3DTexture9* my_texture; //make a texture
void setupTexture() //set up the texture
{
//D3DXCreateTextureFromFile(Device,"ast.jpg",&my_texture);
if(FAILED(D3DXCreateTextureFromFile(Device,"ast.jpg",&my_texture)))
{
  ::MessageBox(0, "Tex - FAILED", 0, 0);
}
}

Next i Create an asteroid in my message loop:
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
{
main_instance = hinstance;
if(!d3d::InitD3D(hinstance, Width, Height, true, D3DDEVTYPE_HAL, &Device))
{
  ::MessageBox(0, "InitD3D() - FAILED", 0, 0);
  return 0;
}

if(!Setup())
{
  ::MessageBox(0, "Setup() - FAILED", 0, 0);
  return 0;
}
createAsteroid(Device,Height,Width, my_texture); //create asteroid

d3d::EnterMsgLoop(Display);
Cleanup();
Device->Release();
return 0;
}

I have a struct for an asteroid:
struct ASTEROID
{
LPD3DXMESH Mesh;
D3DMATERIAL9 Mtrl;
D3DXMATRIX Location;
IDirect3DTexture9* Texture;
	float x;	// Asteriod X Posistion
	float y;	// Asteriod Y Posistion
float z;
float raduis;

int hit;
int direction;
bool visible;   // were we collide?
bool split;
};

I build a matrix of asteroids that i want to texture
bool createAsteroid(IDirect3DDevice9* device, const int Height, const int Width, IDirect3DTexture9* texture)
{
time_t now = time(0);
srand((unsigned int )&now);
for(int i = 0; i < TOTAL_ASTEROIDS + level; i++)
{
  asteroids[i].Location = asteroid_matrix[i];

  asteroids[i].Texture = texture; //<- texture set
  asteroids[i].z = 80;

  asteroids[i].x = 20.0f - (rand()%60);
  if(asteroids[i-1].x <= asteroids[i].x + 20) asteroids[i].x = 20.0f - (rand()%60);
  asteroids[i].y = 20.0f - (rand()%60);
  if(asteroids[i-1].y <= asteroids[i].y + 20) asteroids[i].y = 20.0f - (rand()%60);
}
return true;
}

next i move and render the asteroids :this is my recursive loop:
bool render(IDirect3DDevice9* device, const int Height, const int Width)
{
if(!device)return false;
  moveAsteroids(device, Height, Width);
  device->BeginScene();

  renderAsteroids(device);

  device->EndScene();
return true;
}

which movement is just moving cords no big deal then re render the object:
void renderAsteroids(IDirect3DDevice9* device)
{
D3DLIGHT9 light;
ZeroMemory(&light,sizeof(light));
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse = d3d::WHITE;
light.Direction = D3DXVECTOR3(-1.0f, -0.3f, -1.0f);
device->SetLight(0,&light);
device->LightEnable(0,true);
light.Direction = D3DXVECTOR3(1.0f,0.3f,1.0f);
device->SetLight(1,&light);
device->LightEnable(1,true);
//set light render states
device->SetRenderState(D3DRS_NORMALIZENORMALS, true);
device->SetRenderState(D3DRS_SPECULARENABLE, false);

astroidNotHit(device);
}

Problem is the Texture is created (doesnt fail and prompt out) ... i can see that the value is being applied to my structure... but i can not see the asteroid on my screen.. i have a feeling the problem is my lighting.

Any suggestions?

Meshes and Primatives

14 February 2012 - 09:07 PM

based on my old thread which i got to work perfectly

http://www.gamedev.net/topic/620018-one-star-instead-of-many/page__fromsearch__1

i made a second class i called asteroids

same kind of idea:

struct ASTEROID
{
LPD3DXMESH Mesh;
D3DMATERIAL9 Mtrl;
LPDIRECT3DTEXTURE9* Texture;
D3DXMATRIX Location;
    float x;    // Star X Posistion
    float y;    // Star Y Posistion
float z;    // Star Z Position ( = velocity)
int direction;
bool visible;   // did we collide?
};


same kind of global
//Stars
IDirect3DVertexBuffer9 * asteroid_VB;
const int TOTAL_ASTEROIDS = 5;
ASTEROID asteroids[TOTAL_ASTEROIDS];
LPD3DXMESH asteroidMesh;
LPDIRECT3DTEXTURE9* texture;
D3DXMATRIX asteroid_matrix[TOTAL_ASTEROIDS];


float asteroid_velocity = 0.2f;
const int Far_Depth = 100;
const int Near_Depth = 00;

same kind of create function:
bool createAsteroid(IDirect3DDevice9* device, const int Height, const int Width)
{
D3DXMATRIX proj;
D3DXMatrixPerspectiveFovLH(&proj,D3DX_PI * 0.25f , (float)Width/(float)Height, 0.01f, 1000.0f);
device->SetTransform(D3DTS_PROJECTION,&proj);
time_t now = time(0);
srand((unsigned int )&now);
D3DXMATRIX V;
D3DXMatrixIdentity(&V);
device->SetTransform(D3DTS_WORLD,&V);
device->SetTransform(D3DTS_VIEW, &V);
for(int i = 0; i < TOTAL_ASTEROIDS; i++)
{
  asteroids[i].Mesh =asteroidMesh;
  asteroids[i].Location = asteroid_matrix[i];
  asteroids[i].Mtrl = d3d::GREEN_MTRL;
  asteroids[i].z -= asteroid_velocity;
  asteroids[i].x = 30.0f - (rand()%60);
  asteroids[i].y = 30.0f - (rand()%60);
}
return true;
}


same kind of render:
void renderAsteroids(IDirect3DDevice9* device)
{
device->SetRenderState(D3DRS_LIGHTING,FALSE);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_COLORARG1,D3DTA_DIFFUSE);
for(int i = 0; i < TOTAL_ASTEROIDS; i++)
{

  D3DXCreateSphere(device, 8.2f, 8, 50, &asteroids[i].Mesh, 0);
  D3DXMatrixTranslation(&asteroids[i].Location,asteroids[i].x,asteroids[i].y,asteroids[i].z);
 
  device->SetTransform(D3DTS_WORLD, &asteroids[i].Location);
  asteroids[i].Mesh->DrawSubset(0);
}
for(int i = 0; i < TOTAL_ASTEROIDS; i++) d3d::Release<ID3DXMesh*>(asteroids[i].Mesh);
}

problem im having is when they render and move they take my premitive stars and put them Way behind them and move them around the screen as they move. the stars do not stay on the screen like i was hoping.

void moveAsteroids(IDirect3DDevice9* device, const int Height, const int Width, int dir)
{
for(int i = 0; i < TOTAL_ASTEROIDS; i++)
{
  asteroids[i].direction = dir;
  device->SetMaterial(&asteroids[i].Mtrl);
  device->SetTransform(D3DTS_WORLD, &asteroids[i].Location);
  D3DXCreateSphere(device,8.2f, 8, 50, &asteroids[i].Mesh, 0);
  D3DXMatrixTranslation(&asteroids[i].Location,asteroids[i].x,asteroids[i].y,asteroids[i].z);
 
  asteroids[i].Mesh->DrawSubset(0);
 
  asteroids[i].z -= 0.5f;
  //if turning left '4' stars move right
  if(asteroids[i].direction == 4)
  {
   asteroids[i].x += 0.05f;
   if(asteroids[i].x >= 30) asteroids[i].x = -30;
  }

  //if turning right '6' move left
  if(asteroids[i].direction == 6)
  {
   asteroids[i].x -= 0.05f;
   if(asteroids[i].x <= -30) asteroids[i].x = 30;
  }
  //if going Up '8' stars move down
  if(asteroids[i].direction == 8)
  {
   asteroids[i].y -= 0.05f;
   if(asteroids[i].y <= -30) asteroids[i].y = 30;
  }
  //if going up and right '8' and '6' stares move down and left
  if(asteroids[i].direction == 9)
  {
   asteroids[i].y -= 0.05f;
   asteroids[i].x -= 0.05f;
   if(asteroids[i].x <= -30) asteroids[i].x = 30;
   if(asteroids[i].y <= -30) asteroids[i].y = 30;
  }
  //if going up and left '8' and '4' stares move down and right
  if(asteroids[i].direction == 7)
  {
   asteroids[i].y -= 0.05f;
   asteroids[i].x += 0.05f;
   if(asteroids[i].x >= 30) asteroids[i].x = -30;
   if(asteroids[i].y <= -30) asteroids[i].y = 30;
  }
  //if going down and right '2' and '3' stares move up and left
  if(asteroids[i].direction == 3)
  {
   asteroids[i].y += 0.05f;
   asteroids[i].x -= 0.05f;
   if(asteroids[i].x <= -30) asteroids[i].x = 30;
   if(asteroids[i].y >= 30) asteroids[i].y = -30;
  }
  //if going down '2' stares move up
  if(asteroids[i].direction == 2)
  {
   asteroids[i].y += 0.05f;
   if(asteroids[i].y >= 30) asteroids[i].y = -30;
  }
  //if going down and left '1' and '2' stares move up and right
  if(asteroids[i].direction == 1)
  {
   asteroids[i].y += 0.05f;
   asteroids[i].x += 0.05f;
   if(asteroids[i].x >= 30) asteroids[i].x = -30;
   if(asteroids[i].y >= 30) asteroids[i].y = -30;
  }


  if(asteroids[i].z <= Near_Depth) asteroids[i].z = Far_Depth;
}
}

Dont know if anyone could shed some light on the idea as to why this might be happening.

one star instead of many...

08 February 2012 - 08:10 PM

Im just trying to make the old flying through space screen saver in direct X and could use a little help.

oh the star is just a basic struct:
struct STAR
{
    float x;		  // Star X Posistion
    float y;		  // Star Y Posistion
float z;    // Star Z Position
    float velocity;   // Star Velocity
int direction;
    DWORD color;   // Star Color
bool hyperspace;  //boost?
};

global variables
//Stars
IDirect3DVertexBuffer9 * star_VB;
const int TOTAL_STARS = 250;
STAR stars[TOTAL_STARS]; //star vertex
float star_velocity = 0.1f;
const int Far_Depth = 100;
const int Near_Depth = 20;

//how i create my star
bool createStars(IDirect3DDevice9* device, const int Height, const int Width)
{
D3DXMATRIX proj;
D3DXMatrixPerspectiveFovLH(&proj,D3DX_PI * 0.25f , (float)Width/(float)Height, 0.01f, 1000.0f);//45, 1.0f, 0.1f, 500.0f));
device->SetTransform(D3DTS_PROJECTION,&proj);
time_t now = time(0);
srand((unsigned int )&now);
D3DXMATRIX V;
D3DXMatrixIdentity(&V);
device->SetTransform(D3DTS_WORLD,&V);
device->SetTransform(D3DTS_VIEW, &V);
for(int i=0; i < TOTAL_STARS;i++)
{
  stars[i].z -= star_velocity;
  stars[i].x = 30.0f - (rand()%60);
  stars[i].y = 30.0f - (rand()%60);

  stars[i].z = Near_Depth + (float)(rand()%(Far_Depth - Near_Depth));
  stars[i].color = d3d::WHITE;
}
return true;
}

which i call in my winMain:
// WinMain
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
{
main_instance = hinstance;
if(!d3d::InitD3D(hinstance, Width, Height, true, D3DDEVTYPE_HAL, &Device))
{
  ::MessageBox(0, "InitD3D() - FAILED", 0, 0);
  return 0;
}

if(!Setup())
{
  ::MessageBox(0, "Setup() - FAILED", 0, 0);
  return 0;
}
bool test = true;
test = createStars(Device,Height,Width);

if(test == false)
{
  ::MessageBox(0, "createStars() - FAILED",0,0);
  return 0;
}
d3d::EnterMsgLoop(Display);
Cleanup();
Device->Release();
return 0;
}

and i call the function render() in my display
bool render(IDirect3DDevice9* device)
{
if(!device)return false;
moveStars(device);

device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, d3d::BLACK, 1.0f,0);
device->BeginScene();
renderStars(device);

device->EndScene();
return true;
}

which calls movestars:
void moveStars(IDirect3DDevice9* device)
{
for(int i = 0; i < TOTAL_STARS; i++)
{
  //move the star
  stars[i].z -= star_velocity;

  if(stars[i].z <= Near_Depth) stars[i].z = Far_Depth;
  if(stars[i].direction == 2)
  {
   stars[i].x += 0.1f;
  }
}
}

then renders them:
void renderStars(IDirect3DDevice9* device)
{
device->SetRenderState(D3DRS_LIGHTING,FALSE);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_COLORARG1,D3DTA_DIFFUSE);
device->CreateVertexBuffer(TOTAL_STARS*sizeof(stars),D3DUSAGE_WRITEONLY, CUSTOMFVF,D3DPOOL_MANAGED,&star_VB,NULL);

VOID* temp_pointer_vb;
star_VB->Lock(0,TOTAL_STARS*sizeof(stars),&temp_pointer_vb,0);
memcpy(temp_pointer_vb,stars,TOTAL_STARS);
star_VB->Unlock();
device->SetStreamSource(0,star_VB,0,sizeof(stars));
device->SetFVF(CUSTOMFVF);
device->DrawPrimitive(D3DPT_POINTLIST,0,TOTAL_STARS);
star_VB->Release();
}

Now problem im having is im only rendering 1 star somewhere on the screen over and over again... so the move function is obviously working... Problem is that it should be rendering 250 stars..

Just wondering if someone might have some thoughts on this..

Trying to make a room... Need some help

04 February 2012 - 09:06 PM

Okay so I have been trying to build a basic room with textures right now im just trying to figure out how to texture a cube and be able to move throughout space.

unfortunately my cube isn't showing up and i'm not sure why... hoping maybe someone can shed some light on this:

main.cpp:
#include "base.h"
#include "camera.h"
#include "room.h"
// Globals
IDirect3DDevice9* Device = 0;
float intiTime = (float)timeGetTime();
LPDIRECT3DTEXTURE9 texture;
D3DXMATRIX World;
IDirect3DVertexBuffer9* Floor = 0; // vertex buffer to store
IDirect3DIndexBuffer9* floorBuff = 0;
//set screen
const int Width  = 900;
const int Height = 600;
//Position tracking
Camera TheCamera;
float camPosX = 0.0f,camPosY = 0.0f, camPosZ = -5.0f;
bool drawFloor()
{
D3DXCreateTextureFromFile(Device,    // the Direct3D device
						  "carpet.jpg",    // the filename of the texture
						  &texture);    // the address of the texture storage
if(!texture)
{
  ::MessageBox(0, "D3DXCreateTextureFromFile() - FAILED", 0, 0);
  return false;
}
CUSTOMVERTEX vertices[] =
{
  { -3.0f, -3.0f, 3.0f,  0.0f, 0.0f, 1.0f,  0.0f, 0.0f, },    // side 1
	    { 3.0f, -3.0f, 3.0f,  0.0f, 0.0f, 1.0f,  1.0f, 0.0f, },
	    { -3.0f, 3.0f, 3.0f,  0.0f, 0.0f, 1.0f,  0.0f, 1.0f, },
	    { 3.0f, 3.0f, 3.0f,  0.0f, 0.0f, 1.0f,  1.0f, 1.0f, },
	    { -3.0f, -3.0f, -3.0f,  0.0f, 0.0f, -1.0f,  0.0f, 0.0f, },    // side 2
	    { -3.0f, 3.0f, -3.0f,  0.0f, 0.0f, -1.0f,  0.0f, 1.0f, },
	    { 3.0f, -3.0f, -3.0f,  0.0f, 0.0f, -1.0f,  1.0f, 0.0f, },
	    { 3.0f, 3.0f, -3.0f,  0.0f, 0.0f, -1.0f,  1.0f, 1.0f, },
	    { -3.0f, 3.0f, -3.0f,  0.0f, 1.0f, 0.0f,  0.0f, 0.0f, },    // side 3
	    { -3.0f, 3.0f, 3.0f,  0.0f, 1.0f, 0.0f,  0.0f, 1.0f, },
	    { 3.0f, 3.0f, -3.0f,  0.0f, 1.0f, 0.0f,  1.0f, 0.0f, },
	    { 3.0f, 3.0f, 3.0f,  0.0f, 1.0f, 0.0f,  1.0f, 1.0f, },
	    { -3.0f, -3.0f, -3.0f,  0.0f, -1.0f, 0.0f,  0.0f, 0.0f, },    // side 4
	    { 3.0f, -3.0f, -3.0f,  0.0f, -1.0f, 0.0f,  1.0f, 0.0f, },
	    { -3.0f, -3.0f, 3.0f,  0.0f, -1.0f, 0.0f,  0.0f, 1.0f, },
	    { 3.0f, -3.0f, 3.0f,  0.0f, -1.0f, 0.0f,  1.0f, 1.0f, },
	    { 3.0f, -3.0f, -3.0f,  1.0f, 0.0f, 0.0f,  0.0f, 0.0f, },    // side 5
	    { 3.0f, 3.0f, -3.0f,  1.0f, 0.0f, 0.0f,  0.0f, 1.0f, },
	    { 3.0f, -3.0f, 3.0f,  1.0f, 0.0f, 0.0f,  1.0f, 0.0f, },
	    { 3.0f, 3.0f, 3.0f,  1.0f, 0.0f, 0.0f,  1.0f, 1.0f, },
	    { -3.0f, -3.0f, -3.0f,  -1.0f, 0.0f, 0.0f,  0.0f, 0.0f, },    // side 6
	    { -3.0f, -3.0f, 3.0f,  -1.0f, 0.0f, 0.0f,  1.0f, 0.0f, },
	    { -3.0f, 3.0f, -3.0f,  -1.0f, 0.0f, 0.0f,  0.0f, 1.0f, },
	    { -3.0f, 3.0f, 3.0f,  -1.0f, 0.0f, 0.0f,  1.0f, 1.0f, },
};
Device->CreateVertexBuffer(24*sizeof(CUSTOMVERTEX),0,CUSTOMFVF,D3DPOOL_MANAGED,&Floor,NULL);
VOID* pVoid; //void pointer
Floor->Lock(0,0,(void**)&pVoid,0);
memcpy(pVoid,vertices,sizeof(vertices));
Floor->Unlock();
  // create the indices using an int array
    short indices[] =
    {
	    0, 1, 2,    // side 1
	    2, 1, 3,
	    4, 5, 6,    // side 2
	    6, 5, 7,
	    8, 9, 10,    // side 3
	    10, 9, 11,
	    12, 13, 14,    // side 4
	    14, 13, 15,
	    16, 17, 18,    // side 5
	    18, 17, 19,
	    20, 21, 22,    // side 6
	    22, 21, 23,
    };
Device->CreateIndexBuffer(36*sizeof(short),0,D3DFMT_INDEX16,D3DPOOL_MANAGED,&floorBuff,NULL);
floorBuff->Lock(0,0,(void**)&pVoid,0);
memcpy(pVoid,indices,sizeof(indices));
floorBuff->Unlock();
return true;
}

//Lighting to see currObject
void renderLight()
{
//Set up Directional Light
D3DXVECTOR3 dir(1.0f, -0.0f, 0.25f);
D3DXCOLOR c = d3d::WHITE;
D3DLIGHT9 dirLight = d3d::InitDirectionalLight(&dir, &c);
//enable lights
Device->SetLight(0, &dirLight); // 0,1,2,3 etc for whatever light your on. / name of light
Device->LightEnable(0, true);
//set light render states
Device->SetRenderState(D3DRS_NORMALIZENORMALS, true);
Device->SetRenderState(D3DRS_SPECULARENABLE, false);
}

// Framework functions
bool Setup()
{
renderLight();
// Set camera.
D3DXVECTOR3 pos(camPosX, camPosY, camPosZ);
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXMATRIX V;
D3DXMatrixLookAtLH(&V, &pos, &target, &up);
Device->SetTransform(D3DTS_VIEW, &V);
// Set projection matrix.
D3DXMATRIX proj;
D3DXMatrixPerspectiveFovLH(
   &proj,
   D3DX_PI * 0.25f, // 45 - degree
   (float)Width / (float)Height,
   0.01f,
   1000.0f);
Device->SetTransform(D3DTS_PROJECTION, &proj);
return true;
}
void Cleanup()
{
d3d::Release<IDirect3DVertexBuffer9*>(Floor);
d3d::Release<IDirect3DIndexBuffer9*>(floorBuff);
//d3d::Release<ID3DXMesh*>;
}
//render the world
void render(float timeDelta)
{

// Render
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
Device->BeginScene();

//INSERT WHAT TO BE RENDERED
drawFloor();
Device->SetStreamSource(0,Floor,0,sizeof(CUSTOMVERTEX));
Device->SetIndices(floorBuff);
Device->SetFVF(CUSTOMFVF);
Device->SetTexture(0,texture);
Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,24,0,12);
Device->EndScene();
}

//uptates current state
bool Display(float timeDelta)
{
if( Device )
{
  if( ::GetAsyncKeyState('W') & 0x8000f )
   TheCamera.walk(4.0f * timeDelta);
  if( ::GetAsyncKeyState('S') & 0x8000f )
   TheCamera.walk(-4.0f * timeDelta);
  if( ::GetAsyncKeyState('A') & 0x8000f )
   TheCamera.strafe(-4.0f * timeDelta);
  if( ::GetAsyncKeyState('D') & 0x8000f )
   TheCamera.strafe(4.0f * timeDelta);
  if( ::GetAsyncKeyState(VK_DOWN) & 0x8000f )
   TheCamera.pitch(0.3f * timeDelta);
  if( ::GetAsyncKeyState(VK_UP) & 0x8000f )
   TheCamera.pitch(-.3f * timeDelta);
  if( ::GetAsyncKeyState(VK_LEFT) & 0x8000f )
   TheCamera.yaw(-0.3f * timeDelta);
  if( ::GetAsyncKeyState(VK_RIGHT) & 0x8000f )
   TheCamera.yaw(0.3f * timeDelta);
  // Update the view matrix representing the cameras
  // new position/orientation.
  D3DXMATRIX V;
  TheCamera.getViewMatrix(&V);
  Device->SetTransform(D3DTS_VIEW, &V);
 
  render(timeDelta);
  Device->Present(0, 0, 0, 0);
}
return true;
}
// WndProc
LRESULT CALLBACK d3d::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
  case WM_DESTROY:
   ::PostQuitMessage(0);
   break;
 
  case WM_KEYDOWN:
   if( wParam == VK_ESCAPE )
    ::DestroyWindow(hwnd);
   break;
  break;
}
return ::DefWindowProc(hwnd, msg, wParam, lParam);
}

// WinMain
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE prevInstance, PSTR cmdLine,int showCmd)
{
if(!d3d::InitD3D(hinstance, Width, Height, true, D3DDEVTYPE_HAL, &Device))
{
  ::MessageBox(0, "InitD3D() - FAILED", 0, 0);
  return 0;
}
 
if(!Setup())
{
  ::MessageBox(0, "Setup() - FAILED", 0, 0);
  return 0;
}
d3d::EnterMsgLoop( Display );
Cleanup();
Device->Release();
return 0;
}


attached is a zip with all files to run it.. but im just having one of those moments i could use some more eyes.

Drawing subset of an array of pointers

22 January 2012 - 08:23 PM

Short version lets say i want to make 10 objects:
Atom, Bullet, Tree, etc, etc. using ID3DXMesh's.

My idea was it would be something like:


//setup objects in world
ID3DXMesh** Objects[10]  = {0,0,0,0,0,0,0,0,0};
ID3DXMesh *Atom[4] = {0,0,0,0};

//set up 4 meshes for atom
void renderAtom()
{
D3DXCreateTorus(Device, 0.1f, 2.0f, 20, 20, &Atom[0], 0);
D3DXCreateSphere(Device, 0.5f, 20, 20, &Atom[1], 0);
D3DXCreateTorus(Device, 0.1f, 2.0f, 20, 20, &Atom[2], 0);
D3DXCreateTorus(Device, 0.1f, 2.0f, 20, 20, &Atom[3], 0);
}

//set atom to the first pointer
Objects[0] = Atom;

do the rest of the objects

//render the world
void render(float timeDelta)
{
// Render
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
Device->BeginScene();
for(int i = 0; i < 10; i++)
{
  Device->SetMaterial(&Mtrls[i]);
  Device->SetTransform(D3DTS_WORLD, &Worlds[i]);
  Objects[i]->DrawSubset(0);
}
 
Device->EndScene();
}


problem is DrawSubset needs to point to a class/struct/union or generic type. Would there be an easy way to do this?

PARTNERS