[7] 金字塔(Pyramid)图形的生成算法
顶点数据的生成
bool YfBuildPyramidVertices
(
Yreal width,
Yreal length,
Yreal height,
YeOriginPose originPose,
Yuint vertexStriding,
Yuint vertexPos,
void* pVerticesBuffer
)
{
if (!pVerticesBuffer)
{
return false;
} Yuint numVertices = ; char* vertexPtr = (char*)pVerticesBuffer + vertexPos;
YsVector3* curVertexPtr = NULL;
Yuint nOffset = ; YsVector3 vOriginOffset(-width / , -height / , -length / );
if (originPose == YE_ORIGIN_POSE_TOP)
{
vOriginOffset.y = -height;
}
else if (originPose == YE_ORIGIN_POSE_BOTTOM)
{
vOriginOffset.y = 0.0f;
} // 底四个顶点
for (Yuint j = ; j < ; j++)
{
for (Yuint i = ; i < ; i++)
{
nOffset = (j* + i) * vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = width*i + vOriginOffset.x;
curVertexPtr->y = vOriginOffset.y;
curVertexPtr->z = length*j + vOriginOffset.z;
}
} // 顶尖顶点
nOffset = * vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = 0.0f;
curVertexPtr->y = height + vOriginOffset.y;
curVertexPtr->z = 0.0f; return true;
}
三角形索引数据的生成
bool YfBuildPyramidTriIndices
(
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pTriIndicesBuffer
)
{
if (!pTriIndicesBuffer)
{
return false;
} char* indexPtr = (char*)pTriIndicesBuffer + indexPos;
if (indexType == YE_INDEX_16_BIT)
{
YsTriIndex16* triIndexPtr = NULL; // bottom
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ; // 4 face
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex16*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
}
else
{
YsTriIndex32* triIndexPtr = NULL; // bottom
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ; // 4 face
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
} return true;
}
线框索引数据的生成
bool YfBuildPyramidWireIndices
(
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pWireIndicesBuffer
)
{
if (!pWireIndicesBuffer)
{
return false;
} Yuint numVertices = ;
Yuint numLines = ;
if (indexType == YE_INDEX_16_BIT &&
numVertices > YD_MAX_UNSIGNED_INT16)
{
return false;
} // 索引赋值
char* indexPtr = (char*)pWireIndicesBuffer + indexPos;
Yuint nOffset = ;
if (indexType == YE_INDEX_16_BIT)
{
YsLineIndex16* lineIndexPtr = NULL; // bottom
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ; // 4 lines
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex16*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
}
else
{
YsLineIndex32* lineIndexPtr = NULL; // bottom
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ; // 4 lines
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
lineIndexPtr = (YsLineIndex32*)(indexPtr + *indexStriding);
lineIndexPtr->index0 = ; lineIndexPtr->index1 = ;
} return true;
}
[7] 金字塔(Pyramid)图形的生成算法的更多相关文章
- [20] 鼓状物(Drum)图形的生成算法
顶点数据的生成 bool YfBuildDrumVertices ( Yreal radius, Yreal assistRadius, Yuint slices, Yuint stacks, YeO ...
- [17] 楼梯(Stairs)图形的生成算法
感觉这图形怎么看怎么像搓衣板. 顶点数据的生成 bool YfBuildStairsVertices ( Yreal width, Yreal length, Yreal height, Yuint ...
- [19] 半球形(Hemisphere)图形的生成算法
顶点数据的生成 bool YfBuildHemisphereVertices ( Yreal radius, Yuint slices, Yuint stacks, YeOriginPose orig ...
- [18] 螺旋楼梯(Spiral Stairs)图形的生成算法
顶点数据的生成 bool YfBuildSpiralStairsVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint sli ...
- [16] 螺旋面(Spire)图形的生成算法
顶点数据的生成 bool YfBuildSpireVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint slices, Yu ...
- [15] 星星(Star)图形的生成算法
顶点数据的生成 bool YfBuildStarVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint slices, YeO ...
- [14] 齿轮(Gear Wheel)图形的生成算法
顶点数据的生成 bool YfBuildGearwheelVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint slices ...
- [13] 弧面(Arc)图形的生成算法
顶点数据的生成 bool YfBuildArcVertices ( Yreal radius, Yreal degree, Yreal height, Yuint slices, Yuint stac ...
- [12] 扇形体(Fan)图形的生成算法
顶点数据的生成 bool YfBuildFunVertices ( Yreal radius, Yreal degree, Yreal height, Yuint slices, YeOriginPo ...
随机推荐
- caffe中根据 *_train_test.prototxt文件生成 *_deploy.prototxt文件 (转载)
见博客:http://blog.csdn.net/u010417185/article/details/52137825
- vue 组件使用中的细节点
1.is属性 有些 HTML 元素,诸如 <ul>.<ol>.<table> 和 <select>,对于哪些元素可以出现在其内部是有严格限制的.而有些元 ...
- FGPA 中的计数器Verilog语言(时钟分频器)
在quartusII8.0中为ALTERAFPGA设置一个分频器(计数器) 输入时钟48Mhz 输出时钟9600HZ /* 实验名称: 计数器 ** 程序功能: 将48Mhz的时钟分频为9600Hz ...
- [ 原创 ]学习笔记- 数据在Activity之间的传递的情况
情况一:一个Activity跳转到另一个Activity时,将第一个Activity的数据传递到第二个Activity里面. 分析:当一个界面跳转到另一个界面的同时还要讲数据传递过去,这种情况需要用I ...
- [BZOJ5306][HAOI2018]染色(容斥+FFT)
https://www.cnblogs.com/zhoushuyu/p/9138251.html 注意如果一开始F(i)中内层式子中j枚举的是除前i种颜色之外还有几种出现S次的颜色,那么后面式子就会难 ...
- BZOJ 4945 UOJ #317 NOI2017 游戏 2-SAT 拓扑排序
http://uoj.ac/problem/317 https://www.lydsy.com/JudgeOnline/problem.php?id=4945 我现在的程序uoj的额外数据通过不了,b ...
- redis 多实例 连接 加密码
=启动多个redis实例= #redis-server/usr/local/redis/redis6370.conf #redis-server/usr/local/redis/redis6371.c ...
- hdu 1116 并查集判断欧拉回路通路
判断一些字符串能首尾相连连在一起 并查集求欧拉回路和通路 Sample Input 3 2 acm ibm 3 acm malform mouse 2 ok ok Sample Output The ...
- TCP的建立和终止 图解
前言 在没有理解TCP连接是如何建立和终止之前,我想你可能并不会使用connect,accept,close这三个函数并且使用netstat程序来调试应用.所以掌握TCP连接的建立和终止势在必行. 三 ...
- JS判断图片上传时文件大小和图片尺寸
如何读取图片的size: 首先,原生input file控件有个files属性,该属性是一个数组.数组中的元素有以下属性:lastModifiedDate,name,size,type,webkitR ...