标签:
1.实训时间:2016.9.5上午8:00-11:30
2.实训内容:项目在完成.x文件的固定导入后,尝试文件旋转,缩小,放大功能的开发。
3.具体实现:通过网上百度的源代码,进行阅读和修改。
具体为摄像头的处理。
阅读代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _3dpicture
{
public partial class Form1 : Form
{
private SpriteCanvas.Canvas canvas1;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//create two viewports, one default size and origin
myWorld.CreateViewport(pictureBox1, Background.Image);
//... the other somewhat smaller and showing different portion of "world"
myWorld.CreateViewport(View2, View2.CreateGraphics(), new Point(145, 25), new Rectangle(30, 30, 120, 120), Background.Image);
//create some sprites
CreateTestObjects();
//main loop timer
timer.Start();
//animation loop timer
AnimationTimer.Start();
}
//create "world"
public SpriteWorld.World myWorld = new SpriteWorld.World();
public bool pMouseDrag = false;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
//static void Main()
//{
// Application.Run(new Form1());
//}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
myWorld.Library.Item(2).oFrame++;
myWorld.RequestRendering(2);
myWorld.Library.Item(3).oFrame++;
myWorld.RequestRendering(3);
textBox1.Text = Convert.ToString(myWorld.Library.Item(2).oFrame);
}
private void button2_Click(object sender, EventArgs e)
{
myWorld.Library.Item(2).oFrame--;
myWorld.RequestRendering(2);
myWorld.Library.Item(3).oFrame--;
myWorld.RequestRendering(3);
textBox1.Text = Convert.ToString(myWorld.Library.Item(2).oFrame);
}
private void ScaleScroll_Scroll(object sender, ScrollEventArgs e)
{
myWorld.ResizeSprite(0, Convert.ToDouble(e.NewValue) / 100.0);
}
private void CreateTestObjects()
{
//animated
myWorld.AddSprite(canvas1, new Point(20, 60), new Point(0, 59), 30, true);
//also animated
myWorld.AddSprite(canvas1, new Point(175, 60), new Point(0, 59), 60, true);
//static
myWorld.AddSprite(canvas1, new Point(80, 50));
//static
myWorld.AddSprite(canvas1, new Point(70, 80));
//start updating FPS monitor
FPStimer.Start();
//show some numbers
textBox3.Text = Convert.ToString(myWorld.Library.Item(1).oFPS);
textBox1.Text = Convert.ToString(myWorld.Library.Item(2).oFrame);
}
private void timer_Tick(object sender, EventArgs e)
{
//check if we need some rendering
myWorld.RenderingLoop();
}
private void FPStimer_Tick(object sender, EventArgs e)
{
//show new FPS
textBox2.Text = Convert.ToString(myWorld.GetFPS());
}
private void FPSScroll_Scroll(object sender, ScrollEventArgs e)
{
//we will adjust fps of sprite[1] with this
myWorld.Library.Item(1).oFPS = e.NewValue;
textBox3.Text = Convert.ToString(myWorld.Library.Item(1).oFPS);
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
//this is used only when we have some area that needs to be redrawn
//like when we start, or min. then restore app, or bring it to front from behind
//some other app
myWorld.RePaint(sender, e.Graphics, e.ClipRectangle);
}
private void AnimationTimer_Tick(object sender, EventArgs e)
{
//we animate sprites here
myWorld.UpdateAnimated();
}
private void View2_Paint(object sender, PaintEventArgs e)
{
// k, again when window needs to be repainted
myWorld.RePaint(sender, e.Graphics, e.ClipRectangle);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
//when we click mouse we will start dragging sprites underneath
//when we click again we drop ‘em
if (pMouseDrag)
{
pMouseDrag = false;
return;
}
myWorld.StartMouseDrag(e.X, e.Y);
pMouseDrag = true;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
//if we selected some sprites move ‘em around
if (pMouseDrag)
{
myWorld.MoveSelected(e.X, e.Y);
}
}
}
}
载入新建文件运行,未果。
工作效率评价:低。
标签:
原文地址:http://www.cnblogs.com/licongzhuo/p/5845069.html