资源简介
使用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版本)
- 下一篇:信息论编码——信道编码实验
相关资源
- MFC可视化信息管理系统简单的程序,
- C#遗传算法程序可视化版
- OpenGL窗口背景绘制
- C++(CS起源GDI透视自瞄)+代码全写了
- 学生成绩管理系统C++QT可视化
- opengl绘制花瓶源码基于glut库
- 球的绘制与消隐
- 立方体的绘制与消隐
- CPlot - MFC绘制曲线
- c++密度据类MFC可视化
- 汉诺塔的C语言可视化实现使用EasyX图
- 使用DirectX3D、传统方法绘制的绕Y轴不
- de Casteljau算法绘制Bezier曲线
- MFC绘制阿基米德螺旋线.rar
- 用C语言实现卷积计算并绘制出卷积计
- OpenGL+MFC显示三维点云中每一个点的法
- opencv绘制点与坐标系
- MFC动态绘制曲线图-HightSpeedChart实现
- OpenGL绘制三维坐标图
- OpenGL绘制三维地形(MFC)
- VC++ 6.0 线程实现实时动态曲线绘制
- C++ 基于遗传算法的矩形排样 具有可视
- qt实现千万级数据实时展示.zip
- 绘制柱状图的C++类(附demo)
- vC++ 绘制金刚石图案
- Qt5+QtChart绘制饼图
- C++实战源码-在图像上绘制线条
- C++实战源码-在图像上绘制网格
- C++实战源码-在菱形内绘制图像
- C++实战源码-在视图中绘制图像
评论
共有 条评论