Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/physics/physics_engine.cc @ 4378

Last change on this file since 4378 was 4378, checked in by bensch, 19 years ago

orxonox/trunk: applying force works for particle-systems again

File size: 2.6 KB
Line 
1/*
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:
12   main-programmer: ...
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18#include "physics_engine.h"
19
20#include "list.h"
21
22using namespace std;
23
24
25/**
26   \brief standard constructor
27*/
28PhysicsEngine::PhysicsEngine() 
29{
30   this->setClassName ("PhysicsEngine");
31
32   this->connections = new tList<PhysicsConnection>;
33}
34
35/**
36   \brief the singleton reference to this class
37*/
38PhysicsEngine* PhysicsEngine::singletonRef = NULL;
39
40/**
41   \returns a Pointer to this Class
42*/
43PhysicsEngine* PhysicsEngine::getInstance(void)
44{
45  if (!PhysicsEngine::singletonRef)
46    PhysicsEngine::singletonRef = new PhysicsEngine();
47  return PhysicsEngine::singletonRef;
48}
49
50/**
51   \brief standard deconstructor
52
53*/
54PhysicsEngine::~PhysicsEngine () 
55{
56  PhysicsEngine::singletonRef = NULL;
57}
58
59/**
60   \brief adds A Physical Connection to the List of Connections
61   \param connection the Connection to add
62   
63   Usually this is done through the constructor of PhysicshConnections
64*/
65void PhysicsEngine::addConnection(PhysicsConnection* connection)
66{
67  this->connections->add(connection);
68}
69
70/**
71   \brief removes A Physical Connection from the List of Connections
72   \param connection the Connection to remove
73   
74   Usually this is done through the destructor of PhysicsConnections
75*/
76void PhysicsEngine::removeConnection(PhysicsConnection* connection)
77{
78  this->connections->remove(connection);
79}
80
81
82
83
84
85/**
86   \brief Steps through all the Connections and Ticks them
87   \param dt The time Passed in Seconds
88
89   This function brings a flow into the whole animation
90*/
91void PhysicsEngine::tick(float dt)
92{
93  tIterator<PhysicsConnection>* iterator = this->connections->getIterator();
94  PhysicsConnection* enumConn = iterator->nextElement();
95  while (enumConn)
96    {
97      enumConn->apply(dt);
98      enumConn = iterator->nextElement();
99    }
100  delete iterator;
101}
102
103
104
105/**
106   \brief print out interesting debug information of this class
107*/
108void PhysicsEngine::debug(void) const
109{
110  PRINT(0)("====================================\n");
111  PRINT(0)("= Physics-Engine debug information =\n");
112  PRINT(0)("====================================\n");
113  PRINT(0)(" reference: %p\n", this);
114  PRINT(0)(" numbers of Connections: %d\n", this->connections->getSize());
115
116  PRINT(0)("==============================PHYS==\n");
117}
Note: See TracBrowser for help on using the repository browser.