顶点数据的生成

 bool                        YfBuildBoxVertices
(
Yreal extentX,
Yreal extentY,
Yreal extentZ,
YeOriginPose originPose,
Yuint vertexStriding,
Yuint vertexPos,
void* pVerticesBuffer
)
{
if (!pVerticesBuffer)
{
return false;
} Yuint numVertices = ; // 顶点赋值
char* vertexPtr = (char*)pVerticesBuffer + vertexPos; YsVector3* curVertexPtr = NULL;
YsVector3* curNormalPtr = NULL;
YsVector2* curTexcoordPtr = NULL; Yuint nOffset = ; YsVector3 vOriginOffset(-extentX / , -extentY / , -extentZ / );
if (originPose == YE_ORIGIN_POSE_TOP)
{
vOriginOffset.y = -extentY;
}
else if (originPose == YE_ORIGIN_POSE_BOTTOM)
{
vOriginOffset.y = 0.0f;
} for (Yuint k = ; k < ; k++)
{
for (Yuint j = ; j < ; j++)
{
for (Yuint i = ; i < ; i++)
{
nOffset = (k* + j* + i) * vertexStriding;
curVertexPtr = (YsVector3*)(vertexPtr + nOffset);
curVertexPtr->x = extentX*i + vOriginOffset.x;
curVertexPtr->z = extentZ*j + vOriginOffset.z;
curVertexPtr->y = extentY*k + vOriginOffset.y;
}
}
} return true;
}

三角形索引数据的生成

 bool                        YfBuildBoxTriIndices
(
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[];
for (Yuint i = ; i < ; i++)
{
triIndexPtr[i] = (YsTriIndex16*)(indexPtr + i * indexStriding);
} // bottom
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // top
triIndexPtr[]->index0= ; triIndexPtr[]->index1= ; triIndexPtr[]->index2= ;
triIndexPtr[]->index0= ; triIndexPtr[]->index1= ; triIndexPtr[]->index2= ; // front side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // back side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // right side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // left side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
}
else
{
YsTriIndex32* triIndexPtr[];
for (Yuint i = ; i < ; i++)
{
triIndexPtr[i] = (YsTriIndex32*)(indexPtr + i * indexStriding);
} // bottom
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // top
triIndexPtr[]->index0= ; triIndexPtr[]->index1= ; triIndexPtr[]->index2= ;
triIndexPtr[]->index0= ; triIndexPtr[]->index1= ; triIndexPtr[]->index2= ; // front side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // back side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // right side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ; // left side
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
triIndexPtr[]->index0 = ; triIndexPtr[]->index1 = ; triIndexPtr[]->index2 = ;
} return true;
}

线框索引数据的生成

 bool                        YfBuildBoxWireIndices
(
YeIndexType indexType,
Yuint indexStriding,
Yuint indexPos,
void* pWireIndicesBuffer
)
{
if (!pWireIndicesBuffer)
{
return false;
} char* indexPtr = (char*)pWireIndicesBuffer + indexPos;
if (indexType == YE_INDEX_16_BIT)
{
YsLineIndex16* lineIndexPtr[];
for (Yuint i = ; i < ; i++)
{
lineIndexPtr[i] = (YsLineIndex16*)(indexPtr + i * indexStriding);
} // bottom
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ; // center
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ; // top
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0= ; lineIndexPtr[]->index1= ;
lineIndexPtr[]->index0= ; lineIndexPtr[]->index1= ;
}
else
{
YsLineIndex32* lineIndexPtr[];
for (Yuint i = ; i < ; i++)
{
lineIndexPtr[i] = (YsLineIndex32*)(indexPtr + i * indexStriding);
} // bottom
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ; // center
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ; // top
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0 = ; lineIndexPtr[]->index1 = ;
lineIndexPtr[]->index0= ; lineIndexPtr[]->index1= ;
lineIndexPtr[]->index0= ; lineIndexPtr[]->index1= ;
} return true;
}

[2] 立方体(Box)图形的生成算法的更多相关文章

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

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

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

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

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

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

  4. [18] 螺旋楼梯(Spiral Stairs)图形的生成算法

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

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. 6-14 Inspector s Dilemma uva12118(欧拉道路)

    题意:给出一个国家城市个数n   所需走过道路个数e   每条道路长t   该国家任意两个城市之间都存在唯一道路长t     要求 :找一条最短的路遍历所有所需走过的路 一开始以为是图的匹配  但是好 ...

  2. Ubuntu 17.04 搭建 NodeJS

    可以在云主机上执行以下的命令: apt-get update apt-get install -y python-software-properties software-properties-com ...

  3. 洛谷P2671 求和 [数论]

    题目传送门 求和 格式难调,题面就不放了. 分析: $ZYYS$的一道题. 很显然是大力推公式.我们分析一下题目,实际上限制条件就是:下标同奇偶且颜色相同的数,那么我们先拿这个公式$(x+z)*(nu ...

  4. My blog in AI ---神经网络,网络架构

    上一篇博文中,我们介绍了神经网络中的神经元,那么该如何组织起来这些神经元,才能发挥出最好的效果去解决现实中的问题呢? 这是一个复杂的问题,在工程中,神经网络的架构也是训练的也是一种超参数,本节先在理论 ...

  5. MIT-6.828-JOS-环境搭建

    MIT 6.828是操作系统中最经典的一门课程.完成所有的lab就相当于完成了一个迷你的操作系统.我跟的是2018年的课程,课程首页在6.828课程官网.当然所有资料都是英文的,所以难度也不低,这里推 ...

  6. 【原创】MySQL复制slave服务器死锁案例

    MySQL复制刚刚触发了一个bug,该bug的触发条件是slave上Xtrabackup备份的时候执行flushs tables with read lock和show slave status有可能 ...

  7. Tensorflow学习:(三)神经网络优化

    一.完善常用概念和细节 1.神经元模型: 之前的神经元结构都采用线上的权重w直接乘以输入数据x,用数学表达式即,但这样的结构不够完善. 完善的结构需要加上偏置,并加上激励函数.用数学公式表示为:.其中 ...

  8. 【漏洞预警】CVE-2017-8464 震网三代漏洞复现

    早在6月13日,微软发布补丁修复编号为CVE-2017-8464的漏洞,本地用户或远程攻击者可以利用该漏洞生成特制的快捷方式,并通过可移动设备或者远程共享的方式导致远程代码执行,追溯到以前,NSA就承 ...

  9. w​x​F​o​r​m​B​u​i​l​d​e​r​初​体​验

    第一步 打开wxFormBuilder 修改工程信息并保存工程 Name: 工程名 File: 生成代码(.py)文件名 Code_generation: 生成代码类型 第二步 创建窗体 切换至for ...

  10. Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate

    C. Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standa ...