Draw a circle (wireframe and solid versions) with C# DirectX

EFileTahi-A

Contributor
Joined
Aug 8, 2004
Location
Portugal / Barreiro
I understand that DirectX has no primitives for such task. I also understand that the circle should be done with the Line object, through connected segments. But all examples I've found so far are in c++;

Come someone one help me?

Thanks
 

snarfblam

Ultimate Contributor
Joined
Jun 10, 2003
Location
USA
Is there something in particualar that is stopping you from converting the code to C#? I'm guessing that the C++ code does not use MDX, but if your difficulty is in understanding the different syntax, maybe I could help with the translation.
 

EFileTahi-A

Contributor
Joined
Aug 8, 2004
Location
Portugal / Barreiro
Well, I manged to make it work:

Code:
for (float fAngle = 0.0f; fAngle <= (2.0f * Math.PI); fAngle += fSteps)
{
      v2[0].X = ptCenter.X + (iRadius * (float)Math.Sin(fAngle));
      v2[0].Y = ptCenter.Y + (iRadius * (float)Math.Cos(fAngle));

      VAR.dxSpriteMain.Draw((Texture)VAR.htGfxResources["1x1"], new Rectangle(0, 0, 1, 1), new Vector3(0, 0, 0), new Vector3(v2[0].X, v2[0].Y, 0), color);
}

This is the dot version. But since I did not find any pixel or dot object I'm using a 1x1 texture to build the dots... Too bad some of them get kinda antialized.
 

snarfblam

Ultimate Contributor
Joined
Jun 10, 2003
Location
USA
I'm far from an MDX expert, so sorry if this is a useless thought, but could you draw a dot as a line where both endpoints have the same coordinates?
 
Top Bottom