Hi guys,
I seem to be having an issue with drawing.
I had it working 2 or 3 patches ago, but today it seems to fail -.-
I am trying to draw 'in' the world, for example drawing a circle at my location, when I move away I can see it in the distance. However in my test it looked like nothing was drawn. However when I added this code:
Code:
Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 32000);
to my DrawCircle function this happened:

this leads me to believe that its drawing, but in the wrong place.
I am not 100% sure what's wrong but ill post some code that I have below:
My Camera Struct:
Code:
public struct CameraInfo {
public float Aspect;
public float FarZ;
public float FieldOfView;
public Matrix3 Matrix;
public float NearZ;
public Vector3 Position;
private uint unk0;
private uint unk1;
private float unk2;
private int unk3;
}
Drawing Addresses:
Code:
internal class Drawing //16/08/2012 {
internal static uint WorldFrame = 0xAD7A10;
internal static uint ActiveCamera = 0x80D0;
internal static uint AspectRatio = 0xAD74A4;
}
My Draw Circle code:
Code:
public static void DrawCircle(Location center, float radius, Color innerColor, Color outerColor, int complexity = 24, bool isFilled = true) {
var vertices = new List<PositionColored>();
if (isFilled)
vertices.Add(new PositionColored(Vector3.Zero, innerColor.ToArgb()));
double stepAngle = (Math.PI*2)/complexity;
for (int i = 0; i <= complexity; i++)
{
double angle = (Math.PI*2) - (i*stepAngle);
var x = (float) (radius*Math.Cos(angle));
var y = (float) (-radius*Math.Sin(angle));
vertices.Add(new PositionColored(new Vector3(x, y, 0), outerColor.ToArgb()));
}
PositionColored[] buffer = vertices.ToArray();
InternalRender(center.ToSlimV3() + new Vector3(0, 0, 0.3f));
//Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 32000);
if (isFilled)
Device.DrawUserPrimitives(PrimitiveType.TriangleFan, buffer.Length - 2, buffer);
else
Device.DrawUserPrimitives(PrimitiveType.LineStrip, buffer.Length - 1, buffer);
}
I am not sure if this is enough to help me along. As it worked before I am quite confident that the drawing code is fine(but ugly xD), I think its my Camera Struct.
Also, I should point out that I probably found a lot of this code here on OwnedCore.
Thanks