Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2056


Ignore:
Timestamp:
Oct 29, 2008, 3:58:18 PM (15 years ago)
Author:
martisty
Message:

BulletEngine: Box with gravity, no compile error every thing works fine :)

Location:
code/branches/physics/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/CMakeLists.txt

    r1995 r2056  
    1111ADD_SUBDIRECTORY(bullet)
    1212ADD_SUBDIRECTORY(ogrebullet)
    13 ADD_SUBDIRECTORY(ogreode)
     13# ADD_SUBDIRECTORY(ogreode)
    1414ADD_SUBDIRECTORY(lua)
    1515ADD_SUBDIRECTORY(tolua)
  • code/branches/physics/src/bullet/BulletCollision/CMakeLists.txt

    r1972 r2056  
    1 ADD_LIBRARY(LibBulletCollision
     1ADD_LIBRARY(LibBulletCollision SHARED
    22                                BroadphaseCollision/btAxisSweep3.cpp
    33                                BroadphaseCollision/btAxisSweep3.h
  • code/branches/physics/src/bullet/BulletDynamics/CMakeLists.txt

    r1963 r2056  
    1 ADD_LIBRARY(LibBulletDynamics
     1ADD_LIBRARY(LibBulletDynamics SHARED
    22
    33        ConstraintSolver/btContactConstraint.cpp
  • code/branches/physics/src/bullet/BulletSoftBody/CMakeLists.txt

    r1963 r2056  
    1 ADD_LIBRARY(LibBulletSoftBody
     1ADD_LIBRARY(LibBulletSoftBody SHARED
    22        btSoftBody.cpp
    33        btSoftBody.h
  • code/branches/physics/src/bullet/LinearMath/CMakeLists.txt

    r1983 r2056  
    1 ADD_LIBRARY(LibLinearMath
     1ADD_LIBRARY(LibLinearMath SHARED
    22                btAlignedObjectArray.h
    33                btList.h
  • code/branches/physics/src/orxonox/CMakeLists.txt

    r1995 r2056  
    107107  tinyxml_orxonox
    108108  tolualib_orxonox
    109   ogreode_orxonox
    110109  LibLinearMath
    111110  LibBulletCollision
  • code/branches/physics/src/orxonox/objects/HelloBullet.cc

    r2047 r2056  
    4242#include "GraphicsEngine.h"
    4343
     44#include "util/Sleep.h"
     45
     46
    4447namespace orxonox
    4548{
     
    5053           RegisterObject(HelloBullet);
    5154           COUT(0) << "HelloBullet loaded" << std::endl ;
    52            int maxProxies = 1024
     55           int maxProxies = 1024;
    5356
    5457
    55            btVector3 worldAabbMin(-10000,-10000,-10000);
    56            btVector3 worldAabbMax(10000,10000,10000);
    57            btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
     58        btVector3 worldAabbMin(-10000,-10000,-10000);
     59        btVector3 worldAabbMax(10000,10000,10000);
     60        btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
    5861
    59             // Set up the collision configuration and dispatcher
    60             btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
    61             btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
     62        btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
     63        btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
    6264
    63             // The actual physics solver
    64             btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
     65        btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
    6566
    66             // The world.
    67             btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
     67        dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
     68
     69        dynamicsWorld->setGravity(btVector3(0,-10,0));
     70
     71
     72        btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),10);
     73
     74        btCollisionShape* fallShape = new btSphereShape(1);
     75
     76
     77        btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,-1,0)));
     78        btRigidBody::btRigidBodyConstructionInfo
     79                groundRigidBodyCI(0,groundMotionState,groundShape,btVector3(0,0,0));
     80        btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
     81        dynamicsWorld->addRigidBody(groundRigidBody);
     82
     83
     84        btDefaultMotionState* fallMotionState =
     85                new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,100,0)));
     86        btScalar mass = 1000;
     87        btVector3 fallInertia(0,0,0);
     88        fallShape->calculateLocalInertia(mass,fallInertia);
     89        btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,fallMotionState,fallShape,fallInertia);
     90        fallRigidBody = new btRigidBody(fallRigidBodyCI);
     91        dynamicsWorld->addRigidBody(fallRigidBody);
     92
     93 
     94
     95//load floor mash
     96        Ogre::SceneManager* sceneMgr = GraphicsEngine::getInstance().getLevelSceneManager();
     97
     98        int i = 0;
     99        Ogre::StaticGeometry* floor;
     100        floor = sceneMgr->createStaticGeometry("StaticFloor");
     101        floor->setRegionDimensions(Ogre::Vector3(160.0, 100.0, 160.0));
     102        // Set the region origin so the center is at 0 world
     103        floor->setOrigin(Ogre::Vector3::ZERO);
     104        for (Real z = -80.0; z <= 80.0; z += 20.0)
     105        {
     106            for (Real x = -80.0; x <= 80.0; x += 20.0)
     107            {
     108                std::string name = std::string("Ground") + convertToString(i++);
     109                Ogre::Entity* entity = sceneMgr->createEntity(name, "plane.mesh");
     110                entity->setQueryFlags (1<<4);
     111                entity->setCastShadows(false);
     112                floor->addEntity(entity, Ogre::Vector3(x,0,z));
     113            }
     114        }       
     115
     116        floor->build();
     117
     118
     119// crate
     120
     121        entity_ = sceneMgr->createEntity("crate","crate.mesh");
     122        entity_->setQueryFlags (1<<2);
     123        sceneNode_ = sceneMgr->getRootSceneNode()->createChildSceneNode("crate");
     124        sceneNode_->attachObject(entity_);
     125        entity_->setNormaliseNormals(true);
     126        entity_->setCastShadows(true);
     127        sceneNode_ -> setPosition(Vector3(0,100,0));
     128
     129
     130     
     131
     132
    68133    }
    69134
    70135    HelloBullet::~HelloBullet()
    71136    {
    72      // empty
     137     //  dynamicsWorld->removeRigidBody(fallRigidBody);
     138     //   delete fallRigidBody->getMotionState();
     139     //   delete fallRigidBody;
     140
     141     //   dynamicsWorld->removeRigidBody(groundRigidBody);
     142     //   delete groundRigidBody->getMotionState();
     143     //   delete groundRigidBody;
     144
     145
     146     //   delete fallShape;
     147
     148     //   delete groundShape;
     149
     150
     151     //   delete dynamicsWorld;
     152     //   delete solver;
     153     //   delete collisionConfiguration;
     154     //   delete dispatcher;
     155     //   delete broadphase;
     156
    73157    }
    74158
     
    95179    void HelloBullet::tick(float dt)
    96180    {
    97         // only update physics in a certain interval
     181                dynamicsWorld->stepSimulation(1/60.f,10);
     182                btTransform trans;
     183                fallRigidBody->getMotionState()->getWorldTransform(trans);
     184                COUT(0) << "sphere height: " << trans.getOrigin().getY() << std::endl;
     185                sceneNode_ -> setPosition(Vector3(0,trans.getOrigin().getY(),0));
     186        //      msleep(20);
     187               
     188               
    98189    }
    99190
  • code/branches/physics/src/orxonox/objects/HelloBullet.h

    r1995 r2056  
    5151
    5252    private:
    53 
     53        Ogre::SceneNode*                sceneNode_;
     54        Ogre::Entity*                   entity_;
     55        btRigidBody* fallRigidBody;
     56        btDiscreteDynamicsWorld* dynamicsWorld;
    5457    };
    5558
Note: See TracChangeset for help on using the changeset viewer.