Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc @ 8131

Last change on this file since 8131 was 8119, checked in by amaechler, 19 years ago

branches/atmospheric_engine: added function to slowly start rain

File size: 2.8 KB
Line 
1/*
2        orxonox - the future of 3D-vertical-scrollers
3
4        Copyright (C) 2004 orx
5
6        This program is free software; you can redistribute it and/or modify
7        it under the terms of the GNU General Public License as published by
8        the Free Software Foundation; either version 2, or (at your option)
9        any later version.
10
11### File Specific:
12        main-programmer: hdavid, amaechler
13        Taken from SkySphere
14*/
15
16// TODO: Vektortextur erzeugen und Regionen auswaehlen, Sky...
17
18#include "cloud_effect.h"
19
20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
22
23#include "glincl.h"
24#include "material.h"
25#include <math.h>
26#include "material.h"
27#include "state.h"
28#include "p_node.h"
29
30#include "parser/tinyxml/tinyxml.h"
31
32using namespace std;
33
34CREATE_FACTORY(CloudEffect, CL_CLOUD_EFFECT);
35
36CloudEffect::CloudEffect(const TiXmlElement* root)
37{
38        this->setClassID(CL_CLOUD_EFFECT, "CloudEffect");
39
40        this->init();
41
42        if (root != NULL)
43                this->loadParams(root);
44
45        this->activate();
46}
47
48CloudEffect::~CloudEffect()
49{
50        this->deactivate();
51
52        //delete this->skyMaterial;
53        //gluDeleteQuadric(this->sphereObj);
54}
55
56
57bool CloudEffect::init()
58{
59        PRINTF(1)("Initializing CloudEffect\n");
60
61        this->sphereObj = gluNewQuadric();
62        //this->setParentMode(PNODE_MOVEMENT);
63
64        gluQuadricTexture(this->sphereObj, GL_TRUE);
65        gluQuadricOrientation(this->sphereObj, GLU_INSIDE);
66
67        this->setRadius(1900.0);
68
69        mover = 0.0f;
70
71        // Initializing default values
72        this->cloudSpeed = 1.0f;
73        this->cloudTexture = "pictures/sky/cloud1.jpg";
74}
75
76
77void CloudEffect::loadParams(const TiXmlElement* root)
78{
79        WeatherEffect::loadParams(root);
80
81        LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
82        LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
83}
84
85
86bool CloudEffect::activate()
87{
88        PRINTF(0)( "Activating CloudEffect with Material %s\n", this->cloudTexture.c_str());
89
90        this->cloudMaterial = new Material("Sky");
91        this->cloudMaterial->setIllum(3);
92        this->cloudMaterial->setAmbient(1.0, 1.0, 1.0);
93        this->cloudMaterial->setDiffuseMap(this->cloudTexture);
94}
95
96bool CloudEffect::deactivate()
97{
98        PRINTF(0)("Deactivating CloudEffect\n");
99}
100
101void CloudEffect::draw() const
102{
103        /* TODO:
104                -Load a texture, for now from an existing image, a cloud texture
105                -Blend / Overlay this with a blue sky like in the tutorial
106                -Animate it (for now move it along the sky)
107        */
108
109        glMatrixMode(GL_MODELVIEW);
110        glPushMatrix();
111
112        // Move sphere along with the camera
113        Vector r = State::getCameraNode()->getAbsCoor();
114        glTranslatef(r.x, r.y, r.z);
115
116        // Sky movement
117        glRotatef(mover, 0, 0, 1);
118
119        cloudMaterial->select();
120        gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
121        glPopMatrix();
122}
123
124void CloudEffect::tick (float dt)
125{
126        mover = mover + this->cloudSpeed * dt;
127}
128
129
130/**
131*  sets the Radius of the Sphere.
132* @param radius The Radius of The Sphere
133*/
134void CloudEffect::setRadius(float radius)
135{
136        this->sphereRadius = radius;
137}
138
139
Note: See TracBrowser for help on using the repository browser.