资源简介
一个用c++实现的marching cubes算法,非常好用,挺有教育意义
代码片段和文件信息
//
// 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 afS
- 上一篇:Vc++6.0MFC入门教程,很好的资源。
- 下一篇:des算法的c语言实现c源代码
相关资源
- Vc++6.0MFC入门教程,很好的资源。
- VC++6.0 MFC 超简易计算器
- C++画数学函数图象
- c++实现数字转换英文无and
- c++利用数组实现简单的奇偶校验
- C++实现软件自动更新(update)
- c++遗传算法,用bitset实现
- VC++ OPC客户端程序
- C++纸牌游戏——21点
- 大整数乘法全解绝对可运行C++
- 《C++标准库 第2版》 中文版
- 车辆管理系统C++
- 小型C++设计的数据库设计
- C++ Primer Plus第6版中文版源代码
- C++ 二叉树 动物猜想游戏
- 多个定时器的 Timer VC++
- C++primer 第五版最新版 源代码 程序.
- Visual C++开发的网络监听程序
- HTTP上传和C++封装类支持GET、POST多种方
- 课程设计 电梯模拟 c++语言
- 东南大学复试c++题目及答案
- Demo: c/c++动态库DLL调用,c#等其他语言
- 可变分区存储管理方式的内存分配与
- 实现三维坐标变换、投影变换,C++实
- VC++铰链四杆机构运动仿真编程-
- C++制作的简单工厂模式计算器
- 电力网潮流计算C++实现
- 在Unity3d中使用C++ DLL
- C利用循环左移函数流水灯
- C++统计票数的实现源码
评论
共有 条评论