关于3d圆球顶点数据算法
来源:互联网 发布:虚无世界2java下载 编辑:程序博客网 时间:2024/04/25 09:12
//Establish constants used in sphere generation
FLOAT rDeltaRingAngle = (D3DX_PI / m_nRings);
FLOAT rDeltaSegAngle = (2.0f * D3DX_PI / m_nSegments);
//Generate the group of rings for the sphere
for(nCurrentRing = 0; nCurrentRing < m_nRings + 1; nCurrentRing++)
{
FLOAT r0 = sinf(nCurrentRing * rDeltaRingAngle);
FLOAT y0 = cosf(nCurrentRing * rDeltaRingAngle);
//Generate the group of segments for the current ring
for(nCurrentSegment = 0; nCurrentSegment < m_nSegments + 1; nCurrentSegment++)
{
FLOAT x0 = r0 * sinf(nCurrentSegment * rDeltaSegAngle);
FLOAT z0 = r0 * cosf(nCurrentSegment * rDeltaSegAngle);
vNormal.x = x0;
vNormal.y = y0;
vNormal.z = z0;
D3DXVec3Normalize(&vNormal, &vNormal);
//Add one vertex to the strip which makes up the sphere
pVertex->x = x0;
pVertex->y = y0;
pVertex->z = z0;
pVertex->nx = vNormal.x;
pVertex->ny = vNormal.y;
pVertex->nz = vNormal.z;
pVertex->tu = 1.0f - ((FLOAT)nCurrentSegment / (FLOAT)m_nSegments);
pVertex->tv = (FLOAT)nCurrentRing / (FLOAT)m_nRings;
pVertex++;
//Add two indices except for the last ring
if(nCurrentRing != m_nRings)
{
*pIndices = wVertexIndex;
pIndices++;
*pIndices = wVertexIndex + (WORD)(m_nSegments + 1);
pIndices++;
wVertexIndex++;
}
}
}
- 关于3d圆球顶点数据算法
- 关于Android手势缩放圆球
- 3D顶点转换和法线转换
- 3D顶点转换和法线转换
- 3D图形关于bresenham算法原理
- 关于3D模型的搜索算法
- 关于自定义圆环或者小圆球
- Direct 3D学习笔记二:顶点的创建
- 3D游戏从头编--第四回:顶点渲染
- 3D游戏从头编--第五回:索引顶点
- 3D 顶点颜色 纹理 材质之间的关系
- C#实现3D三角形 顶点转换以及投影
- 关于R-D 优化算法
- 处理顶点数据
- Unity 获得顶点数据
- 顶点数据随笔
- 用3DXI导出顶点数据的代码段
- 关于3d旋转
- CLI 日志查询
- 通用序列化类
- 你不是菜鸟(7):五年工作经验的笨蛋
- 打电话时查看log
- Android--将数据保存到SDCard中
- 关于3d圆球顶点数据算法
- 超牛JS
- XMLHttpRequest对象的属性和事件
- 位运算
- 如何保持网络畅通 整理贴
- C++实现机制(二)——编译器实现对象模型的方法
- 2010年8月4日
- A good experience
- 一个简单C程序引发的讨论