0
我使用C++和g3d繪製一個簡單的球體,但不知道如何在圓形中排列多個對象/球體。在圓形中排列3d對象
for(i = 0.0f;i<1.4f;i+=0.2f){
sphere->position = (Vector3(2,i,0));
}
如果有人知道並能告訴我如何做到這一點我將不勝感激,我使用G3D不是OpenGL的混亂對不起
我使用C++和g3d繪製一個簡單的球體,但不知道如何在圓形中排列多個對象/球體。在圓形中排列3d對象
for(i = 0.0f;i<1.4f;i+=0.2f){
sphere->position = (Vector3(2,i,0));
}
如果有人知道並能告訴我如何做到這一點我將不勝感激,我使用G3D不是OpenGL的混亂對不起
// num_points is the number of points/objects in
// the circle and coords is just the center location of where to draw
static void draw_circle_loop(float radius, int num_points, struct vector2d *coords)
{
int i;
float x, y;
float angle;
for (i = 0; i < num_points; i++)
{
angle = i * (2.0f * M_PI/num_points);
x = coords->x + cosf(angle) * radius;
y = coords->y + sinf(angle) * radius;
glVertex2f(x, y);
}
glVertex2f(coords->x + radius, coords->y);
}
嘗試這樣的事情。而不是調用glVertex2f
使用這些座標循環放置東西。
我沒有注意到,當我發佈它時,格式化已經搞亂了,現在代碼已修復且更清晰。 –