Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10253 was 10253, checked in by stefalie, 17 years ago
File size: 4.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2006 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:
13*/
14
15#include "blink.h"
16
17#include "util/loading/load_param.h"
18#include "util/loading/factory.h"
19#include "debug.h"
20#include "state.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
43
44/**
45 * destroys a Blink
46 */
47Blink::~Blink ()
48{
49  if (this->material)
50    delete this->material;
51}
52
53
54/**
55 * initializes the Blink
56 */
57void Blink::init()
58{
59  this->registerObject(this, Blink::_objectList);
60  this->setName("Blink");
61
62  this->toList(OM_COMMON);
63
64  this->material = new Material();
65  //this->material->setIllum(0);
66  //this->material->setDiffuse(1.0,1.0,1.0);
67  //this->material->setTransparency(0.0);
68 // this->material->setSpecular(0.0,0.0,0.0);
69 // this->material->setAmbient(1.0, 1.0, 1.0);
70  //this->material->setBlendFunc(GL_ZERO,GL_ZERO);
71  //this->material->setDiffuseMap("pictures/rblink2.png");
72  this->material->setDiffuseMap("maps/star.bmp");
73  //this->setAbsCoor(0, 0, 0);d
74  //this->setVisibiliy(true);
75  // this->setSize(5, 5);
76
77  this->setAbsCoor(0, 0, 0); 
78  this->position = Vector(0, 0, 0); ///remove
79  this->size = 10;
80}
81
82
83/**
84 *  load params
85 * @param root TiXmlElement object
86 */
87void Blink::loadParams(const TiXmlElement* root)
88{
89  WorldEntity::loadParams(root);
90
91  LoadParam(root, "position", this, Blink, setPosition);
92  LoadParam(root, "size", this, Blink, setSize);
93//   LoadParam(root, "watersize", this, Blink, setWaterSize);
94//   LoadParam(root, "wateruv", this, Blink, setWaterUV);
95//   LoadParam(root, "waterflow", this, Blink, setWaterFlow);
96//   LoadParam(root, "lightpos", this, Blink, setLightPos);
97//   LoadParam(root, "waterangle", this, Blink, setWaterAngle);
98//   LoadParam(root, "normalmapscale", this, Blink, setNormalMapScale);
99//   LoadParam(root, "shinesize", this, Blink, setShineSize);
100//   LoadParam(root, "shinestrength", this, Blink, setShineStrength);
101//   LoadParam(root, "reflstrength", this, Blink, setReflStrength);
102//   LoadParam(root, "refraction", this, Blink, setRefraction);
103//   LoadParam(root, "watercolor", this, Blink, setWaterColor);
104  /*LoadParam(root, "texture", this->material, Material, setDiffuseMap)
105      .describe("the texture-file to load onto the Blink");
106
107  LoadParam(root, "size", this, Blink, setSize)
108  .describe("the size of the Blink in Pixels");*/
109}
110
111
112/**
113 * ticks the Blink
114 * @param dt the time to ticks
115 */
116void Blink::tick(float dt)
117{
118}
119
120
121/**
122 * draws the blink
123 */
124void Blink::draw() const
125{
126  glPushAttrib(GL_ENABLE_BIT);
127  glDisable(GL_LIGHTING);
128  glDisable(GL_FOG);
129  glMatrixMode(GL_MODELVIEW);
130  glPushMatrix();
131
132//   Vector pos = this->getAbsCoor();
133//   Vector dir = pos - State::getCameraNode()->getAbsCoor();
134//   dir.normalize();
135//
136//   Vector up = Vector(0, 1, 0);
137//   Vector h = dir.cross(up);
138//
139//   Vector pos = this->getAbsCoor();
140//   glTranslatef(pos.x, pos.y, pos.z);
141
142    /* translate */
143//     glTranslatef (this->getAbsCoor ().x,
144//                   this->getAbsCoor ().y,
145//                   this->getAbsCoor ().z);
146//     Vector tmpRot = this->getAbsDir().getSpacialAxis();
147//     glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
148
149  glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Set The Blending Function For Translucency
150  glEnable(GL_BLEND);
151  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
152
153  //glTranslatef(position.x + size/2, position.y + size/2, position.z);
154
155  glTranslatef(this->position.x - this->size/2, this->position.y - this->size/2, this->position.z);
156
157//   Vector view = this->getAbsCoor() - State::getCameraNode()->getAbsCoor();
158//   view.normalize();
159//
160//   Vector up = Vector(0, 1, 0);
161//   Vector h = view.cross(up);
162
163  this->material->select();
164
165
166  glColor4ub(255, 0, 0, 255);
167  glBegin(GL_QUADS);
168    glTexCoord2f(1, 1); glVertex3f(0, 0, 0);
169    glTexCoord2f(1, 0); glVertex3f(this->size, 0, 0);
170    glTexCoord2f(0, 0); glVertex3f(this->size, this->size, 0);
171    glTexCoord2f(0, 1); glVertex3f(0, this->size, 0);
172  glEnd();
173
174
175  glPopMatrix();
176  glPopAttrib();
177}
Note: See TracBrowser for help on using the repository browser.