source: OGRE/trunk/ogrenew/Samples/Transpacency/include/Transparency.h @ 692

Revision 692, 3.1 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10You may use this sample code for anything you like, it is not covered by the
11LGPL like the rest of the engine.
12-----------------------------------------------------------------------------
13*/
14
15/**
16    \file
17        Transparency.h
18    \brief
19        Specialisation of OGRE's framework application to show the transparency,
20        or scene blending features.
21    \par
22        Note that this is a little rudimentary - it's because whilst
23        OGRE supports lots of blending options, the SceneManager has
24        to ensure the rendering order is correct when object transparency
25        is enabled. Right now this is not quite right in the default
26        manager so this scene is kept deliberately simple.
27*/
28
29#include "ExampleApplication.h"
30
31class TransApplication : public ExampleApplication
32{
33public:
34    TransApplication() {}
35
36protected:
37
38    // Just override the mandatory create scene method
39    void createScene(void)
40    {
41        // Set ambient light
42        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
43
44        // Create a light
45        Light* l = mSceneMgr->createLight("MainLight");
46        // Accept default settings: point light, white diffuse, just set position
47        // NB I could attach the light to a SceneNode if I wanted it to move automatically with
48        //  other objects, but I don't
49        l->setPosition(20,80,50);
50
51
52        // Create a prefab plane
53        Entity *planeEnt = mSceneMgr->createEntity("Plane", SceneManager::PT_PLANE);
54        // Give the plane a texture
55        planeEnt->setMaterialName("Examples/BumpyMetal");
56
57        // Create an entity from a model (will be loaded automatically)
58        Entity* knotEnt = mSceneMgr->createEntity("Knot", "knot.mesh");
59
60        knotEnt->setMaterialName("Examples/TransparentTest");
61
62        // Attach the 2 new entities to the root of the scene
63        SceneNode* rootNode = mSceneMgr->getRootSceneNode();
64        rootNode->attachObject(planeEnt);
65        rootNode->attachObject(knotEnt);
66
67        // Add a whole bunch of extra transparent entities
68        Entity *cloneEnt;
69        for (int n = 0; n < 10; ++n)
70        {
71            // Create a new node under the root
72            SceneNode* node = mSceneMgr->createSceneNode();
73            // Random translate
74            Vector3 nodePos;
75            nodePos.x = Math::SymmetricRandom() * 500.0;
76            nodePos.y = Math::SymmetricRandom() * 500.0;
77            nodePos.z = Math::SymmetricRandom() * 500.0;
78            node->setPosition(nodePos);
79            rootNode->addChild(node);
80            // Clone knot
81            char cloneName[12];
82            sprintf(cloneName, "Knot%d", n);
83            cloneEnt = knotEnt->clone(cloneName);
84            // Attach to new node
85            node->attachObject(cloneEnt);
86
87        }
88    }
89
90};
Note: See TracBrowser for help on using the repository browser.