关于3d圆球顶点数据算法

本文介绍了一种3D圆球的顶点数据生成算法,通过计算环形和扇形的角度来确定每个顶点的位置。利用D3DX库函数进行向量归一化,确保顶点的正确分布,并生成相应的纹理坐标。每环内部通过添加两个索引来构建球体的表面。
摘要由CSDN通过智能技术生成

//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
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值