PDA

View Full Version : سوال: گرافیک



sajjad1365
چهارشنبه 29 مهر 1388, 20:24 عصر
سلام. من برای رسم یک مثلث این کدها رو وارد کردم ولی خطا میده:
در فرم 1:
namespace graphic1
{
public class Form1 : System.Windows.Forms.Form
{
Device device3d;
;
GraphicEngine ge ;
public Form1()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque , true);
GraphicInitiator gi=new GraphicInitiator ();
device3d= gi.initDevice(this);
ge=new GraphicEngine(gi.initDevice(this));

InitializeComponent();

}
protected override void OnPaint(PaintEventArgs e)
{


ge.DrawWorld ();
this.Invalidate(true);

}
و در این کلاس این کد ها رو نوشتم: به vertices ها خطا میده
public class GraphicEngine
{
private Device device3d;
private float angle=0f;
public GraphicEngine(Device dev)
{
device3d=dev;
device3d.Clear(ClearFlags.Target ,Color.BlanchedAlmond ,1.0f,0);
vertices=new CustomVertex.PositionColored[3];
vertices[0]=new CustomVertex.PositionColored (new Vector4 (0f,0f,0f,1f),Color.Red.ToArgb ());
vertices[1]=new CustomVertex.PositionColored (new Vector4 (10f,0f,0f,1f),Color.Azure.ToArgb ());
vertices[2]=new CustomVertex.PositionColored (new Vector4 (10f,0f,10f,1f),Color.Blue.ToArgb ());
}
public void DrawWorld()
{
device3d.Transform.Projection=Matrix.PerspectiveFo vLH((float)Math.PI / 2, width/height,1f,50f);
device3d.Transform.View=Matrix.LookAtLH(new Vector3 (0,-15,0),new Vector3(0,0,0),new Vector3 (0,0,1));

device3d.Clear(ClearFlags.Target ,Color.BlanchedAlmond ,1.0f,0);
device3d.BeginScene ();
device3d.VertexFormat = CustomVertex.PositionColored .Format ;

device3d.DrawUserPrimitives(PrimitiveType.Triangle List , 1 ,vertices);
device3d.EndScene ();
device3d.Present();


}
}
}
ممنون میشم اگه راهنمایی کنین

sajjad1365
پنج شنبه 30 مهر 1388, 16:17 عصر
سلام.
از دوستان کسی راهنمایی نمیکنن؟