ultraxion

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

102 Neutral

About ultraxion

  • Rank
    Newbie
  1. [quote name='Gavin Williams' timestamp='1355675135' post='5011294'] Why use a 2D array for your vertices ? I cannot think of a reason why I would ever need to do that ! [/quote] Ah.2D array I put vertices in, I think it may clearly show a sphere has how many stack, and how many slices ? Do you have some good idea for drawing sphere in D3D11 ? I try 'D3DXCreateSphere', but it needs D3D9 ! : ( I would appreciate.
  2. Hi everyone [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] ? Im newer of D3D11, and Im doing some simple work for practice. [i][b]My 1st question is[/b][/i] [b]:[/b] I use following code to generate sphere's vertices' position data. I use [b]Two-dimensional Array[/b] to save vertices, but I don't know whether following code [b]vertexData.pSysMem = vertices; [/b]correct ? And will the data in [b]vertex-buffer[/b] correct ? [b][i]My 2nd question is[/i] : [/b]I don't know how to compute index of each triangle ? [b]Following code shows my way to create sphere's vertices' data.[/b] [u][b]Variable 'stack' like weft, and slice like warp, by them I create sphere with 2 step, each step create half-sphere.[/b][/u] for(int iStack = 0; iStack < stack; iStack++) { if( iStack == (stack / 2) ) { tmp_radius = 0; height = 0; } if( iStack < ((stack - 1) / 2) ) { double angle = 0.0f; height = pos.y - radius + tmp_radius; for(int iSlice = 0; iSlice < (slices * 2); iSlice++) { vertices[iStack][iSlice].position.x = pos.x + (float)(cos(angle) * tmp_radius); vertices[iStack][iSlice].position.y = (float)height; vertices[iStack][iSlice].position.z = pos.z + (float)(sin(angle) * tmp_radius); angle += phi; } tmp_radius += delta_of_radius; continue; } else { double angle = 0; height = pos.y + radius - tmp_radius; for(int iSlice = 0; iSlice < (slices * 2); iSlice++) { vertices[iStack][iSlice].position.x = pos.x + (float)(cos(angle) * tmp_radius); vertices[iStack][iSlice].position.y = (float)height; vertices[iStack][iSlice].position.z = pos.z + (float)(sin(angle) * tmp_radius); angle += phi; } tmp_radius += delta_of_radius; continue; } }