91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

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

評論

共有 條評論