Code Search for Developers
 
 
  

DopeEscena.h from Project OGRE Lia Game (POGLI Game) at Krugle


Show DopeEscena.h syntax highlighted

#ifndef __DOPE_ESCENA_H__
#define __DOPE_ESCENA_H__

#include "DopePrerequisites.h"
#include "DopeJoint.h"
#include <OgreSingleton.h>

namespace Dope {

    class Escena : public Singleton<Escena>
    {
    public:
        /// World type, you'll want to extend this for your own apps
        enum WorldType {
            WT_REFAPP_GENERIC,
            WT_REFAPP_BSP
        };
    protected:
        /// Pointer to OGRE's scene manager
        SceneManager* mSceneMgr;

        typedef std::map<String, Entidad*> ObjectMap;
        /// Main list of objects
        ObjectMap mObjects;

        typedef std::map<String, Joint*> JointMap;
        JointMap mJoints;

        typedef std::set<Entidad*> ObjectSet;
        /// Set of dynamics objects (those to perform physics on)
        ObjectSet mDynamicsObjects;

        // ODE world object
        dWorld* mOdeWorld;

        /// Contact joint group
        dJointGroup* mOdeContactGroup;

        Vector3 mGravity;

        IntersectionSceneQuery* mIntersectionQuery;

        /// The step size of the collision / physics simulation
        Real mSimulationStepSize;

        /// The type of world we're dealing with
        WorldType mWorldType;

    public:
        /** Creates an instance of the world. 
        @param sceneMgr Pointer to the scene manager which will manage the scene
        @param worldType The type of world being used
        */
        Escena(SceneManager* sceneMgr, WorldType worldType = WT_REFAPP_GENERIC);
        ~Escena();

        /// Get the scene manager for this world
        SceneManager* getSceneManager(void);

        /** Create an OGRE head object. */
        JP* createJP(const String& name, const Vector3& pos = Vector3::ZERO, 
            const Quaternion& orientation = Quaternion::IDENTITY);

        /** Create a plane object. */
        Plano* createPlano(const String& name, Real width, Real height, const Vector3& pos = Vector3::ZERO, 
            const Quaternion& orientation = Quaternion::IDENTITY);

        /** Create a camera which interacts with the world. */
        Camara* createCamara(const String& name, 
            const Vector3& pos = Vector3::ZERO, 
            const Quaternion& orientation = Quaternion::IDENTITY);

        /** Clears the scene. */
        void clear(void);

        dWorld* getOdeWorld(void);
        dJointGroup* getOdeContactJointGroup(void);

        /** Detects all the collisions in the world and acts on them.
        @remarks
            This method performs the appropriate queries to detect all the colliding objects
            in the world, tells the objects about it and adds the appropriate physical simulation
            constructs required to apply collision response when applyDynamics is called.
        @par This method is called automatically by World::simulationStep()
        */
        void _applyCollision(void);

        /** Updates the world simulation. 
        @par This method is called automatically by World::simulationStep()
        */
        void _applyDynamics(Real timeElapsed);

        /** Internal method for notifying the world of a change in the dynamics status of an object. */
        void _notifyDynamicsStateForObject(Entidad* obj, bool dynamicsEnabled);

        /** Sets the gravity vector, units are in m/s^2.
        @remarks
            The world defaults to no gravity.
            Tip: Earth gravity is Vector3(0, -9.81, 0);
        */
        void setGravity(const Vector3& vec);

        /** Gets the gravity vector. */
        const Vector3& getGravity(void);

        /** Creates a Joint object for linking objects together in the world. 
        @param name The name of the Joint.
        @param jtype The type of joint, see Joint::JointType.
        @param obj1 The first object to attach, or NULL to attach to the static world.
        @param obj2 The second object to attach, or NULL to attach to the static world.
        */
        Joint* createJoint(const String& name, Joint::JointType jtype,
            Entidad* obj1, Entidad* obj2);

        /** Sets the step size of the simulation.
        @remarks
            This parameter allows you to alter the accuracy of the simulation. 
            This is the interval at which collision and physics are performed,
            such that in high frame rate scenarios these operations are
            not done every single frame, and in low frame rate situations more
            steps are performed per frame to ensure the stability of the
            simulation.
        @par
            The default value for this parameter is 0.01s.
        */
        void setSimulationStepSize(Real step);
        /** Returns the size of the simulation step. */
        Real getSimulationStepSize(void);

        /** Performs a simulation step, ie applies collision and physics.
        @remarks
            Collision events will cause callbacks to your ApplicationObject
            instances to notify them of the collisions; this is for information,
            dynamics are applied automatically if turned on for the objects so you
            do not need to handle physics yourself if you do not wish to.
        @par
            Note that if the timeElapsed parameter is greater than the simulation
            step size (as set using setSimulationStepSize), more than one collision
            and dynamics step will take place during this call. Similarly, no step
            may occur if the time elapsed has not reached the simulation step
            size yet.
        */
        void simulationStep(Real timeElapsed);
        /** Override standard Singleton retrieval.
        @remarks
        Why do we do this? Well, it's because the Singleton
        implementation is in a .h file, which means it gets compiled
        into anybody who includes it. This is needed for the
        Singleton template to work, but we actually only want it
        compiled into the implementation of the class based on the
        Singleton, not all of them. If we don't change this, we get
        link errors when trying to use the Singleton-based class from
        an outside dll.
        @par
        This method just delegates to the template version anyway,
        but the implementation stays in this single compilation unit,
        preventing link errors.
        */
        static Escena& getSingleton(void);
        /** Override standard Singleton retrieval.
        @remarks
        Why do we do this? Well, it's because the Singleton
        implementation is in a .h file, which means it gets compiled
        into anybody who includes it. This is needed for the
        Singleton template to work, but we actually only want it
        compiled into the implementation of the class based on the
        Singleton, not all of them. If we don't change this, we get
        link errors when trying to use the Singleton-based class from
        an outside dll.
        @par
        This method just delegates to the template version anyway,
        but the implementation stays in this single compilation unit,
        preventing link errors.
        */
        static Escena* getSingletonPtr(void);

    };


}

#endif





See more files for this project here

Project OGRE Lia Game (POGLI Game)

Video juego desarrollado en OGRE, multiplataforma (a nivel de codigo fuente). Proyecto desarrollado como tesis para la facultad de ingenieria, UNAM, Mexico

Project homepage: http://sourceforge.net/projects/tesis-h4l9k-jp
Programming language(s): C++
License: other

  Dope.h
  DopeAplicacion.h
  DopeCamara.h
  DopeEntidad.h
  DopeEntrada.h
  DopeEscena.h
  DopeJP.h
  DopeJoint.h
  DopeJointSubtypes.h
  DopePlano.h
  DopePrerequisites.h