资源简介
opengl 做的很漂亮的一棵树,用分形算法实现 含代码
代码片段和文件信息
//****************************************************************************
// Branch.cpp: implementation of the CBranch class.
//
// Copyright (c) Boris J. Wang (e_boris2002@hotmail.com) 2002 - 2003
// From Institute of Computing Technology Chinese Academy of Sciences
// Beijing 100871 China
//
// THIS CODE AND INFORMATION IS PROVIDED “AS IS“ WITHOUT WARRANTY OF
// ANY KIND EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//****************************************************************************
#include “stdafx.h“
#include “opengl.h“
#include “Branch.h“
#include “tree.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////
//Implement for CSegment
////////////////////////////////////////////////////
CglMaterial CSegment::BarkMTR;
float CSegment::SegLeafSize = 1.970f;
float CSegment::LeafExpand = 26.4f;
float CSegment::SegExpand = 26.4f;
float CSegment::SegScaleLen = 0.83f;
float CSegment::SegScaleRad = 0.75f;
float CSegment::SegTwistInc = 61.02f;
float CSegment::SegSideExpand = 58.8f;
float CSegment::SegSideScaleDepth = 0.81f;
float CSegment::SegSideScale = 0.93f;
CglTexture CSegment::Tex(_T(“bark.bmp“)GL_Tex_BMP7);
#define SegDefaultLength 8.0f
CSegment::~CSegment()
{
if(SideBranch)
{
delete SideBranch;
SideBranch = NULL;
}
if(Leaves)
{
delete Leaves;
Leaves = NULL;
}
}
CSegment::CSegment()
{
SetExpand(0.0f);
SetLength(SegDefaultLength);
SetRadius(0.8f);
SetTwist(0.0f);
SideBranch = NULL;
Leaves = NULL;
}
void CSegment::Render(CSegment &Father)
{
Tex.Apply();
BarkMTR.Apply();
glColor4f(000CTree::BranchShadowDensity);
glBegin(GL_QUAD_STRIP);
DefineOneLine(HalfRadius TriRadius Father.HalfRadius Father.TriRadius 0.0f ); // 0/6
DefineOneLine(-HalfRadius TriRadius -Father.HalfRadius Father.TriRadius 0.1666666667f ); // 1/6
DefineOneLine(-Radius 0.0f -Father.Radius 0.0f 0.3333333333f ); // 2/6 and so on
DefineOneLine(-HalfRadius -TriRadius -Father.HalfRadius -Father.TriRadius 0.5f );
DefineOneLine(HalfRadius -TriRadius Father.HalfRadius -Father.TriRadius 0.6666666667f );
DefineOneLine(Radius 0.0f Father.Radius 0.0f 0.8333333333f );
DefineOneLine(HalfRadius TriRadius Father.HalfRadius Father.TriRadius 1.0f ); // 6/6
glEnd();
CTree::TotalQuad += 6;
CTree::TotalVertex += 12;
CTree::TotalNode ++;
CTree::TotalMemory += sizeof(CSegment);
}
void CSegment::DefineOneLine(GLfloat x GLfloat z GLfloat fx GLfloat fz GLfloat Tex)
{
glNormal3f(fx0.0ffz);
glTexCoord2f(Tex0.0f);
glVertex3f(fx 0.0f fz);
{GLfloat x3y3z3x2z2x1;
x1 = - z*SinTwist + x*CosTwist
相关资源
- 3ds模型导入opengl,实现旋转平移缩放
- 给定一个地区的n 个城市间最小生成树
- opengl中点画圆法
- opengl编程指南第7版源代码
- 3D酷炫屏幕保护程序OpenGL
- 使用LabVIEW打开Windows系统的树形文件夹
- 树套树数据结构从入门到精通
- 有关树莓派的应用设计报告
- 树莓派代码
- OpenGL文件.zip
- 二叉树与哈夫曼压缩编码实验
- 最小生成树问题报告
- scratch画二叉树
- 配置OpenGL以及glaux所需资源.h.dll
- IDL树高反演 三阶段算法直线拟合
- 信贷树决策树的金融行业应用
- 虚幻4简单AI的实现:自动寻路,场景
- luweiqi素材
- VS2017&OpenGL;环境搭建
- 运用ID3算法训练决策树
- 决策树算法ID3和C45
- 《数据结构》实验报告 涉及客房管理
- 树莓派3b+资料
- OpenGL 顶点数组+拾取
- Jtopo读取Json生成树状拓扑图
- openGL配置资源文件,含32/64位
- GLPrint_demo
- 遍历多级树状json获得父子节点值
- 圆球圆环构造opengl函数
- opengl画圆柱体直接函数法,逼近法
评论
共有 条评论