2
// C++ Implementation: Tree
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2005
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
28
#include "meshtree/TParameters.h"
29
#include "meshtree/MeshTree.h"
30
#include "../OgreIncludes.h"
35
namespace Environment {
41
/* Material *pBarkMat = (Material*)MaterialManager::getSingleton().create( "BarkTextMat" );
42
pBarkMat->getTechnique(0)->getPass(0)->createTextureUnitState( "tree_bark.jpg" );
43
Material *pLeafMat = (Material*)MaterialManager::getSingleton().create( "LeafTextMat" );
45
pLeafMat->getTechnique(0)->getPass(0)->createTextureUnitState( "tree_leaves_pack1.tga" );
46
pLeafMat->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
47
pLeafMat->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_NONE);
48
pLeafMat->getTechnique(0)->getPass(0)->setManualCullingMode(Ogre::MANUAL_CULL_NONE);
49
pLeafMat->getTechnique(0)->getPass(0)->setLightingEnabled(true);
50
pLeafMat->getTechnique(0)->getPass(0)->setDiffuse(0.9f, 1.0f, 0.9f, 1.0f); // alpha not working with DX9 !!!!!!!
51
pLeafMat->getTechnique(0)->getPass(0)->setAmbient(0.5f, 0.6f, 0.5f);
53
Material *pCoordFrameMat = (Material*)MaterialManager::getSingleton().create( "CoordFrameMat" );
54
pCoordFrameMat->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
55
pCoordFrameMat->getTechnique(0)->getPass(0)->setLightingEnabled(false);*/
64
void Tree::makeMesh(Ogre::String meshName, Ogre::TParameters::TreeType type)
66
//pCoordFrameMat->getTechnique(0)->getPass(0)->setShadingMode();
69
// Attach the entity to the root of the scene
73
TParameters* pParams = new TParameters(u8Levels);
79
Ogre::Tree* pTree = new Ogre::Tree("TreeTest", pParams, u8Season, iSeed);
81
MeshPtr pTreeMesh = pTree->CreateMesh(meshName);
82
pTreeMesh->getSubMesh(0)->setMaterialName("BarkTextMat");
83
if (pTree->GetParameters()->GetLeaves() > 0)
85
pTreeMesh->getSubMesh(1)->setMaterialName("LeafTextMat");
86
if (pTree->GetParameters()->GetTreeType() == TParameters::Simple)
87
pTreeMesh->getSubMesh(2)->setMaterialName("CoordFrameMat");
89
else if (pTree->GetParameters()->GetTreeType() == TParameters::Simple)
90
pTreeMesh->getSubMesh(1)->setMaterialName("CoordFrameMat");