1.创建Vector4 来表示顶点数据类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _3DTemple
{
class Vector4
{
public double x, y, z, w;
public Vector4() {
}
public Vector4(double x,double y,double z,double w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
public Vector4(Vector4 vets) {
this.x = vets.x;
this.y = vets.y;
this.z = vets.z;
this.w = vets.w;
}
}
}
2.创建一个基础的矩阵类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _3DTemple
{
class Matrix4x4
{
private double[,] pts;
public Matrix4x4() {
pts = new double[4,4];
}
public double this[int i,int j]
{
get {
return pts[i - 1,j - 1];
}
set {
pts[i - 1, j - 1] = value;
}
}
//矩阵 X 矩阵