Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/Samples/TextureFX/include/TextureFX.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 3.1 KB
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-2006 Torus Knot Software Ltd
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        TextureFX.h
18    \brief
19        Shows OGRE's ability to handle different types of texture effects.
20*/
21
22
23#include "ExampleApplication.h"
24
25class TextureEffectsApplication : public ExampleApplication
26{
27public:
28    TextureEffectsApplication() {}
29
30protected:
31
32    void createScalingPlane()
33    {
34        // Set up a material for the plane
35
36        // Create a prefab plane
37        Entity *planeEnt = mSceneMgr->createEntity("Plane", SceneManager::PT_PLANE);
38        // Give the plane a texture
39        planeEnt->setMaterialName("Examples/TextureEffect1");
40
41        SceneNode* node = 
42            mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(-250,-40,-100));
43
44        node->attachObject(planeEnt);
45    }
46
47    void createScrollingKnot()
48    {
49        Entity *ent = mSceneMgr->createEntity("knot", "knot.mesh");
50
51
52        ent->setMaterialName("Examples/TextureEffect2");
53        // Add entity to the root scene node
54        SceneNode* node = 
55            mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(200,50,150));
56
57        node->attachObject(ent);
58
59    }
60
61    void createWateryPlane()
62    {
63        // Create a prefab plane
64        Entity *planeEnt = mSceneMgr->createEntity("WaterPlane", SceneManager::PT_PLANE);
65        // Give the plane a texture
66        planeEnt->setMaterialName("Examples/TextureEffect3");
67
68        mSceneMgr->getRootSceneNode()->attachObject(planeEnt);
69    }
70
71    // Just override the mandatory create scene method
72    void createScene(void)
73    {
74
75        // Set ambient light
76        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
77
78        // Create a point light
79        Light* l = mSceneMgr->createLight("MainLight");
80        // Accept default settings: point light, white diffuse, just set position
81        // NB I could attach the light to a SceneNode if I wanted it to move automatically with
82        //  other objects, but I don't
83        l->setPosition(20,80,50);
84
85
86        createScalingPlane();
87        createScrollingKnot();
88        createWateryPlane();
89
90
91        // Set up a material for the skydome
92        MaterialPtr skyMat = MaterialManager::getSingleton().create("SkyMat",
93            ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
94        // Perform no dynamic lighting on the sky
95        skyMat->setLightingEnabled(false);
96        // Use a cloudy sky
97        TextureUnitState* t = skyMat->getTechnique(0)->getPass(0)->createTextureUnitState("clouds.jpg");
98        // Scroll the clouds
99        t->setScrollAnimation(0.15, 0);
100
101        // System will automatically set no depth write
102
103        // Create a skydome
104        mSceneMgr->setSkyDome(true, "SkyMat", -5, 2);
105
106
107
108
109
110    }
111
112};
Note: See TracBrowser for help on using the repository browser.