public void PopulateAsHollowCone(float radius, float height, LCC3Tessellation angleAndHeightDivs) { uint numAngularDivs = Math.Max(angleAndHeightDivs.X, 3); uint numHeightDivs = Math.Max(angleAndHeightDivs.Y, 1); float radiusHeightRatio = radius / height; float angularDivSpan = (float)(Math.PI * 2) / numAngularDivs; float heightDivSpan = height / numHeightDivs; float radialDivSpan = radius / numHeightDivs; float texAngularDivSpan = 1.0f / numAngularDivs; float texHeightDivSpan = 1.0f / numHeightDivs; uint vertexCount = (numAngularDivs + 1) * (numHeightDivs + 1); uint triangleCount = 2 * numAngularDivs * numHeightDivs - numAngularDivs; this.EnsureVertexContent(); this.AllocatedVertexCapacity = vertexCount; this.AllocatedVertexIndexCapacity = (triangleCount * 3); uint vIdx = 0; uint iIdx = 0; for (uint ia = 0; ia <= numAngularDivs; ia++) { float angle = angularDivSpan * ia; float ca = (float)-Math.Cos(angle); float sa = (float)-Math.Sin(angle); LCC3Vector vtxNormal = new LCC3Vector(sa, radiusHeightRatio, ca).NormalizedVector(); for (uint ih = 0; ih <= numHeightDivs; ih++, vIdx++) { float vtxRadius = radius - (radialDivSpan * ih); float vtxHt = heightDivSpan * ih; LCC3Vector vtxLoc = new LCC3Vector(vtxRadius * sa, vtxHt, vtxRadius * ca); this.SetVertexLocationAtIndex(vtxLoc,vIdx); this.SetNormalAtIndex(vtxNormal, vIdx); CCTex2F texCoord = new CCTex2F(texAngularDivSpan * ia, (1.0f - texHeightDivSpan * ih)); this.SetVertexTexCoord2FAtIndex(texCoord, vIdx); if (ia < numAngularDivs && ih < numHeightDivs) { this.SetVertexIndexAtIndex( vIdx, iIdx++); this.SetVertexIndexAtIndex((vIdx + numHeightDivs + 1),iIdx++); this.SetVertexIndexAtIndex((vIdx + numHeightDivs + 2),iIdx++); if (ih < numHeightDivs - 1) { this.SetVertexIndexAtIndex((vIdx + numHeightDivs + 2), iIdx++); this.SetVertexIndexAtIndex((vIdx + 1), iIdx++); this.SetVertexIndexAtIndex(vIdx, iIdx++); } } } } }
protected CCTex2F TextureCoordFromAlphaPoint(CCPoint alpha) { var ret = new CCTex2F(0.0f, 0.0f); if (m_pSprite == null) { return(ret); } CCV3F_C4B_T2F_Quad quad = m_pSprite.Quad; var min = new CCPoint(quad.BottomLeft.TexCoords.U, quad.BottomLeft.TexCoords.V); var max = new CCPoint(quad.TopRight.TexCoords.U, quad.TopRight.TexCoords.V); // Fix bug #1303 so that progress timer handles sprite frame texture rotation if (m_pSprite.IsTextureRectRotated) { float tmp = alpha.X; alpha.X = alpha.Y; alpha.Y = tmp; } return(new CCTex2F(min.X * (1f - alpha.X) + max.X * alpha.X, min.Y * (1f - alpha.Y) + max.Y * alpha.Y)); }
public static CCTex2F Tex2(float u, float v) { CCTex2F t = new CCTex2F(u, v); return(t); }
public CCV2F_C4F_T2F() { Vertices = new CCVertex2F(); Colors = new CCColor4F(); TexCoords = new CCTex2F(); }
public static CCTex2F Tex2(float u, float v) { CCTex2F t = new CCTex2F(u, v); return t; }
protected CCTex2F TextureCoordFromAlphaPoint(CCPoint alpha) { var ret = new CCTex2F(0.0f, 0.0f); if (m_pSprite == null) { return ret; } CCV3F_C4B_T2F_Quad quad = m_pSprite.Quad; var min = new CCPoint(quad.BottomLeft.TexCoords.U, quad.BottomLeft.TexCoords.V); var max = new CCPoint(quad.TopRight.TexCoords.U, quad.TopRight.TexCoords.V); // Fix bug #1303 so that progress timer handles sprite frame texture rotation if (m_pSprite.IsTextureRectRotated) { float tmp = alpha.X; alpha.X = alpha.Y; alpha.Y = tmp; } return new CCTex2F(min.X * (1f - alpha.X) + max.X * alpha.X, min.Y * (1f - alpha.Y) + max.Y * alpha.Y); }
public void SetTexCoord2FAtIndex(CCTex2F tex2F, uint index) { _vertices[(int)index] = tex2F; }
public void SetVertexTexCoord2FAtIndex(CCTex2F texCoord, uint index) { _vertexTexCoords.SetTexCoord2FAtIndex(texCoord, index); }