Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 1:38:17 PM (17 years ago)
Author:
rgrieder
Message:

Trying to synchronise phyiscs over the network.

  • Removed derivation of CollisionShape from WorldEntity (BaseObject instead).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/Scene.cc

    r2315 r2374  
    4343#include "core/Core.h"
    4444#include "core/XMLPort.h"
     45#include "tools/BulletConversions.h"
    4546#include "objects/worldentities/WorldEntity.h"
    4647
     
    117118        XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true);
    118119
    119         const int defaultMaxWorldSize = 100000;
    120         Vector3 worldAabbMin(-defaultMaxWorldSize, -defaultMaxWorldSize, -defaultMaxWorldSize);
    121         Vector3 worldAabbMax( defaultMaxWorldSize,  defaultMaxWorldSize,  defaultMaxWorldSize);
    122         XMLPortParamVariable(Scene, "negativeWorldRange", worldAabbMin, xmlelement, mode);
    123         XMLPortParamVariable(Scene, "positiveWorldRange", worldAabbMax, xmlelement, mode);
    124         XMLPortParam(Scene, "hasPhysics", setPhysicalWorld, hasPhysics, xmlelement, mode).defaultValue(0, true).defaultValue(1, worldAabbMin).defaultValue(2, worldAabbMax);
     120        //const int defaultMaxWorldSize = 100000;
     121        //Vector3 worldAabbMin(-defaultMaxWorldSize, -defaultMaxWorldSize, -defaultMaxWorldSize);
     122        //Vector3 worldAabbMax( defaultMaxWorldSize,  defaultMaxWorldSize,  defaultMaxWorldSize);
     123        //XMLPortParamVariable(Scene, "negativeWorldRange", worldAabbMin, xmlelement, mode);
     124        //XMLPortParamVariable(Scene, "positiveWorldRange", worldAabbMax, xmlelement, mode);
     125        XMLPortParam(Scene, "hasPhysics", setPhysicalWorld, hasPhysics, xmlelement, mode).defaultValue(0, true);//.defaultValue(1, worldAabbMin).defaultValue(2, worldAabbMax);
    125126
    126127        XMLPortObjectExtended(Scene, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
     
    131132        REGISTERSTRING(this->skybox_,     network::direction::toclient, new network::NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
    132133        REGISTERDATA(this->ambientLight_, network::direction::toclient, new network::NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
    133     }
    134 
    135     void Scene::setPhysicalWorld(bool wantPhysics, const Vector3& worldAabbMin, const Vector3& worldAabbMax)
    136     {
     134        REGISTERDATA(this->bHasPhysics_,  network::direction::toclient, new network::NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
     135    }
     136
     137    void Scene::setPhysicalWorld(bool wantPhysics)//, const Vector3& worldAabbMin, const Vector3& worldAabbMax)
     138    {
     139        this->bHasPhysics_ = wantPhysics;
    137140        if (wantPhysics && !hasPhysics())
    138141        {
    139                         float x = worldAabbMin.x;
    140                         float y = worldAabbMin.y;
    141                         float z = worldAabbMin.z;
    142             btVector3 worldAabbMin(x,y,z);
    143                         x = worldAabbMax.x;
    144                         y = worldAabbMax.y;
    145                         z = worldAabbMax.z;
    146             btVector3 worldAabbMax(x,y,z);
     142            //float x = worldAabbMin.x;
     143            //float y = worldAabbMin.y;
     144            //float z = worldAabbMin.z;
     145            btVector3 worldAabbMin(-100000, -100000, -100000);
     146            //x = worldAabbMax.x;
     147            //y = worldAabbMax.y;
     148            //z = worldAabbMax.z;
     149            btVector3 worldAabbMax(100000, 100000, 100000);
    147150
    148151            btDefaultCollisionConfiguration*     collisionConfig = new btDefaultCollisionConfiguration();
     
    173176                {
    174177                    if (!(*it)->isInWorld())
     178                    {
     179                        //COUT(0) << "body position: " << omni_cast<Vector3>((*it)->getWorldTransform().getOrigin()) << std::endl;
     180                        //COUT(0) << "body velocity: " << omni_cast<Vector3>((*it)->getLinearVelocity()) << std::endl;
     181                        //COUT(0) << "body orientation: " << omni_cast<Quaternion>((*it)->getWorldTransform().getRotation()) << std::endl;
     182                        //COUT(0) << "body angular: " << omni_cast<Vector3>((*it)->getAngularVelocity()) << std::endl;
     183                        //COUT(0) << "body mass: " << omni_cast<float>((*it)->getInvMass()) << std::endl;
     184                        //COUT(0) << "body inertia: " << omni_cast<Vector3>((*it)->getInvInertiaDiagLocal()) << std::endl;
    175185                        this->physicalWorld_->addRigidBody(*it);
     186                    }
    176187                }
    177188                this->physicsQueue_.clear();
     
    234245    {
    235246        if (!this->physicalWorld_)
    236             COUT(1) << "Error: Cannot WorldEntity body to physical Scene: No physics." << std::endl;
     247            COUT(1) << "Error: Cannot add WorldEntity body to physical Scene: No physics." << std::endl;
    237248        else if (body)
    238249            this->physicsQueue_.insert(body);
     
    242253    {
    243254        if (!this->physicalWorld_)
    244             COUT(1) << "Error: Cannot WorldEntity body to physical Scene: No physics." << std::endl;
     255            COUT(1) << "Error: Cannot remove WorldEntity body from physical Scene: No physics." << std::endl;
    245256        else if (body)
    246257        {
Note: See TracChangeset for help on using the changeset viewer.