Beispiel #1
0
 void AreaEffect::RemoveFromWorld()
 {
     Physics::PhysicsManager* PhysMan = Entresol::GetSingletonPtr()->GetPhysicsManager();
     btSoftRigidDynamicsWorld* BWorld = PhysMan->_GetPhysicsWorldPointer();
     //first remove any collision metadata
     /*if( !CurrentCollisions.empty() )
     {
         PhysMan->RemoveCollisionsContainingActor(this);
     }// */
     BWorld->removeCollisionObject(this->PhysicsObject);
     this->DetachFromGraphics();
     DetachAllChildren();
 }
Beispiel #2
0
    void TerrainManager::Initialize()
    {
        if( !this->Initialized )
        {
            WorldManager::Initialize();

            this->TheEntresol->GetScheduler().AddWorkUnitMain( this->TerrainUpdateWork, "TerrainUpdateWork" );
            Physics::PhysicsManager* PhysicsMan = static_cast<Physics::PhysicsManager*>( this->ParentWorld->GetManager(ManagerBase::MT_PhysicsManager) );
            if( PhysicsMan ) {
                this->TerrainUpdateWork->AddDependency( PhysicsMan->GetSimulationWork() );
            }

            this->Initialized = true;
        }
    }
Beispiel #3
0
    void ActorRigid::RemoveFromWorld()
    {
        if( !IsInWorld() )
            return;

        try{
            Physics::PhysicsManager* PhysMan = Entresol::GetSingletonPtr()->GetPhysicsManager();
            btSoftRigidDynamicsWorld* BWorld = PhysMan->_GetPhysicsWorldPointer();
            BWorld->removeRigidBody(this->PhysicsRigidBody);
            DetachAllChildren();
        }catch (...) {
            Entresol::GetSingletonPtr()->Log("Failed to locate PhysicsManager While Destructing ActorRigid. This is not a problem if already shutting down.");
        }

        //first remove any collision metadata
        /*if( !CurrentCollisions.empty() )
        {
            PhysMan->RemoveCollisionsContainingActor(this);
        }// */

        this->DetachFromGraphics();
    }
Beispiel #4
0
    void GravityField::ApplyEffect()
    {
        std::vector<ActorBase*>::iterator It;
        Physics::PhysicsManager* Physics = Entresol::GetSingletonPtr()->GetPhysicsManager();
        ActorBase* Act = NULL;

        if ( !AddedActors.empty() )
        {
            for ( It = AddedActors.begin() ; It != AddedActors.end() ; It++ )
            {
                Act = (*It);
                Physics->SetIndividualGravity(Act, Grav);
            }
        }
        if ( !RemovedActors.empty() )
        {
            for ( It = RemovedActors.begin() ; It != RemovedActors.end() ; It++ )
            {
                Act = (*It);
                Physics->SetIndividualGravity(Act, Physics->GetGravity());
            }
        }
    }
Beispiel #5
0
void StartArea::ApplyEffect()
{
    Vector3 Grav(0,0,0);
    ActorBase* Act = NULL;
    Physics::PhysicsManager* PhysMan = Entresol::GetSingletonPtr()->GetPhysicsManager();
    if(!AddedActors.empty())
    {
        for( std::vector<ActorBase*>::iterator it = AddedActors.begin() ; it != AddedActors.end() ; it++ )
        {
            Act = (*it);
            ((ActorBasePhysicsSettings*)Act->GetPhysicsSettings())->SetCollisionResponse(false);
            PhysMan->SetIndividualGravity(Act, Grav);
        }
    }
    if(!RemovedActors.empty())
    {
        for( std::vector<ActorBase*>::iterator it = RemovedActors.begin() ; it != RemovedActors.end() ; it++ )
        {
            Act = (*it);
            ((ActorBasePhysicsSettings*)Act->GetPhysicsSettings())->SetCollisionResponse(true);
            PhysMan->SetIndividualGravity(Act, PhysMan->GetGravity());
        }
    }
}
Beispiel #6
0
void LoadContent()
{
    DebrisManager* DebrisMan = static_cast<DebrisManager*>( DemoWorld->GetManager(ManagerBase::MT_DebrisManager) );
    Graphics::SceneManager* SceneMan = static_cast<Graphics::SceneManager*>( DemoWorld->GetManager(ManagerBase::MT_SceneManager) );
    Physics::PhysicsManager* PhysMan = static_cast<Physics::PhysicsManager*>( DemoWorld->GetManager(ManagerBase::MT_PhysicsManager) );
    Resource::ResourceManager* ResourceMan = static_cast<Resource::ResourceManager*>( TheEntresol->GetManager(ManagerBase::MT_ResourceManager) );

    SceneMan->SetAmbientLight(0.10,0.10,0.10,0.10);

    RigidDebris* object1;
    RigidDebris* object2;
    RigidDebris* object3;
    RigidDebris* object4;
    RigidDebris* object5;
    RigidDebris* object6;
    RigidDebris* object7;
    //Ogre Setup Code
    String groupname("Group1");
    String filerobot("robot.mesh");
    String robotprefix("Robot");

    Real mass = 15.0;
    /// @todo Figure why the EngineDemo fails on Linux when trying to find items in the
    ResourceMan->AddAssetLocation("data/common", Resource::AT_FileSystem, groupname, false);
    ResourceMan->AddAssetLocation("data/common/music", Resource::AT_FileSystem, groupname, false);
    ResourceMan->AddAssetLocation("data/common/sounds", Resource::AT_FileSystem, groupname, false);
    //ResourceMan->AddAssetLocation(zipname.str(), "Zip", groupname, false);
    ResourceMan->AddAssetLocation("", Resource::AT_FileSystem, groupname, false);
    ResourceMan->InitAssetGroup(groupname);

    Vector3 grav( 0.0, -400.0, 0.0 );
    PhysMan->SetWorldGravity(grav);
    PhysMan->SetWorldSoftGravity(grav);

    //ParticleEffect *GreenPart = SceneMan->CreateParticleEffect("GreenParticles", "Examples/GreenyNimbus");
    //GreenPart->SetLocation(Vector3(-70,70,-100));

    Physics::CollisionShapeManager* CSMan = static_cast<Physics::CollisionShapeManager*>( TheEntresol->GetManager(ManagerBase::MT_CollisionShapeManager) );
    Physics::CollisionShape* RobitCH = CSMan->GenerateConvexHull("RobitConvexHull",filerobot,groupname);
    //Physics::CollisionShape* RobitCD = CSMan->PerformConvexDecomposition("RobitConvexDecomp",filerobot,groupname,5.0,5.0,10.0);
    Physics::CollisionShape* PlaneStatic = CSMan->GenerateStaticTriMesh("PlaneShape","Plane.mesh",groupname);
    Physics::CollisionShape* WoodenSphere = new Physics::SphereCollisionShape("WoodSphere",250.0);
    Physics::CollisionShape* MetalSphere = new Physics::SphereCollisionShape("MetalSphere",250.0);
    Physics::CollisionShape* MetalSphere2 = new Physics::SphereCollisionShape("MetalSphere2",250.0);

    // Now Lets make some bowling pins
    Real PinSpacing=75.0;           //This is how far apart we want the pins
    RigidDebris* RigDeb = NULL;
    for(unsigned int c=0; c<4; c++)     //make the back row
    {
        std::stringstream namestream;
        namestream << robotprefix << c;
        RigDeb = DebrisMan->CreateRigidDebris(namestream.str(),mass);
        RigDeb->GetRigidProxy()->SetCollisionShape(RobitCH);
        RigDeb->GetEntityProxy()->SetMesh(filerobot,groupname);
        //TheEntresol->GetResourceManager()->ImportShapeData(RigDeb, "data/common/RobotDecomp3.bullet");
        RigDeb->SetLocation(Vector3( (-2.0*PinSpacing)+(c*PinSpacing), -90.0, 0));
        RigDeb->AddToWorld();
    }

    for(unsigned int c=0; c<3; c++)     //the row with three pins
    {
        std::stringstream namestream;
        namestream << robotprefix << (c+4);
        RigDeb = DebrisMan->CreateRigidDebris(namestream.str(),mass);
        RigDeb->GetRigidProxy()->SetCollisionShape(RobitCH);
        RigDeb->GetEntityProxy()->SetMesh(filerobot,groupname);
        //TheEntresol->GetResourceManager()->ImportShapeData(RigDeb, "data/common/RobotDecomp3.bullet");
        RigDeb->SetLocation(Vector3( (-1.5*PinSpacing)+(c*PinSpacing), -66.0, -PinSpacing));
        RigDeb->AddToWorld();
    }
    //TheEntresol->Resources->ImportShapeData(RigDeb, "RobotDecomp3.bullet");

    for(unsigned int c=0; c<2; c++)     //the row with 2 pins
    {
        std::stringstream namestream;
        namestream << robotprefix << (c+7);
        RigDeb = DebrisMan->CreateRigidDebris(namestream.str(),mass);
        RigDeb->GetRigidProxy()->SetCollisionShape(RobitCH);
        RigDeb->GetEntityProxy()->SetMesh(filerobot,groupname);
        RigDeb->SetLocation(Vector3( (-PinSpacing)+(c*PinSpacing), -30.0, -PinSpacing*2));
        if (c+7==7)
            {Robot7=RigDeb;}
        if (c+7==8)
            {Robot8=RigDeb;}
        RigDeb->AddToWorld();
    }

    std::stringstream namestream;           //make the front pin
    namestream << robotprefix << 9;
    RigDeb = DebrisMan->CreateRigidDebris(namestream.str(),mass);
    RigDeb->GetRigidProxy()->SetCollisionShape(RobitCH);
    RigDeb->GetEntityProxy()->SetMesh(filerobot,groupname);
    RigDeb->SetLocation(Vector3( (-0.5*PinSpacing), 0.0, -PinSpacing*3));
    RigDeb->AddToWorld();

    object5 = DebrisMan->CreateRigidDebris("Plane",0);
    object5->GetRigidProxy()->SetCollisionShape(PlaneStatic);
    object5->GetEntityProxy()->SetMesh("Plane.mesh",groupname);
    object5->SetLocation(Vector3(0.0,-100,-300.0));
    object5->AddToWorld();

    object6 = DebrisMan->CreateRigidDebris("Ramp",0);
    object6->GetRigidProxy()->SetCollisionShape(PlaneStatic);
    object6->GetEntityProxy()->SetMesh("Plane.mesh",groupname);
    object6->SetLocation(Vector3(00.0,300.0,-1100.0));
    object6->SetOrientation(Quaternion(0.5, 0.0, 0.0, -0.25));
    object6->AddToWorld();

    object1 = DebrisMan->CreateRigidDebris("RobotWayUpFrontRight",mass);
    object1->GetRigidProxy()->SetCollisionShape(RobitCH);
    object1->GetEntityProxy()->SetMesh(filerobot,groupname);
    object1->SetLocation(Vector3(400,70,100));
    object1->SetOrientation(Quaternion(0.5, 0.5, 0.0, 0.9));
    object1->AddToWorld();

    object2 = DebrisMan->CreateRigidDebris("WoodSphere",150.0);
    object2->GetRigidProxy()->SetCollisionShape(WoodenSphere);
    object2->GetEntityProxy()->SetMesh("Sphere_Wood.mesh",groupname);
    object2->SetScale(Vector3(0.5,0.5,0.5));
    object2->SetLocation(Vector3(-140.0,2800.0,-1150.0));
    object2->AddToWorld();

    object3 = DebrisMan->CreateRigidDebris("MetalSphere",200.0);
    object3->GetRigidProxy()->SetCollisionShape(MetalSphere);
    object3->GetEntityProxy()->SetMesh("Sphere_Metal.mesh",groupname);
    object3->SetScale(Vector3(0.7,0.7,0.7));
    object3->SetLocation(Vector3(150.0,1800.0,-1300.0));
    object3->AddToWorld();

    object4 = DebrisMan->CreateRigidDebris("RobotWayUpFrontLeft",mass);
    object4->GetRigidProxy()->SetCollisionShape(RobitCH);
    object4->GetEntityProxy()->SetMesh(filerobot,groupname);
    object4->SetLocation(Vector3(-400,10, 100));
    object4->SetOrientation(Quaternion(0.5, 0.5, 0.0, 0.9));
    object4->AddToWorld();

    object7 = DebrisMan->CreateRigidDebris("MetalSphere2",800.0);
    object7->GetRigidProxy()->SetCollisionShape(MetalSphere2);
    object7->GetEntityProxy()->SetMesh("Sphere_Metal.mesh",groupname);
    object7->SetScale(Vector3(0.3,0.3,0.3));
    object7->SetLocation(Vector3(10.0,25000.0,-1300.0));
    object7->GetRigidProxy()->SetDamping(0.3,0.0);
    object7->AddToWorld();

    //GravityField
    /*GravityField* Reverse = new GravityField(String("UpField"), Vector3(0.0,-100.0,0.0));
    Reverse->CreateCylinderShapeY(Vector3(100.0,200.0,100));
    Reverse->SetLocation(Vector3(200,50,-5.0));
    PhysMan->AddAreaEffect(Reverse); // Now that we have passed it, we can forget about it*/

    //GravityWell
    /*GravityWell* BlackHole = new GravityWell("BlackHole", Vector3(0.0,200.0,-300.0));
    BlackHole->GetPhysicsSettings()->SetCollisionShape(new Physics::SphereCollisionShape("GravWellShape",750.0));
    BlackHole->SetAllowWorldGravity(false);
    BlackHole->SetFieldStrength(1000.0);
    BlackHole->SetAttenuation(3.000,Mezzanine::Att_Linear);
    //BlackHole->GetGraphicsSettings()->SetMesh(MeshManager::GetSingletonPtr()->CreateSphereMesh("GravWellMesh",ColourValue(0.8,0.1,0.1,0.15),750.0));
    PhysMan->AddAreaEffect(BlackHole);// */

    Physics::RigidProxy* InvisFloor = PhysMan->CreateRigidProxy(0,NULL);
    InvisFloor->SetCollisionShape( new Physics::PlaneCollisionShape("InvisFloor",Plane(Vector3::Unit_Y(),Vector3(0,-300,0))) );
    InvisFloor->AddToWorld();

    //Final Steps
    Audio::iSound* Sound = NULL;
    Audio::AudioManager* AudioMan = static_cast<Audio::AudioManager*>( TheEntresol->GetManager(ManagerBase::MT_AudioManager) );
    Sound = AudioMan->CreateDialogSound("welcomefun-1-edit.ogg", groupname);
    Announcer.push_back(Sound);
    Sound = AudioMan->CreateDialogSound("welcomefun-1-edit.ogg", groupname);
    Announcer.push_back(Sound);

    Sound = AudioMan->CreateMusicSound("cAudioTheme1.ogg", groupname);
    Soundtrack.push_back(Sound);
    Sound = AudioMan->CreateMusicSound("cAudioTheme2.ogg", groupname);
    Soundtrack.push_back(Sound);

    TheEntresol->_Log("Debris Count ");
    TheEntresol->_Log( DebrisMan->GetNumDebris() );
}
Beispiel #7
0
void CreateDemoWorld()
{
    Physics::ManagerConstructionInfo Info;
    Info.PhysicsFlags = Physics::ManagerConstructionInfo::PCF_LimitlessWorld | Physics::ManagerConstructionInfo::PCF_SoftRigidWorld | Physics::ManagerConstructionInfo::PCF_Multithreaded;

    // Create World and all it's lovely Managers
    DemoWorld = TheEntresol->CreateWorld( "DemoWorld", Info, "DefaultSceneManager" );

    if( DemoWorld == NULL ) {
        throw RuntimeAssertionException(
            "Failed to Create New Demo World",
            __func__,
            __FILE__,
            __LINE__
        );
    }

    DemoWorld->Initialize();

    AreaEffectManager* AreaEffectMan = static_cast<AreaEffectManager*>( DemoWorld->GetManager(ManagerBase::MT_AreaEffectManager) );
    EventManager* EventMan = static_cast<EventManager*>( TheEntresol->GetManager(ManagerBase::MT_EventManager) );
    Graphics::GraphicsManager* GraphMan = static_cast<Graphics::GraphicsManager*>( TheEntresol->GetManager(ManagerBase::MT_GraphicsManager) );
    Graphics::SceneManager* SceneMan = static_cast<Graphics::SceneManager*>( DemoWorld->GetManager(ManagerBase::MT_SceneManager) );
    Input::InputManager* InputMan = static_cast<Input::InputManager*>( TheEntresol->GetManager(ManagerBase::MT_InputManager) );
    Physics::PhysicsManager* PhysMan = static_cast<Physics::PhysicsManager*>( DemoWorld->GetManager(ManagerBase::MT_PhysicsManager) );

    MainCam = SceneMan->CreateCamera();
    MainCam->SetLocation(Vector3(0.0,200.0,1000.0));
    MainCam->LookAt(Vector3(0,0,0));

    CamControl = new CameraController(MainCam);
    //CamControl->SetMovementMode(CameraController::CCM_Walk);
    //CamControl->SetHoverHeight(75);

    // Create the window(s)!
    FirstWindow = GraphMan->CreateGameWindow("First",1024,768,0);
    FirstWindow->CreateViewport(MainCam,0);

    // Setup our workunits
    DemoPreEventWork = new DemoPreEventWorkUnit();
    EventMan->GetEventPumpWork()->AddDependency( DemoPreEventWork );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPreEventWork, "DemoPreEventWork" );

    DemoPostInputWork = new DemoPostInputWorkUnit(DemoWorld);
    DemoPostInputWork->AddDependency( InputMan->GetDeviceUpdateWork() );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPostInputWork, "DemoPostInputWork" );

    DemoPostRenderWork = new DemoPostRenderWorkUnit();
    DemoPostRenderWork->AddDependency( GraphMan->GetRenderWork() );
    DemoPostRenderWork->AddDependency( AreaEffectMan->GetAreaEffectUpdateWork() );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPostRenderWork, "DemoPostRenderWork" );

    DemoPostPhysicsWork = new DemoPostPhysicsWorkUnit();
    DemoPostPhysicsWork->AddDependency( PhysMan->GetSimulationWork() );
    TheEntresol->GetScheduler().AddWorkUnitMain( DemoPostPhysicsWork, "DemoPostPhysicsWork" );

    // Configure Shadows
    SceneMan->SetSceneShadowTechnique(Graphics::SceneManager::SST_Stencil_Additive);
    SceneMan->SetShadowFarDistance(3000);

    //Set up polling for the letter Q
    EventMan->AddPollingCheck( Input::MetaCode(0, Input::KEY_Q) );

    //Actually Load the game stuff
    LoadContent();

    // Configure the wireframe Drawer
    //TheEntresol->GetPhysicsManager()->SetDebugRenderingMode(Physics::DDM_DrawWireframe);
    //TheEntresol->GetPhysicsManager()->SetSimulationSubstepModifier(3);

    Graphics::LightProxy* Headlight = SceneMan->CreateLightProxy(Graphics::LT_Directional);
    Vector3 LightLoc(200,300,0);
    Headlight->SetLocation(LightLoc);
    LightLoc.X = -LightLoc.X;
    LightLoc.Y = -LightLoc.Y;
    LightLoc.Normalize();
    Headlight->SetDirection(LightLoc);
    Headlight->SetDiffuseColour(ColourValue(0.7,0.7,0.7,1.0));
    Headlight->SetSpecularColour(ColourValue(0.7,0.7,0.7,1.0));
    Headlight->SetLocation(Vector3(0,150,0));
    Headlight->AddToWorld();
    //Headlight->SetAttenuation(1000.0, 0.0, 1.0, 0.0);         //I couldn't get these to work
    // CameraNode->AttachObject(Headlight);

    std::cerr << "Finished Creating World\n";
}
Beispiel #8
0
    void DoWork(Threading::DefaultThreadSpecificStorage::Type& CurrentThreadStorage)
    {
        //User Input through a WorldQueryTool
        Input::InputManager* InputMan = Input::InputManager::GetSingletonPtr();
        Input::Mouse* SysMouse = InputMan->GetSystemMouse();
        Input::Keyboard* SysKeyboard = InputMan->GetSystemKeyboard();
        Input::Controller* Controller1 = NULL;
        if( InputMan->GetNumControllers() > 0 )
            Controller1 = InputMan->GetController(0);

        if( SysKeyboard->IsButtonPressed(Input::KEY_LEFT) || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_LEFT) : false) )
            { CamControl->StrafeLeft( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_RIGHT) || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_RIGHT) : false) )
            { CamControl->StrafeRight( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_UP) || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_UP) : false) )
            { CamControl->MoveForward( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_DOWN)  || (Controller1 ? Controller1->IsHatPushedInDirection(1,Input::CONTROLLERHAT_DOWN) : false) )
            { CamControl->MoveBackward( 300 * ( TheEntresol->GetLastFrameTimeMilliseconds() * 0.001 ) ); }

        static bool MouseCam = false;
        if( SysKeyboard->IsButtonPressed(Input::KEY_HOME) )
            { MouseCam = true; }

        if( SysKeyboard->IsButtonPressed(Input::KEY_END))
            { MouseCam = false; }

        Physics::PhysicsManager* PhysMan = static_cast<Physics::PhysicsManager*>( this->OneWorld->GetManager(ManagerBase::MT_PhysicsManager) );

        if( SysKeyboard->IsButtonPressed(Input::KEY_BACKSLASH) )
            { PhysMan->SetTimeMultiplier(1.0); }

        if( SysKeyboard->IsButtonPressed(Input::KEY_RIGHTBRACKET) ) {
            Real Factor = PhysMan->GetTimeMultiplier() * 1.5;
            if( Factor > 2.0 )
                { Factor = 2.0; }
            PhysMan->SetTimeMultiplier(Factor);
        }

        if( SysKeyboard->IsButtonPressed(Input::KEY_LEFTBRACKET) ) {
            Real Factor = PhysMan->GetTimeMultiplier() * .75;
            if( Factor < 0.01 )
                { Factor = 0.01; }
            PhysMan->SetTimeMultiplier(Factor);
        }

        Vector2 Offset = SysMouse->GetMouseDelta();
        if( MouseCam && Vector2(0,0) != Offset )
            CamControl->Rotate(Offset.X * 0.01,Offset.Y * 0.01,0);

        if( SysKeyboard->IsButtonPressing(Input::KEY_M) || (Controller1 ? Controller1->IsButtonPressed(1) : false) ) {
            Audio::iSound* Theme = Soundtrack.at(1);
            if( !Theme->IsPlaying() ) {
                Theme->Play();
            }
        }

        if( SysKeyboard->IsButtonPressing(Input::KEY_N) || (Controller1 ? Controller1->IsButtonPressed(2) : false) ) {
            Audio::iSound* Theme = Soundtrack.at(1);
            if( Theme->IsPlaying() ) {
                Theme->Stop();
            }
        }

        // Audio test fun
        if( SysKeyboard->IsButtonPressing(Input::KEY_T) ) {
            static Boole Toggle = true;
            Audio::iSound* Welcome = ( Announcer.size() >= 2 ? ( Toggle ? Announcer[1] : Announcer[0] ) : NULL );
            if( Welcome != NULL ) {
                if( Welcome->IsPlaying() ) {
                    Welcome->Stop();
                }
                Welcome->Play();
            }
            Toggle = !Toggle;
        }

        // Make a declaration for a static constrain so it survives the function lifetime
        static Physics::Point2PointConstraint* Dragger = NULL;

        if( SysMouse->IsButtonPressed(1) ) {
            UI::UIManager* UIMan = UI::UIManager::GetSingletonPtr();
            if( UIMan->MouseIsInUISystem() ) {
                //UI::Screen* DScreen = UIMan->GetScreen("DefaultScreen");
                UI::Widget* Hover = UIMan->GetHoveredWidget();
                if(Hover) {
                    Hover = Hover->GetBottomMostHoveredWidget();
                    if( "D_Exit" == Hover->GetName() ) {
                        TheEntresol->BreakMainLoop();
                    }
                }
            }else{
                Ray MouseRay = RayQueryTool::GetMouseRay();
                RayCaster.GetFirstObjectOnRayByPolygon(MouseRay,Mezzanine::WO_RigidDebris);

                bool firstframe=false;
                if( 0 == RayCaster.LastQueryResultsObjectPtr() ) {
                    #ifdef MEZZDEBUG
                    //TheEntresol->Log("No Object Clicked on");
                    #endif
                }else{
                    #ifdef MEZZDEBUG
                    //TheEntresol->Log("Object Clicked on"); TheEntresol->Log(*ClickOnActor);
                    //TheEntresol->Log("MouseRay"); TheEntresol->Log(*MouseRay);
                    //TheEntresol->Log("PlaneOfPlay"); TheEntresol->Log(PlaneOfPlay);
                    //TheEntresol->Log("ClickOnActor"); TheEntresol->Log(*ClickOnActor);
                    #endif
                    if( !( RayCaster.LastQueryResultsObjectPtr()->IsStatic() ) ) {
                        if(!Dragger) { //If we have a dragger, then this is dragging, not clicking
                            if(RayCaster.LastQueryResultsObjectPtr()->GetType() == Mezzanine::WO_RigidDebris) { //This is Dragging let's do some checks for sanity
                                Vector3 LocalPivot = RayCaster.LastQueryResultsOffset();
                                RigidDebris* rigid = static_cast<RigidDebris*>(RayCaster.LastQueryResultsObjectPtr());
                                rigid->GetRigidProxy()->SetActivationState(Physics::AS_DisableDeactivation);
                                //Dragger = new Generic6DofConstraint(rigid, LocalPivot, Quaternion(0,0,0,1), false);
                                Dragger = PhysMan->CreatePoint2PointConstraint(rigid->GetRigidProxy(),LocalPivot);
                                Dragger->SetTAU(0.001);
                                Dragger->EnableConstraint(true);
                                Dragger->SetParam(Physics::Con_Stop_CFM,0.8,-1); Dragger->SetParam(Physics::Con_Stop_CFM,0.8,-1); Dragger->SetParam(Physics::Con_Stop_CFM,0.8,-1);
                                Dragger->SetParam(Physics::Con_Stop_ERP,0.1,-1); Dragger->SetParam(Physics::Con_Stop_ERP,0.1,-1); Dragger->SetParam(Physics::Con_Stop_ERP,0.1,-1);
                                firstframe=true;
                            }else{  // since we don't
                                #ifdef MEZZDEBUG
                                //TheEntresol->Log("Object is not an ActorRigid.  Aborting.");
                                #endif
                            }
                        }
                    }else{
                        #ifdef MEZZDEBUG
                        //TheEntresol->Log("Object is Static/Kinematic.  Aborting.");
                        #endif
                    }
                }

                // This chunk of code calculates the 3d point that the actor needs to be dragged to
                if( RayCaster.RayPlaneIntersection(MouseRay, PlaneOfPlay) ) {
                    if(Dragger&&!firstframe)
                        { Dragger->SetPivotB(RayCaster.LastQueryResultsOffset()); }
                }
            }

        }else{  //Since we are no longer clicking we need to setup for the next clicking
            if( Dragger ) {
                Physics::RigidProxy* Prox = Dragger->GetProxyA();
                PhysMan->DestroyConstraint(Dragger);
                Dragger = NULL;
                Prox->SetActivationState(Physics::AS_Active);
            }
        }
    }