本文整理匯總了C++中D3DXVECTOR2函數的典型用法代碼示例。如果您正苦於以下問題:C++ D3DXVECTOR2函數的具體用法?C++ D3DXVECTOR2怎麽用?C++ D3DXVECTOR2使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了D3DXVECTOR2函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: D3DXVECTOR2
// Author : masato masuda
//
//*****************************************************************************
//*****************************************************************************
// include
//*****************************************************************************
#include "sprite_smooth.h"
#include "render/sprite.h"
#include "system/system.h"
#include "system/directx9/texture/texture.h"
//*****************************************************************************
// constant definition
//*****************************************************************************
const D3DXVECTOR2 SpriteSmooth::DEFAULT_POSITION = D3DXVECTOR2(0.0f, 0.0f);
const D3DXVECTOR2 SpriteSmooth::DEFAULT_SIZE = D3DXVECTOR2(0.0f, 0.0f);
const D3DXVECTOR2 CLEAR_VECTOR2 = D3DXVECTOR2(0.0f, 0.0f);
const D3DXCOLOR CLEAR_COLOR = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
const f32 HALF_PI = D3DX_PI / 2.0f;
//=============================================================================
// constructor
//=============================================================================
SpriteSmooth::SpriteSmooth(void)
:sprite_(nullptr)
,dest_frame_(0)
,now_frame_(0)
,is_move_(false)
示例2: CreateFile
HRESULT Engine::CTerrainTex::Create_Buffer(const _ushort& wCntX, const _ushort& wCntZ, const _ushort& wItv)
{
HANDLE hFile;
_ulong dwByte;
hFile = CreateFile(L"../Resource/Texture/StageScene/Terrain/Height.bmp", GENERIC_READ, 0
, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
BITMAPFILEHEADER fh;
BITMAPINFOHEADER ih;
ReadFile(hFile, &fh, sizeof(fh), &dwByte, NULL);
ReadFile(hFile, &ih, sizeof(ih), &dwByte, NULL);
_ulong* pdwPixel = new _ulong[ih.biWidth * ih.biHeight];
ReadFile(hFile, pdwPixel, sizeof(_ulong) * ih.biWidth * ih.biHeight, &dwByte, NULL);
CloseHandle(hFile);
m_dwVtxSize = sizeof(VTXTEX);
m_dwVtxCnt = wCntX * wCntZ ;
m_dwVtxFVF = VTXFVF_TEX;
m_dwIdxSize = sizeof(INDEX16);
m_IdxFmt = D3DFMT_INDEX16;
m_dwTriCnt = (wCntX - 1) * (wCntZ - 1) * 2;
FAILED_CHECK(CVIBuffer::Create_Buffer());
VTXTEX* pVtxTex = NULL;
m_pVB->Lock(0, 0, (void**)&pVtxTex, 0);
int iIndex = NULL;
for(int z = 0; z < wCntZ; ++z)
{
for(int x = 0; x < wCntX; ++x)
{
iIndex = z * wCntX + x;
pVtxTex[iIndex].vPos = D3DXVECTOR3(
float(x) * wItv ,
(pdwPixel[iIndex] & 0x000000ff) / 5.f ,
float(z) * wItv);
pVtxTex[iIndex].vNormal = D3DXVECTOR3(0.f, 0.f, 0.f);
pVtxTex[iIndex].vTexUV = D3DXVECTOR2( x / (wCntX - 1.f), z / (wCntZ - 1.f) );
}
}
INDEX16* pIndex = NULL;
m_pIB->Lock(0, 0, (void**)&pIndex, 0);
int iTriCnt = 0;
for(int z = 0; z < wCntZ - 1; ++z)
{
for(int x = 0; x < wCntX - 1; ++x)
{
iIndex = z * wCntX + x;
pIndex[iTriCnt]._1 = iIndex + wCntX; //1-2
pIndex[iTriCnt]._2 = iIndex + wCntX + 1; // \|
pIndex[iTriCnt]._3 = iIndex + 1; // 3
D3DXVECTOR3 vDest, vSour, vNormal;
vDest = pVtxTex[ pIndex[iTriCnt]._2 ].vPos - pVtxTex[ pIndex[iTriCnt]._1 ].vPos;
vSour = pVtxTex[ pIndex[iTriCnt]._3 ].vPos - pVtxTex[ pIndex[iTriCnt]._2 ].vPos;
D3DXVec3Cross(&vNormal, &vDest, &vSour);
pVtxTex[ pIndex[iTriCnt]._1 ].vNormal += vNormal;
pVtxTex[ pIndex[iTriCnt]._2 ].vNormal += vNormal;
pVtxTex[ pIndex[iTriCnt]._3 ].vNormal += vNormal;
++iTriCnt;
pIndex[iTriCnt]._1 = iIndex + wCntX;
pIndex[iTriCnt]._2 = iIndex + 1;
pIndex[iTriCnt]._3 = iIndex;
vDest = pVtxTex[ pIndex[iTriCnt]._2 ].vPos - pVtxTex[ pIndex[iTriCnt]._1 ].vPos;
vSour = pVtxTex[ pIndex[iTriCnt]._3 ].vPos - pVtxTex[ pIndex[iTriCnt]._2 ].vPos;
D3DXVec3Cross(&vNormal, &vDest, &vSour);
pVtxTex[ pIndex[iTriCnt]._1 ].vNormal += vNormal;
pVtxTex[ pIndex[iTriCnt]._2 ].vNormal += vNormal;
pVtxTex[ pIndex[iTriCnt]._3 ].vNormal += vNormal;
++iTriCnt;
}
}
for(_ushort i = 0; i < m_dwVtxCnt; ++i)
{
D3DXVec3Normalize(&pVtxTex[i].vNormal, &pVtxTex[i].vNormal);
}
m_pVB->Unlock();
m_pIB->Unlock();
Engine::Safe_Delete_Array(pdwPixel);
return S_OK;
}
示例3: D3DXVECTOR3
void InBuilding::build(float w, float h, float d){
VertexPNTList vertices;
VertexPNT v;
float width = w;
float height = h;
float depth = d;
float thrirdwidth = w/3;
float twothirdwidth = (2*w)/3;
float twothirdheight = (2*h)/3;
//Front
v.normal = D3DXVECTOR3( 0.0f, 0.0f, -1.0f);
v.pos = D3DXVECTOR3(0.1f, 0.1f, 0.1f);
v.texC = D3DXVECTOR2(0.0,0.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(0.1f, height, 0.1f);
v.texC = D3DXVECTOR2(0.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(thrirdwidth, height, 0.1f);
v.texC = D3DXVECTOR2(0.4,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(thrirdwidth, 0.1f, 0.1f);
v.texC = D3DXVECTOR2(0.4,0.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(thrirdwidth, twothirdheight, 0.1f);
v.texC = D3DXVECTOR2(0.4,0.7);
vertices.push_back(v);
v.pos = D3DXVECTOR3(twothirdwidth, twothirdheight, 0.1f);
v.texC = D3DXVECTOR2(0.8,0.7);
vertices.push_back(v);
v.pos = D3DXVECTOR3(twothirdwidth, height, 0.1f);
v.texC = D3DXVECTOR2(0.8,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, height, 0.1f);
v.texC = D3DXVECTOR2(1.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, 0.1f, 0.1f);
v.texC = D3DXVECTOR2(1.0,0.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(twothirdwidth, 0.1f, 0.1f);
v.texC = D3DXVECTOR2(0.8,0.0);
vertices.push_back(v);
//Left Face
v.normal = D3DXVECTOR3( -1.0f, 0.0f, 0.0f);
v.pos = D3DXVECTOR3(0.1f, 0.1f, 0.1f);
v.texC = D3DXVECTOR2(0.0,0.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(0.1f, height, 0.1f);
v.texC = D3DXVECTOR2(0.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(0.1f, height, depth);
v.texC = D3DXVECTOR2(1.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(0.1f, 0.1f, depth);
v.texC = D3DXVECTOR2(1.0,0.0);
vertices.push_back(v);
//Top
v.normal = D3DXVECTOR3( 0.0f, 1.0f, 0.0f);
v.pos = D3DXVECTOR3(0.1f, height, 0.1f);
v.texC = D3DXVECTOR2(0.0,0.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(0.1f, height, depth);
v.texC = D3DXVECTOR2(0.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, height, depth);
v.texC = D3DXVECTOR2(1.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, height, 0.1f);
v.texC = D3DXVECTOR2(1.0,0.0);
vertices.push_back(v);
//Right
v.normal = D3DXVECTOR3( 1.0f, 0.0f, 0.0f);
v.pos = D3DXVECTOR3(width, 0.1f, 0.1f);
v.texC = D3DXVECTOR2(0.0,0.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, 0.1f, depth);
v.texC = D3DXVECTOR2(0.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, height, depth);
v.texC = D3DXVECTOR2(1.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, height, 0.1f);
v.texC = D3DXVECTOR2(1.0,0.0);
vertices.push_back(v);
//Bottom
v.normal = D3DXVECTOR3( 0.0f, -1.0f, 0.0f);
v.pos = D3DXVECTOR3(0.1f, 0.1f, 0.1f);
v.texC = D3DXVECTOR2(0.0,0.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(0.1f, 0.1f, depth);
v.texC = D3DXVECTOR2(0.0,1.0);
vertices.push_back(v);
v.pos = D3DXVECTOR3(width, 0.1f, depth);
v.texC = D3DXVECTOR2(1.0,1.0);
vertices.push_back(v);
//.........這裏部分代碼省略.........
示例4: D3DXVECTOR3
bool ModelClass::InitializeBuffers(ID3D11Device* device)
{
VertexType* vertices;
unsigned long* indices;
D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
D3D11_SUBRESOURCE_DATA vertexData, indexData;
HRESULT result;
// Set the number of vertices in the vertex array.
m_vertexCount = 3;
// Set the number of indices in the index array.
m_indexCount = 3;
// Create the vertex array.
vertices = new VertexType[m_vertexCount];
if(!vertices)
{
return false;
}
// Create the index array.
indices = new unsigned long[m_indexCount];
if(!indices)
{
return false;
}
// Load the vertex array with data.
vertices[0].position = D3DXVECTOR3(-1.0f, -1.0f, 0.0f); // Bottom left.
vertices[0].texture = D3DXVECTOR2(0.0f, 1.0f);
vertices[1].position = D3DXVECTOR3(0.0f, 1.0f, 0.0f); // Top middle.
vertices[1].texture = D3DXVECTOR2(0.5f, 0.0f);
vertices[2].position = D3DXVECTOR3(1.0f, -1.0f, 0.0f); // Bottom right.
vertices[2].texture = D3DXVECTOR2(1.0f, 1.0f);
// Load the index array with data.
indices[0] = 0; // Bottom left.
indices[1] = 1; // Top middle.
indices[2] = 2; // Bottom right.
// Set up the description of the static vertex buffer.
vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(VertexType) * m_vertexCount;
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;
vertexBufferDesc.StructureByteStride = 0;
// Give the subresource structure a pointer to the vertex data.
vertexData.pSysMem = vertices;
vertexData.SysMemPitch = 0;
vertexData.SysMemSlicePitch = 0;
// Now create the vertex buffer.
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
if(FAILED(result))
{
return false;
}
// Set up the description of the static index buffer.
indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(unsigned long) * m_indexCount;
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
indexBufferDesc.StructureByteStride = 0;
// Give the subresource structure a pointer to the index data.
indexData.pSysMem = indices;
indexData.SysMemPitch = 0;
indexData.SysMemSlicePitch = 0;
// Create the index buffer.
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
if(FAILED(result))
{
return false;
}
// Release the arrays now that the vertex and index buffers have been created and loaded.
delete [] vertices;
vertices = 0;
delete [] indices;
indices = 0;
return true;
}
示例5: D3DXVECTOR2
void Warlock::Intro()
{
float x = this->mGe->GetEngineParameters().windowWidth * 0.5f - this->mGe->GetEngineParameters().windowWidth * 0.2125f;
float y = this->mGe->GetEngineParameters().windowHeight * 0.4f;
Text* intro = mGe->CreateText("Warlock", D3DXVECTOR2(x, y), 2.0f, "Media/Fonts/1");
mGe->LoadingScreen("Media/LoadingScreen/LoadingScreenBG.png", "Media/LoadingScreen/LoadingScreenPB.png", 0.0f, 1.0f, 1.0f, 1.0f); // Changed by MaloW
intro->SetText("");
mGe->DeleteText(intro);
float width = GetGraphicsEngine()->GetEngineParameters().windowWidth;
float height = GetGraphicsEngine()->GetEngineParameters().windowHeight;
/* Set hud */
this->mHud[0] = NULL;
this->mHud[1] = NULL;
this->mHud[2] = NULL;
this->mHud[3] = NULL;
this->mHud[4] = NULL;
this->mHud[5] = NULL;
this->mHud[6] = NULL;
this->mHud[7] = NULL;
this->mHud[8] = NULL;
this->mHud[9] = NULL;
this->mHud[10] = NULL;
// Rework ScreenWidth to 4:3
const float UISCALE = 0.5f;
float screenHeight = this->mGe->GetEngineParameters().windowHeight;
float screenWidth = (screenHeight * 4) / 3;
float distX = (mGe->GetEngineParameters().windowWidth - screenWidth) / 2;
distX /= UISCALE;
D3DXVECTOR2 imgDim = D3DXVECTOR2(screenWidth / 5, screenWidth / 5) * UISCALE;
distX = (this->mGe->GetEngineParameters().windowWidth / 2.0f) - ((imgDim.x * 5.0f) / 2.0f);
for(int i = 11; i < 16; i++)
{
this->mHud[i] = mGe->CreateText("",D3DXVECTOR2(distX + imgDim.x * (i-11) + (imgDim.x * 0.2f), screenHeight - imgDim.y * 0.65f), 1.0f, "Media/Fonts/1");
}
this->mHud[16] = NULL;
this->mProgressBars = new ProgressBar*[6];
float percentX = 0.02f;
float percentY = 0.88f;
for(int i = 0; i<5;i++)
{
D3DXVECTOR2 temp = D3DXVECTOR2(percentX,percentY);
this->mProgressBars[i] = new ProgressBar(distX + imgDim.x * i, screenHeight - imgDim.y - (screenHeight * 0.03f), imgDim.x, (screenHeight * 0.03f));
this->mProgressBars[i]->SetPercentOfProgressBarColor1(0.0f);
this->mProgressBars[i]->SetPercentOfProgressBarColor2(0.0f);
this->mProgressBars[i]->SetPercentOfProgressBarColor3(0.0f);
this->mProgressBars[i]->SetPercentOfProgressBarColor4(0.0f);
percentX = percentX + 0.16f;
}
D3DXVECTOR2 temp = D3DXVECTOR2(percentX,percentY);
this->mProgressBars[5] = new ProgressBar(distX, screenHeight - imgDim.y - (screenHeight * 0.08f) , imgDim.x * 5.0f, (screenHeight * 0.05f));
this->mProgressBars[5]->SetPercentOfProgressBarColor1(0.0f);
this->mProgressBars[5]->SetPercentOfProgressBarColor2(0.0f);
this->mProgressBars[5]->SetPercentOfProgressBarColor3(0.0f);
this->mProgressBars[5]->SetPercentOfProgressBarColor4(0.0f);
percentX = percentX + 0.16f;
this->mTimeElapsedText = this->mGe->CreateText( "", D3DXVECTOR2(15.0f, 10.0f), 1.0f, "Media/Fonts/1");
// Add spell Icons
Image* charge = mGe->CreateImage(D3DXVECTOR2(distX, screenHeight - imgDim.y), imgDim, "Media/WarlockUI/ChargeIcon.png");
Image* sprint = mGe->CreateImage(D3DXVECTOR2(distX + imgDim.x, screenHeight - imgDim.y), imgDim, "Media/WarlockUI/SprintIcon.png");
Image* harden = mGe->CreateImage(D3DXVECTOR2(distX + imgDim.x * 2, screenHeight - imgDim.y), imgDim, "Media/WarlockUI/HardenIcon.png");
Image* invis = mGe->CreateImage(D3DXVECTOR2(distX + imgDim.x * 3, screenHeight - imgDim.y), imgDim, "Media/WarlockUI/InvisIcon.png");
Image* jump = mGe->CreateImage(D3DXVECTOR2(distX + imgDim.x * 4, screenHeight - imgDim.y), imgDim, "Media/WarlockUI/JumpIcon.png");
this->SpellIcons.add(charge);
this->SpellIcons.add(sprint);
this->SpellIcons.add(harden);
this->SpellIcons.add(invis);
this->SpellIcons.add(jump);
}
示例6: D3DXVECTOR3
bool Model::InitBuffers(ID3D11Device* device)
{
Vertex* vertices;
unsigned long* indices;
D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
D3D11_SUBRESOURCE_DATA vertexData, indexData;
HRESULT result;
int i; //new to 0.6 for counter
// Create vertex array.
vertices = new Vertex[_vertexCount]; // longer set to 3. new to 0.6
// Create index array.
indices = new unsigned long[_indexCount]; // longer set to 3. new to 0.6
// Load vertex array and index array with data. new to 0.6
for(i=0; i<_vertexCount; i++)
{
vertices[i].position = D3DXVECTOR3(_model[i].x+20, _model[i].y, _model[i].z+60);
vertices[i].texture = D3DXVECTOR2(_model[i].tu, _model[i].tv);
vertices[i].normal = D3DXVECTOR3(_model[i].nx, _model[i].ny, _model[i].nz);
indices[i] = i;
}
// Set up description of static vertex buffer.
vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(Vertex) * _vertexCount;
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;
vertexBufferDesc.StructureByteStride = 0;
// Give subresource structure a pointer to vertex data.
vertexData.pSysMem = vertices;
vertexData.SysMemPitch = 0;
vertexData.SysMemSlicePitch = 0;
// Now create vertex buffer.
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &_vertexBuffer);
if(FAILED(result))
{
return false;
}
// Set up description of static index buffer.
indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(unsigned long) * _indexCount;
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
indexBufferDesc.StructureByteStride = 0;
// Give subresource structure a pointer to index data.
indexData.pSysMem = indices;
indexData.SysMemPitch = 0;
indexData.SysMemSlicePitch = 0;
// Create index buffer.
result = device->CreateBuffer(&indexBufferDesc, &indexData, &_indexBuffer);
if(FAILED(result))
{
return false;
}
//once ind and vert buffers been created arrays no longer needed as data in buffers
// Release arrays now that vertex and index buffers have been created and loaded.
delete [] vertices;
vertices = 0;
delete [] indices;
indices = 0;
return true;
}
示例7: D3DXVECTOR3
bool ModelClass::InitializeBuffers(ID3D10Device* device)
{
VertexType* vertices;
unsigned long* indices;
D3D10_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
D3D10_SUBRESOURCE_DATA vertexData, indexData;
HRESULT result;
int i;
// Create the vertex array.
vertices = new VertexType[m_vertexCount];
if(!vertices)
{
return false;
}
// Create the index array.
indices = new unsigned long[m_indexCount];
if(!indices)
{
return false;
}
// Load the vertex array and index array with data.
for(i=0; i<m_vertexCount; i++)
{
vertices[i].position = D3DXVECTOR3(m_model[i].x, m_model[i].y, m_model[i].z);
vertices[i].texture = D3DXVECTOR2(m_model[i].tu, m_model[i].tv);
indices[i] = i;
}
// Set up the description of the vertex buffer.
vertexBufferDesc.Usage = D3D10_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(VertexType) * m_vertexCount;
vertexBufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;
// Give the subresource structure a pointer to the vertex data.
vertexData.pSysMem = vertices;
// Now finally create the vertex buffer.
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
if(FAILED(result))
{
return false;
}
// Set up the description of the index buffer.
indexBufferDesc.Usage = D3D10_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(unsigned long) * m_indexCount;
indexBufferDesc.BindFlags = D3D10_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
// Give the subresource structure a pointer to the index data.
indexData.pSysMem = indices;
// Create the index buffer.
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
if(FAILED(result))
{
return false;
}
// Release the arrays now that the vertex and index buffers have been created and loaded.
delete [] vertices;
vertices = 0;
delete [] indices;
indices = 0;
return true;
}
示例8: chainDir
void ElBillboardChain::_setupVertices(ElCamera* cam)
{
D3DXVECTOR3 chainDir(0.0f, 0.0f, 0.0f);
if (!mChainElementList.empty())
chainDir = mChainElementList.back().position - mChainElementList.begin()->position;
int numElements = (int)mChainElementList.size();
int lastElement = numElements - 1;
for (int i = 0; i < numElements; ++i)
{
Element prevElement, nextElement;
if (i != lastElement)
{
prevElement = mChainElementList[i];
nextElement = mChainElementList[i + 1];
}
else if (i != 0)
{
prevElement = mChainElementList[i - 1];
nextElement = mChainElementList[i];
}
else
{
prevElement = nextElement = mChainElementList[i];
}
D3DXVECTOR3 segmentDir;
if (mUseChainDirection)
segmentDir = chainDir;
else
segmentDir = nextElement.position - prevElement.position;
D3DXVECTOR3 lookAt(0.0f, 0.0f, 1.0f);
if (cam)
lookAt = -cam->getDirection();
D3DXVECTOR3 strechDir;
D3DXVec3Cross(&strechDir, &lookAt, &segmentDir);
D3DXVec3Normalize(&strechDir, &strechDir);
// each element can be extended to two vertices, according to positions of
// its neighbors and itself
Element currentElement = mChainElementList[i];
int vertexIdx = i * 2;
mVertices[vertexIdx].pos = currentElement.position + (currentElement.width * strechDir);
mVertices[vertexIdx].color = currentElement.colour;
if (mTexCoordMode == TextCoord_CustomX)
mVertices[vertexIdx].tex = D3DXVECTOR2(currentElement.texCoord, 1.0f);
else if (mTexCoordMode == TextCoord_CustomY)
mVertices[vertexIdx].tex = D3DXVECTOR2(1.0f, currentElement.texCoord);
++vertexIdx;
mVertices[vertexIdx].pos = currentElement.position - (currentElement.width * strechDir);
mVertices[vertexIdx].color = currentElement.colour;
if (mTexCoordMode == TextCoord_CustomX)
mVertices[vertexIdx].tex = D3DXVECTOR2(currentElement.texCoord, 0.0f);
else if (mTexCoordMode == TextCoord_CustomY)
mVertices[vertexIdx].tex = D3DXVECTOR2(0.0f, currentElement.texCoord);
}
}
示例9: D3DXVECTOR3
//.........這裏部分代碼省略.........
if (workBlockPos2.y - blockSize.y < blockPos.y + blockSize.y && workBlockPos2.y + blockSize.y > blockPos.y - blockSize.y
&& workBlockPos2.x - blockSize.x < blockPos.x + blockSize.x && workBlockPos2.x + blockSize.x > blockPos.x - blockSize.x
&& workBlockPos2.x - blockPos.x > -BLOCK_WIDTH && workBlockPos2.x - blockPos.x < 0.0f)
{
workBlockPos2.x = blockPos.x - blockSize.x - BLOCK_WIDTH;
workBlockPos2.y = blockPos.y - blockSize.y;
pBlock->SetPosition(workBlockPos2);
CBlockManager::CalculateBlockArrayNum(workBlockPos2, &nWorkBlockArrayNumX, &nWorkBlockArrayNumY);
if (nWorkBlockArrayNumX != nArrayNumX - 1)
{
CBlockManager::SetBlock(nWorkBlockArrayNumX, nWorkBlockArrayNumY, pBlock);
CBlockManager::SetBlock(nArrayNumX - 1, nArrayNumY, nullptr);
}
}
}
}
// 落下していき、配列番號が変化する位置になった場合は、
// BlockManagerに登録してある場所を切り替える。その時、
// 前回いた場所を初期化しておく。
workBlockPos = blockPos - blockSize;
CBlockManager::CalculateBlockArrayNum(workBlockPos, &nWorkBlockArrayNumX, &nWorkBlockArrayNumY);
if ( nArrayNumX != nWorkBlockArrayNumX || nArrayNumY != nWorkBlockArrayNumY )
{
CBlockManager::SetBlock(nWorkBlockArrayNumX, nWorkBlockArrayNumY, ( CBlock* )this);
CBlockManager::SetBlock(nArrayNumX, nArrayNumY, nullptr);
}
m_pos = D3DXVECTOR2(workBlockPos.x, workBlockPos.y);
break;
case CBlock::BLOCKID_WARP_BLUE:
// ワープするタイミングになったら
if (m_bWarpFlag && m_pWarpPoint->GetWarpFlag()
&& m_pos.x < antonPos.x && m_pos.x + BLOCK_WIDTH > antonPos.x
&& m_pos.y < antonPos.y + BLOCK_HEIGHT && m_pos.y + BLOCK_HEIGHT > antonPos.y + BLOCK_HEIGHT)
{
// アントンを転移先の座標へ(ビーコンも移動する可能性あり)
D3DXVECTOR3 warpPos = m_pWarpPoint->GetPosition();
warpPos.x = warpPos.x + BLOCK_WIDTH / 2.0f;
warpPos.y = warpPos.y - (65.0f);
pAnton->SetPosition(warpPos);
pAnton->SetPositionOld(warpPos);
pAnton->SetTargetPosition(warpPos.x, warpPos.y);
warpPos.y -= BLOCK_HEIGHT;
pBeecon->SetPosition(warpPos);
pBeecon->SetPositionOld(warpPos);
pBeecon->SetTargetPosition(warpPos.x, warpPos.y);
// ワープ終了
m_bWarpFlag = false;
m_pWarpPoint->SetWarpFlag(false);
m_nRetryWarpWaitTime = WARP_WAIT_TIME;
}
else if (m_nRetryWarpWaitTime == 0)
{
示例10: D3DXVECTOR3
//.........這裏部分代碼省略.........
faceNormalCounter++;
// 2つ目
vecSecondA = pVtx[vtxIndexOne + (wblock + 1)].vtx - pVtx[vtxIndexOne].vtx;
vecSecondB = pVtx[vtxIndexOne - 1].vtx - pVtx[vtxIndexOne].vtx;
D3DXVec3Cross(&norSecond, &vecSecondA, &vecSecondB);
D3DXVec3Normalize(&norSecond, &norSecond);
m_vFaceNormalBuf[faceNormalCounter] = norSecond;
// 頂點の法線の設定
pVtx[vtxIndexOne + (wblock + 1)].nor += m_vFaceNormalBuf[faceNormalCounter];
D3DXVec3Normalize(&pVtx[vtxIndexOne + (wblock + 1)].nor, &pVtx[vtxIndexOne + (wblock + 1)].nor);
pVtx[vtxIndexOne].nor += m_vFaceNormalBuf[faceNormalCounter];
D3DXVec3Normalize(&pVtx[vtxIndexOne].nor, &pVtx[vtxIndexOne].nor);
pVtx[vtxIndexOne - 1].nor += m_vFaceNormalBuf[faceNormalCounter];
D3DXVec3Normalize(&pVtx[vtxIndexOne - 1].nor, &pVtx[vtxIndexOne - 1].nor);
faceNormalCounter++;
}
vtxIndexOne++;
vtxIndexSecond++;
}
// 使用したいテクスチャの座標
for (i = 0; i < m_nNumVtxNum; i++)
{
if (i != 0)
{
if (pVtx[i].vtx.x != pVtx[i - 1].vtx.x)
{
tex_X += Add_tex_X;
// 1を超えないようにする
if (tex_X > 1.f)
{
tex_X = 1.f;
}
}
// 1列やったら
//if (i - 1 == wblock + counter * (wblock + 1))
if (pVtx[i].vtx.z != pVtx[i - 1].vtx.z)
{
counter++;
tex_Y += Add_tex_Y;
tex_X = 0.f;
if (tex_Y > 1.f)
{
tex_Y = 1.f;
}
}
}
// テクスチャ設定
pVtx[i].tex = D3DXVECTOR2((float)tex_X, (float)tex_Y);
}
m_pD3DVtxBuff->Unlock(); // ロックしたら必ずアンロック!!
//********************************************************************************************************************
WORD *pIndex;
// ロック
m_pD3DIndexBuff->Lock(0, 0, (void**)&pIndex, 0);
// インデックスの設定 2つづつ見てるので2つづつ進む
for (int i = 0, first = wblock + 1, second = 0, counter = 0; i < m_nNumVertexIndex - 1; i += 2, first++, second++)
{
// 橫に見たときに1づつ増えていくことを利用
pIndex[i] = first;
pIndex[i + 1] = second;
if (counter < hblock - 1)
{
// 折り返しの処理
if (second == wblock + (wblock + 1) * counter)
{
i += 2; // 2つづつ見てるので2つづつ進む
pIndex[i] = second;
pIndex[i + 1] = first + 1;
// 折り返し數カウントアップ
counter++;
}
}
}
// アンロック
m_pD3DIndexBuff->Unlock();
// 頂點宣言したものを作る
(*m_pD3DDevice)->CreateVertexDeclaration(GetVertexElement(), &m_pDecl);
// リストに追加
CScene::AddLinkList(CRenderer::TYPE_RENDER_NORMAL);
// テクスチャ設定
m_pD3DTexBuff = CTexture::GetTexture(texType);
}
示例11: D3DXVECTOR3
void cPart::Setup(float fWidth, float fHeight, float fDepth, Cube_Part type){
ST_PT_VERTEX v;
D3DXMATRIXA16 matScale, matRotate, matTrans, matFinal;
m_epart = type;
float left = -0.5f;
float top = 0.5f;
float right = 0.5f;
float bottom = -0.5f;
float frontdepth = 0.5f;
float backdepth = -0.5f;
//front
std::vector<ST_PT_VERTEX> plane;
v.p = D3DXVECTOR3(left, top, 0);
plane.push_back(v);
v.p = D3DXVECTOR3(right, top, 0);
plane.push_back(v);
v.p = D3DXVECTOR3(left, bottom, 0);
plane.push_back(v);
v.p = D3DXVECTOR3(left, bottom, 0);
plane.push_back(v);
v.p = D3DXVECTOR3(right, top, 0);
plane.push_back(v);
v.p = D3DXVECTOR3(right, bottom, 0);
plane.push_back(v);
for (UINT j = 0; j < plane.size(); j++){
v = plane[j];
D3DXMatrixRotationY(&matRotate, D3DXToRadian(180.0f));
//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
//matFinal = matRotate * matTrans;
D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
v.p.z = v.p.z + frontdepth;
m_vecVertex.push_back(v);
}
// right
for (UINT j = 0; j < plane.size(); j++){
v = plane[j];
D3DXMatrixRotationY(&matRotate, D3DXToRadian(270.0f));
//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
//matFinal = matRotate * matTrans;
D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
v.p.x = v.p.x + right;
m_vecVertex.push_back(v);
}
//back
for (UINT j = 0; j < plane.size(); j++){
v = plane[j];
//D3DXMatrixRotationY(&matRotate, D3DXToRadian(0.0f));
//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
//matFinal = matRotate * matTrans;
//D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
v.p.z = v.p.z + backdepth;
m_vecVertex.push_back(v);
}
//left
for (UINT j = 0; j < plane.size(); j++){
v = plane[j];
D3DXMatrixRotationY(&matRotate, D3DXToRadian(90.0f));
//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
//matFinal = matRotate * matTrans;
D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
v.p.x = v.p.x + left;
m_vecVertex.push_back(v);
}
//top
for (UINT j = 0; j < plane.size(); j++){
v = plane[j];
D3DXMatrixRotationX(&matRotate, D3DXToRadian(90.0f));
//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
//matFinal = matRotate * matTrans;
D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
v.p.y = v.p.y + top;
m_vecVertex.push_back(v);
}
// bottom
// lefttop righttop leftbottom leftbottom righttop rightbottom
for (UINT j = 0; j < plane.size(); j++){
v = plane[j];
D3DXMatrixRotationX(&matRotate, D3DXToRadian(270.0f));
//D3DXMatrixTranslation(&matTrans, m_vec3Origin.x, m_vec3Origin.y, m_vec3Origin.z);
//matFinal = matRotate * matTrans;
D3DXVec3TransformCoord(&v.p, &v.p, &matRotate);
v.p.y = v.p.y + bottom;
m_vecVertex.push_back(v);
}
D3DXMatrixScaling(&matScale, fWidth, fHeight, fDepth);
for (UINT i = 0; i < m_vecVertex.size(); i++){
D3DXVec3TransformCoord(&m_vecVertex[i].p, &m_vecVertex[i].p, &matScale);
}
if (type == PT_head){
// right
m_vecVertex[0].t = D3DXVECTOR2(128.0f / 1024.0f, 128.0f / 512.0f);
//.........這裏部分代碼省略.........
示例12: U2_ALLOC
bool QuadMesh::Initialize(DWORD m, DWORD n, float dx)
{
mNumRows = m;
mNumCols = n;
unsigned int uiNumVertices, uiNumFaces, uiNumIndices;
uiNumVertices = m * n;
uiNumFaces = (m-1) * (n-1) * 2;
uiNumIndices = uiNumFaces * 3;
U2TriListData *pData = NULL;
nMeshGroup* pMeshGroup = NULL;
pData = U2_NEW U2TriListData;
//m_spMesh = U2_NEW U2N2Mesh(pData);
this->SetModelData(pData);
this->SetUsages(U2N2Mesh::WriteOnly);
this->SetVertexComponents(U2N2Mesh::Coord | U2N2Mesh::Normal |
U2N2Mesh::Tangent | U2N2Mesh::Uv0);
//this->CreateMeshGroups(1);
//m_meshGroups.Resize(1);
m_meshGroups.AddElem(U2_NEW nMeshGroup);
U2Mesh::m_uNumGroups = 1;
pMeshGroup = static_cast<nMeshGroup*>(GroupPtr(0));
pMeshGroup->SetMesh(this);
pMeshGroup->SetModelData(pData);
// 저장하지 않음...
pData->SetVertexCount(uiNumVertices, uiNumVertices);
pData->CreateVertices();
pData->CreateNormals(false);
pData->CreateTangents(false);
pData->CreateTexCoords(1);
//D3DXVECTOR3* pVert = pData->GetVertices();
float halfWidth = (n-1)*dx*0.5f;
float halfDepth = (m-1)*dx*0.5f;
uint16* pusIdxArray = U2_ALLOC(uint16, uiNumIndices);
m_spModelData->SetIndices(uiNumFaces, uiNumFaces, pusIdxArray, 0, 1);
if (!this->CreateEmptyBuffers())
{
U2ASSERT(FALSE);
return false;
}
float *vBasePtr = LockVertices();
U2ASSERT(vBasePtr);
float du = 1.0f / (n-1);
float dv = 1.0f / (m-1);
for(DWORD i = 0; i < m; i++)
{
float z = halfDepth - i*dx;
for(DWORD j = 0; j < n; j++)
{
float x = -halfWidth + j*dx;
D3DXVECTOR3* pVert = pData->GetVertices();
D3DXVECTOR3* pNorm = pData->GetNormals();
D3DXVECTOR3* pTangent = pData->GetTangents();
D3DXVECTOR2* pUV0 = pData->GetTexCoordSet(0);
pVert[i*n+j] = D3DXVECTOR3(x, 0.0f, z);
pNorm[i*n+j] = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
pTangent[i*n+j] = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
pUV0[i*n+j] = D3DXVECTOR2(j * du, i * dv);
*vBasePtr++ = x; *vBasePtr++ = 0.0f; *vBasePtr++ = z;
*vBasePtr++ = 0.0f; *vBasePtr++ = 1.0f; *vBasePtr++ = 0.0f;
*vBasePtr++ = 1.0f; *vBasePtr++ = 0.0f; *vBasePtr++ = 0.0f;
*vBasePtr++ = j * du; *vBasePtr++ = i * dv;
}
}
UnlockVertices();
pMeshGroup->SetFirstVertex(0);
pMeshGroup->SetNumVertices(uiNumVertices);
int ibSize = sizeof(uint16) * uiNumIndices;
uint16* p = LockIndices();
U2ASSERT(p);
DWORD k = 0;
// Iterate over each quad and compute indices.
for(DWORD i = 0; i < m-1; ++i)
{
for(DWORD j = 0; j < n-1; ++j)
{
pusIdxArray[k] = p[k] = i*n+j;
pusIdxArray[k+1] = p[k+1] = i*n+j+1;
pusIdxArray[k+2] = p[k+2] = (i+1)*n+j;
pusIdxArray[k+3] = p[k+3] = (i+1)*n+j;
//.........這裏部分代碼省略.........
示例13: A
HRESULT KGraphicsEngine::Render2SmallerTexture()
{
LPTEXTURE pTexBuffer = NULL;
LPTEXTURE pTexSmaller = NULL;
LPTEXTURE pTexBlur = NULL;
if (FAILED(g_cTextureTable.GetTexture(&pTexBuffer,m_BufferTextureID)))
return E_FAIL;
if (FAILED(g_cTextureTable.GetTexture(&pTexSmaller,m_SmallerTextureID)))
return E_FAIL;
if (FAILED(g_cTextureTable.GetTexture(&pTexBlur,m_BlurTextureID)))
return E_FAIL;
if(!pTexBuffer->m_lpTexture)
return E_FAIL;
if(!pTexSmaller->m_lpTexture)
return E_FAIL;
if(!pTexBlur->m_lpTexture)
return E_FAIL;
D3DSURFACE_DESC Desc;
if(FAILED(pTexSmaller->m_lpTexture->GetLevelDesc(0,&Desc)))
return E_FAIL;
D3DSURFACE_DESC DescBlur;
if(FAILED(pTexBlur->m_lpTexture->GetLevelDesc(0,&DescBlur)))
return E_FAIL;
LPDIRECT3DSURFACE9 lpSurfaceSmaller = NULL;
if(FAILED(pTexSmaller->m_lpTexture->GetSurfaceLevel(0,&lpSurfaceSmaller)))
return E_FAIL;
lpSurfaceSmaller->Release();
LPDIRECT3DSURFACE9 lpSurfaceBlur = NULL;
if(FAILED(pTexBlur->m_lpTexture->GetSurfaceLevel(0,&lpSurfaceBlur)))
return E_FAIL;
lpSurfaceBlur->Release();
D3DXMATRIX Mat_View_Save;
D3DXMATRIX Mat_Proj_Save;
LPDIRECT3DSURFACE9 lpSurfaceSave = NULL;
D3DVIEWPORT9 ViewPort,ViewPortBlur,ViewPortSave;
//////////////////////////////////////////////////////////////////////////
//Save back buffer & transform & viewport
g_pd3dDevice->GetRenderTarget(0,&lpSurfaceSave);
lpSurfaceSave->Release();
g_pd3dDevice->GetTransform( D3DTS_VIEW, &Mat_View_Save );
g_pd3dDevice->GetTransform( D3DTS_PROJECTION, &Mat_Proj_Save );
g_pd3dDevice->GetViewport(&ViewPortSave);
//////////////////////////////////////////////////////////////////////////
ViewPort.X = 0;ViewPort.Y = 0;
ViewPort.Width = Desc.Width;
ViewPort.Height = Desc.Height;
ViewPort.MinZ = 0;ViewPort.MaxZ = 1.0f;
ViewPortBlur.X = 0;ViewPortBlur.Y = 0;
ViewPortBlur.Width = DescBlur.Width;
ViewPortBlur.Height = DescBlur.Height;
ViewPortBlur.MinZ = 0;ViewPortBlur.MaxZ = 1.0f;
D3DXVECTOR2 A(0,0);
D3DXVECTOR2 C((float)Desc.Width,(float)Desc.Height);
D3DXVECTOR2 A1(0,0);
D3DXVECTOR2 C1((float)DescBlur.Width,(float)DescBlur.Height);
//////////////////////////////////////////////////////////////////////////
g_pd3dDevice->SetViewport(&ViewPort);
g_pd3dDevice->SetRenderTarget(0,lpSurfaceSmaller);
//////////////////////////////////////////////////////////////////////////
//reade began to render
//g_pd3dDevice->BeginScene();
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,
0x00000000, 1.0f, 0 );
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
float K = 2;
D3DXVECTOR2 T1( K,K);
D3DXVECTOR2 T2(-K,K);
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
DWORD Color = m_lpCurScene->m_Glow.m_GateColor;
g_cTextureTable.SetTexture(0,m_BufferTextureID);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SUBTRACT);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
/*g_cTextureTable.SetTexture(1,m_BufferTextureID);
g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_MODULATE2X);
g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE);
g_pd3dDevice->SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_CURRENT);*/
g_cGraphicsTool.DrawScreenRectNormal(&A,&C,0.0f,Color,Color,Color,Color);
//g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
//g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
//g_cGraphicsTool.DrawScreenRect(&A,&C,0.0f,Color,m_SmallerTextureID);
//.........這裏部分代碼省略.........
示例14: D3DXMatrixTranslation
Sprite::Sprite(DeviceHandler *_deviceHandler, FLOAT2 position, FLOAT2 size,ID3D10ShaderResourceView *_texture, int _layer)
{
this->m_deviceHandler = _deviceHandler;
this->m_texture = _texture;
this->m_nrOfVertices = 6;
this->m_layer = _layer;
this->m_visible = true;
m_position = position;
m_size = size;
//Convert the position and size to projection space
//position.x = (position.x / this->m_deviceHandler->getScreenSize().x) * 2 - 1;
//position.y = (position.y / this->m_deviceHandler->getScreenSize().y) * 2 - 1;
//size.x = (size.x / this->m_deviceHandler->getScreenSize().x) * 2;
//size.y = (size.y / this->m_deviceHandler->getScreenSize().y) * 2;
//Create the modelmatrix
D3DXMatrixTranslation(&this->m_modelMatrix, position.x, position.y, 0.0f);
//Create the vertex buffer
D3D10_BUFFER_DESC bd;
bd.Usage = D3D10_USAGE_DYNAMIC;
bd.ByteWidth = sizeof( Vertex ) * 6;
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
bd.MiscFlags = 0;
HRESULT hr = this->m_deviceHandler->getDevice()->CreateBuffer( &bd, 0, &this->m_buffer);
if(FAILED(hr))
{
MessageBox( 0, "Unable to create Vertex Buffer", "VB Error", 0 );
}
//Load vertices
D3DXVECTOR2 pos = D3DXVECTOR2(-size.x / 2, -size.y / 2);
Vertex *vertexData = NULL;
this->m_buffer->Map( D3D10_MAP_WRITE_DISCARD, 0, reinterpret_cast< void** >((void**)&vertexData));
vertexData[0].pos = D3DXVECTOR3(pos.x, pos.y + size.y, 0.0f);
vertexData[0].texCoord = D3DXVECTOR2(0.0f, 0.0f);
vertexData[1].pos = D3DXVECTOR3(pos.x + size.x, pos.y + size.y, 0.0f);
vertexData[1].texCoord = D3DXVECTOR2(1.0f, 0.0f);
vertexData[2].pos = D3DXVECTOR3(pos.x, pos.y, 0.0f);
vertexData[2].texCoord = D3DXVECTOR2(0.0f, 1.0f);
vertexData[3].pos = D3DXVECTOR3(pos.x + size.x, pos.y, 0.0f);
vertexData[3].texCoord = D3DXVECTOR2(1.0f, 1.0f);
vertexData[4].pos = D3DXVECTOR3(pos.x, pos.y, 0.0f);
vertexData[4].texCoord = D3DXVECTOR2(0.0f, 1.0f);
vertexData[5].pos = D3DXVECTOR3(pos.x + size.x, pos.y + size.y, 0.0f);
vertexData[5].texCoord = D3DXVECTOR2(1.0f, 0.0f);
this->m_buffer->Unmap();
}
示例15: D3DCOLOR_XRGB
void RaftMesh::GenerateMesh()
{
// Initial position where the mesh will be drawn.
float mast_x = (width / 32);
float mast_y = height;
float mast_z = (depth / 32);
float body_x = (width / 2);
float body_y = 0.0f;
float body_z = (depth / 2);
float sail_x = (width / 4);
float sail_y = height;
float sail_z = mast_z;
float height_dist = height/8.0f;
// Create vertexes (Sail)
// 13 14
// 15 16
//
// 17 18
// 19 20
vertexes.push_back(Vertex(D3DXVECTOR3(-sail_x, sail_y, sail_z), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
vertexes.push_back(Vertex(D3DXVECTOR3(sail_x, sail_y, sail_z), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
vertexes.push_back(Vertex(D3DXVECTOR3(-sail_x, sail_y - height_dist, sail_z - height_dist), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
vertexes.push_back(Vertex(D3DXVECTOR3(sail_x, sail_y - height_dist, sail_z - height_dist), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
vertexes.push_back(Vertex(D3DXVECTOR3(-sail_x, sail_y - 5 * height_dist, sail_z - height_dist), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
vertexes.push_back(Vertex(D3DXVECTOR3(sail_x, sail_y - 5 *height_dist, sail_z - height_dist), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
vertexes.push_back(Vertex(D3DXVECTOR3(-sail_x, sail_y - 6 * height_dist, sail_z), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
vertexes.push_back(Vertex(D3DXVECTOR3(sail_x, sail_y - 6 * height_dist, sail_z), D3DCOLOR_XRGB(128, 128, 128) , D3DXVECTOR2(0,0) ));
// Indexes (Sail)
// 13 14
// 15 16
//
// 17 18
// 19 20
indexes.push_back(0);
indexes.push_back(1);
indexes.push_back(2);
indexes.push_back(2);
indexes.push_back(1);
indexes.push_back(3);
indexes.push_back(2);
indexes.push_back(3);
indexes.push_back(4);
indexes.push_back(4);
indexes.push_back(3);
indexes.push_back(5);
indexes.push_back(4);
indexes.push_back(5);
indexes.push_back(6);
indexes.push_back(6);
indexes.push_back(5);
indexes.push_back(7);
indexCount = indexes.size();
triangleCount = indexCount / 3;
vertexCount = vertexes.size();
}