在 9中呈现径向菜单(带有DirectX动态数)的最简单方法是什么?

void DrawMenu(int x, int y, int radius, int width, int segments, LPDIRECT3DDEVICE9 dev){
Draw2DCircle(x, y, radius, D3DCOLOR_RGBA(0, 255, 255, 255), dev);
Draw2DCircle(x, y, radius-width, D3DCOLOR_RGBA(0, 255, 255, 255), dev);
float innerX, innerY, outerX, outerY;
float Theta;
for (int i = 0; i < segments; i++){
Theta = i * (2*PI / segments);
innerX = (radius - width)*cos(Theta) + x;
innerY = (radius - width)*sin(Theta) + y;
outerX = (radius)*cos(Theta) + x;
outerY = (radius)*sin(Theta) + y;
DrawLine(innerX, innerY, outerX, outerY, D3DCOLOR_RGBA(0, 255, 255, 255), dev);
}
}我照马里奥说的做了,这就像一种魅力,但是.我需要做什么,菜单会被着色吗?
选举职能:
void DrawLine(int x1, int y1, int x2, int y2, D3DCOLOR color, LPDIRECT3DDEVICE9 dev){
D3DTLVERTEX Line[2];
Line[0] = CreateD3DTLVERTEX(x1, y1, 0.0f, 1.0f, color, 0.0f, 0.0f);
Line[1] = CreateD3DTLVERTEX(x2, y2, 0.0f, 1.0f, color, 0.0f, 0.0f);
dev->SetFVF(D3DFVF_TL);
dev->SetTexture(0, NULL);
dev->DrawPrimitiveUP(D3DPT_LINESTRIP, 2, &Line[0], sizeof(Line[0]));}
void Draw2DCircle(int x, int y, float radius, D3DCOLOR color, LPDIRECT3DDEVICE9 dev){
const int NUMPOINTS = 40;
D3DTLVERTEX Circle[NUMPOINTS + 1];
int i;
float X;
float Y;
float Theta;
float AngleBetweenPoints;
AngleBetweenPoints = (float)((2 * PI) / NUMPOINTS);
for (i = 0; i <= NUMPOINTS; i++)
{
Theta = i * AngleBetweenPoints;
X = (float)(x + radius * cos(Theta));
Y = (float)(y - radius * sin(Theta));
Circle[i] = CreateD3DTLVERTEX(X, Y, 0.0f, 1.0f, color, 0.0f, 0.0f);
}
dev->SetFVF(D3DFVF_TL);
dev->SetTexture(0, NULL);
dev->DrawPrimitiveUP(D3DPT_LINESTRIP, NUMPOINTS, &Circle[0], sizeof(Circle[0]));}自定义顶点结构
struct D3DTLVERTEX{
float fX;
float fY;
float fZ;
float fRHW;
D3DCOLOR Color;
float fU;
float fV;};发布于 2014-06-15 06:13:22
对于未来的问题,你应该包括一些代码,这样人们就可以帮助你找出你犯了什么错误,而不是(重新)从头开始写所有东西。
考虑以下未经测试的伪代码。您可能需要更多的调整和/或修复一些bug(从内存中编写此代码,而不是在某些dev环境中运行)。
30 / number_of_segments点。但是有一个问题:在某些情况下,段的结尾应该在两个点之间,所以最好对每个段使用30 / number_of_segments + 1点。start = segment_number * (360 / number_of_segments)的角度。end = (segment_number + 1) * (360 / number_of_segments)的角度。start和end之间。
r是半径,a是角度):
X=r* cos(a);y=r* sin(a);https://stackoverflow.com/questions/24223047
复制相似问题