資源簡(jiǎn)介
非“按角度旋轉(zhuǎn)”,實(shí)現(xiàn)的是立體旋轉(zhuǎn)。
實(shí)現(xiàn)QQ旋轉(zhuǎn)窗體功能,窗口為不規(guī)則圖像,打開時(shí)旋轉(zhuǎn)180度展示。
原本只需1個(gè)窗體直接可實(shí)現(xiàn)旋轉(zhuǎn)功能,但由于窗體模糊透明陰影旋轉(zhuǎn)無法處理,
所以采用2個(gè)窗體次序顯示:
首先第一個(gè)窗體截取屏幕為窗體的背景,進(jìn)行旋轉(zhuǎn),再打開第二個(gè)窗體顯示,同時(shí)關(guān)閉第1個(gè)窗體。
2個(gè)窗體均為圖像,顯示一致,第2個(gè)多加了點(diǎn)擊,第一個(gè)只是圖像顯示和旋轉(zhuǎn)。
原理:實(shí)際是制作立方體進(jìn)行旋轉(zhuǎn),在立方體表面添加圖像,鼠標(biāo)點(diǎn)擊時(shí)判斷位置進(jìn)行響應(yīng),
前面寫的例子關(guān)于圖形窗體的點(diǎn)擊操作已經(jīng)有完整的示例(http://www.haolizi.net/example/view_12149.html)。
目錄中含有DLL的源碼和例子,就是立方體的旋轉(zhuǎn),根據(jù)此例子,修改了DLL代碼重新進(jìn)行了編譯。
此DLL源碼和示例較簡(jiǎn)單,可直接應(yīng)用到你的程序里面,可實(shí)現(xiàn)立體上下旋轉(zhuǎn)、傾斜旋轉(zhuǎn)等等。
實(shí)現(xiàn)QQ旋轉(zhuǎn)窗體功能,窗口為不規(guī)則圖像,打開時(shí)旋轉(zhuǎn)180度展示。
原本只需1個(gè)窗體直接可實(shí)現(xiàn)旋轉(zhuǎn)功能,但由于窗體模糊透明陰影旋轉(zhuǎn)無法處理,
所以采用2個(gè)窗體次序顯示:
首先第一個(gè)窗體截取屏幕為窗體的背景,進(jìn)行旋轉(zhuǎn),再打開第二個(gè)窗體顯示,同時(shí)關(guān)閉第1個(gè)窗體。
2個(gè)窗體均為圖像,顯示一致,第2個(gè)多加了點(diǎn)擊,第一個(gè)只是圖像顯示和旋轉(zhuǎn)。
原理:實(shí)際是制作立方體進(jìn)行旋轉(zhuǎn),在立方體表面添加圖像,鼠標(biāo)點(diǎn)擊時(shí)判斷位置進(jìn)行響應(yīng),
前面寫的例子關(guān)于圖形窗體的點(diǎn)擊操作已經(jīng)有完整的示例(http://www.haolizi.net/example/view_12149.html)。
目錄中含有DLL的源碼和例子,就是立方體的旋轉(zhuǎn),根據(jù)此例子,修改了DLL代碼重新進(jìn)行了編譯。
此DLL源碼和示例較簡(jiǎn)單,可直接應(yīng)用到你的程序里面,可實(shí)現(xiàn)立體上下旋轉(zhuǎn)、傾斜旋轉(zhuǎn)等等。
程序中如有立方面的圖像放反或錯(cuò)位,調(diào)整一下角度RotateFlip(RotateFlipType.Rotate90FlipXY);
時(shí)間有限,程序?qū)懙妮^粗陋,顯示效果自行修改調(diào)整添加。
壓縮文件里還有一種更簡(jiǎn)單的方式,沒來得及修改,參考,步驟和上面一樣。
說明:
public partial class Form1 : Form { YLScsDrawing.Drawing3d.Cuboid cub = new YLScsDrawing.Drawing3d.Cuboid(400, 300, 1); //立方體的寬度400、高度300、厚度1,因?yàn)樾D(zhuǎn)的是一幅圖片,所以厚度為1 YLScsDrawing.Drawing3d.Camera cam = new YLScsDrawing.Drawing3d.Camera(); Bitmap[] bmp = new Bitmap[6]; public Form1() ............. .....重新寫了個(gè)旋轉(zhuǎn)函數(shù)
private void Roti (int speed,int thd) //速度和延時(shí) { for (int i=0;i<speed;i ) { YLScsDrawing.Drawing3d.Quaternion q = new YLScsDrawing.Drawing3d.Quaternion(); q.FromAxisAngle(new YLScsDrawing.Drawing3d.Vector3d(0, 1, 0), 5 * Math.PI / (speed*5)); cub.RotateAt(cub.Center, q); Invalidate(); Application.DoEvents(); Thread.Sleep(thd); } }
例如Roti(5, 1);根據(jù)圖片大小設(shè)置,圖像越大,值設(shè)置越小
例如在窗體內(nèi)旋轉(zhuǎn)圖片,完整代碼
public partial class Form1 : Form { YLScsDrawing.Drawing3d.Cuboid cub = new YLScsDrawing.Drawing3d.Cuboid(400, 300, 1); YLScsDrawing.Drawing3d.Camera cam = new YLScsDrawing.Drawing3d.Camera(); Bitmap[] bmp = new Bitmap[6]; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { cub.Center = new YLScsDrawing.Drawing3d.Point3d(200, 200, 0); //窗體內(nèi)位置 cam.Location = new YLScsDrawing.Drawing3d.Point3d(200, 200, -500); bmp[0] = (Bitmap)Image.FromFile("wfm.png"); bmp[5] = (Bitmap)Image.FromFile("wfm.png");//可以用不同的圖片 bmp[5].RotateFlip(RotateFlipType.Rotate90FlipXY);//立方面的圖像是反的,放正它 cub.FaceImageArray = bmp; cub.DrawingLine = false; cub.DrawingImage = true; cub.FillingFace = true; //Invalidate(); } private void Form1_Paint(object sender, PaintEventArgs e) { cub.Draw(e.Graphics, cam); } private void button1_Click(object sender, EventArgs e) { Roti(5, 1); //圖片較大400的,所以用5, } private void Roti (int speed,int thd) { for (int i=0;i<speed;i ) { YLScsDrawing.Drawing3d.Quaternion q = new YLScsDrawing.Drawing3d.Quaternion(); q.FromAxisAngle(new YLScsDrawing.Drawing3d.Vector3d(0, 1, 0), 5 * Math.PI / (speed*5)); cub.RotateAt(cub.Center, q); Invalidate(); Application.DoEvents(); Thread.Sleep(thd); } } }
壓縮文件里的另一種方法,可以實(shí)現(xiàn)窗體內(nèi)任意控件的立體旋轉(zhuǎn),但在處理透明模糊陰影上沒法處理,不能當(dāng)做窗體,再想想辦法。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
namespace?WindowsApplication1
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????//orientation
????????int?cameraX=0?cameraY=0?cameraZ=0?cubeX=0?cubeY=0?cubeZ=0;
????????YLScsDrawing.Drawing3d.Cuboid?cub?=?new?YLScsDrawing.Drawing3d.Cuboid(150?150?150);
????????YLScsDrawing.Drawing3d.Camera?cam?=?new?YLScsDrawing.Drawing3d.Camera();
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????
????????????cub.Center?=?new?YLScsDrawing.Drawing3d.Point3d(400?240?0);
????????????cam.Loca
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
????..A..H.?????90624??2017-10-13?17:12??窗體旋轉(zhuǎn)\修改dll代碼\.vs\YLScsDrawing\v14\.suo
?????文件??????23461??2017-10-11?21:30??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\bin\Debug\2.jpg
?????文件??????23552??2017-10-11?22:25??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\bin\Debug\WindowsApplication1.exe
?????文件??????34304??2017-10-11?22:25??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\bin\Debug\WindowsApplication1.pdb
?????文件??????21680??2017-10-13?17:11??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\bin\Debug\WindowsApplication1.vshost.exe
?????文件????????490??2017-03-19?05:00??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\bin\Debug\WindowsApplication1.vshost.exe.manifest
?????文件??????21504??2017-10-11?22:18??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\bin\Debug\YLScsDrawing.dll
?????文件??????69120??2017-10-11?22:18??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\bin\Debug\YLScsDrawing.pdb
?????文件???????9799??2017-10-11?22:25??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Form1.cs
?????文件??????31487??2017-10-11?22:01??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Form1.Designer.cs
?????文件???????5814??2017-10-11?22:01??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Form1.resx
?????文件????????486??2009-04-11?06:30??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Program.cs
?????文件???????1292??2009-04-11?06:30??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Properties\AssemblyInfo.cs
?????文件???????2878??2017-10-11?21:40??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Properties\Resources.Designer.cs
?????文件???????5612??2009-04-11?06:30??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Properties\Resources.resx
?????文件???????1119??2017-10-11?21:40??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Properties\Settings.Designer.cs
?????文件????????249??2009-04-11?06:30??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\Properties\Settings.settings
?????文件???????3777??2017-10-11?21:40??窗體旋轉(zhuǎn)\修改dll代碼\WindowsApplication1\WindowsApplication1.csproj
?????文件??????21504??2017-10-11?22:18??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\bin\Debug\YLScsDrawing.dll
?????文件??????69120??2017-10-11?22:18??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\bin\Debug\YLScsDrawing.pdb
?????文件???????3211??2009-04-18?03:47??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Drawing3d\Camera.cs
?????文件???????4102??2017-10-11?22:18??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Drawing3d\Cuboid.cs
?????文件???????1935??2009-04-18?03:43??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Drawing3d\Point3d.cs
?????文件???????3305??2009-04-19?05:48??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Drawing3d\Quaternion.cs
?????文件???????1439??2009-04-19?06:53??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Drawing3d\Shape3d.cs
?????文件???????2753??2009-04-15?05:32??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Drawing3d\Vector3d.cs
?????文件???????3262??2009-05-09?13:06??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Geometry\Vector.cs
?????文件???????7838??2009-05-15?05:15??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Imaging\Filters\FreeTransform.cs
?????文件???????6223??2009-04-11?05:35??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\Imaging\ImageData.cs
?????文件???????5920??2017-10-13?17:11??窗體旋轉(zhuǎn)\修改dll代碼\YLScsDrawing\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
............此處省略143個(gè)文件信息
評(píng)論
共有 條評(píng)論