Created
July 16, 2017 21:56
-
-
Save Alan-FGR/d12aa6f952d5e2dd56036419f8163790 to your computer and use it in GitHub Desktop.
Atomic Impostors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector<Node*> imposterNodes; | |
protected: | |
SharedPtr<Geometry> geometry_; | |
private: | |
VertexBuffer* vb = NULL; | |
IndexBuffer* ib = NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ImpostorChunk::CreateGeometryBuffers() | |
{ | |
int imposterAmount = imposterNodes.Size(); | |
int vertsQty = imposterAmount * 4; | |
int indsQty = imposterAmount * 6; | |
vb = new VertexBuffer(context_); | |
vb->SetSize(vertsQty, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1); | |
ib = new IndexBuffer(context_); | |
ib->SetSize(indsQty, true); | |
vt* vert = (vt*)vb->Lock(0, vertsQty); | |
unsigned* index = (unsigned*)ib->Lock(0, indsQty); | |
for (int i = 0; i < imposterAmount; ++i) | |
{ | |
Node* impNode = imposterNodes.At(i); | |
Vector3 impPos = GetNode()->WorldToLocal(impNode->GetWorldPosition()); | |
vert[i*4+0].pos = impPos + Vector3(0, 0, 0); | |
vert[i*4+1].pos = impPos + Vector3(0, 2, 0); | |
vert[i*4+2].pos = impPos + Vector3((rand()%100) * 0.01f + 0.25f, (rand() % 100) * 0.01f + 2, 0); //DBG randomization | |
vert[i*4+3].pos = impPos + Vector3(0.25f, 0, 0); | |
index[i*6+0] = i*4+0; | |
index[i*6+1] = i*4+1; | |
index[i*6+2] = i*4+2; | |
index[i*6+3] = i*4+0; | |
index[i*6+4] = i*4+2; | |
index[i*6+5] = i*4+3; | |
} | |
vb->Unlock(); | |
ib->Unlock(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment