Jump to content
  • Advertisement
Sign in to follow this  
Valmian

rotating vertex buffer error

This topic is 5401 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to rotate a crosshair every time a shot is fired. Here is the rendering code:
int CHUD::RenderCrossHair()
{
	if (CBase::m_bLeftMouse)
	{
		m_bCrossrotate=true;
		CLog log;
		log.WriteMessage("Left Mouse Click");
	}
	if (m_bCrossrotate)
	{
		m_dCrossrotate+=2*M_PI/360;
		CLog log;
		log.WriteMessage("Rotation is at point %f",m_dCrossrotate);
	}
	if(m_dCrossrotate>2*M_PI)
	{
		m_dCrossrotate=0;
		m_bCrossrotate=false;
	}
D3DXMATRIX cWorld;
	CBase::m_pDevice->GetTransform(WORLD_MATRIX,&cWorld);
	D3DXMATRIX cRotate;
	
	D3DXMatrixRotationX(&cRotate,m_dCrossrotate);
	
	CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cRotate);
	
	
	if (m_pDevice && m_pCrosshair && m_pCrosshairbuffer)
	{
	
	CBase::m_pDevice->SetTexture(0, m_pCrosshair);
	CBase::m_pDevice->SetStreamSource(0, m_pCrosshairbuffer, 0, sizeof(TransformedVertex_t));
	CBase::m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
	CBase::m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

	}

	CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cWorld);

	return 1;
}
The problem is that it does not rotate My log tells me that my code does detect left click and does change rotation variables but that doesn't influence the crosshair. Thank you in advance, Ilya P.S.: Here is how I created the buffer
if(FAILED(CBase::m_pDevice->CreateVertexBuffer(sizeof(TransformedVertex_t)*6, D3DUSAGE_DYNAMIC,
		D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &m_pCrosshairbuffer, NULL))) {
		return false;
	}

Share this post


Link to post
Share on other sites
Advertisement
D3DFVF_XYZRHW tells D3D "the vertices I'm passing for this draw call have already been transformed so you don't need to apply any transformations to them".

Thus your SetTransform() call has absolutely no effect.


For already transformed vertices (D3DFVF_XYZRHW) you'll need to transform the vertices manually.

Or alternatively use untransformed vertices (D3DFVF_XYZ), with those the SetTransform() call will be applied as expected.

Share this post


Link to post
Share on other sites
Quote:
Original post by Valmian
hm... it stopped rendering the crosshair all together...
If you just changed your vertices to D3DFVF_XYZ then you need to transform the vertices into screen space, and change your vertex format to remove the RHW.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Valmian
hm... it stopped rendering the crosshair all together...
If you just changed your vertices to D3DFVF_XYZ then you need to transform the vertices into screen space, and change your vertex format to remove the RHW.


That's what I am trying to do:

D3DXMATRIX cWorld;
CBase::m_pDevice->GetTransform(WORLD_MATRIX,&cWorld);
D3DXMATRIX cScale,cTranslate,cRotate,cFinal;
D3DXMatrixScaling(&cScale,10,10,10);
D3DXMatrixRotationY(&cRotate,m_dCrossrotate);
D3DXMatrixTranslation(&cTranslate,1,1,4);
cFinal=cRotate*cTranslate*cScale;
CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cFinal);


if (m_pDevice && m_pCrosshair && m_pCrosshairbuffer)
{

CBase::m_pDevice->SetTexture(0, m_pCrosshair);
CBase::m_pDevice->SetStreamSource(0, m_pCrosshairbuffer, 0, sizeof(TransformedVertex_t));
CBase::m_pDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
CBase::m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

}

CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cWorld);

Share this post


Link to post
Share on other sites
Unless you changed your TransformedVertex_t structure, then you'll be passing gibberish to D3D. Its expecting structures in the format {x,y,z,diffuse,tu,tv}, but you're passing it {x,y,z,rhw,diffuse,tu,tv}.
You also need to set up your view and projection matrices if you haven't already done so.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Unless you changed your TransformedVertex_t structure, then you'll be passing gibberish to D3D. Its expecting structures in the format {x,y,z,diffuse,tu,tv}, but you're passing it {x,y,z,rhw,diffuse,tu,tv}.
You also need to set up your view and projection matrices if you haven't already done so.


Changed it to

struct TransformedVertex2_t {
float x;
float y;
float z;
DWORD dDiffuse;
float u;
float v;
};

But it still does not render the crosshair

Share this post


Link to post
Share on other sites
here is all of the code:


---CHud.cpp---


#include "CHud.h"

CHUD::CHUD()
{
m_pCrosshair=NULL;
m_pCrosshairbuffer=NULL;
m_pBar=NULL;
m_pBarbuffer=NULL;
m_pOther=NULL;
m_pOtherbuffer=NULL;
abbababa=0;
m_pKillbuffer=NULL;
m_pHealthbuffer=NULL;
m_dCrossrotate=0;
m_bCrossrotate=false;
}

CHUD::~CHUD()
{

}

int CHUD::RenderCrossHair()
{
if (CBase::m_bLeftMouse)
{
m_bCrossrotate=true;
CLog log;
log.WriteMessage("Left Mouse Click");
}
if (m_bCrossrotate)
{
m_dCrossrotate+=2*M_PI/360;
CLog log;
log.WriteMessage("Rotation is at point %f",m_dCrossrotate);
}
if(m_dCrossrotate>2*M_PI)
{
m_dCrossrotate=0;
m_bCrossrotate=false;
}
D3DXMATRIX cWorld;
CBase::m_pDevice->GetTransform(WORLD_MATRIX,&cWorld);
D3DXMATRIX cScale,cTranslate,cRotate,cFinal;
D3DXMatrixScaling(&cScale,10,10,1);
D3DXMatrixRotationY(&cRotate,m_dCrossrotate);
D3DXMatrixTranslation(&cTranslate,1,1,4);
cFinal=cRotate*cTranslate*cScale;
CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cFinal);


if (m_pDevice && m_pCrosshair && m_pCrosshairbuffer)
{

CBase::m_pDevice->SetTexture(0, m_pCrosshair);
CBase::m_pDevice->SetStreamSource(0, m_pCrosshairbuffer, 0, sizeof(TransformedVertex2_t));
CBase::m_pDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
CBase::m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

}

CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cWorld);

return 1;
}

int CHUD::RenderBar()
{
if (m_pDevice && m_pBar && m_pBarbuffer)
{

CBase::m_pDevice->SetTexture(0, m_pBar);
CBase::m_pDevice->SetStreamSource(0, m_pBarbuffer, 0, sizeof(TransformedVertex_t));
CBase::m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
CBase::m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

}
return 1;
}

int CHUD::RenderOther()
{
if (m_pDevice && m_pOther && m_pOtherbuffer)
{

CBase::m_pDevice->SetTexture(0, m_pOther);
CBase::m_pDevice->SetStreamSource(0, m_pOtherbuffer, 0, sizeof(TransformedVertex_t));
CBase::m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
CBase::m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

}
return 1;
}



int CHUD::RenderHud()
{
KillRatio();
Health();
RenderCrossHair();
RenderBar();
RenderOther();


D3DXMATRIX cWorld;
CBase::m_pDevice->GetTransform(WORLD_MATRIX,&cWorld);
D3DXMATRIX cScale,cTranslate,cRotate,cFinal;
D3DXMatrixScaling(&cScale,0.03,0.03,0.03);
//D3DXMatrixRotationY(&cRotate,M_PI/2);
D3DXMatrixTranslation(&cTranslate,1,1,6);
cFinal=cTranslate*cScale;
CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cFinal);
m_tWireframe.RenderModel(WIREFRAME_RENDER);
// m_tWireframe.RenderModel(REGULAR_RENDER);
CBase::m_pDevice->SetTransform(WORLD_MATRIX,&cWorld);


return 1;
}



int CHUD::LoadCrossHair()
{
D3DVIEWPORT9 tViewport;
CBase::m_pDevice->GetViewport(&tViewport);

float fX=0.49;
float fY=0.49/(float)tViewport.Height*(float)tViewport.Width-.23;
float fX2=0.51;
float fY2=0.51/(float)tViewport.Height*(float)tViewport.Width-.23;
int iX, iY, iX2, iY2;

if(FAILED(D3DXCreateTextureFromFile(CBase::m_pDevice, m_szCrosshair, &m_pCrosshair))) {
CLog log;
log.WriteMessage("Could not load %s", m_szCrosshair);
return false;
}

iX = (int)(((float)tViewport.Width) * fX);
iX2 = (int)(((float)tViewport.Width) * fX2);
iY = (int)(((float)tViewport.Height) * fY);
iY2 = (int)(((float)tViewport.Height) * fY2);
m_iX = iX;
m_iY = iY;
m_iX2 = iX2;
m_iY2 = iY2;
if(FAILED(CBase::m_pDevice->CreateVertexBuffer(sizeof(TransformedVertex2_t)*6, D3DUSAGE_DYNAMIC,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &m_pCrosshairbuffer, NULL))) {
return false;
}

TransformedVertex2_t *pVertices;
if(FAILED(m_pCrosshairbuffer->Lock(0, 0, (void **)&pVertices, 0))) {
return false;
}
pVertices[0].x = (float)(iX);
pVertices[0].y = (float)(iY);
pVertices[0].z = 0.5f;
pVertices[0].u = 0.0f;
pVertices[0].v = 0.0f;


pVertices[1].x = (float)(iX2);
pVertices[1].y = (float)(iY);
pVertices[1].z = 0.5f;
pVertices[1].u = 1.0f;
pVertices[1].v = 0.0f;


pVertices[2].x = (float)(iX);
pVertices[2].y = (float)(iY2);
pVertices[2].z = 0.5f;
pVertices[2].u = 0.0f;
pVertices[2].v = 1.0f;


pVertices[3].x = (float)(iX);
pVertices[3].y = (float)(iY2);
pVertices[3].z = 0.5f;
pVertices[3].u = 0.0f;
pVertices[3].v = 1.0f;


pVertices[4].x = (float)(iX2);
pVertices[4].y = (float)(iY);
pVertices[4].z = 0.5f;
pVertices[4].u = 1.0f;
pVertices[4].v = 0.0f;


pVertices[5].x = (float)(iX2);
pVertices[5].y = (float)(iY2);
pVertices[5].z = 0.5f;
pVertices[5].u = 1.0f;
pVertices[5].v = 1.0f;


for(int i=0; i<6; i++) {

pVertices.dDiffuse = D3DCOLOR_XRGB(255, 255, 255);
}
if(FAILED(m_pCrosshairbuffer->Unlock())) {
return -10;
}

}

int CHUD::LoadBar()
{
D3DVIEWPORT9 tViewport;
CBase::m_pDevice->GetViewport(&tViewport);

float fX=.85;
float fY=0.78;
float fX2=1;
float fY2=.95;
int iX, iY, iX2, iY2;

if(FAILED(D3DXCreateTextureFromFile(CBase::m_pDevice, m_szBar, &m_pBar))) {
CLog log;
log.WriteMessage("Could not load %s", m_szBar);
return false;
}

iX = (int)(((float)tViewport.Width) * fX);
iX2 = (int)(((float)tViewport.Width) * fX2);
iY = (int)(((float)tViewport.Height) * fY);
iY2 = (int)(((float)tViewport.Height) * fY2);
m_iX = iX;
m_iY = iY;
m_iX2 = iX2;
m_iY2 = iY2;
if(FAILED(CBase::m_pDevice->CreateVertexBuffer(sizeof(TransformedVertex_t)*6, 0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &m_pBarbuffer, NULL))) {
return false;
}
TransformedVertex_t *pVertices;
if(FAILED(m_pBarbuffer->Lock(0, 0, (void **)&pVertices, 0))) {
return false;
}
pVertices[0].x = (float)(iX);
pVertices[0].y = (float)(iY);
pVertices[0].z = 0.5f;
pVertices[0].u = 0.0f;
pVertices[0].v = 0.0f;


pVertices[1].x = (float)(iX2);
pVertices[1].y = (float)(iY);
pVertices[1].z = 0.5f;
pVertices[1].u = 1.0f;
pVertices[1].v = 0.0f;


pVertices[2].x = (float)(iX);
pVertices[2].y = (float)(iY2);
pVertices[2].z = 0.5f;
pVertices[2].u = 0.0f;
pVertices[2].v = 1.0f;


pVertices[3].x = (float)(iX);
pVertices[3].y = (float)(iY2);
pVertices[3].z = 0.5f;
pVertices[3].u = 0.0f;
pVertices[3].v = 1.0f;


pVertices[4].x = (float)(iX2);
pVertices[4].y = (float)(iY);
pVertices[4].z = 0.5f;
pVertices[4].u = 1.0f;
pVertices[4].v = 0.0f;


pVertices[5].x = (float)(iX2);
pVertices[5].y = (float)(iY2);
pVertices[5].z = 0.5f;
pVertices[5].u = 1.0f;
pVertices[5].v = 1.0f;


for(int i=0; i<6; i++) {
pVertices.w = 1.0;
pVertices.dDiffuse = D3DCOLOR_XRGB(255, 255, 255);
}
if(FAILED(m_pBarbuffer->Unlock())) {
return -10;
}

}
int CHUD::KillRatio()
{

D3DVIEWPORT9 tViewport;
CBase::m_pDevice->GetViewport(&tViewport);
if (abbababa<MAX_HP)
abbababa++;


float fX=0.89;
float fY=-.15+.94;

float fX2=0.92;
float fY2=.94;
int iX, iY, iX2, iY2;


iX = (int)(((float)tViewport.Width) * fX);
iX2 = (int)(((float)tViewport.Width) * fX2);
iY = (int)(((float)tViewport.Height) * fY);
iY2 = (int)(((float)tViewport.Height) * fY2);
m_iX = iX;
m_iY = iY;
m_iX2 = iX2;
m_iY2 = iY2;
if(FAILED(CBase::m_pDevice->CreateVertexBuffer(sizeof(TransformedVertex_t)*6, D3DPOOL_DEFAULT,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &m_pKillbuffer, NULL))) {
return false;
}
TransformedVertex_t *pVertices;
if(FAILED(m_pKillbuffer->Lock(0, 0, (void **)&pVertices, 0))) {
return false;
}
pVertices[0].x = (float)(iX);
pVertices[0].y = (float)(iY);
pVertices[0].z = 0.5f;
pVertices[0].u = 0.0f;
pVertices[0].v = 0.0f;


pVertices[1].x = (float)(iX2);
pVertices[1].y = (float)(iY);
pVertices[1].z = 0.5f;
pVertices[1].u = 1.0f;
pVertices[1].v = 0.0f;


pVertices[2].x = (float)(iX);
pVertices[2].y = (float)(iY2);
pVertices[2].z = 0.5f;
pVertices[2].u = 0.0f;
pVertices[2].v = 1.0f;


pVertices[3].x = (float)(iX);
pVertices[3].y = (float)(iY2);
pVertices[3].z = 0.5f;
pVertices[3].u = 0.0f;
pVertices[3].v = 1.0f;


pVertices[4].x = (float)(iX2);
pVertices[4].y = (float)(iY);
pVertices[4].z = 0.5f;
pVertices[4].u = 1.0f;
pVertices[4].v = 0.0f;


pVertices[5].x = (float)(iX2);
pVertices[5].y = (float)(iY2);
pVertices[5].z = 0.5f;
pVertices[5].u = 1.0f;
pVertices[5].v = 1.0f;


for(int i=0; i<6; i++) {
pVertices.w = 1.0;
pVertices.dDiffuse = D3DCOLOR_XRGB(255, 0, 0);
}
if(FAILED(m_pKillbuffer->Unlock())) {
return -10;
}

if (m_pDevice && m_pKillbuffer)
{

CBase::m_pDevice->SetTexture(0,NULL);
CBase::m_pDevice->SetStreamSource(0, m_pKillbuffer, 0, sizeof(TransformedVertex_t));
CBase::m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
CBase::m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

}

}

int CHUD::Health()
{

D3DVIEWPORT9 tViewport;
CBase::m_pDevice->GetViewport(&tViewport);
if (abbababa<MAX_HP)
abbababa++;


float fX=0.86;
float fY=-.15*(abbababa)/MAX_HP+.94;

float fX2=0.89;
float fY2=.94;
int iX, iY, iX2, iY2;


iX = (int)(((float)tViewport.Width) * fX);
iX2 = (int)(((float)tViewport.Width) * fX2);
iY = (int)(((float)tViewport.Height) * fY);
iY2 = (int)(((float)tViewport.Height) * fY2);
m_iX = iX;
m_iY = iY;
m_iX2 = iX2;
m_iY2 = iY2;
if(FAILED(CBase::m_pDevice->CreateVertexBuffer(sizeof(TransformedVertex_t)*6, D3DUSAGE_DYNAMIC,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &m_pHealthbuffer, NULL))) {
return false;
}
TransformedVertex_t *pVertices;
if(FAILED(m_pHealthbuffer->Lock(0, 0, (void **)&pVertices, 0))) {
return false;
}
pVertices[0].x = (float)(iX);
pVertices[0].y = (float)(iY);
pVertices[0].z = 0.5f;
pVertices[0].u = 0.0f;
pVertices[0].v = 0.0f;


pVertices[1].x = (float)(iX2);
pVertices[1].y = (float)(iY);
pVertices[1].z = 0.5f;
pVertices[1].u = 1.0f;
pVertices[1].v = 0.0f;


pVertices[2].x = (float)(iX);
pVertices[2].y = (float)(iY2);
pVertices[2].z = 0.5f;
pVertices[2].u = 0.0f;
pVertices[2].v = 1.0f;


pVertices[3].x = (float)(iX);
pVertices[3].y = (float)(iY2);
pVertices[3].z = 0.5f;
pVertices[3].u = 0.0f;
pVertices[3].v = 1.0f;


pVertices[4].x = (float)(iX2);
pVertices[4].y = (float)(iY);
pVertices[4].z = 0.5f;
pVertices[4].u = 1.0f;
pVertices[4].v = 0.0f;


pVertices[5].x = (float)(iX2);
pVertices[5].y = (float)(iY2);
pVertices[5].z = 0.5f;
pVertices[5].u = 1.0f;
pVertices[5].v = 1.0f;


for(int i=0; i<6; i++) {
pVertices.w = 1.0;
pVertices.dDiffuse = D3DCOLOR_XRGB((int)((1.0-(float)abbababa/MAX_HP)*255), (int)((float)abbababa/MAX_HP*255), 0);
}
if(FAILED(m_pHealthbuffer->Unlock())) {
return -10;
}

if (m_pDevice && m_pHealthbuffer)
{

CBase::m_pDevice->SetTexture(0,NULL);
CBase::m_pDevice->SetStreamSource(0, m_pHealthbuffer, 0, sizeof(TransformedVertex_t));
CBase::m_pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
CBase::m_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

}

}

int CHUD::LoadOther()
{
D3DVIEWPORT9 tViewport;
CBase::m_pDevice->GetViewport(&tViewport);

float fX=0.0;
float fY=1;
float fX2=.25;
float fY2=.7;
int iX, iY, iX2, iY2;

if(FAILED(D3DXCreateTextureFromFile(CBase::m_pDevice, m_szOther, &m_pOther))) {
CLog log;
log.WriteMessage("Could not load %s", m_szOther);
return false;
}

iX = (int)(((float)tViewport.Width) * fX);
iX2 = (int)(((float)tViewport.Width) * fX2);
iY = (int)(((float)tViewport.Height) * fY);
iY2 = (int)(((float)tViewport.Height) * fY2);
m_iX = iX;
m_iY = iY;
m_iX2 = iX2;
m_iY2 = iY2;
if(FAILED(CBase::m_pDevice->CreateVertexBuffer(sizeof(TransformedVertex_t)*6, 0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, D3DPOOL_DEFAULT, &m_pOtherbuffer, NULL))) {
return false;
}
TransformedVertex_t *pVertices;
if(FAILED(m_pOtherbuffer->Lock(0, 0, (void **)&pVertices, 0))) {
return false;
}
pVertices[0].x = (float)(iX);
pVertices[0].y = (float)(iY);
pVertices[0].z = 0.5f;
pVertices[0].u = 0.0f;
pVertices[0].v = 0.0f;


pVertices[1].x = (float)(iX2);
pVertices[1].y = (float)(iY);
pVertices[1].z = 0.5f;
pVertices[1].u = 1.0f;
pVertices[1].v = 0.0f;


pVertices[2].x = (float)(iX);
pVertices[2].y = (float)(iY2);
pVertices[2].z = 0.5f;
pVertices[2].u = 0.0f;
pVertices[2].v = 1.0f;


pVertices[3].x = (float)(iX);
pVertices[3].y = (float)(iY2);
pVertices[3].z = 0.5f;
pVertices[3].u = 0.0f;
pVertices[3].v = 1.0f;


pVertices[4].x = (float)(iX2);
pVertices[4].y = (float)(iY);
pVertices[4].z = 0.5f;
pVertices[4].u = 1.0f;
pVertices[4].v = 0.0f;


pVertices[5].x = (float)(iX2);
pVertices[5].y = (float)(iY2);
pVertices[5].z = 0.5f;
pVertices[5].u = 1.0f;
pVertices[5].v = 1.0f;


for(int i=0; i<6; i++) {
pVertices.w = 1.0;
pVertices.dDiffuse = D3DCOLOR_XRGB(255, 255, 255);
}
if(FAILED(m_pOtherbuffer->Unlock())) {
return -10;
}

}

int CHUD::LoadHud(char *szHudImagesFile)
{



memset(m_szCrosshair,0,64);
memset(m_szBar,0,64);
memset(m_szOther,0,64);
FILE *fin=fopen(szHudImagesFile,"r");
if (!fin)
{
CLog tlog;
tlog.WriteMessage("Cannot open %s to load hud data",szHudImagesFile);
return -1;
}

if(!fgets(m_szCrosshair,64,fin))
{
CLog tlog;
tlog.WriteMessage("Cannot load crosshair image filename from %s",szHudImagesFile);
return -2;
}
m_szCrosshair[strlen(m_szCrosshair)-1]=0;
if(!fgets(m_szBar,64,fin))
{
CLog tlog;
tlog.WriteMessage("Cannot load szBar image filename from %s",szHudImagesFile);
return -3;
}
m_szBar[strlen(m_szBar)-1]=0;
if(!fgets(m_szOther,64,fin))
{
CLog tlog;
tlog.WriteMessage("Cannot load szOther image filename from %s",szHudImagesFile);
return -4;
}

fclose (fin);
LoadCrossHair();
LoadBar();
LoadOther();
m_tWireframe.LoadModel("galper fighter textureless.X");


return 1;

}

---CHud.h---

#ifndef __CHUD__
#define __CHUD__

#include "CScene.h"
#include "C2DFont.h"
#include "CLog.h"
#include "CModel.h"

#define MAX_HP 1000.0

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif



class CHUD : public CObject {
public:
CHUD();
~CHUD();

int LoadHud(char *szHudImagesFile);
int RenderHud();

private:

int LoadCrossHair();
int LoadBar();
int LoadOther();
int RenderCrossHair();
int RenderBar();
int RenderOther();
int KillRatio();
int Health();

char m_szCrosshair[64];
char m_szBar[64];
char m_szOther[64];

int abbababa;
double m_dCrossrotate;
bool m_bCrossrotate;
CModel m_tWireframe;
IDirect3DVertexBuffer9 *m_pCrosshairbuffer;
IDirect3DVertexBuffer9 *m_pKillbuffer;
IDirect3DVertexBuffer9 *m_pHealthbuffer;
IDirect3DTexture9 *m_pCrosshair;
IDirect3DVertexBuffer9 *m_pBarbuffer;
IDirect3DTexture9 *m_pBar;
IDirect3DVertexBuffer9 *m_pOtherbuffer;
IDirect3DTexture9 *m_pOther;
int m_iX;
int m_iY;
int m_iX2;
int m_iY2;

};
#endif

--VertecFromats.h---

#ifndef __VERTEXFORMATS__
#define __VERTEXFORMATS__

struct Vertex_t {
float x;
float y;
float z;
};

struct ColorVertex_t {
float x;
float y;
float z;
DWORD dDiffuse;
};

struct TextureVertex_t {
float x;
float y;
float z;
DWORD dDiffuse;
float u;
float v;
};

struct ColorVertexW_t {
float x;
float y;
float z;
float w;
DWORD dDiffuse;
};

struct TransformedVertex_t {
float x;
float y;
float z;
float w;
DWORD dDiffuse;
float u;
float v;
};

struct TransformedVertex2_t {
float x;
float y;
float z;
DWORD dDiffuse;
float u;
float v;
};

#endif


Ilya

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!