[11] 楔形体(Wedge)图形的生成算法
顶点数据的生成
bool YfBuildWedgeVertices
(
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;
if (vertexPtr)
{
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = vOriginOffset.x + width / ;
curVertexPtr->y = height + vOriginOffset.y;
curVertexPtr->z = vOriginOffset.z; curVertexPtr = (YsVector3*)(vertexPtr + nOffset + vertexStriding);
curVertexPtr->x = vOriginOffset.x + width / ;
curVertexPtr->y = height + vOriginOffset.y;
curVertexPtr->z = length + vOriginOffset.z;
} return true;
}
三角形索引数据的生成
bool YfBuildWedgeTriIndices
(
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 = ; // 2 face
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 = ; // 2 face
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
triIndexPtr = (YsTriIndex32*)(indexPtr + *indexStriding);
triIndexPtr->index0 = ; triIndexPtr->index1 = ; triIndexPtr->index2 = ;
} return true;
}
线框索引数据的生成
bool YfBuildWedgeWireIndices
(
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pWireIndicesBuffer
)
{
if (!pWireIndicesBuffer)
{
return false;
} Yuint numVertices = ;
Yuint numLines = ; // 索引赋值
char* indexPtr = (char*)pWireIndicesBuffer + indexPos;
Yuint nOffset = ;
if (indexType == YE_INDEX_16_BIT)
{
YsLineIndex16* lineIndexPtr = NULL; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex16*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ;
}
else
{
YsLineIndex32* lineIndexPtr = NULL; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ; nOffset = * indexStriding;
lineIndexPtr = (YsLineIndex32*)(indexPtr + nOffset);
lineIndexPtr->index0 = ;
lineIndexPtr->index1 = ;
} return true;
}
[11] 楔形体(Wedge)图形的生成算法的更多相关文章
- [20] 鼓状物(Drum)图形的生成算法
顶点数据的生成 bool YfBuildDrumVertices ( Yreal radius, Yreal assistRadius, Yuint slices, Yuint stacks, YeO ...
- [17] 楼梯(Stairs)图形的生成算法
感觉这图形怎么看怎么像搓衣板. 顶点数据的生成 bool YfBuildStairsVertices ( Yreal width, Yreal length, Yreal height, Yuint ...
- [6] 胶囊体(Capsule)图形的生成算法
顶点数据的生成 bool YfBuildCapsuleVertices ( Yreal radius, Yreal height, Yuint slices, Yuint stacks, YeOrig ...
- [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 ...
随机推荐
- 基于 Laravel 开发博客应用系列 —— 从测试开始(一):创建项目和PHPUnit
1.创建博客项目 我们将遵循上一节提到的六步创建一个新 Laravel 5.1 项目的步骤,创建本节要用到的博客项目 —— blog. 首先,在本地主机安装应用骨架: nonfu@ubuntu:~/C ...
- C#使用Pechkin与CPechkin生成PDF
http://blog.sina.com.cn/s/blog_5a52cec70102wpcf.html 1. Pechkin 从NuGet程序管理器中获得Pechkin,代码示例如下: ...
- Java double 精度
1. 范围 float和double的范围是由指数的位数来决定的. float的指数位有8位,而double的指数位有11位,分布如下: float: 1bit(符号位) 8bits(指数位) ...
- 使用UniBeast安装Hackintosh(黑苹果)
前期准备 UniBeast 原版macOS Sierra安装包,由于苹果并没有提供完整dmg的下载地址,我也不在此提供,大家可以从信任的途径取得,文件后缀必须为dmg. 16GB或者更大的U盘 至少2 ...
- [ 原创 ] Java基础1--Java中super和this的用法和区别
许多同学在学习Java时分不清楚this和super的用法和区别,今天偶然发现一片加精的博文,看完内容准备自己也写下来积累一下 1.如果想在子类的构造方法中调用父类的构造方法,必须在子类的构造方法中使 ...
- django设置数据库事务,通过异常处理回滚事务
1.setting.py配置文件,开启事务ATOMIC_REQUESTS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql' ...
- [CC-MCHEF]MasterChef
[CC-MCHEF]MasterChef 题目大意: \(n(n\le10^5)\)片花,第\(i\)片花的美观度为\(b_i(|b_i|\le10^9)\).总体美观度为各片花的美观度之和. 由于有 ...
- MySQL的五种日期和时间类型
MySQl中有多种表示日期和时间的数据类型.其中YEAR表示年份,DATE表示日期,TIME表示时间,DATETIME和TIMESTAMP表示日期和实践.它们的对比如下:YEAR ,字节数 ...
- Codeforces Round #353 (Div. 2) E. Trains and Statistic dp 贪心
E. Trains and Statistic 题目连接: http://www.codeforces.com/contest/675/problem/E Description Vasya comm ...
- Android 通话记录分析
http://stackoverflow.com/questions/6786666/how-do-i-access-call-log-for-android http://android2011de ...