Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

blink: blinki moutni works

File size: 2.5 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: Lieni
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
23
24
25ObjectListDefinition(Blink);
26CREATE_FACTORY(Blink);
27
28/**
29 * standart constructor
30 */
31Blink::Blink (const TiXmlElement* root)
32{
33  this->init();
34
35  if(root)
36    this->loadParams(root);
37
38  // calculation of the symbolTime
39  this->symbolTime = this->period / this->blinkSequence.length();
40}
41
42
43/**
44 * destroys a Blink
45 */
46Blink::~Blink ()
47{
48  if(bBoard)
49    delete bBoard;
50}
51
52
53/**
54 * initializes the Blink
55 */
56void Blink::init()
57{
58  this->registerObject(this, Blink::_objectList);
59  this->setName("Blink");
60
61  this->toList(OM_COMMON);
62
63  this->bBoard = new Billboard;
64  this->bBoard->setVisibiliy(true);
65  this->bBoard->setTexture("textures/light/blink.png");
66
67  /// Standard values
68  this->bBoard->setAbsCoor(0, 0, 0);
69  // default position if not set in xml
70  this->color = Color(1, 0, 0);
71  // 10x10 pxl if not defined in xml
72  this->size = 10;
73  // default period
74  this->period = 1;
75  // default blink sequence
76  this->blinkSequence = "00011234567889998876543211";
77
78  // start values of non-loadable variables
79  this->blinkStr = 0;
80  this->timer = 0;
81  this->seqCounter = 0;
82}
83
84
85/**
86 *  load params
87 * @param root TiXmlElement object
88 */
89void Blink::loadParams(const TiXmlElement* root)
90{
91  WorldEntity::loadParams(root);
92
93  LoadParam(root, "position", this, Blink, PNode::setAbsCoor);
94  LoadParam(root, "size", this, Blink, setSize);
95  LoadParam(root, "color", this, Blink, setColor);
96  LoadParam(root, "period", this, Blink, setPeriod);
97  LoadParam(root, "sequence", this, Blink, loadBlinkSequence);
98}
99
100
101/**
102 * ticks the Blink
103 * @param dt the time to ticks
104 */
105void Blink::tick(float dt)
106{
107  this->bBoard->setAbsCoor(this->getAbsCoor());
108
109  timer += dt;
110
111  while(this->timer >= this->symbolTime)
112  {
113    this->blinkStr = (float)((int)(blinkSequence[seqCounter]) - 48) / 9;
114
115    this->timer -= symbolTime;
116
117    seqCounter++;
118    seqCounter %= this->blinkSequence.length();
119  }
120
121  this->bBoard->colorTexture(Color(color.r(), color.g(), color.b(), this->blinkStr));
122
123  PRINTF(0)("hithere\n\n\n\n\n\n");
124}
125
126
127/**
128 * draws the blink
129 */
130void Blink::draw() const
131{
132
133}
Note: See TracBrowser for help on using the repository browser.