顶点数据的生成

 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
);
}

[18] 螺旋楼梯(Spiral Stairs)图形的生成算法的更多相关文章

  1. [17] 楼梯(Stairs)图形的生成算法

    感觉这图形怎么看怎么像搓衣板. 顶点数据的生成 bool YfBuildStairsVertices ( Yreal width, Yreal length, Yreal height, Yuint ...

  2. [20] 鼓状物(Drum)图形的生成算法

    顶点数据的生成 bool YfBuildDrumVertices ( Yreal radius, Yreal assistRadius, Yuint slices, Yuint stacks, YeO ...

  3. [19] 半球形(Hemisphere)图形的生成算法

    顶点数据的生成 bool YfBuildHemisphereVertices ( Yreal radius, Yuint slices, Yuint stacks, YeOriginPose orig ...

  4. [16] 螺旋面(Spire)图形的生成算法

    顶点数据的生成 bool YfBuildSpireVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint slices, Yu ...

  5. [15] 星星(Star)图形的生成算法

    顶点数据的生成 bool YfBuildStarVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint slices, YeO ...

  6. [14] 齿轮(Gear Wheel)图形的生成算法

    顶点数据的生成 bool YfBuildGearwheelVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint slices ...

  7. [13] 弧面(Arc)图形的生成算法

    顶点数据的生成 bool YfBuildArcVertices ( Yreal radius, Yreal degree, Yreal height, Yuint slices, Yuint stac ...

  8. [12] 扇形体(Fan)图形的生成算法

    顶点数据的生成 bool YfBuildFunVertices ( Yreal radius, Yreal degree, Yreal height, Yuint slices, YeOriginPo ...

  9. [11] 楔形体(Wedge)图形的生成算法

    顶点数据的生成 bool YfBuildWedgeVertices ( Yreal width, Yreal length, Yreal height, YeOriginPose originPose ...

随机推荐

  1. 8-2 Building for UN Uva1605

    题意:你的任务是设计一个包含若干层的联合国大楼,其中每层都是一个等大的网络 由若干个国家需要在联合国大楼里面办公 你需要把每个格子分配给一个国家 使得任意两个不同的国家都有一对相邻的格子  (要没是同 ...

  2. LINUX 下挂载 exfat 格式 u 盘或移动硬盘

    apt-get update apt-get install exfat-utils

  3. 在控制台连接oracle

    Microsoft Windows [版本 6.1.7601]版权所有 (c) 2009 Microsoft Corporation.保留所有权利. C:\Users\lijt>sqlplus ...

  4. Oracle 默认的几个登陆用户名和密码

    默认用户有这么几个,system,sys,scott,hr ,一般scott 和hr 作为你的练习用户.system的默认密码是 manager sys的默认密码是 change_on_install ...

  5. NetStandard类库实现Log4Net集成

    前面都是Log4Net集成到NetCore项目中,集成到NetStandard类库还是第一次,所以记录一下 小提示:NetStandard要想同时被NetCore和NetFramework调用,需要在 ...

  6. 【WIN10】使用自己的PageLoader加載Page

    源碼下載:http://yunpan.cn/cFwwrT4V5rHIM  访问密码 1b97 在上一篇博客中,我已經說明了為什麼要自己寫一個PageLoader.原因就是,Frame的GoBack只是 ...

  7. wpf企业应用之SelectButton(用于列表页之类的选择)

    在企业级应用中,通常我们会遇到这样的需求,需要点击一个按钮选择列表中的一项或者多项,然后将结果显示到按钮中.这里我给自己的控件命名为SelectButton,具体效果见 wpf企业级开发中的几种常见业 ...

  8. BZOJ 2653: middle 主席树 二分

    https://www.lydsy.com/JudgeOnline/problem.php?id=2653 因为是两个方向向外延伸所以不能对编号取前缀和(这里只有前缀和向后传递的性质,不是实际意义的和 ...

  9. bzoj 1337 最小圆覆盖

    /************************************************************** Problem: 1337 User: idy002 Language: ...

  10. python及其模块下载集合

    1)python平台 https://www.python.org/downloads/ 2)打包工具 cx-freeze(python3以上版本打包工具) http://cx-freeze.sour ...