[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 ...
随机推荐
- Web层的Controller代码逻辑
需要做的功能: 1.数据的校验. 为什么不在后面的Service层校验呢? 原因:Service是通用的,而调用方Controller有多个,每一个Controller代表一个业务,这些业务需要校验的 ...
- 300万大奖:欢迎参加美团联合主办的全球AI挑战赛
2018年8月29日,由美团.创新工场.搜狗.美图联合主办的“AI Challenger 2018全球AI挑战赛”正式启动.美团CTO罗道峰.创新工场CEO李开复.搜狗CEO王小川和美图CEO吴欣鸿共 ...
- Android IntentService
IntentService简要分析 IntentService 继承自 android.app.Service.内部实现极其简单. 首先在 onCreate()中去开启了一个 HandlerThrea ...
- [leetcode sort]57. Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa ...
- 1021 Deepest Root (25)(25 point(s))
problem A graph which is connected and acyclic can be considered a tree. The height of the tree depe ...
- Linux驱动之IIC总线
<作用> 电子设备中有很多IIC设备之间需要进行相互通信,这样就产生了IIC总线,常用来实现设备之间的数据通信. <IIC总线结构> IIC总线只有两条线,一条是串行数据线 ...
- 【BZOJ 2318】 2318: Spoj4060 game with probability Problem(概率DP)
2318: Spoj4060 game with probability Problem Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 371 Sol ...
- bzoj1814: Ural 1519 Formula 1 动态规划 插头dp
http://acm.timus.ru/problem.aspx?space=1&num=1519 题目描述 一个 m * n 的棋盘,有的格子存在障碍,求经过所有非障碍格子的哈密顿回路个数. ...
- 读书笔记_Effective_C++_条款四十:明智而审慎地使用多重继承
多重继承是一种比较复杂的继承关系,它意味着如果用户想要使用这个类,那么就要对它的父类也了如指掌,所以在项目中会带来可读性的问题,一般我们都会尽量选择用单继承去替代它. 使用多重继承过程容易碰到的问题就 ...
- UploadFileUtil
package cn.tz.util.file; import java.io.File; import java.io.FileOutputStream; import java.io.InputS ...