Example #1
0
        /// <summary>
        /// Method to set up the initial values of necessary variables.
        /// <summary>
        /// <param name="meshmerizer">Mesher used for creating meshes from
        /// shape descriptions</param>
        /// <param name="config">Configuration file that will load the initial
        /// values set up inside of TBD</param>
        /// <param name="regionExtent">The size of the region which will either
        /// be the basic 256 by 256 or a value given by the scene class</param>
        public override void Initialise(IMesher meshmerizer,
                                        IConfigSource config, Vector3 regionExtent)
        {
            // Get the PhysX configuration section
            IConfig physicsConfig = config.Configs["PhysX"];

            // Create the configuration using the user given values inside
            // of the PhysX.ini file located in the bin/config-include
            UserConfig.Initialize(physicsConfig);

            // Create the PhysX scene that will be used to represent the
            // region; all physics objects will be depicted in this scene;
            PhysX.CreateScene(UserConfig.GPUEnabled, UserConfig.CPUMaxThreads);

            // Create the initial ground plane for the physics engine
            PhysX.CreateGroundPlane(0.0f, 0.0f, -500.0f);

            // The scene has now been initialized
            m_isInitialized = true;

            // Initialize the mesher
            SceneMesher = meshmerizer;

            // Store the size of the region for use with height field
            // generation
            m_regionExtents = regionExtent;

            // New dictionary to keep track of physical objects
            // added to the scene
            m_physObjectsDict = new Dictionary <uint, PxPhysObject>();

            // New dictionary to keep track of avatars that need to send a
            // collision update for OpenSim to update animations
            m_avatarsSet = new HashSet <PxPhysObject>();

            // Allocate memory for returning of the updates from the
            // physics engine and send data to the PhysX engine
            m_updateArray = new EntityProperties[
                UserConfig.MaxUpdatesPerFrame];
            PhysX.InitEntityUpdate(ref m_updateArray,
                                   UserConfig.MaxUpdatesPerFrame);

            // Allocate memory for returning of the collisions
            // from the physics engine and send data to the PhysX engine
            m_collisionArray =
                new CollisionProperties[UserConfig.MaxCollisionsPerFrame];
            PhysX.InitCollisionUpdate(
                ref m_collisionArray, UserConfig.MaxCollisionsPerFrame);

            // Create the material library that will track various material
            // archetypes
            MaterialLibrary = new PxMaterialLibrary(UserConfig);
        }