Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8087 was 8084, checked in by amaechler, 19 years ago

branches/atmospheric_engine: cloud hacking

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
68  this->setRadius(1900.0);
69
70  mover = 0.0f;
71
72  // Initializing default values
73  this->cloudSpeed = 1.0f;
74        this->cloudTexture = "pictures/sky/cloud1.jpg";
75}
76
77
78void CloudEffect::loadParams(const TiXmlElement* root)
79{
80        WeatherEffect::loadParams(root);
81
82        LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
83        LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
84}
85
86
87bool CloudEffect::activate()
88{
89        PRINTF(0)( "Activating CloudEffect with Material %s\n", this->cloudTexture.c_str());
90
91        this->cloudMaterial = new Material("Sky");
92  this->cloudMaterial->setIllum(3);
93  this->cloudMaterial->setAmbient(1.0, 1.0, 1.0);
94  this->cloudMaterial->setDiffuseMap(this->cloudTexture);
95}
96
97bool CloudEffect::deactivate()
98{
99        PRINTF(0)("Deactivating CloudEffect\n");
100}
101
102void CloudEffect::draw() const
103{
104        /* TODO:
105                -Load a texture, for now from an existing image, a cloud texture
106                -Blend / Overlay this with a blue sky like in the tutorial
107                -Animate it (for now move it along the sky)
108        */
109
110  glMatrixMode(GL_MODELVIEW);
111  glPushMatrix();
112
113  // Move sphere along with the camera
114  Vector r = State::getCameraNode()->getAbsCoor();
115  glTranslatef(r.x, r.y, r.z);
116
117        // Sky movement
118        glRotatef(mover, 0, 0, 1);
119
120  cloudMaterial->select();
121  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
122  glPopMatrix();
123}
124
125void CloudEffect::tick (float dt)
126{
127  mover = mover + this->cloudSpeed * dt;
128}
129
130
131/**
132 *  sets the Radius of the Sphere.
133 * @param radius The Radius of The Sphere
134*/
135void CloudEffect::setRadius(float radius)
136{
137  this->sphereRadius = radius;
138}
139
140
Note: See TracBrowser for help on using the repository browser.