Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/power_ups/turret_power_up.cc @ 9869

Last change on this file since 9869 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.1 KB
RevLine 
[4597]1/*
[2077]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:
[5434]12   main-programmer: Benjamin Grauer
[2077]13   co-programmer: ...
14*/
15
[5439]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
[2077]17
[5434]18#include "turret_power_up.h"
[7193]19#include "util/loading/factory.h"
[6424]20#include "network_game_manager.h"
[5435]21#include "state.h"
[2077]22
[5437]23#include "primitive_model.h"
24
[2077]25
[9869]26#include "class_id_DEPRECATED.h"
27ObjectListDefinitionID(TurretPowerUp, CL_TURRET_POWER_UP);
28CREATE_FACTORY(TurretPowerUp);
[9406]29
[6113]30TurretPowerUp::TurretPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0)
[5434]31{
32  this->init();
[2077]33
[6695]34  if( root != NULL)
35    this->loadParams(root);
[5434]36}
[2077]37
38
[5437]39TurretPowerUp::~TurretPowerUp ()
40{
41  delete this->sphereModel;
42  delete this->sphereMaterial;
[5435]43}
[5434]44
[5435]45
[5434]46void TurretPowerUp::init()
47{
[9869]48  this->registerObject(this, TurretPowerUp::_objectList);
[5499]49  this->loadModel("models/guns/turret1.obj", 2.0);
[5435]50
[5437]51  this->sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5);
52  this->sphereMaterial = new Material;
[5439]53  this->sphereMaterial->setTransparency(.1);
[5437]54  this->sphereMaterial->setDiffuse(.1, .1, .8);
55
[5435]56  this->rotation = Vector(0,1,0);
[5437]57  this->cycle    = (float)rand()/RAND_MAX*M_2_PI;
58  this->shiftDir(Quaternion((float)rand()/RAND_MAX*M_2_PI, this->rotation));
[5434]59}
60
61
62void TurretPowerUp::loadParams(const TiXmlElement* root)
63{
[6512]64  PowerUp::loadParams(root);
[5434]65
66}
[5435]67
68
69/**
70 * this function is called, when two entities collide
71 * @param entity: the world entity with whom it collides
72 *
73 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
74 */
75void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location)
76{
[9406]77 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassCName(), entity->getClassCName(), location.x, location.y, location.z);
[5915]78 if (entity->isA(CL_PLAYABLE))
[6142]79   this->toList(OM_DEAD);
[5435]80}
81
82/**
83 *  this method is called every frame
84 * @param time: the time in seconds that has passed since the last tick
85 *
86 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
87*/
88void TurretPowerUp::tick(float dt)
89{
90  this->shiftDir(Quaternion(dt, this->rotation));
91  this->cycle+=dt;
92
93}
94
95/**
96 *  the entity is drawn onto the screen with this function
97 *
98 * This is a central function of an entity: call it to let the entity painted to the screen.
99 * Just override this function with whatever you want to be drawn.
100*/
[5500]101void TurretPowerUp::draw() const
[6780]102{
103  glMatrixMode(GL_MODELVIEW);
[5435]104  glPushMatrix();
105  /* translate */
106  glTranslatef (this->getAbsCoor ().x,
107                this->getAbsCoor ().y + cos(this->cycle*3.0)*2.0,
108                this->getAbsCoor ().z);
109  /* rotate */
110  Vector tmpRot = this->getAbsDir().getSpacialAxis();
111  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
[5994]112  this->getModel()->draw();
[5437]113
114  this->sphereMaterial->select();
115  this->sphereModel->draw();
[5435]116  glPopMatrix();
117}
Note: See TracBrowser for help on using the repository browser.