~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/environment/Tree.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// C++ Implementation: Tree
 
3
//
 
4
// Description: 
 
5
//
 
6
//
 
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2005
 
8
//
 
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.
 
13
// 
 
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.
 
18
// 
 
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.//
 
22
//
 
23
#ifdef HAVE_CONFIG_H
 
24
#include "config.h"
 
25
#endif
 
26
 
 
27
 
 
28
#include "meshtree/TParameters.h"
 
29
#include "meshtree/MeshTree.h"
 
30
#include "../OgreIncludes.h"
 
31
#include "Tree.h"
 
32
 
 
33
namespace EmberOgre {
 
34
 
 
35
namespace Environment {
 
36
 
 
37
using namespace Ogre;
 
38
 
 
39
Tree::Tree()
 
40
{
 
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" );
 
44
    
 
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);
 
52
 
 
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);*/
 
56
}
 
57
 
 
58
 
 
59
Tree::~Tree()
 
60
{
 
61
}
 
62
 
 
63
 
 
64
void Tree::makeMesh(Ogre::String meshName, Ogre::TParameters::TreeType type)
 
65
{
 
66
        //pCoordFrameMat->getTechnique(0)->getPass(0)->setShadingMode();
 
67
 
 
68
 
 
69
        // Attach the entity to the root of the scene
 
70
 
 
71
 
 
72
        uchar u8Levels = 2;
 
73
        TParameters* pParams = new TParameters(u8Levels);
 
74
        pParams->Set( type );
 
75
 
 
76
        uchar u8Season = 0;
 
77
        int iSeed = 0;
 
78
 
 
79
        Ogre::Tree* pTree = new Ogre::Tree("TreeTest", pParams, u8Season, iSeed);
 
80
        pTree->Grow();
 
81
        MeshPtr pTreeMesh = pTree->CreateMesh(meshName);
 
82
        pTreeMesh->getSubMesh(0)->setMaterialName("BarkTextMat");
 
83
        if (pTree->GetParameters()->GetLeaves() > 0)
 
84
        {
 
85
                        pTreeMesh->getSubMesh(1)->setMaterialName("LeafTextMat");
 
86
          if (pTree->GetParameters()->GetTreeType() == TParameters::Simple)
 
87
            pTreeMesh->getSubMesh(2)->setMaterialName("CoordFrameMat");
 
88
        }
 
89
        else if (pTree->GetParameters()->GetTreeType() == TParameters::Simple)
 
90
          pTreeMesh->getSubMesh(1)->setMaterialName("CoordFrameMat");
 
91
 
 
92
 
 
93
}
 
94
 
 
95
}
 
96
 
 
97
}