PDA

View Full Version : چگونگی رسم پرسپکتیو



ho3ein.3ven
پنج شنبه 21 اسفند 1393, 21:58 عصر
سلام دوستان

من تو یکی از پروژه هام احتیاج دارم یک پرسپکتیو رسم کنم .

پرسپکتیوی که احتیاج به رسمش دارم یه چیزی تو مایه های تصویر زیره :
129387
البته ببخشید نقاشیم بده .

یه سورس هم پیدا کردم که یه پرسپکتیو رو روی فرم رسم می کنه .

public Form1()
{
InitializeComponent();
ResizeRedraw = DoubleBuffered = true;
Width = 800;
Height = 600;
Paint += new PaintEventHandler(Form1_Paint);
}
void Form1_Paint(object sender, PaintEventArgs e)
{
// a few parameters that control the projection transform
// these are the parameters that you can modify to change
// the output
double cz = 10; // distortion
double m = 1000; // magnification, usually around 1000 (the pixel width of the monitor)
double y0 = -100; // floor height
string texturePath = @"c:\icon.png";//@"c:\pj\Chrysanthemum.jpg";

// screen size
int height = ClientSize.Height;
int width = ClientSize.Width;
// center of screen
double cx = width / 2;
double cy = height / 2;

// render destination
var dst = new Bitmap(width, height);
// source texture
var src = Bitmap.FromFile(texturePath) as Bitmap;
// texture dimensions
int tw = src.Width;
int th = src.Height;
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
{
double v = m * y0 / (y - cy) - cz;
double u = (x - cx) * (v - cz) / m;
int uu = ((int)u % tw + tw) % tw;
int vv = ((int)v % th + th) % th;
// The following .SetPixel() and .GetPixel() are painfully slow
// You can replace this whole loop with an equivalent implementation
// using pointers inside unsafe{} code to make it much faster.
// Note that by casting u and v into integers, we are performing
// a nearest pixel interpolation... It's sloppy but effective.
dst.SetPixel(x, y, src.GetPixel(uu, vv));
}
// draw result on the form
e.Graphics.DrawImage(dst, 0, 0);
}
}


ولی این پرسپکتیو اون چیزی نیست که من می خوام . فرمول هاش هم خیلی پیچیدست اصلا سر در نیاوردم.

اگر از دوستان کسی تو این زمینه کار کرده خواهشمندم بنده رو راهنمایی کنه .

ممنون از همگی