public Cube() { //顶面两个三角形,可以看到的面所以顺时针(顺时针)方向 triangels[0] = new Triangle3D(a, b, c); triangels[1] = new Triangle3D(a, c, d); //下面两个三角形,不能看到所以逆时针(左右坐标)方向 triangels[2] = new Triangle3D(e, h, f); triangels[3] = new Triangle3D(f, h, g); //正面 , 顺时针方向 triangels[4] = new Triangle3D(d, c, g); triangels[5] = new Triangle3D(d, g, h); //背面,逆时针方向 triangels[6] = new Triangle3D(a, e, b); triangels[7] = new Triangle3D(b, e, f); //右面,顺时针方向 triangels[8] = new Triangle3D(b, f, c); triangels[9] = new Triangle3D(c, f, g); //左面,逆时针 triangels[10] = new Triangle3D(a, d, h); triangels[11] = new Triangle3D(a, h, e); }
//应用部分,-------从这里开始保存原始顶点 private void Form1_Load(object sender, EventArgs e) { //初始化三角形的三个点(最初的点),最初特别小 //,Vector4的最后一个分量1表示点(顶点),0的话表示分量,详细请看shader基础矩阵各种特性章节 //在3D的矩阵空间里屏幕Y轴向上是取正值的,而屏幕里Y轴向上是负值,要以3D的为准所以这里取正值 Vector4 a = new Vector4(0, 0.5, 0, 1); Vector4 b = new Vector4(0.5, -0.5, 0, 1); Vector4 c = new Vector4(-0.5, -0.5, 0, 1); //调用自定义的函数,把(顶点)存到原始顶点变量A,B,C t = new Triangle3D(a, b, c); // t.Transform( m_scale ); //变换三角形顶点(缩放) }