長方體按位置繪制成可視的立體模
我有很多三維長方體的坐標資料,包括位置長寬高,就像超時放物品的貨架一樣,一層層,每一層有多列,每一列有多個方盒, 我需要把它們繪制成可視的立體模型,需要用什么技術才能實作或者什么類別庫,比如使用C#,或者其他什么工具?
uj5u.com熱心網友回復:
代碼不長,就200多行,
public class Cube
{
public int width = 0,height = 0,depth = 0;
double xRotation = 0.0,yRotation = 0.0,zRotation = 0.0;
Math3D.Camera camera1 = new Math3D.Camera();
Math3D.Point3D cubeOrigin;
public Point[,] Area = new Point[6,4];
public double RotateX { get { return xRotation; } set { xRotation = value; } }
public double RotateY { get { return yRotation; } set { yRotation = value; } }
public double RotateZ { get { return zRotation; } set { zRotation = value; } }
public Cube(int Width, int Height, int Depth)
{
width = Width;
height = Height;
depth = Depth;
cubeOrigin = new Math3D.Point3D(width / 2, height / 2, depth / 2);
}
public static Rectangle getBounds(PointF[] points)
{
double left = points[0].X;
double right = points[0].X;
double top = points[0].Y;
double bottom = points[0].Y;
for (int i = 1; i < points.Length; i++)
{
if (points[i].X < left)
left = points[i].X;
if (points[i].X > right)
right = points[i].X;
if (points[i].Y < top)
top = points[i].Y;
if (points[i].Y > bottom)
bottom = points[i].Y;
}
return new Rectangle(0, 0, (int)Math.Round(right - left), (int)Math.Round(bottom - top));
}
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
下載
https://pan.baidu.com/s/15mJroMcZphg8mzi9GB7v-g

uj5u.com熱心網友回復:
3d立方體好畫,但要在每個面上附著影像,需要影像的變形處理,也不怎么麻煩,2個檔案就300多行,包括支持透明陰影等
下載
https://pan.baidu.com/s/15mJroMcZphg8mzi9GB7v-g
但是如果實時要求高的話,這玩意比較慢,按800*600大小,每個面變形180度,每個刻度的生成影像,總共大概1.5秒左右(180副影像),
winform搞這個還是不行,用wpf或GPU相關庫進行運算
uj5u.com熱心網友回復:
樓上地址錯了,是這個https://pan.baidu.com/s/1fl6eyQl0JUBOhLbTiz_zgQ
uj5u.com熱心網友回復:
牛
uj5u.com熱心網友回復:
你好,vector類里面的方法顯示不存在,我用的是wpf,這個vector應該是哪個命名空間?
uj5u.com熱心網友回復:
不好意思,少壓縮了一個檔案
using System;
using System.Drawing;
public struct Vector
{
double _x, _y;
public Vector(double x, double y)
{
_x = x; _y = y;
}
public Vector(PointF pt)
{
_x = pt.X;
_y = pt.Y;
}
public Vector(PointF st, PointF end)
{
_x = end.X - st.X;
_y = end.Y - st.Y;
}
public double X
{
get { return _x; }
set { _x = value; }
}
public double Y
{
get { return _y; }
set { _y = value; }
}
public double Magnitude
{
get { return Math.Sqrt(X * X + Y * Y); }
}
public static Vector operator +(Vector v1, Vector v2)
{
return new Vector(v1.X + v2.X, v1.Y + v2.Y);
}
public static Vector operator -(Vector v1, Vector v2)
{
return new Vector(v1.X - v2.X, v1.Y - v2.Y);
}
public static Vector operator -(Vector v)
{
return new Vector(-v.X, -v.Y);
}
public static Vector operator *(double c, Vector v)
{
return new Vector(c * v.X, c * v.Y);
}
public static Vector operator *(Vector v, double c)
{
return new Vector(c * v.X, c * v.Y);
}
public static Vector operator /(Vector v, double c)
{
return new Vector(v.X / c, v.Y / c);
}
public double CrossProduct(Vector v)
{
return _x * v.Y - v.X * _y;
}
public double DotProduct(Vector v)
{
return _x * v.X + _y * v.Y;
}
public static bool IsClockwise(PointF pt1, PointF pt2, PointF pt3)
{
Vector V21 = new Vector(pt2, pt1);
Vector v23 = new Vector(pt2, pt3);
return V21.CrossProduct(v23) < 0;
}
public static bool IsCCW(PointF pt1, PointF pt2, PointF pt3)
{
Vector V21 = new Vector(pt2, pt1);
Vector v23 = new Vector(pt2, pt3);
return V21.CrossProduct(v23) > 0;
}
public static double DistancePointLine(PointF pt, PointF lnA, PointF lnB)
{
Vector v1 = new Vector(lnA, lnB);
Vector v2 = new Vector(lnA, pt);
v1 /= v1.Magnitude;
return Math.Abs(v2.CrossProduct(v1));
}
public void Rotate(int Degree)
{
double radian = Degree * Math.PI / 180.0;
double sin = Math.Sin(radian);
double cos = Math.Cos(radian);
double nx = _x * cos - _y * sin;
double ny = _x * sin + _y * cos;
_x = nx;
_y = ny;
}
public PointF ToPointF()
{
return new PointF((float)_x, (float)_y);
}
}
uj5u.com熱心網友回復:
以上方法是winform的,不適用wpfwpf的可以參考
https://www.haolizi.net/example/view_14155.html
uj5u.com熱心網友回復:
如果要生成很多個方盒,比如一層有三列,每列有四個,一共10層,很多個方盒如果展示在一起?就像超時貨架上的東西一樣
uj5u.com熱心網友回復:
如果要生成很多個方盒,比如一層有三列,每列有四個,一共10層,很多個方盒如果展示在一起?就像超時貨架上的東西一樣
.......
使用比如
List<bb>aaa啊,
aaa.add(new bb(.....))
等等,基礎的就不討論了。能實作1個物件,就能搞個List
uj5u.com熱心網友回復:
如果要生成很多個方盒,比如一層有三列,每列有四個,一共10層,很多個方盒如果展示在一起?就像超時貨架上的東西一樣
.......
使用比如
List<bb>aaa啊,
aaa.add(new bb(.....))
等等,基礎的就不討論了。能實作1個物件,就能搞個List
感謝感謝!這個分數是不是APP端不能操作
uj5u.com熱心網友回復:
感謝感謝!這個分數是不是APP端不能操作
沒關系,要是上面下載需要分數什么的不方便,發郵件告知,把分數搞成0,注冊個名字就可以。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/129556.html
標籤:C#
上一篇:Es給某個欄位映射ik分詞器失敗
