资源简介
使用marching-cube算法实现的等值面绘制效果
代码片段和文件信息
//
// Marching Cubes Example Program
// by Cory Bloyd (corysama@yahoo.com)
//
// A simple portable and complete implementation of the Marching Cubes
// and Marching Tetrahedrons algorithms in a single source file.
// There are many ways that this code could be made faster but the
// intent is for the code to be easy to understand.
//
// For a description of the algorithm go to
// http://astronomy.swin.edu.au/pbourke/modelling/polygonise/
//
// This code is public domain.
//
#include “stdio.h“
#include “math.h“
//This program requires the OpenGL and GLUT libraries
// You can obtain them for free from http://www.opengl.org
#include “GL/glut.h“
struct GLvector
{
GLfloat fX;
GLfloat fY;
GLfloat fZ;
};
//These tables are used so that everything can be done in little loops that you can look at all at once
// rather than in pages and pages of unrolled code.
//a2fVertexOffset lists the positions relative to vertex0 of each of the 8 vertices of a cube
static const GLfloat a2fVertexOffset[8][3] =
{
{0.0 0.0 0.0}{1.0 0.0 0.0}{1.0 1.0 0.0}{0.0 1.0 0.0}
{0.0 0.0 1.0}{1.0 0.0 1.0}{1.0 1.0 1.0}{0.0 1.0 1.0}
};
//a2iEdgeConnection lists the index of the endpoint vertices for each of the 12 edges of the cube
static const GLint a2iEdgeConnection[12][2] =
{
{01} {12} {23} {30}
{45} {56} {67} {74}
{04} {15} {26} {37}
};
//a2fEdgeDirection lists the direction vector (vertex1-vertex0) for each edge in the cube
static const GLfloat a2fEdgeDirection[12][3] =
{
{1.0 0.0 0.0}{0.0 1.0 0.0}{-1.0 0.0 0.0}{0.0 -1.0 0.0}
{1.0 0.0 0.0}{0.0 1.0 0.0}{-1.0 0.0 0.0}{0.0 -1.0 0.0}
{0.0 0.0 1.0}{0.0 0.0 1.0}{ 0.0 0.0 1.0}{0.0 0.0 1.0}
};
//a2iTetrahedronEdgeConnection lists the index of the endpoint vertices for each of the 6 edges of the tetrahedron
static const GLint a2iTetrahedronEdgeConnection[6][2] =
{
{01} {12} {20} {03} {13} {23}
};
//a2iTetrahedronEdgeConnection lists the index of verticies from a cube
// that made up each of the six tetrahedrons within the cube
static const GLint a2iTetrahedronsInACube[6][4] =
{
{0516}
{0126}
{0236}
{0376}
{0746}
{0456}
};
static const GLfloat afAmbientWhite [] = {0.25 0.25 0.25 1.00};
static const GLfloat afAmbientRed [] = {0.25 0.00 0.00 1.00};
static const GLfloat afAmbientGreen [] = {0.00 0.25 0.00 1.00};
static const GLfloat afAmbientBlue [] = {0.00 0.00 0.25 1.00};
static const GLfloat afDiffuseWhite [] = {0.75 0.75 0.75 1.00};
static const GLfloat afDiffuseRed [] = {0.75 0.00 0.00 1.00};
static const GLfloat afDiffuseGreen [] = {0.00 0.75 0.00 1.00};
static const GLfloat afDiffuseBlue [] = {0.00 0.00 0.75 1.00};
static const GLfloat afSpecularWhite[] = {1.00 1.00 1.00 1.00};
static const GLfloat afSpecularRed
- 上一篇:PL/0编译程序文本(C版本)
- 下一篇:信息论编码——信道编码实验
相关资源
- opengl绘制汽车.cpp
- MFC绘制Bezier曲线B样条曲线曲线拟合
- 基于OSG的三维河流的可视化研究——
- 功能强大的多条曲线绘制类 (MFC,
- 基于C语言绘制学校校徽
- C++绘制漂亮仪表盘
- MFC 绘制指针式钟表
- c++可视化学生选课系统
- mfc绘制任意图形,实现图形按比例缩
- MFC可视化界面ping程序
- MFC 与GDI++绘制仪表盘
- VTK三维可视化读取RAW数据的c++源代码
- 利用MFC绘制B样条曲线
- SNL语言编译器GUI VC++ 2008版 MFC实现可
- MFC可视化_迷宫算法_最短路径
- VC6中使用MFC自动化Excel数据写入和图表
- MFC绘制的移动小车,包含了图形的平
- 使用MFC实现真实感图形绘制
- MFC计算器编程,可视化,含详细实现
- vc6.0+opengl动态绘制五角星
- C++可视化MFC课设_五子棋带报告
- 基于UDP的简单可视化界面聊天程序c
- MFC校园导航图 可视化校园地图
- C++语言绘制中国地图
- 绘制任意斜率的直线段
- 黄维通Visual C++面向对象与可视化程序
- 动态分区存储管理的mfc可视化实现
- 黄维通Visual C++面向对象与可视化程序
- C++中,用mfc做的可视化的计算器程序
- MFC可视化五子棋游戏
评论
共有 条评论