Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/blink/src/world_entities/effects/blink.cc @ 10425

Last change on this file since 10425 was 10425, checked in by stefalie, 17 years ago

blink: 1 bug less

File size: 5.2 KB
Line 
1/*
2
3   Copyright (C) 2006 orx
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2, or (at your option)
8   any later version.
9
10### File Specific:
11   main-programmer:
12*/
13
14#include "blink.h"
15
16#include "util/loading/load_param.h"
17#include "util/loading/factory.h"
18#include "debug.h"
19#include "state.h"
20#include "effects/billboard.h"
21
22#include "material.h"
23
24
25
26
27
28
29ObjectListDefinition(Blink);
30CREATE_FACTORY(Blink);
31
32/**
33 * standart constructor
34 */
35Blink::Blink (const TiXmlElement* root)
36{
37  this->init();
38
39  if( root)
40    this->loadParams(root);
41
42//   this->bBoard->setSize(this->size, this->size);
43}
44
45
46/**
47 * destroys a Blink
48 */
49Blink::~Blink ()
50{
51//  if (this->material)
52  //  delete this->material;
53}
54
55
56/**
57 * initializes the Blink
58 */
59void Blink::init()
60{
61  this->registerObject(this, Blink::_objectList);
62  this->setName("Blink");
63
64  this->toList(OM_COMMON);
65
66  //this->material = new Material();
67  //this->material->setIllum(0);
68  //this->material->setDiffuse(1.0,1.0,1.0);
69  //this->material->setTransparency(0.0);
70 // this->material->setSpecular(0.0,0.0,0.0);
71 // this->material->setAmbient(1.0, 1.0, 1.0);
72  //this->material->setBlendFunc(GL_ZERO,GL_ZERO);
73  //this->material->setDiffuseMap("pictures/rblink2.png");
74  //this->material->setDiffuseMap("maps/star_alpha.png");
75  //this->setAbsCoor(0, 0, 0);d
76  //this->setVisibiliy(true);
77  // this->setSize(5, 5);
78
79  //srand((unsigned)time(NULL));
80
81
82  this->bBoard = new Billboard;
83  this->bBoard->setVisibiliy(true);
84  this->bBoard->setTexture("maps/star_alpha.png");
85  this->bBoard->setAbsCoor(this->position.x, this->position.y, this->position.z);
86
87
88  /// Standard values
89  this->setAbsCoor(0, 0, 0); 
90  this->position = Vector(0, 0, 0); ///remove
91  this->color = Color(1, 1, 0);
92  this->size = 10;
93  this->omega = 10;
94  this->angle = rand() % 1000;
95  PRINTF(0)("\n\n\n\n\n\n\nangle: %f\n\n\n\n\n\n\n\n", this->angle);
96  this->angle *= 2 * M_PI;
97  PRINTF(0)("\n\n\n\n\n\n\nangle: %f\n\n\n\n\n\n\n\n", this->angle);
98}
99
100
101/**
102 *  load params
103 * @param root TiXmlElement object
104 */
105void Blink::loadParams(const TiXmlElement* root)
106{
107  WorldEntity::loadParams(root);
108
109  LoadParam(root, "position", this, Blink, setPosition);
110  LoadParam(root, "size", this, Blink, setSize);
111  LoadParam(root, "color", this, Blink, setColor);
112  LoadParam(root, "omega", this, Blink, setOmega);
113//   LoadParam(root, "watersize", this, Blink, setWaterSize);
114//   LoadParam(root, "wateruv", this, Blink, setWaterUV);
115//   LoadParam(root, "waterflow", this, Blink, setWaterFlow);
116//   LoadParam(root, "lightpos", this, Blink, setLightPos);
117//   LoadParam(root, "waterangle", this, Blink, setWaterAngle);
118//   LoadParam(root, "normalmapscale", this, Blink, setNormalMapScale);
119//   LoadParam(root, "shinesize", this, Blink, setShineSize);
120//   LoadParam(root, "shinestrength", this, Blink, setShineStrength);
121//   LoadParam(root, "reflstrength", this, Blink, setReflStrength);
122//   LoadParam(root, "refraction", this, Blink, setRefraction);
123//   LoadParam(root, "watercolor", this, Blink, setWaterColor);
124  /*LoadParam(root, "texture", this->material, Material, setDiffuseMap)
125      .describe("the texture-file to load onto the Blink");
126
127  LoadParam(root, "size", this, Blink, setSize)
128  .describe("the size of the Blink in Pixels");*/
129}
130
131
132/**
133 * ticks the Blink
134 * @param dt the time to ticks
135 */
136void Blink::tick(float dt)
137{
138  this->angle += dt * this->omega;
139
140  if (this->angle > 2 * M_PI)
141    this->angle -= 2 * M_PI;
142
143  this->blinkStr = sinf(angle);
144}
145
146
147/**
148 * draws the blink
149 */
150void Blink::draw() const
151{
152//   glPushAttrib(GL_ENABLE_BIT);
153//   glEnable(GL_LIGHTING); //glDisable(GL_LIGHTING);
154//   glDisable(GL_FOG);
155//   glMatrixMode(GL_MODELVIEW);
156//   glPushMatrix();
157
158//   Vector pos = this->getAbsCoor();
159//   Vector dir = pos - State::getCameraNode()->getAbsCoor();
160//   dir.normalize();
161//
162//   Vector up = Vector(0, 1, 0);
163//   Vector h = dir.cross(up);
164//
165//   Vector pos = this->getAbsCoor();
166//   glTranslatef(pos.x, pos.y, pos.z);
167
168    /* translate */
169//     glTranslatef (this->getAbsCoor ().x,
170//                   this->getAbsCoor ().y,
171//                   this->getAbsCoor ().z);
172//     Vector tmpRot = this->getAbsDir().getSpacialAxis();
173//     glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
174
175//   glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Set The Blending Function For Translucency
176//   glEnable(GL_BLEND);
177//   glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
178//   glShadeModel(GL_SMOOTH);
179
180/*
181  Vector camCoor = State::getCameraNode()->getAbsCoor();
182  Vector diff = camCoor - this->position;
183
184
185  //glTranslatef(position.x + size/2, position.y + size/2, position.z);
186
187  glTranslatef(this->position.x - this->size/2, this->position.y - this->size/2, this->position.z);*/
188
189//   Vector view = this->getAbsCoor() - State::getCameraNode()->getAbsCoor();
190//   view.normalize();
191//
192//   Vector up = Vector(0, 1, 0);
193//   Vector h = view.cross(up);
194
195  //this->material->select();
196  PRINTF(0)("\n\n\n\n::%f,%f,%f\n\n\n\n", color.r(), color.g(), color.b());
197  this->bBoard->colorTexture(Color(color.r(), color.g(), color.b(), 1));
198
199  glPopMatrix();
200  glPopAttrib();
201}
Note: See TracBrowser for help on using the repository browser.