Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

blink: more clean up + positioning works now

File size: 2.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->bBoard = new Billboard;
67  this->bBoard->setVisibiliy(true);
68  this->bBoard->setTexture("maps/star_alpha.png");
69  this->bBoard->setAbsCoor(0, 0, 0);
70
71
72  /// Standard values
73  this->setAbsCoor(0, 0, 0);
74  // red if not defined in xml
75  this->color = Color(1, 0, 0);
76  // 10x10 pxl if not defined in xml
77  this->size = 10;
78  this->omega = 10;
79  this->angle = rand() % 1000;
80  PRINTF(0)("\n\n\n\n\n\n\nangle: %f\n\n\n\n\n\n\n\n", this->angle);
81  this->angle *= 2 * M_PI;
82  PRINTF(0)("\n\n\n\n\n\n\nangle: %f\n\n\n\n\n\n\n\n", this->angle);
83}
84
85
86/**
87 *  load params
88 * @param root TiXmlElement object
89 */
90void Blink::loadParams(const TiXmlElement* root)
91{
92  WorldEntity::loadParams(root);
93
94  LoadParam(root, "position", this, Blink, setPosition);
95  LoadParam(root, "size", this, Blink, setSize);
96  LoadParam(root, "color", this, Blink, setColor);
97  LoadParam(root, "omega", this, Blink, setOmega);
98}
99
100
101/**
102 * ticks the Blink
103 * @param dt the time to ticks
104 */
105void Blink::tick(float dt)
106{
107  this->angle += dt * this->omega;
108
109  if (this->angle > 2 * M_PI)
110    this->angle -= 2 * M_PI;
111
112  this->blinkStr = sinf(angle);
113
114  this->bBoard->colorTexture(Color(color.r(), color.g(), color.b(), 1));
115}
116
117
118/**
119 * draws the blink
120 */
121void Blink::draw() const
122{
123
124}
Note: See TracBrowser for help on using the repository browser.