顶点数据的生成

 bool                        YfBuildSpiralStairsVertices
(
Yreal radius,
Yreal assistRadius,
Yreal height,
Yuint slices,
Yuint stacks,
YeOriginPose originPose,
Yuint vertexStriding,
Yuint vertexPos,
void* pVerticesBuffer
)
{
if (stacks < || slices < || !pVerticesBuffer)
{
return false;
}
Yuint numVertices = + stacks * ;
//Yuint numTriangles = stacks * 8; char* vertexPtr = (char*)pVerticesBuffer + vertexPos;
YsVector3* curVertexPtr = NULL;
Yuint nOffset = ; Yreal originOffsetY = 0.0f;
if (originPose == YE_ORIGIN_POSE_TOP)
{
originOffsetY = -height;
}
else if (originPose == YE_ORIGIN_POSE_CENTER)
{
originOffsetY = -height * 0.5f;
} Yreal fStepTexcoord = 1.0f / (stacks - );
Yreal fStepHeight = height / stacks;
Yreal fStepAngle = YD_REAL_TWAIN_PI / slices; Yreal angleXZ;
Yreal posX, posZ;
for (Yuint i = ; i <= stacks; i++)
{
angleXZ = i * fStepAngle;
posX = yf_sin(angleXZ);
posZ = yf_cos(angleXZ); nOffset = i * * vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = radius * posX;
curVertexPtr->y = i * fStepHeight + originOffsetY;
curVertexPtr->z = radius * posZ; nOffset += vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = assistRadius * posX;
curVertexPtr->y = i * fStepHeight + originOffsetY;
curVertexPtr->z = assistRadius * posZ; if (i == stacks)
{
continue;
} nOffset += vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = radius * posX;
curVertexPtr->y = (i+) * fStepHeight + originOffsetY;
curVertexPtr->z = radius * posZ; nOffset += vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = assistRadius * posX;
curVertexPtr->y = (i+) * fStepHeight + originOffsetY;
curVertexPtr->z = assistRadius * posZ;
} return true;
}

三角形索引数据的生成和线框索引数据的生成与楼梯的生成方式一样

 bool                        YfBuildSpiralStairsTriIndices
(
Yuint stacks,
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pTriIndicesBuffer
)
{
return YfBuildStairsTriIndices(
stacks,
indexType,
indexStriding,
indexPos,
pTriIndicesBuffer
);
} bool YfBuildSpiralStairsWireIndices
(
Yuint stacks,
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pWireIndicesBuffer
)
{
return YfBuildStairsWireIndices(
stacks,
indexType,
indexStriding,
indexPos,
pWireIndicesBuffer
);
}

最新文章

  1. Disruptor-NET和内存栅栏
  2. 转:TopN推荐系统——推荐的实现与推荐效果的评价指标
  3. laravel redis
  4. python之网络爬虫
  5. poj: 2255
  6. 如何将jsp中&lt;input&gt;设为只读
  7. Shiro 缓存失效以后的一个问题
  8. Pyhon之类学习1
  9. [記錄用]python py2app 檔案批次重新命名
  10. Python使用heapq实现小顶堆(TopK大)、大顶堆(BtmK小)
  11. hdu1876(dp)
  12. linux上安装mysql及简单的使用
  13. 【Python爬虫实战--2】时间戳转换为指定格式日期
  14. Python之路【第二篇】:Python基础(二)
  15. tyvj4865 天天和树tree
  16. C# new关键字和对象类型转换(双括号、is操作符、as操作符)
  17. Android动态加载入坑指南
  18. OTP&amp;ETS
  19. PS调出怀旧雨中特写的非主流照片
  20. 强大的xargs

热门文章

  1. Ionic Js七:手势事件
  2. php匹配邮箱正则
  3. python面向对象中类对象、实例对象、类变量、实例变量、类方法、实例方法、静态方法
  4. Ajax与传统Web开发的区别
  5. HTML基础-DAY1
  6. 20162327WJH实验四——图的实现与应用
  7. Codecademy python
  8. Shell中EOF内容转义
  9. CentOS 7挂载磁盘提示: mount: unknown filesystem type &#39;LVM2_member&#39;
  10. PHP自学之路---雇员管理系统(1)