Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/physics/physics_connection.cc @ 5067

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

orxonox/trunk: renamed all the \param → @param and so on in Doxygen tags.
Thanks a lot to the kDevelop team. this took since the last commit :)

File size: 2.7 KB
RevLine 
[4597]1/*
[1853]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.
[1855]10
11   ### File Specific:
[4181]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[4178]16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
[1853]17
[4181]18#include "physics_connection.h"
[1853]19
[4183]20#include "physics_engine.h"
21
[4375]22#include "field.h"
23#include "particle_system.h"
24#include "physics_interface.h"
25
[4728]26#include "factory.h"
27
[1856]28using namespace std;
[1853]29
[4728]30CREATE_FACTORY(PhysicsConnection);
31
[4480]32/**
[4836]33 *  creates a PhysicsConnection
[4480]34*/
[4377]35PhysicsConnection::PhysicsConnection(PhysicsInterface* subject, Field* field)
[3365]36{
[4597]37  this->setClassID(CL_PHYSICS_CONNECTION, "PhysicsConnection");
[4377]38  this->type = PCON_PhysIField;
[4731]39
[4377]40  this->subject = subject;
[4182]41  this->field = field;
[4183]42
43  PhysicsEngine::getInstance()->addConnection(this);
[3365]44}
[1853]45
[4728]46PhysicsConnection::PhysicsConnection(const TiXmlElement* root)
47{
48  this->setClassID(CL_PHYSICS_CONNECTION, "PhysicsConnection");
49  this->type = PCON_PhysIField;
[1853]50
[4728]51  static_cast<BaseObject*>(this)->loadParams(root);
52
53  LoadParam<PhysicsConnection>(root, "subject", this, &PhysicsConnection::setSubject)
54      .describe("set the subject by a name");
55
56  LoadParam<PhysicsConnection>(root, "field", this, &PhysicsConnection::setField)
57      .describe("set the field by name");
[4731]58
59  PhysicsEngine::getInstance()->addConnection(this);
[4728]60}
61
[3245]62/**
[4836]63 *  standard deconstructor
[1853]64
[3245]65*/
[4597]66PhysicsConnection::~PhysicsConnection ()
[3543]67{
[4183]68  PhysicsEngine::getInstance()->removeConnection(this);
[3543]69}
[4181]70
[4597]71/**
[4836]72 * @param subjectName the name of the Subject for this PhysicsConnection
[4728]73*/
74void PhysicsConnection::setSubject(const char* subjectName)
75{
76  this->subject = PhysicsEngine::getInstance()->getPhysicsInterfaceByName(subjectName);
77  if (this->subject == NULL)
[4731]78  {
[4728]79    PRINTF(2)("subject: (%s) not found for PhysicsConnection\n", subjectName);
[4731]80  }
81  else
82    PRINTF(5)("subject::%s\n", this->subject->getName());
[4728]83}
84
85/**
[4836]86* @param fieldName the Name of the Field for this connection
[4728]87*/
88void PhysicsConnection::setField(const char* fieldName)
89{
90  this->field = PhysicsEngine::getInstance()->getFieldByName(fieldName);
91  if (this->field == NULL)
[4731]92  {
93        PRINTF(2)("field: (%s) not found for PhysicsConnection\n", fieldName);
94  }
95  else
96    PRINTF(5)("field::%s\n", this->field->getName());
97
[4728]98}
99
100/**
[4836]101  *  applies the Force to some Object.
[4182]102*/
[4746]103void PhysicsConnection::apply() const
[4182]104{
[4728]105  if (likely(this->type == PCON_PhysIField && this->field->getMagnitude() != 0.0
106      && this->subject != NULL && this->field != NULL))
[4395]107      this->subject->applyField(this->field);
[4378]108  else ;
[4181]109}
Note: See TracBrowser for help on using the repository browser.