void MyPrimitive::GeneratePlane(float a_fSize, vector3 a_v3Color) { if (a_fSize < 0.01f) a_fSize = 0.01f; Release(); Init(); float fValue = 0.5f * a_fSize; vector3 pointA(-fValue, -fValue, 0.0f); //0 vector3 pointB(fValue, -fValue, 0.0f); //1 vector3 pointC(fValue, fValue, 0.0f); //2 vector3 pointD(-fValue, fValue, 0.0f); //3 vector3 pointE(fValue, -fValue, -0.001f); //1 vector3 pointF(-fValue, -fValue, -0.001f); //0 vector3 pointG(fValue, fValue, -0.001f); //2 vector3 pointH(-fValue, fValue, -0.001f); //3 //F AddQuad(pointA, pointB, pointD, pointC); //Double sided AddQuad(pointE, pointF, pointG, pointH); CompileObject(a_v3Color); }
void MyPrimitive::GenerateTube(float a_fOuterRadius, float a_fInnerRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color) { if (a_nSubdivisions < 3) a_nSubdivisions = 3; if (a_nSubdivisions > 360) a_nSubdivisions = 360; Release(); Init(); for (int i = 0; i < a_nSubdivisions; i++) { float ang = (2 * PI) / a_nSubdivisions; vector3 point0(a_fOuterRadius*cos((i + 1)*ang), a_fHeight, a_fOuterRadius*sin((i + 1)*ang)); //1 vector3 point1(a_fOuterRadius*cos(i*ang), 0, a_fOuterRadius*sin(i*ang)); //2 vector3 point2(a_fOuterRadius*cos(i*ang), a_fHeight, a_fOuterRadius*sin(i*ang)); //0 vector3 point3(a_fOuterRadius*cos((i + 1)*ang), 0, a_fOuterRadius*sin((i + 1)*ang)); //3 vector3 point4(a_fInnerRadius*cos((i + 1)*ang), a_fHeight, a_fInnerRadius*sin((i + 1)*ang)); //1 vector3 point5(a_fInnerRadius*cos(i*ang), 0, a_fInnerRadius*sin(i*ang)); //2 vector3 point6(a_fInnerRadius*cos(i*ang), a_fHeight, a_fInnerRadius*sin(i*ang)); //0 vector3 point7(a_fInnerRadius*cos((i + 1)*ang), 0, a_fInnerRadius*sin((i + 1)*ang)); //3 AddQuad(point4, point0, point6, point2); //Top AddQuad(point0, point3, point2, point1); //Outer AddQuad(point7, point5, point3, point1); //Bottom AddQuad(point5, point7, point6,point4 ); // Inner } //Your code ends here CompileObject(a_v3Color); }
void MyPrimitive::GenerateSphere(float a_fRadius, int a_nSubdivisions, vector3 a_v3Color) { //Sets minimum and maximum of subdivisions if (a_nSubdivisions < 1) { GenerateCube(a_fRadius * 2, a_v3Color); return; } if (a_nSubdivisions > 12) a_nSubdivisions = 12; Release(); Init(); //Your code starts here vector3 base1Center = vector3(0, 0, 0); vector<vector3> centerRingPoints = GenerateNGon(a_fRadius, a_nSubdivisions, base1Center); vector<vector3> prevUpperRingPoints = centerRingPoints; vector<vector3> prevLowerRingPoints = centerRingPoints; vector3 topCenter = vector3(0, 0, a_fRadius); vector3 bottomCenter = vector3(0, 0, -a_fRadius); float radIncrement = (3.1459 / 2) / (a_nSubdivisions / 2); for (size_t i = a_nSubdivisions / 2; i > 0; i--) { float z = a_fRadius * cos(i * radIncrement); float xRadius = a_fRadius * sin(i * radIncrement); vector<vector3> upperRingPoints = GenerateNGon(xRadius, a_nSubdivisions, vector3(0, 0, z)); vector<vector3> lowerRingPoints = GenerateNGon(xRadius, a_nSubdivisions, vector3(0, 0, -z)); for (size_t j = 0; j < a_nSubdivisions; j++) { int rightIndex = j; int leftIndex = (j + 1) % a_nSubdivisions; AddQuad(prevUpperRingPoints[rightIndex], prevUpperRingPoints[leftIndex], upperRingPoints[rightIndex], upperRingPoints[leftIndex]); AddQuad(prevLowerRingPoints[leftIndex], prevLowerRingPoints[rightIndex], lowerRingPoints[leftIndex], lowerRingPoints[rightIndex]); if (i == 1) { AddVertexPosition(upperRingPoints[rightIndex]); AddVertexPosition(upperRingPoints[leftIndex]); AddVertexPosition(topCenter); AddVertexPosition(bottomCenter); AddVertexPosition(lowerRingPoints[leftIndex]); AddVertexPosition(lowerRingPoints[rightIndex]); } } prevUpperRingPoints = upperRingPoints; prevLowerRingPoints = lowerRingPoints; } //Your code ends here CompileObject(a_v3Color); }
void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight, bool tiled) { if (!(element_->HasColorGradient() || element_->GetDerivedColor().ToUInt() & 0xff000000)) return; // No gradient and alpha is 0, so do not add the quad if (!tiled) { AddQuad(x, y, width, height, texOffsetX, texOffsetY, texWidth, texHeight); return; } int tileX = 0; int tileY = 0; int tileW = 0; int tileH = 0; while (tileY < height) { tileX = 0; tileH = Min(height - tileY, texHeight); while (tileX < width) { tileW = Min(width - tileX, texWidth); AddQuad(x + tileX, y + tileY, tileW, tileH, texOffsetX, texOffsetY, tileW, tileH); tileX += tileW; } tileY += tileH; } }
void MyPrimitive::GenerateTube(float a_fOuterRadius, float a_fInnerRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color) { if (a_nSubdivisions < 3) a_nSubdivisions = 3; if (a_nSubdivisions > 360) a_nSubdivisions = 360; Release(); Init(); //Your code starts here vector3 base1Center = vector3(0, 0, -a_fHeight / 2); vector<vector3> base1InnerPoints = GenerateNGon(a_fInnerRadius, a_nSubdivisions, base1Center); vector<vector3> base1OuterPoints = GenerateNGon(a_fOuterRadius, a_nSubdivisions, base1Center); vector3 base2Center = vector3(0, 0, a_fHeight / 2); vector<vector3> base2InnerPoints = GenerateNGon(a_fInnerRadius, a_nSubdivisions, base2Center); vector<vector3> base2OuterPoints = GenerateNGon(a_fOuterRadius, a_nSubdivisions, base2Center); for (size_t i = 0; i < a_nSubdivisions; i++) { int rightIndex = i; int leftIndex = (i + 1) % a_nSubdivisions; AddQuad(base2InnerPoints[rightIndex], base2InnerPoints[leftIndex], base1InnerPoints[rightIndex], base1InnerPoints[leftIndex]); AddQuad(base2OuterPoints[leftIndex], base2OuterPoints[rightIndex], base1OuterPoints[leftIndex], base1OuterPoints[rightIndex]); AddQuad(base2OuterPoints[rightIndex], base2OuterPoints[leftIndex], base2InnerPoints[rightIndex], base2InnerPoints[leftIndex]); AddQuad(base1OuterPoints[leftIndex], base1OuterPoints[rightIndex], base1InnerPoints[leftIndex], base1InnerPoints[rightIndex]); } //Your code ends here CompileObject(a_v3Color); }
void MyPrimitive::GenerateTorus(float a_fOuterRadius, float a_fInnerRadius, int a_nSubdivisionsA, int a_nSubdivisionsB, vector3 a_v3Color) { if (a_fOuterRadius <= a_fInnerRadius + 0.1f) return; if (a_nSubdivisionsA < 3) a_nSubdivisionsA = 3; if (a_nSubdivisionsA > 25) a_nSubdivisionsA = 25; if (a_nSubdivisionsB < 3) a_nSubdivisionsB = 3; if (a_nSubdivisionsB > 25) a_nSubdivisionsB = 25; Release(); Init(); //Your code starts here float fValue = 0.5f; //3--2 //| | //0--1 vector3 point0(-fValue, -fValue, fValue); //0 vector3 point1(fValue, -fValue, fValue); //1 vector3 point2(fValue, fValue, fValue); //2 vector3 point3(-fValue, fValue, fValue); //3 AddQuad(point0, point1, point3, point2); //Your code ends here CompileObject(a_v3Color); }
void MyPrimitive::GenerateCone(float a_fRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color) { if (a_nSubdivisions < 3) a_nSubdivisions = 3; if (a_nSubdivisions > 360) a_nSubdivisions = 360; Release(); Init(); vector3 baseCenter(0, 0, 0); //topCenter vector3 topCenter(0, a_fHeight, 0); //2 //AddQuad(baseCenter, pointtopCenter, point3, point2); for (int i = 0; i < a_nSubdivisions; i++) { float ang = (2*PI)/ a_nSubdivisions; vector3 point2(a_fRadius*cos(i*ang), 0, a_fRadius*sin(i*ang) ); //0 vector3 point3(a_fRadius*cos((i+1)*ang), 0, a_fRadius*sin((i+1)*ang)); //3 AddQuad(topCenter, point3, point2, baseCenter); } CompileObject(a_v3Color); }
void AddArmDetail(Geometry*g,float w,float r, int sides) { Geometry tmp; float ang=(float)(PI/sides); float sina=sin(ang),cosa=cos(ang); int i; vec3 t1(0,0,r),t0(0,0,r),hh(w/2,0,0),hh0(0,0,0); for(i=0; i<sides; i++) { t1.RotateOij(sina,cosa,1,2); AddQuad(&tmp,t0,t1,t1+hh,t0+hh); tmp.AddTriangle(t0,t1,hh0); tmp.AddTriangle(t1+hh,t0+hh,hh); t0=t1; } tmp.SetNormOutOf(vec3((w)/4,0,0)); g->Add(tmp); //tmp.renull(); //AddQuad(&tmp,); AddBox(g,vec3(0,0,r),vec3(w/2,r,-r)); AddBox(g,vec3(-w/2,2*r,r),vec3(w/2,r,-r)); }
bool CPingPong::Draw(CRenderD3D* render) { LPDIRECT3DDEVICE8 d3dDevice = render->GetDevice(); D3DXMATRIX mProjection; D3DXMatrixPerspectiveFovLH( &mProjection, DEGTORAD( 60.0f ), (f32)render->m_Width / (f32)render->m_Height, 0.1f, 2000.0f ); d3dDevice->SetTransform( D3DTS_PROJECTION, &mProjection ); // Fill in the vertex buffers with the quads TRenderVertex* vert = NULL; m_VertexBuffer->Lock( 0, 0, (BYTE**)&vert, 0); vert = AddQuad(vert, m_Ball.m_Pos, m_Ball.m_Size, m_Ball.m_Col.RenderColor()); vert = AddQuad(vert, m_Paddle[0].m_Pos, m_Paddle[0].m_Size, m_Paddle[0].m_Col.RenderColor()); vert = AddQuad(vert, m_Paddle[1].m_Pos, m_Paddle[1].m_Size, m_Paddle[1].m_Col.RenderColor()); m_VertexBuffer->Unlock(); d3dSetRenderState(D3DRS_ZENABLE, FALSE); d3dSetRenderState(D3DRS_LIGHTING, FALSE); d3dSetRenderState(D3DRS_COLORVERTEX,TRUE); d3dSetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID ); d3dSetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); d3dSetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); d3dSetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); d3dSetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE); d3dSetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); d3dSetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); d3dDevice->SetTexture( 0, NULL ); d3dDevice->SetStreamSource( 0, m_VertexBuffer, sizeof(TRenderVertex) ); d3dDevice->SetVertexShader( TRenderVertex::FVF_Flags ); CMatrix m; m.Identity(); d3dDevice->SetTransform(D3DTS_VIEW, (D3DXMATRIX*)&m); m._43 = 70.0f; d3dDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&m); for (int pnr=0; pnr<NUMQUADS; pnr++) { d3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, pnr*4, 2 ); } return true; }
void MyPrimitive::GenerateCylinder(float a_fRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color) { if (a_nSubdivisions < 3) a_nSubdivisions = 3; if (a_nSubdivisions > 360) a_nSubdivisions = 360; Release(); Init(); //Your code starts here float fValue = 0.5f; //3--2 //| | //0--1 //vector3 point0(-fValue, -fValue, fValue); //0 //vector3 point1(fValue, -fValue, fValue); //1 //vector3 point2(fValue, fValue, fValue); //2 //vector3 point3(-fValue, fValue, fValue); //3 // //AddQuad(point0, point1, point3, point2); vector3 point0(0, 0, 0); vector3 point1(0, a_fHeight, 0); for (int i = 0; i < a_nSubdivisions; i++) { float ang = (2 * PI) / a_nSubdivisions; vector3 point2(a_fRadius*cos(i*ang), 0, a_fRadius*sin(i*ang)); //0 vector3 point3(a_fRadius*cos((i + 1)*ang), 0, a_fRadius*sin((i + 1)*ang)); //3 vector3 point4(a_fRadius*cos(i*ang), a_fHeight, a_fRadius*sin(i*ang)); //0 vector3 point5(a_fRadius*cos((i + 1)*ang), a_fHeight, a_fRadius*sin((i + 1)*ang)); //3 AddQuad(point1, point3, point2, point4); AddQuad(point1, point4, point5, point3); } //Your code ends here CompileObject(a_v3Color); }
void MyPrimitive::GenerateTorus(float a_fOuterRadius, float a_fInnerRadius, int a_nSubdivisionsA, int a_nSubdivisionsB, vector3 a_v3Color) { if (a_fOuterRadius <= a_fInnerRadius + 0.1f) return; if (a_nSubdivisionsA < 3) a_nSubdivisionsA = 3; if (a_nSubdivisionsA > 25) a_nSubdivisionsA = 25; if (a_nSubdivisionsB < 3) a_nSubdivisionsB = 3; if (a_nSubdivisionsB > 25) a_nSubdivisionsB = 25; Release(); Init(); //Your code starts here //Your code starts here float ringRadius = (a_fOuterRadius - a_fInnerRadius) / 2; float radIncrement = (3.1459 * 2) / (a_nSubdivisionsB); float z = ringRadius * cos(a_nSubdivisionsB * radIncrement); float xRadius = ringRadius * sin(a_nSubdivisionsB * radIncrement); vector3 base1Center = vector3(0, 0, z); vector<vector3> lastRingPoints = GenerateNGon(a_fInnerRadius + ringRadius + xRadius, a_nSubdivisionsA, base1Center); for (int i = a_nSubdivisionsB - 1; i > -1; i--) { float z = ringRadius * cos(i * radIncrement); float xRadius = ringRadius * sin(i * radIncrement); vector<vector3> ringPoints = GenerateNGon(a_fInnerRadius + ringRadius + xRadius, a_nSubdivisionsA, vector3(0, 0, z)); for (size_t j = 0; j < a_nSubdivisionsA; j++) { int rightIndex = j; int leftIndex = (j + 1) % a_nSubdivisionsA; AddQuad(lastRingPoints[rightIndex], lastRingPoints[leftIndex], ringPoints[rightIndex], ringPoints[leftIndex]); } lastRingPoints = ringPoints; } //Your code ends here CompileObject(a_v3Color); }
void MyPrimitive::GenerateSphere(float a_fRadius, int a_nSubdivisions, vector3 a_v3Color) { //Sets minimum and maximum of subdivisions if (a_nSubdivisions < 1) { GenerateCube(a_fRadius * 2, a_v3Color); return; } if (a_nSubdivisions > 6) a_nSubdivisions = 6; Release(); Init(); //Your code starts here float a_fHeight; vector3 point0(0, 0, 0); vector3 point1(0, a_fHeight, 0); for (int i = 0; i < a_nSubdivisions; i++) { float ang = (2 * PI) / a_nSubdivisions; vector3 point2(a_fRadius*cos(i*ang), 0, a_fRadius*sin(i*ang)); //0 vector3 point3(a_fRadius*cos((i + 1)*ang), 0, a_fRadius*sin((i + 1)*ang)); //3 vector3 point4(a_fRadius*cos(i*ang), a_fHeight, a_fRadius*sin(i*ang)); //0 vector3 point5(a_fRadius*cos((i + 1)*ang), a_fHeight, a_fRadius*sin((i + 1)*ang)); //3 AddQuad(point1, point3, point2, point4); AddQuad(point1, point4, point5, point3); } //Your code ends here CompileObject(a_v3Color); }
void AddSphere(Geometry*g,float r, int sides_a, int sides_b) { Geometry tmp; float ang=(float)(PI/sides_a); float sina=sin(ang),cosa=cos(ang); float ang2=(float)(PI*2.0/sides_b); float sinb=sin(ang2),cosb=cos(ang2); int i,j; vec3 v0(0,r,0),u0,u1,w0,w1; vec3 v1(v0); for(i=0; i<sides_a; i++) { v1.RotateOij(sina,cosa,0,1); u0 = v0; w0 = v1; u1 = v0; w1 = v1; for(j=0; j<sides_b; j++) { u1.RotateOij(sinb,cosb,0,2); w1.RotateOij(sinb,cosb,0,2); if(i==sides_b-1) tmp.AddTriangle(u0,u1,w0); else if(!i) tmp.AddTriangle(u1,w1,w0); else AddQuad(&tmp,u0,u1,w1,w0); u0=u1; w0=w1; } v0=v1; } tmp.SetNormOutOf(vec3(0,0,0)); g->Add(tmp); }
bool MeshMaterialGraphicsObject::InitializeAsync() { assert(_mesh != nullptr); SetMaterial(material()); for (size_t i = 0; i < _mesh->vertices->size(); i++) { AddVertex((*_mesh->vertices)[i], (*_mesh->texCoords)[i], (*_mesh->normals)[i]); } for (Vector<3, unsigned> triangle : *_mesh->triangles) { AddTriangle(triangle[0], triangle[1], triangle[2]); } for (Vector<4, unsigned> quad : *_mesh->quads) { AddQuad(quad[0], quad[1], quad[2], quad[3]); } return VboGraphicsObject::InitializeAsync(); }
void MyPrimitive::GenerateCube(float a_mSize, vector3 a_vColor) { //If the size is less than this make it this large if (a_mSize < 0.01f) a_mSize = 0.01f; //Clean up Memory Release(); Init(); float fValue = 0.5f * a_mSize; //3--2 //| | //0--1 vector3 point0(-fValue, -fValue, fValue); //0 vector3 point1(fValue, -fValue, fValue); //1 vector3 point2(fValue, fValue, fValue); //2 vector3 point3(-fValue, fValue, fValue); //3 //7--6 //| | //4--5 vector3 point4(-fValue, -fValue, -fValue); //4 vector3 point5(fValue, -fValue, -fValue); //5 vector3 point6(fValue, fValue, -fValue); //6 vector3 point7(-fValue, fValue, -fValue); //7 //F AddQuad(point0, point1, point3, point2); //B AddQuad(point5, point4, point6, point7); //L AddQuad(point4, point0, point7, point3); //R AddQuad(point1, point5, point2, point6); //U AddQuad(point3, point2, point7, point6); //D AddQuad(point4, point5, point0, point1); //Compile the object in this color and assign it this name CompileObject(a_vColor); }
void AddCylinder(Geometry*g,float h,float r, int sides) { Geometry tmp; float ang=(float)(PI*2.0/sides); float sina=sin(ang),cosa=cos(ang); int i; vec3 t1(r,0,0),t0(r,0,0),hh(0,h,0),hh0(0,0,0); for(i=0; i<sides; i++) { t1.RotateOij(sina,cosa,0,2); AddQuad(&tmp,t0,t1,t1+hh,t0+hh); tmp.AddTriangle(t0,t1,hh0); tmp.AddTriangle(t1+hh,t0+hh,hh); t0=t1; } tmp.SetNormOutOf(vec3(0,h/2,0)); g->Add(tmp); }
void DrawTorus(float r, float R, int nsides, int rings) { int i, j; float theta, phi, theta1, phi1; Indices.clear(); Vertices.clear(); for (i = 0; i < rings; i++) { theta = (float) i * 2.0f * M_PI / rings; theta1 = (float) (i + 1) * 2.0f * M_PI / rings; for (j = 0; j < nsides; j++) { phi = (float) j * 2.0f * M_PI / nsides; phi1 = (float) (j + 1) * 2.0f * M_PI / nsides; XMFLOAT3 p0 = XMFLOAT3(cos(theta) * (R + r * cos(phi)), // x -sin(theta) * (R + r * cos(phi)), // y r * sin(phi)); // z XMFLOAT3 p1 = XMFLOAT3(cos(theta1) * (R + r * cos(phi)), // x -sin(theta1) * (R + r * cos(phi)), // y r * sin(phi)); // z XMFLOAT3 p2 = XMFLOAT3(cos(theta1) * (R + r * cos(phi1)), // x -sin(theta1) * (R + r * cos(phi1)),// y r * sin(phi1)); // z XMFLOAT3 p3 = XMFLOAT3(cos(theta) * (R + r * cos(phi1)), // x -sin(theta) * (R + r * cos(phi1)), // y r * sin(phi1)); // z // Add XMFLOAT4 color = (ConwayGame.GetCellState(i, j)) ? XMFLOAT4(CELL_ALIVE_COLOR) : ((j + i)&1) ? XMFLOAT4(CELL_DEATH_COLOR) : XMFLOAT4(CELL_DEATH_COLOR2); AddQuad(p0, p1, p2, p3, color); } } }
CMFRet CMesh::AddPolygon(CArrayInt* paiCorners) { CMFRet r; if (paiCorners->NumElements() < 3) { r.PackEmpty(); return r; } else if (paiCorners->NumElements() == 3) { return AddFace(paiCorners->GetValue(0), paiCorners->GetValue(1), paiCorners->GetValue(2)); } else if (paiCorners->NumElements() == 4) { return AddQuad(paiCorners->GetValue(0), paiCorners->GetValue(1), paiCorners->GetValue(2), paiCorners->GetValue(3)); } else { //Remember to return the new edge count also. r.PackOverflow(); return r; } }
void Cloud::Renderer::DebugRenderer::AddBar(const ClFloat2& position, const ClFloat2& size, const ClFloat4& colour, CLfloat value, BarDirection direction) { const CLfloat c_minValue = 0.01f; ClFloat2 topLeft(0.0f, 0.0f); ClFloat2 bottomRight(0.0f, 0.0f); switch (direction) { case Cloud::Renderer::DebugRenderer::BarDirection::Up: { topLeft.Set(position.x - size.x, position.y - size.y); bottomRight.Set(position.x + size.x, position.y + size.y); value = Cloud::Math::Max(value, c_minValue); CLfloat length = topLeft.y - bottomRight.y; topLeft.y = bottomRight.y + length * value; } break; default: CL_ASSERT_MSG("Only 'Up' is implemented!"); } AddQuad(topLeft, bottomRight, colour); }
CLbool Cloud::Renderer::DebugRenderer::InitialiseQuad() { AddQuad(ClFloat2(-0.5f, -0.5f), ClFloat2(0.5f, 0.5f), ClFloat4(1.0f, 0.0f, 0.0f, 1.0f)); // shader m_quadEffect = RenderCore::Instance().GetEffectContainer().GetEffect("data/core/debug/quad.eff"); if (!m_quadEffect) return false; // vertex buffer m_quadVB.SetVertexData(m_quadVertices.GetBuffer()); m_quadVB.SetVertexCount(m_quadVertices.Count()); m_quadVB.SetVertexSize(sizeof(Quad::Vertex)); //m_quadVB.SetTopology(GfxPrimitiveTopology::Trianglelist); if (!m_quadVB.Initialise()) return false; // index buffer Utils::StaticArray<CLuint32, Quad::c_indexCount> indices; for (int i = 0; i < Quad::c_maxCount; ++i) { indices[i * 6] = i * 4 + 0; indices[i * 6 + 1] = i * 4 + 2; indices[i * 6 + 2] = i * 4 + 1; indices[i * 6 + 3] = i * 4 + 1; indices[i * 6 + 4] = i * 4 + 2; indices[i * 6 + 5] = i * 4 + 3; } m_quadIB.SetIndexData(indices.GetBuffer()); m_quadIB.SetIndexCount(indices.Count()); if (!m_quadIB.Initialise()) return false; return true; }
void MyPrimitive::GenerateCube(float a_fSize, vector3 a_v3Color) { if (a_fSize < 0.01f) a_fSize = 0.01f; Release(); Init(); float fValue = 0.5f * a_fSize; //3--2 //| | //0--1 vector3 point0(-fValue, -fValue, fValue); //0 vector3 point1(fValue, -fValue, fValue); //1 vector3 point2(fValue, fValue, fValue); //2 vector3 point3(-fValue, fValue, fValue); //3 vector3 point4(-fValue, -fValue, -fValue); //4 vector3 point5(fValue, -fValue, -fValue); //5 vector3 point6(fValue, fValue, -fValue); //6 vector3 point7(-fValue, fValue, -fValue); //7 //F AddQuad(point0, point1, point3, point2); //B AddQuad(point5, point4, point6, point7); //L AddQuad(point4, point0, point7, point3); //R AddQuad(point1, point5, point2, point6); //U AddQuad(point3, point2, point7, point6); //D AddQuad(point4, point5, point0, point1); CompileObject(a_v3Color); }
void RayTracingEnvironment::AddAxisAlignedRectangularSolid(int id,Vector minc, Vector maxc, const Vector &color) { // "far" face AddQuad(id, Vector(minc.x,maxc.y,maxc.z), Vector(maxc.x,maxc.y,maxc.z),Vector(maxc.x,minc.y,maxc.z), Vector(minc.x,minc.y,maxc.z),color); // "near" face AddQuad(id, Vector(minc.x,maxc.y,minc.z), Vector(maxc.x,maxc.y,minc.z),Vector(maxc.x,minc.y,minc.z), Vector(minc.x,minc.y,minc.z),color); // "left" face AddQuad(id, Vector(minc.x,maxc.y,maxc.z), Vector(minc.x,maxc.y,minc.z), Vector(minc.x,minc.y,minc.z), Vector(minc.x,minc.y,maxc.z),color); // "right" face AddQuad(id, Vector(maxc.x,maxc.y,maxc.z), Vector(maxc.x,maxc.y,minc.z), Vector(maxc.x,minc.y,minc.z), Vector(maxc.x,minc.y,maxc.z),color); // "top" face AddQuad(id, Vector(minc.x,maxc.y,maxc.z), Vector(maxc.x,maxc.y,maxc.z), Vector(maxc.x,maxc.y,minc.z), Vector(minc.x,maxc.y,minc.z),color); // "bot" face AddQuad(id, Vector(minc.x,minc.y,maxc.z), Vector(maxc.x,minc.y,maxc.z), Vector(maxc.x,minc.y,minc.z), Vector(minc.x,minc.y,minc.z),color); }
void AddBox(Geometry*g, vec3 a,vec3 b) { Geometry tmp; if(a.x>b.x)swap(a.x,b.x); if(a.y>b.y)swap(a.y,b.y); if(a.z>b.z)swap(a.z,b.z); vec3 s = b - a; vec3 a_x(s.x,0,0); vec3 a_y(0,s.y,0); vec3 a_z(0,0,s.z); AddQuad(&tmp,a,a+a_y,a+a_x+a_y,a+a_x); AddQuad(&tmp,a,a+a_x,a+a_x+a_z,a+a_z); AddQuad(&tmp,a,a+a_z,a+a_z+a_y,a+a_y); AddQuad(&tmp,b,b-a_x,b-a_x-a_y,b-a_y); AddQuad(&tmp,b,b-a_z,b-a_x-a_z,b-a_x); AddQuad(&tmp,b,b-a_y,b-a_z-a_y,b-a_z); tmp.SetNormOutOf((a+b)*0.5f); g->Add(tmp); }
void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight, const Color& color) { Color derivedColor(color.r_, color.g_, color.b_, color.a_ * element_->GetDerivedOpacity()); AddQuad(x, y, width, height, texOffsetX, texOffsetY, texWidth, texHeight, &derivedColor); }
void Geom_Setup (void) { float x, y, z; float dx, dy, dz; g_numverts = 0; g_numedges = 0; g_numsurfs = 0; g_numsurfedges = 0; /* ================================ */ dx = -64; dy = 16; dz = 128; x = 20; y = 64; z = 12; AddVertex (dx + x, dy + y, dz + z); /* top verts */ AddVertex (dx + -x, dy + y, dz + z); AddVertex (dx + -x, dy + y, dz + -z); AddVertex (dx + x, dy + y, dz + -z); AddVertex (dx + x, dy + -y, dz + z); /* bottom verts */ AddVertex (dx + -x, dy + -y, dz + z); AddVertex (dx + -x, dy + -y, dz + -z); AddVertex (dx + x, dy + -y, dz + -z); AddEdge (0, 1); /* top */ AddEdge (1, 2); AddEdge (2, 3); AddEdge (3, 0); AddEdge (0, 4); /* sides */ AddEdge (1, 5); AddEdge (2, 6); AddEdge (3, 7); AddEdge (4, 5); /* bottom */ AddEdge (5, 6); AddEdge (6, 7); AddEdge (7, 4); AddQuad ("WALL42_1.pcx", 3, 7, 6, 2); /* front */ AddQuad ("WALL42_1.pcx", 1, 5, 4, 0); /* back */ AddQuad ("WALL42_3.pcx", 0, 4, 7, 3); /* right */ AddQuad ("WALL42_3.pcx", 2, 6, 5, 1); /* left */ AddQuad ("CEIL5_2.pcx", 0, 3, 2, 1); /* top */ AddQuad ("CEIL5_2.pcx", 7, 4, 5, 6); /* bottom */ /* ================================ */ dx = 128; dy = 128; dz = 256; x = 32; y = 32; z = 32; AddVertex (dx + x, dy + y, dz + z); /* top verts */ AddVertex (dx + -x, dy + y, dz + z); AddVertex (dx + -x, dy + y, dz + -z); AddVertex (dx + x, dy + y, dz + -z); AddVertex (dx + x, dy + -y, dz + z); /* bottom verts */ AddVertex (dx + -x, dy + -y, dz + z); AddVertex (dx + -x, dy + -y, dz + -z); AddVertex (dx + x, dy + -y, dz + -z); AddEdge (8, 9); /* top */ AddEdge (9, 10); AddEdge (10, 11); AddEdge (11, 8); AddEdge (8, 12); /* sides */ AddEdge (9, 13); AddEdge (10, 14); AddEdge (11, 15); AddEdge (12, 13); /* bottom */ AddEdge (13, 14); AddEdge (14, 15); AddEdge (15, 12); AddQuad ("W28_5.pcx", 11, 15, 14, 10); /* front */ AddQuad ("W28_5.pcx", 9, 13, 12, 8); /* back */ AddQuad ("W28_5.pcx", 8, 12, 15, 11); /* right */ AddQuad ("W28_5.pcx", 10, 14, 13, 9); /* left */ AddQuad ("W28_5.pcx", 8, 11, 10, 9); /* top */ AddQuad ("W28_5.pcx", 15, 12, 13, 14); /* bottom */ /* ================================ */ AddVertex (8, 0, 512); AddVertex (8, -128, 512); AddVertex (0, -128, 512); AddVertex (0, 0, 512); AddEdge (16, 17); AddEdge (17, 18); AddEdge (18, 19); AddEdge (19, 16); AddQuad ("AGB128_1.pcx", 16, 17, 18, 19); /* front */ }
void MyPrimitive::GenerateSphere(float a_fRadius, int a_nSubdivisions, vector3 a_vColor) { //Sets minimum and maximum of subdivisions if (a_nSubdivisions < 1) { GenerateCube(a_fRadius * 2, a_vColor); return; } if (a_nSubdivisions > 6) a_nSubdivisions = 6; //Clean up Memory Release(); Init(); //Your Code Goes Here instead of the next three lines float fValue = 0.5f; vector3 pointA(-fValue, -fValue, fValue); //0 vector3 pointB(fValue, -fValue, fValue); //1 vector3 pointC(-fValue, fValue, fValue); //2 //left to right List of vector3 std::vector<vector3> vectorAB; vectorAB.push_back(pointA); for (int i = 0; i < a_nSubdivisions; i++) { vector3 temp(pointB - pointA); temp /= a_nSubdivisions + 1; temp *= (i + 1); vectorAB.push_back(temp + pointA); } vectorAB.push_back(pointB); //height increments float fHeight = pointC.y - pointA.y; fHeight /= a_nSubdivisions + 1; //List of Lists std::vector<std::vector<vector3>> list; list.push_back(vectorAB); for (int j = 0; j < a_nSubdivisions + 1; j++) { std::vector<vector3> temp = list[0]; float increment = fHeight * (j + 1); for (int i = 0; i < a_nSubdivisions + 2; i++) { temp[i].y += increment; } list.push_back(temp); } //Creating the patch of quads for (int j = 0; j < a_nSubdivisions + 1; j++) { for (int i = 0; i < a_nSubdivisions + 1; i++) { AddQuad(list[j][i], list[j][i + 1], list[j + 1][i], list[j + 1][i + 1]); } } int nVertices = static_cast<int>(m_lVertexPos.size()); //normalizing the vectors to make them round for (int i = 0; i < nVertices; i++) { m_lVertexPos[i] = glm::normalize(m_lVertexPos[i]); m_lVertexPos[i] *= a_fRadius; } //RightSideFace std::vector<vector3> right; for (int i = 0; i < nVertices; i++) { matrix4 rotation; rotation = glm::rotate(matrix4(1.0f), 90.0f, vector3(0.0f, 1.0f, 0.0f)); right.push_back(static_cast <vector3>(rotation * vector4(m_lVertexPos[i], 1.0f))); } for (int i = 0; i < nVertices; i++) { AddVertexPosition(right[i]); } //LeftSideFace std::vector<vector3> left; for (int i = 0; i < nVertices; i++) { matrix4 rotation; rotation = glm::rotate(matrix4(1.0f), -90.0f, vector3(0.0f, 1.0f, 0.0f)); left.push_back(static_cast <vector3>(rotation * vector4(m_lVertexPos[i], 1.0f))); } for (int i = 0; i < nVertices; i++) { AddVertexPosition(left[i]); } //BackSideFace std::vector<vector3> back; for (int i = 0; i < nVertices; i++) { matrix4 rotation; rotation = glm::rotate(matrix4(1.0f), 180.0f, vector3(0.0f, 1.0f, 0.0f)); back.push_back(static_cast <vector3>(rotation * vector4(m_lVertexPos[i], 1.0f))); } for (int i = 0; i < nVertices; i++) { AddVertexPosition(back[i]); } //TopSideFace std::vector<vector3> top; for (int i = 0; i < nVertices; i++) { matrix4 rotation; rotation = glm::rotate(matrix4(1.0f), -90.0f, vector3(1.0f, 0.0f, 0.0f)); top.push_back(static_cast <vector3>(rotation * vector4(m_lVertexPos[i], 1.0f))); } for (int i = 0; i < nVertices; i++) { AddVertexPosition(top[i]); } //BottomSideFace std::vector<vector3> bottom; for (int i = 0; i < nVertices; i++) { matrix4 rotation; rotation = glm::rotate(matrix4(1.0f), 90.0f, vector3(1.0f, 0.0f, 0.0f)); bottom.push_back(static_cast <vector3>(rotation * vector4(m_lVertexPos[i], 1.0f))); } for (int i = 0; i < nVertices; i++) { AddVertexPosition(bottom[i]); } //Compile the object in this color and assign it this name CompileObject(a_vColor); }
void MyPrimitive::GenerateSphere(float a_fRadius, int a_nSubdivisions, vector3 a_v3Color) { ////Sets minimum and maximum of subdivisions //if (a_nSubdivisions < 1) //{ // GenerateCube(a_fRadius * 2, a_v3Color); // return; //} //if (a_nSubdivisions > 6) // a_nSubdivisions = 6; Release(); Init(); //Your code starts here vector3 topPoint(0.00f, a_fRadius, 0.00f); vector3 bottomPoint(0.00f, -a_fRadius, 0.00f); std::vector<std::vector<vector3>> spherePoints; //holds all other vertices on the sphere //add the middle ring of vertices; if the number of subdivisions is even, there are two middle rings if (a_nSubdivisions % 2 == 0) { std::vector<vector3> topMiddleRing; for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fRadius * sin(angle); float z_Value = a_fRadius * cos(angle); topMiddleRing.push_back(vector3(x_Value, a_fRadius / (2 * a_nSubdivisions), z_Value)); } std::vector<vector3> bottomMiddleRing; for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fRadius * sin(angle); float z_Value = a_fRadius * cos(angle); bottomMiddleRing.push_back(vector3(x_Value, -a_fRadius / (2 * a_nSubdivisions), z_Value)); } spherePoints.push_back(topMiddleRing); spherePoints.push_back(bottomMiddleRing); } else { std::vector<vector3> middleRing; for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fRadius * sin(angle); float z_Value = a_fRadius * cos(angle); middleRing.push_back(vector3(x_Value, 0.00f, z_Value)); } spherePoints.push_back(middleRing); } //add more rings to the sphere equal to the number of subdivisions minus existing rings //rings can be added in pairs moving away from the middle ring/rings in both directions, //so the loop will run half the number of times int existingRings = spherePoints.size(); for (int x = 0; x < (a_nSubdivisions - existingRings)/ 2; x++) { std::vector<vector3> upperRing; std::vector<vector3> lowerRing; //get an adjusted radius for this pair of rings float adjustedRadius = (a_fRadius / ((a_nSubdivisions / 2) + 1)) * ((a_nSubdivisions / 2) - x); for (int y = 0; y < a_nSubdivisions; y++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * y; float x_Value = adjustedRadius * sin(angle); float z_Value = adjustedRadius * cos(angle); upperRing.push_back(vector3(x_Value, a_fRadius - adjustedRadius, z_Value)); lowerRing.push_back(vector3(x_Value, -a_fRadius + adjustedRadius, z_Value)); } spherePoints.push_back(upperRing); spherePoints.push_back(lowerRing); } //draw quads around the sphere moving away from the middle ring/rings if (a_nSubdivisions % 2 == 0) { //draw middle ring of quads for (int x = 0; x < spherePoints[0].size(); x++) { if (x != spherePoints[0].size() - 1) { AddQuad(spherePoints[1][x], spherePoints[1][x + 1], spherePoints[0][x], spherePoints[0][x + 1]); } else { AddQuad(spherePoints[1][x], spherePoints[1][0], spherePoints[0][x], spherePoints[0][0]); } } //draw more rings of quads for (int x = 0; x < spherePoints.size() - 2; x++) { if (x % 2 == 0) { for (int y = 0; y < spherePoints[x].size(); y++) { if (y != spherePoints[x].size() - 1) { AddQuad(spherePoints[x][y], spherePoints[x][y + 1], spherePoints[x + 2][y], spherePoints[x + 2][y + 1]); } else { AddQuad(spherePoints[x][y], spherePoints[x][0], spherePoints[x + 2][y], spherePoints[x + 2][0]); } } } else { for (int y = 0; y < spherePoints[x].size(); y++) { if (y != spherePoints[x].size() - 1) { AddQuad(spherePoints[x + 2][y], spherePoints[x + 2][y + 1], spherePoints[x][y], spherePoints[x][y + 1]); } else { AddQuad(spherePoints[x + 2][y], spherePoints[x + 2][0], spherePoints[x][y], spherePoints[x][0]); } } } } } else { } //draw the tris for the top and bottom for (int x = 0; x < spherePoints[spherePoints.size() - 1].size(); x++) { AddVertexPosition(bottomPoint); if (x == spherePoints[spherePoints.size() - 1].size() - 1) { AddVertexPosition(spherePoints[spherePoints.size() - 1][0]); } else { AddVertexPosition(spherePoints[spherePoints.size() - 1][x + 1]); } AddVertexPosition(spherePoints[spherePoints.size() - 1][x]); } for (int x = 0; x < spherePoints[spherePoints.size() - 2].size(); x++) { AddVertexPosition(spherePoints[spherePoints.size() - 2][x]); if (x == spherePoints[spherePoints.size() - 2].size() - 1) { AddVertexPosition(spherePoints[spherePoints.size() - 2][0]); } else { AddVertexPosition(spherePoints[spherePoints.size() - 2][x + 1]); } AddVertexPosition(topPoint); } //float fValue = 0.5f; ////3--2 ////| | ////0--1 //vector3 point0(-fValue, -fValue, fValue); //0 //vector3 point1(fValue, -fValue, fValue); //1 //vector3 point2(fValue, fValue, fValue); //2 //vector3 point3(-fValue, fValue, fValue); //3 //AddQuad(point0, point1, point3, point2); //Your code ends here CompileObject(a_v3Color); }
void MyPrimitive::GenerateTube(float a_fOuterRadius, float a_fInnerRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color) { if (a_nSubdivisions < 3) a_nSubdivisions = 3; if (a_nSubdivisions > 360) a_nSubdivisions = 360; Release(); Init(); //Your code starts here std::vector<vector3> outerTopPoints; //outer-top vertices std::vector<vector3> outerBasePoints; //outer-base vertices for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fOuterRadius * sin(angle); float z_Value = a_fOuterRadius * cos(angle); outerBasePoints.push_back(vector3(x_Value, -(a_fHeight / 2), z_Value)); } for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fOuterRadius * sin(angle); float z_Value = a_fOuterRadius * cos(angle); outerTopPoints.push_back(vector3(x_Value, a_fHeight / 2, z_Value)); } std::vector<vector3> innerTopPoints; //inner-top vertices std::vector<vector3> innerBasePoints; //inner-base vertices for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fInnerRadius * sin(angle); float z_Value = a_fInnerRadius * cos(angle); innerBasePoints.push_back(vector3(x_Value, -(a_fHeight / 2), z_Value)); } for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fInnerRadius * sin(angle); float z_Value = a_fInnerRadius * cos(angle); innerTopPoints.push_back(vector3(x_Value, a_fHeight / 2, z_Value)); } //create outer sides for (int x = 0; x < outerBasePoints.size(); x++) { if (x != outerBasePoints.size() - 1) { AddQuad(outerBasePoints[x], outerBasePoints[x + 1], outerTopPoints[x], outerTopPoints[x + 1]); } else { AddQuad(outerBasePoints[x], outerBasePoints[0], outerTopPoints[x], outerTopPoints[0]); } } //create inner sides for (int x = 0; x < innerBasePoints.size(); x++) { if (x != innerBasePoints.size() - 1) { AddQuad(innerTopPoints[x], innerTopPoints[x + 1], innerBasePoints[x], innerBasePoints[x + 1]); } else { AddQuad(innerTopPoints[x], innerTopPoints[0], innerBasePoints[x], innerBasePoints[0]); } } //create base ring for (int x = 0; x < outerBasePoints.size(); x++) { if (x != outerBasePoints.size() - 1) { AddQuad(innerBasePoints[x], innerBasePoints[x + 1], outerBasePoints[x], outerBasePoints[x + 1]); } else { AddQuad(innerBasePoints[x], innerBasePoints[0], outerBasePoints[x], outerBasePoints[0]); } } //create top ring for (int x = 0; x < outerTopPoints.size(); x++) { if (x != outerTopPoints.size() - 1) { AddQuad(outerTopPoints[x], outerTopPoints[x + 1], innerTopPoints[x], innerTopPoints[x + 1]); } else { AddQuad(outerTopPoints[x], outerTopPoints[0], innerTopPoints[x], innerTopPoints[0]); } } //float fValue = 0.5f; ////3--2 ////| | ////0--1 //vector3 point0(-fValue, -fValue, fValue); //0 //vector3 point1(fValue, -fValue, fValue); //1 //vector3 point2(fValue, fValue, fValue); //2 //vector3 point3(-fValue, fValue, fValue); //3 //AddQuad(point0, point1, point3, point2); //Your code ends here CompileObject(a_v3Color); }
void SkGlyphCache::findIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos, bool yAxis, SkGlyph* glyph, SkScalar* array, int* count) { const SkGlyph::Intercept* match = MatchBounds(glyph, bounds); if (match) { if (match->fInterval[0] < match->fInterval[1]) { OffsetResults(match, scale, xPos, array, count); } return; } SkGlyph::Intercept* intercept = (SkGlyph::Intercept* ) fGlyphAlloc.allocThrow(sizeof(SkGlyph::Intercept)); intercept->fNext = glyph->fPathData->fIntercept; intercept->fBounds[0] = bounds[0]; intercept->fBounds[1] = bounds[1]; intercept->fInterval[0] = SK_ScalarMax; intercept->fInterval[1] = SK_ScalarMin; glyph->fPathData->fIntercept = intercept; const SkPath* path = glyph->fPathData->fPath; const SkRect& pathBounds = path->getBounds(); if (*(&pathBounds.fBottom - yAxis) < bounds[0] || bounds[1] < *(&pathBounds.fTop - yAxis)) { return; } SkPath::Iter iter(*path, false); SkPoint pts[4]; SkPath::Verb verb; while (SkPath::kDone_Verb != (verb = iter.next(pts))) { switch (verb) { case SkPath::kMove_Verb: break; case SkPath::kLine_Verb: AddLine(pts, bounds[0], yAxis, intercept); AddLine(pts, bounds[1], yAxis, intercept); AddPoints(pts, 2, bounds, yAxis, intercept); break; case SkPath::kQuad_Verb: if (!quad_in_bounds(&pts[0].fY - yAxis, bounds)) { break; } AddQuad(pts, bounds[0], yAxis, intercept); AddQuad(pts, bounds[1], yAxis, intercept); AddPoints(pts, 3, bounds, yAxis, intercept); break; case SkPath::kConic_Verb: SkASSERT(0); // no support for text composed of conics break; case SkPath::kCubic_Verb: if (!cubic_in_bounds(&pts[0].fY - yAxis, bounds)) { break; } AddCubic(pts, bounds[0], yAxis, intercept); AddCubic(pts, bounds[1], yAxis, intercept); AddPoints(pts, 4, bounds, yAxis, intercept); break; case SkPath::kClose_Verb: break; default: SkASSERT(0); break; } } if (intercept->fInterval[0] >= intercept->fInterval[1]) { intercept->fInterval[0] = SK_ScalarMax; intercept->fInterval[1] = SK_ScalarMin; return; } OffsetResults(intercept, scale, xPos, array, count); }
void MyPrimitive::GenerateCylinder(float a_fRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color) { if (a_nSubdivisions < 3) a_nSubdivisions = 3; if (a_nSubdivisions > 360) a_nSubdivisions = 360; Release(); Init(); //Your code starts here vector3 topMid(0.00f, a_fHeight / 2, 0.00f); //mid-top vertex vector3 baseMid(0.00f, -(a_fHeight / 2), 0.00f); //mid-base vertex std::vector<vector3> topPoints; //top vertices std::vector<vector3> basePoints; //base vertices for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fRadius * sin(angle); float z_Value = a_fRadius * cos(angle); basePoints.push_back(vector3(x_Value, -(a_fHeight / 2), z_Value)); } for (int x = 0; x < a_nSubdivisions; x++) { //calculate vertex positions float angle = ((2 * PI) / a_nSubdivisions) * x; float x_Value = a_fRadius * sin(angle); float z_Value = a_fRadius * cos(angle); topPoints.push_back(vector3(x_Value, a_fHeight / 2, z_Value)); } //create base for (int x = 0; x < basePoints.size(); x++) { AddVertexPosition(baseMid); if (x == basePoints.size() - 1) { AddVertexPosition(basePoints[0]); } else { AddVertexPosition(basePoints[x + 1]); } AddVertexPosition(basePoints[x]); } //create top for (int x = 0; x <topPoints.size(); x++) { AddVertexPosition(topMid); AddVertexPosition(topPoints[x]); if (x == topPoints.size() - 1) { AddVertexPosition(topPoints[0]); } else { AddVertexPosition(topPoints[x + 1]); } } //create sides for (int x = 0; x < basePoints.size(); x++) { if (x != basePoints.size() - 1) { AddQuad(basePoints[x], basePoints[x + 1], topPoints[x], topPoints[x + 1]); } else { AddQuad(basePoints[x], basePoints[0], topPoints[x], topPoints[0]); } } //float fValue = 0.5f; ////3--2 ////| | ////0--1 //vector3 point0(-fValue, -fValue, fValue); //0 //vector3 point1(fValue, -fValue, fValue); //1 //vector3 point2(fValue, fValue, fValue); //2 //vector3 point3(-fValue, fValue, fValue); //3 //AddQuad(point0, point1, point3, point2); //Your code ends here CompileObject(a_v3Color); }