Beispiel #1
0
        internal override MovableObjectContainer createActualProduct(OgreSceneManager scene, String baseName)
        {
            Camera camera = scene.SceneManager.createCamera(baseName + Name);

            camera.setAutoAspectRatio(AutoAspectRatio);
            camera.setLodBias(LodBias);
            camera.setUseRenderingDistance(UseRenderingDistance);
            camera.setNearClipDistance(NearClipDistance);
            camera.setFarClipDistance(FarClipDistance);
            camera.setPolygonMode(PolygonMode);
            camera.setRenderingDistance(RenderDistance);
            camera.setAspectRatio(AspectRatio);
            camera.setProjectionType(ProjectionType);
            camera.setFOVy(FOVy);
            if (OrthoWindowWidth != -1.0f && OrthoWindowHeight != -1.0f)
            {
                camera.setOrthoWindow(OrthoWindowWidth, OrthoWindowHeight);
            }
            else if (OrthoWindowHeight != -1.0f)
            {
                camera.setOrthoWindowHeight(OrthoWindowHeight);
            }
            else if (OrthoWindowWidth != -1.0f)
            {
                camera.setOrthoWindowWidth(OrthoWindowWidth);
            }
            return(new CameraContainer(Name, camera));
        }
Beispiel #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="sceneID">The identifier of the scene node.</param>
 /// <param name="subscription">The subscription of the scene node.</param>
 /// <param name="scene">The scene this node belongs to.</param>
 /// <param name="node">The node to manage.</param>
 public SceneNodeElement(String elementName, OgreSceneManager scene, SceneNode node, SceneNode parentNode)
     : base(elementName)
 {
     this.scene      = scene;
     this.sceneNode  = node;
     node.UserObject = this;
     this.parentNode = parentNode;
 }
Beispiel #3
0
        /// <summary>
        /// Create the SimElementManager this definition defines and return it.
        /// This may not be safe to call more than once per definition.
        /// </summary>
        /// <returns>The SimElementManager this definition is designed to create.</returns>
        public SimElementManager createSimElementManager()
        {
            SceneManager     scene     = ogreRoot.createSceneManager(SceneTypeMask, name);
            OgreSceneManager ogreScene = new OgreSceneManager(name, scene);

            ogreScene.SceneManager.setShadowTechnique(ShadowTechnique);
            return(ogreScene);
        }
Beispiel #4
0
        /// <summary>
        /// Create the product for this movableobject.
        /// </summary>
        /// <param name="scene">The scene to create the product into.</param>
        /// <param name="baseName">The base name of the MovableObject.</param>
        /// <returns>The newly created MovableObjectContainer or null if there was an error.</returns>
        internal MovableObjectContainer createProduct(OgreSceneManager scene, String baseName)
        {
            MovableObjectContainer movable = createActualProduct(scene, baseName);

            if (movable != null)
            {
                movable.MovableObject.setRenderQueueGroup(RenderQueue);
            }
            return(movable);
        }
Beispiel #5
0
 /// <summary>
 /// Register this class with the factory to be built.
 /// </summary>
 /// <param name="subscene">The subscene to add this definition to.</param>
 /// <param name="instance">The SimObject that will get the product.</param>
 public override void registerScene(SimSubScene subscene, SimObjectBase instance)
 {
     if (subscene.hasSimElementManagerType(typeof(OgreSceneManager)))
     {
         OgreSceneManager sceneManager = subscene.getSimElementManager <OgreSceneManager>();
         sceneManager.getOgreFactory().addSceneNodeDefinition(instance, this);
     }
     else
     {
         Log.Default.sendMessage("Cannot add SceneNodeDefinition {0} to SimSubScene {1} because it does not contain an OgreSceneManager.", LogLevel.Warning, OgreInterface.PluginName);
     }
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="name">The name of the camera control.</param>
 /// <param name="sceneManager">The scene manager to build the camera into.</param>
 /// <param name="renderTarget">The renderwindow to create a viewport on.</param>
 public OgreSceneView(String name, OgreSceneManager sceneManager, RenderTarget renderTarget, int zIndex)
 {
     this.name         = name;
     this.sceneManager = sceneManager;
     this.renderTarget = renderTarget;
     camera            = sceneManager.SceneManager.createCamera(name + CAMERA_RESERVED_NAME);
     camera.setNearClipDistance(1.0f);
     camera.setAutoAspectRatio(true);
     node = sceneManager.SceneManager.createSceneNode(name + CAMERA_NODE_RESERVED_NAME);
     node.attachObject(camera);
     viewport = renderTarget.addViewport(camera, zIndex, 0, 0, 1, 1);
     sceneManager.SceneManager.getRootSceneNode().addChild(node);
     sceneManager.SceneManager.addSceneListener(this);
     sceneManager.SceneManager.addRenderQueueListener(this);
 }
Beispiel #7
0
        public void sceneLoaded(SimScene scene)
        {
            if (!activeSceneLights.ContainsKey(scene))
            {
                SimSubScene subScene = scene.getDefaultSubScene();

                if (subScene.hasSimElementManagerType(typeof(OgreSceneManager)))
                {
                    OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
                    Light            light        = sceneManager.SceneManager.createLight("CameraLight");
                    LightMover       lightMover   = new LightMover(light);
                    sceneManager.SceneManager.addSceneListener(lightMover);
                    activeSceneLights.Add(scene, lightMover);
                }
            }
        }
Beispiel #8
0
 public SceneView createSceneView(SimSubScene subScene, String name, Vector3 positon, Vector3 lookAt, int zIndex)
 {
     if (subScene.hasSimElementManagerType(typeof(OgreSceneManager)))
     {
         OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
         OgreSceneView    camControl   = new OgreSceneView(name, sceneManager, OgreRenderTarget, zIndex);
         camControl.Translation = positon;
         camControl.LookAt      = lookAt;
         return(camControl);
     }
     else
     {
         Log.Default.sendMessage("Cannot create a camera in the subscene {0} named {1} because the subscene has no OgreSceneManager.", LogLevel.Warning, OgreInterface.PluginName, subScene.Name, name);
         return(null);
     }
 }
Beispiel #9
0
        internal override MovableObjectContainer createActualProduct(OgreSceneManager scene, String baseName)
        {
            Light light = scene.SceneManager.createLight(baseName + Name);

            light.setType(LightType);
            light.setAttenuation(AttenuationRange, AttenuationConstant, AttenuationLinear, AttenuationQuadric);
            light.setDiffuseColor(DiffuseColor);
            light.setDirection(Direction);
            light.setPowerScale(PowerScale);
            light.setSpecularColor(SpecularColor);
            if (light.getType() == Light.LightTypes.LT_SPOTLIGHT)
            {
                light.setSpotlightRange(SpotlightInnerAngle, SpotlightOuterAngle, SpotlightFalloff);
            }
            return(new LightContainer(Name, light));
        }
 /// <summary>
 /// This funciton will build the MovableObject and return it to this
 /// class so it can be configured with all of the MovableObject
 /// properties.
 /// </summary>
 /// <param name="element">The SceneNodeElement to add the definition to so it can be destroyed properly.</param>
 /// <param name="scene">The OgreSceneManager that will get the entity.</param>
 /// <param name="simObject">The SimObject that will get the entity.</param>
 /// <returns>The newly created MovableObject or null if there was an error.</returns>
 internal override MovableObjectContainer createActualProduct(OgreSceneManager scene, String baseName)
 {
     if (OgreResourceGroupManager.getInstance().findGroupContainingResource(meshName) != null)
     {
         Entity entity = scene.SceneManager.createEntity(baseName + Name, meshName);
         if (entity.hasSkeleton() && skeleton != null)
         {
             skeleton.initialzeSkeleton(entity.getSkeleton());
         }
         return(new EntityContainer(Name, entity));
     }
     else
     {
         Log.Default.sendMessage("Cannot create entity {0} because the mesh {1} cannot be found.", LogLevel.Warning, OgreInterface.PluginName, Name, meshName);
         return(null);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Create the product of this SceneNode.
        /// </summary>
        /// <param name="instance">The instance to get the product.</param>
        /// <param name="scene">The scene to create the product into.</param>
        internal void createProduct(SimObjectBase instance, OgreSceneManager scene)
        {
            SceneNode node = scene.SceneManager.createSceneNode(instance.Name + Name);

            node.setPosition(instance.Translation);
            node.setOrientation(instance.Rotation);
            SceneNodeElement element = new SceneNodeElement(Name, scene, node, scene.SceneManager.getRootSceneNode());

            instance.addElement(element);
            foreach (MovableObjectDefinition movable in movableObjects.Values)
            {
                element.attachObject(movable);
            }
            foreach (SceneNodeDefinition child in childNodes.Values)
            {
                child.createAsChild(instance, scene, element);
            }
        }
Beispiel #12
0
        public void sceneUnloading(SimScene scene)
        {
            if (scene != null && activeSceneLights.ContainsKey(scene))
            {
                SimSubScene subScene = scene.getDefaultSubScene();

                if (subScene.hasSimElementManagerType(typeof(OgreSceneManager)))
                {
                    LightMover lightMover = activeSceneLights[scene];

                    OgreSceneManager sceneManager = subScene.getSimElementManager <OgreSceneManager>();
                    sceneManager.SceneManager.destroyLight(lightMover.Light);
                    sceneManager.SceneManager.removeSceneListener(lightMover);

                    activeSceneLights.Remove(scene);
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Function used to create all child scene nodes. This will construct
        /// the SceneNode a bit differently and add it as a child of element
        /// instead of the root node.
        /// </summary>
        /// <param name="instance">The instance to get the product.</param>
        /// <param name="scene">The scene to create the product into.</param>
        /// <param name="parentElement">The element of the parent node.</param>
        private void createAsChild(SimObjectBase instance, OgreSceneManager scene, SceneNodeElement parentElement)
        {
            SceneNode node = scene.SceneManager.createSceneNode(instance.Name + Name);

            node.setPosition(LocalTranslation);
            node.setOrientation(LocalRotation);
            SceneNodeElement element = new SceneNodeElement(Name, scene, node, parentElement.SceneNode);

            instance.addWeakElement(element);
            foreach (MovableObjectDefinition movable in movableObjects.Values)
            {
                element.attachObject(movable);
            }
            foreach (SceneNodeDefinition child in childNodes.Values)
            {
                child.createAsChild(instance, scene, element);
            }
            parentElement.addChild(element);
        }
 /// <summary>
 /// This method should not be called outside of ManualObjectDefinition.
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="baseName"></param>
 /// <returns></returns>
 internal override MovableObjectContainer createActualProduct(OgreSceneManager scene, String baseName)
 {
     return(new ManualObjectContainer(Name, scene.SceneManager.createManualObject(baseName + Name)));
 }
Beispiel #15
0
 /// <summary>
 /// Destroy the MovableObject.
 /// </summary>
 /// <param name="sceneManager">The scene to remove the object from.</param>
 public override void destroy(OgreSceneManager sceneManager)
 {
     sceneManager.SceneManager.destroyEntity(movable);
 }
Beispiel #16
0
 /// <summary>
 /// This funciton will build the MovableObject and return it to this
 /// class so it can be configured with all of the MovableObject
 /// properties.
 /// <para>
 /// DO NOT call this method outside of the
 /// MovableObjectDefinition. It must be internal because you cannot be
 /// internal and protected.
 /// </para>
 /// </summary>
 /// <param name="scene">The scene to create the product into.</param>
 /// <param name="name">The base name of the MovableObject.</param>
 /// <returns>The newly created MovableObjectContainer or null if there was an error.</returns>
 internal abstract MovableObjectContainer createActualProduct(OgreSceneManager scene, String baseName);
Beispiel #17
0
 /// <summary>
 /// Build the product normally.
 /// </summary>
 /// <param name="scene">The scene to add the product to.</param>
 public void createProduct(OgreSceneManager scene)
 {
     definition.createProduct(instance, scene);
 }
Beispiel #18
0
 /// <summary>
 /// Destroy the MovableObject.
 /// </summary>
 /// <param name="sceneManager">The scene to remove the object from.</param>
 public abstract void destroy(OgreSceneManager sceneManager);
Beispiel #19
0
 /// <summary>
 /// Destroy the MovableObject.
 /// </summary>
 /// <param name="sceneManager">The scene to remove the object from.</param>
 public override void destroy(OgreSceneManager sceneManager)
 {
     sceneManager.SceneManager.destroyManualObject(movable);
 }
Beispiel #20
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="targetScene">The OgreSceneManager that will recieve the objects built by this factory.</param>
 public OgreFactory(OgreSceneManager targetScene)
 {
     this.targetScene = targetScene;
 }
 /// <summary>
 /// Destroy the MovableObject.
 /// </summary>
 /// <param name="sceneManager">The scene to remove the object from.</param>
 public override void destroy(OgreSceneManager sceneManager)
 {
     sceneManager.SceneManager.destroyCamera(movable);
 }