绘制六面体
来源:互联网 发布:3d下期和值最简单算法 编辑:程序博客网 时间:2024/06/01 23:25
using System.Collections.Generic;
using System.Text;
using System.Drawing;
usingMicrosoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace 绘制基本几何体
{
class DrawHexClass
{
public Device device;
public Vector3[] pointVectors;
public CustomVertex. PositionColored[] vertices;
private int[] indexData;
public DrawHexClass(Device _device, Vector3[] _pointVectors)
{
device = _device;
pointVectors=_pointVectors;
vertices = new CustomVertex.PositionColored[8];
vertices[0].Position = pointVectors[0];
vertices[0].Color = Color.Yellow. ToArgb();
vertices[1].Position = pointVectors[1];
vertices[1].Color = Color.Red. ToArgb();
vertices[2].Position = pointVectors[2];
vertices[2].Color = Color.Green.ToArgb();
vertices[3].Position = pointVectors[3];
vertices[3].Color = Color.Gold.ToArgb();
vertices[4].Position = pointVectors[4];
vertices[4].Color = Color.GhostWhite.ToArgb() ;
vertices[5].Position = pointVectors[5];
vertices[5].Color = Color.LightPink.ToArgb();
vertices[6].Position = pointVectors[6];
vertices[6].Color = Color.Maroon. ToArgb();
vertices[7].Position = pointVectors[7];
vertices[7].Color = Color.Orange. ToArgb();
IndicesDeclaration(); //定义索引
}
private void IndicesDeclaration() //定义索引
{
indexData=new int[36];
//顶部三角形
indexData[0] = 0; indexData[1] = 1; indexData[2] = 3;
indexData[3] = 3; indexData[4] = 1; indexData[5] = 2;
//周围三角形
indexData[6] = 4; indexData[7] = 0; indexData[8] = 7;
indexData[9] = 7; indexData[10] = 0; indexData[11] = 3;
indexData[12] = 7; indexData[13] = 3; indexData[14] = 6;
indexData[15] = 6; indexData[16] = 3; indexData[17] = 2;
indexData[18] = 6; indexData[19] = 2; indexData[20] = 5;
indexData[21] = 5; indexData[22] = 2; indexData[23] = 1;
indexData[24] = 5; indexData[25] = 1; indexData[26] = 4;
indexData[27] = 4; indexData[28] = 1; indexData[29] = 0;
//底部三角形
indexData[30] = 5; indexData[31] = 4; indexData[32] = 7;
indexData[33] = 7; indexData[34] = 6; indexData[35] = 5;
}
public void DrawHex()
{
device.DrawIndexedUserPrimitives(PrimitiveType.TriangleList, 0, 8, 12, indexData,
false, vertices);
}
}
}
在程序的渲染函数 Render()中代码“device. BeginScene(); ”和“ device.EndScene(); ”
之间添加如下代码:
Vector3[] points =newVector3[8] ;
points[0] = new Vector3(30f, 20f, 0f);
points[1] = new Vector3(30f, 20f, 10f);
points[2] = new Vector3(40f, 20f, 10f);
points[3] = new Vector3(40f, 20f, 0f);
points[4] = new Vector3(30f, 10f, 0f);
points[5] = new Vector3(30f, 10f, 10f);
points[6] = new Vector3(40f, 10f, 10f);
points[7] = new Vector3(40f, 10f, 0f);
DrawHexClass drawTri = new DrawHexClass(device, points);
drawTri.DrawHex();
- 绘制六面体
- OpenGL: 显示列表绘制六面体
- vr视频六面体变换
- 六面体魔方转动
- CSS3实现3D六面体
- 六面体魔术相册代码(收藏)
- d3d 画旋转方棱椎与六面体
- CSS3轻松实现彩色旋转六面体动画
- 高效的六面体变换算法实现(一) —— 等圆柱映射 与 六面体映射
- TCL建立六面体网格并导入到有限元软件
- [蓝桥杯历届题目] 正六面体染色 ; 取字母组成串
- 蓝桥杯 结果填空 正六面体染色 Burnside引理
- 蓝桥杯Java练习——正六面体染色
- Hypermesh 12.0 中球体的六面体网格划分
- Java正六面体4种颜色染色方式
- 高效的六面体变换算法实现(一) —— 等圆柱映射 与 六面体映射(MarkDown编辑器版)
- 绘制
- 正六面体染色 正六面体用4种颜色染色。共有多少种不同的染色样式?要考虑六面体可以任意旋转、翻转。
- How to remove the component VOB in Components?
- phpexcel 导出不好使的问题
- WebLogicSSL解决苹果IOS itms下载问题
- 单页面旋转 ios
- 无效数字和数字溢出问题
- 绘制六面体
- framebuffer的结构介绍和驱动分析
- 深入理解C语言指针的奥秘
- c语言静态变量和静态函数
- windows环境下wampserver环境搭建
- PullToRefreshView下拉刷新上来加载更多,支持任何子view!
- 非线性最优化(二)——高斯牛顿法和Levengerg-Marquardt迭代
- Cython基础--Cython入门
- 简明 Vim 练级攻略(by陈皓)