资源简介
一个用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源代码
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
川公网安备 51152502000135号
评论
共有 条评论