Ejemplo n.º 1
0
        /// <summary>
        /// Set active camera
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <param name="timeOrStep">The time or step.</param>
        public void SetActiveCamera(String name, InterpolationType type, float timeOrStep)
        {
            if (activeCameraType == State.NORMAL)
            {
                activeCameraType = State.INTERPOLATING;
                int ind = _cameras.FindIndex(delegate(CameraDescription t) { return(t.name == name); });
                if (ind == -1)
                {
                    ActiveLogger.LogMessage("Camera Name Not found, maybe you did not added it to the camera manager", LogLevel.RecoverableError);
                    return;
                }
                CameraInterpolator ci = new CameraInterpolator(_activeCam, _cameras[ind].cam, type, timeOrStep);

                ci.OnInterpolationFinished += new CameraInterpolator.InterpolationFinished(ci_OnInterpolationFinished);
                ci.Name = INTERPOLATORCAMERA;
                CameraDescription cc = new CameraDescription();
                cc.cam  = ci;
                cc.name = INTERPOLATORCAMERA;
                _cameras.Add(cc);
                int added = _cameras.FindIndex(delegate(CameraDescription t) { return(t.name == INTERPOLATORCAMERA); });
                _activeCam = _cameras[added].cam;
            }
            else
            {
                CameraInterpolator ac = (_activeCam as CameraInterpolator);
                int ind = _cameras.FindIndex(delegate(CameraDescription t) { return(t.name == name); });
                if (ind == -1)
                {
                    ActiveLogger.LogMessage("Camera Name Not found, maybe you did not added it to the camera manager", LogLevel.RecoverableError);
                }
                ac.Reset(_activeCam, _cameras[ind].cam);
            }
        }
Ejemplo n.º 2
0
        public void StartAcelerometer()
        {
            if (useAcelerometer)
            {
                if (accelActive == true)
                {
                    return;
                }

                try
                {
                    accelSensor.Start();
                    accelActive = true;
                }
                catch (Microsoft.Devices.Sensors.AccelerometerFailedException e)
                {
                    // the accelerometer couldn't be started.  No fun!
                    accelActive = false;
                }
                catch (UnauthorizedAccessException e)
                {
                    // This exception is thrown in the emulator-which doesn't support an accelerometer.
                    accelActive = false;
                }
            }
            else
            {
                ActiveLogger.LogMessage("need to enable acelerometer before trying to start it on the camerafirstperson", LogLevel.RecoverableError);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IWorld"/> class.
        /// </summary>
        /// <param name="PhysicWorld">The physic world.</param>
        /// <param name="particleManager">The particle manager.</param>
        /// <param name="culler">The culler.</param>
        public I2DWorld(I2DPhysicWorld PhysicWorld, IParticleManager particleManager = null, I2DCuller culler = null)
        {
            if (PhysicWorld == null)
            {
                ActiveLogger.LogMessage("Physic World cannot be null", LogLevel.FatalError);
                Debug.Assert(PhysicWorld != null);
                throw new Exception("Physic World cannot be null");
            }

            if (culler == null)
            {
                this.culler = new Simple2DCuller();
            }
            else
            {
                this.culler = culler;
            }
            this.culler.world = this;

            this.particleManager = particleManager;
            this.PhysicWorld     = PhysicWorld;
            Dummies                 = new List <IDummy>();
            Objects                 = new List <I2DObject>();
            SoundEmiters2D          = new List <ISoundEmitter2D>();
            CleanUpObjectsOnDispose = true;


#if !WINDOWS_PHONE && !REACH
            Lights2D = new List <PloobsEngine.Light2D.Light2D>();
#endif
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeferredCustomShader"/> class.
 /// </summary>
 /// <param name="useGlow">if set to <c>true</c> [use glow].</param>
 /// <param name="useBump">if set to <c>true</c> [use bump].</param>
 /// <param name="useSpecular">if set to <c>true</c> [use specular].</param>
 /// <param name="useParalax">if set to <c>true</c> [use paralax].</param>
 /// <param name="specularIntensity">The specular intensity.</param>
 /// <param name="specularPower">The specular power.</param>
 public DeferredShatterCustomShader(bool useGlow, bool useBump, bool useSpecular, bool useParalax, float specularIntensity = 0, float specularPower = 0)
 {
     if (specularPower < 0)
     {
         ActiveLogger.LogMessage("specularPower cannot be negative, setting to 0", LogLevel.RecoverableError);
         specularPower = 0;
     }
     if (specularIntensity < 0)
     {
         ActiveLogger.LogMessage("specularIntensity cannot be negative, setting to 0", LogLevel.RecoverableError);
         specularIntensity = 0;
     }
     this.specularIntensity    = specularIntensity;
     this.specularPower        = specularPower;
     this.useGlow              = useGlow;
     this.useSpecular          = useSpecular;
     this.useBump              = useBump;
     this.useParalax           = useParalax;
     specularPowerMapScale     = 1;
     specularIntensityMapScale = 1;
     if (useParalax == true && useBump == false)
     {
         ActiveLogger.LogMessage("Are you sure you will use only Paralax without BUMP, the paralax expects bump", LogLevel.Warning);
     }
 }
Ejemplo n.º 5
0
        public PreRenderTechnic(PrePassRenderTechnicInitDescription desc)
            : base(PostEffectType.Deferred)
        {
            this.desc        = desc;
            deferredGBuffer  = new PreGBuffer();
            deferredLightMap = new PreLightMap();
            if (desc.LightDebug)
            {
                ActiveLogger.LogMessage("LighDebug is not implemented yet, will be disabled", LogLevel.Warning);
            }

            if (desc.DefferedDebug)
            {
                if (desc.RenderTargetsNameToDefferedDebug != null)
                {
                    if (desc.RenderTargetsNameToDefferedDebug.Count() != 4)
                    {
                        ActiveLogger.LogMessage("RenderTargetsNameToDefferedDebug must be 4, Deferred Degug Disabled", LogLevel.RecoverableError);
                        desc.DefferedDebug = false;
                    }
                }
                else
                {
                    ActiveLogger.LogMessage("RenderTargetsNameToDefferedDebug must be 4, Deferred Degub Disabled", LogLevel.RecoverableError);
                    desc.DefferedDebug = false;
                }
            }
        }
Ejemplo n.º 6
0
        public IWorld(IPhysicWorld PhysicWorld, ICuller Culler, IParticleManager particleManager = null)
#endif
        {
            if (PhysicWorld == null)
            {
                ActiveLogger.LogMessage("Physic World cannot be null", LogLevel.FatalError);
                Debug.Assert(PhysicWorld != null);
                throw new Exception("Physic World cannot be null");
            }
            if (Culler == null)
            {
                ActiveLogger.LogMessage("Culler cannot be null", LogLevel.FatalError);
                Debug.Assert(Culler != null);
                throw new Exception("Culler cannot be null");
            }

            this.particleManager = particleManager;
            this.PhysicWorld     = PhysicWorld;
            this.CameraManager   = new CameraManager();
            Dummies                 = new List <IDummy>();
            Lights                  = new List <ILight>();
            Objects                 = new List <IObject>();
            Triggers                = new List <ITrigger>();
            SoundEmiters3D          = new List <ISoundEmitter3D>();
            this.Culler             = Culler;
            this.culler.world       = this;
            CleanUpObjectsOnDispose = true;
#if WINDOWS
            this.multThreading = multiThread;
#endif
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Checks if render target properties combination is supported.
        /// </summary>
        /// <param name="format">The format.</param>
        /// <param name="depthFormat">The depth format.</param>
        /// <param name="useMipMap">if set to <c>true</c> [use mip map].</param>
        /// <param name="multisample">The multisample.</param>
        /// <param name="GraphicsProfile">The graphics profile.</param>
        /// <returns></returns>
        public bool CheckIfRenderTargetFormatIsSupported(SurfaceFormat format, DepthFormat depthFormat, bool useMipMap, int multisample, GraphicsProfile GraphicsProfile = GraphicsProfile.HiDef)
        {
            SurfaceFormat outformat;
            DepthFormat   outdepthFormat;
            int           outmultisample;

            if (GraphicsAdapter.QueryRenderTargetFormat(GraphicsProfile, format, depthFormat, multisample, out outformat, out outdepthFormat, out outmultisample) == false)
            {
                if (outformat != format)
                {
                    ActiveLogger.LogMessage("The Combination is not supported, problem in the format", LogLevel.Warning);
                }

                if (outdepthFormat != depthFormat)
                {
                    ActiveLogger.LogMessage("The Combination is not supported, problem in the dephformat", LogLevel.Warning);
                }

                if (outmultisample != multisample)
                {
                    ActiveLogger.LogMessage("The Combination is not supported, problem in the multisample", LogLevel.Warning);
                }

                return(false);
            }
            else //true !!!
            {
                return(true);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Init Screen
        /// </summary>
        /// <param name="GraphicInfo">The graphic info.</param>
        /// <param name="engine"></param>
        protected override void InitScreen(GraphicInfo GraphicInfo, EngineStuff engine)
        {
            SetWorldAndRenderTechnich(out _renderTecnic, out _world);
            if (_renderTecnic == null)
            {
                ActiveLogger.LogMessage("IScene must have a renderTechnic", LogLevel.FatalError);
#if WINDOWS
                Debug.Fail("IScene must have a renderTechnic");
#endif
                throw new Exception("IScene must have a renderTechnic");
            }
            if (_world == null)
            {
                ActiveLogger.LogMessage("World cannot be null", LogLevel.FatalError);
#if WINDOWS
                Debug.Fail("World cannot be null");
#endif
                throw new Exception("World cannot be null");
            }

            this._world.GraphicsFactory = GraphicFactory;
            this._world.GraphicsInfo    = GraphicInfo;
            this._world.ContentManager  = screenManager.contentManager;
            this._world.iInitWorld();
            base.InitScreen(GraphicInfo, engine);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Add a camera and set it active if not yet was setted
        /// </summary>
        /// <param name="cam"></param>
        public void AddCamera(ICamera cam)
        {
            if (cam == null)
            {
                ActiveLogger.LogMessage("Can add null camera, Skipping adding this Camera", LogLevel.RecoverableError);
                return;
            }

            if (String.IsNullOrEmpty(cam.Name))
            {
                AddCamera(cam, DEFAULTCAMERA);
                if (_activeCam == null)
                {
                    SetActiveCamera(DEFAULTCAMERA);
                }
            }
            else
            {
                AddCamera(cam, cam.Name);
                if (_activeCam == null)
                {
                    SetActiveCamera(cam.Name);
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Sets the volume.
 /// </summary>
 /// <param name="vol">The vol.</param>
 public void setVolume(float vol)
 {
     if (started)
     {
         videoPlayer.Volume = vol;
     }
     ActiveLogger.LogMessage("Cant set volume if the movie did not started", LogLevel.RecoverableError);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Adds the light.
 /// </summary>
 /// <param name="light">The light.</param>
 public virtual void AddLight(ILight light)
 {
     if (light == null)
     {
         ActiveLogger.LogMessage("Cant Add null Light", LogLevel.RecoverableError);
         return;
     }
     Lights.Add(light);
 }
Ejemplo n.º 12
0
 public override void AddSoundEmitter(Audio.ISoundEmitter3D em, bool play = false)
 {
     if (em == null)
     {
         ActiveLogger.LogMessage("Emitter is Null " + em.ToString(), LogLevel.RecoverableError);
         return;
     }
     SoundEmiters3D.Add(em);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Retorna o nome da camera ativa
 /// </summary>
 /// <returns></returns>
 public String GetActiveCameraName()
 {
     if (_activeCameraIndex == -1)
     {
         ActiveLogger.LogMessage("No camera has been added yet, can access any, returning null", LogLevel.RecoverableError);
         return(null);
     }
     return(_cameras[_activeCameraIndex].name);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Contains the specified obj.
 /// </summary>
 /// <param name="obj">The obj.</param>
 /// <returns></returns>
 public virtual bool ContainsObject(IObject obj)
 {
     if (obj == null)
     {
         ActiveLogger.LogMessage("Cant compare with null obj", LogLevel.RecoverableError);
         return(false);
     }
     return(Objects.Contains(obj));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Gets the state.
 /// </summary>
 /// <returns></returns>
 public MediaState getState()
 {
     if (started)
     {
         return(videoPlayer.State);
     }
     ActiveLogger.LogMessage("Cant get state if the movie did not started", LogLevel.RecoverableError);
     return(MediaState.Stopped);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DPFSParticleSystem"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="IDPSFParticleSystem">The IDPSF particle system.</param>
 public DPFSParticleSystem(String name, IDPSFParticleSystem IDPSFParticleSystem)
     : base(name)
 {
     if (IDPSFParticleSystem == null)
     {
         ActiveLogger.LogMessage("IDPSFParticleSystem cannot be null", LogLevel.FatalError);
         throw new Exception("IDPSFParticleSystem cannot be null");
     }
     this.IDPSFParticleSystem = IDPSFParticleSystem;
 }
Ejemplo n.º 17
0
 public SkyBoxSetTextureCube(String textureCubeName, bool enable = true)
 {
     if (String.IsNullOrEmpty(textureCubeName))
     {
         ActiveLogger.LogMessage("You must provide the a name for the TextureCube of the Skybox", LogLevel.FatalError);
         throw new Exception("You must provide the a name for the TextureCube of the Skybox");
     }
     this.texName = textureCubeName;
     this.enable  = enable;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// TODO
 /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
 /// </summary>
 /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
 /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
 /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
 public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     ActiveLogger.LogMessage("Serialization not implemented", LogLevel.RecoverableError);
     //info.AddValue("Objects", Objects, Objects.GetType());
     //info.AddValue("Lights", Lights, Lights.GetType());
     //info.AddValue("Triggers", Triggers, Triggers.GetType());
     //info.AddValue("SoundEmitter3D", SoundEmiters3D, SoundEmiters3D.GetType());
     //info.AddValue("Culler", Culler, Culler.GetType());
     //info.AddValue("PhysicWorld", PhysicWorld, PhysicWorld.GetType());
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Removes one post effect.
 /// </summary>
 /// <param name="postEffect">The post effect.</param>
 public virtual void RemovePostEffect(IPostEffect postEffect)
 {
     System.Diagnostics.Debug.Assert(postEffect != null);
     if ((postEffect.PostEffectType & PostEffectType) != PostEffectType)
     {
         ActiveLogger.LogMessage("Trying to remove a wrong post effect type for this Render Technich, pls check if the PostEffectType of the IPostEffect is All or " + PostEffectType + ", The engine is ignoring this operation", LogLevel.RecoverableError);
     }
     PostEffects.RemoveLocation(postEffect);
     postEffect.tech = null;
 }
Ejemplo n.º 20
0
        public override void Init(PloobsEngine.Engine.GraphicInfo ginfo, PloobsEngine.Engine.GraphicFactory factory)
        {
            switch (BlurRadiusSize)
            {
            case BlurRadiusSize.Fifteen:
                effect = factory.GetEffect("sblur", true, true);
                break;

            case BlurRadiusSize.Seven:
                effect = factory.GetEffect("sblur2", true, true);
                break;

            case BlurRadiusSize.Three:
                effect = factory.GetEffect("sblur3", true, true);
                break;

            default:
                ActiveLogger.LogMessage("Wrong Blur Radius Size Specified", LogLevel.RecoverableError);
                effect = factory.GetEffect("sblur", true, true);
                break;
            }

            if (!destinySize.HasValue)
            {
                destinySize = new Vector2(ginfo.BackBufferWidth, ginfo.BackBufferHeight);
            }

            if (SurfaceFormat.HasValue)
            {
                if (SurfaceFormat.Value == Microsoft.Xna.Framework.Graphics.SurfaceFormat.Single ||
                    SurfaceFormat.Value == Microsoft.Xna.Framework.Graphics.SurfaceFormat.HalfSingle)
                {
                    effect.CurrentTechnique = effect.Techniques["GAUSSSingle"];
                }
                else
                {
                    effect.CurrentTechnique = effect.Techniques["GAUSSTriple"];
                }
                RenderTarget2D = factory.CreateRenderTarget((int)destinySize.Value.X, (int)destinySize.Value.Y, SurfaceFormat.Value);
            }
            else
            {
                RenderTarget2D = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight);
            }

            ComputeKernel(BLUR_RADIUS, BLUR_AMOUNT);
            if (OriginSize.HasValue)
            {
                ComputeOffsets(OriginSize.Value.X, OriginSize.Value.Y);
            }
            else
            {
                ComputeOffsets(ginfo.BackBufferWidth, ginfo.BackBufferHeight);
            }
        }
Ejemplo n.º 21
0
 public void SetIndices(int[] indices)
 {
     if (isDynamic)
     {
         BatchInformations[0][0].IndexBuffer.SetData <int>(indices);
     }
     else
     {
         ActiveLogger.LogMessage("Cant set indices/vertices on Non Dynamic Modelo", LogLevel.RecoverableError);
     }
 }
 public void AddVertex(T vertex)
 {
     if (added)
     {
         ActiveLogger.LogMessage("cant change the model after build it", LogLevel.RecoverableError);
     }
     else
     {
         vertices.Add(vertex);
     }
 }
Ejemplo n.º 23
0
 public override void ReportError(ErrorCode errorCode, string message, string file, int lineNumber)
 {
     if (errorCode == ErrorCode.Assertion || errorCode == ErrorCode.InternalError || errorCode == ErrorCode.OutOfMemory)
     {
         ActiveLogger.LogMessage("PhysX: " + message, LogLevel.FatalError);
     }
     else
     {
         ActiveLogger.LogMessage("PhysX: " + message, LogLevel.RecoverableError);
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Return a list of RecieveEntities that has the parameter tag
        /// </summary>
        /// <param name="tag">tag</param>
        /// <returns></returns>
        public IList <IRecieveMessageEntity> GetTagRecieveEntity(string tag)
        {
            System.Diagnostics.Debug.Assert(tag != null);

            if (tagRecieveEntity.ContainsKey(tag))
            {
                return(tagRecieveEntity[tag]);
            }
            ActiveLogger.LogMessage("Tag does not exists: " + tag, LogLevel.FatalError);
            throw new Exception("Tag does not exists: " + tag);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IParticleSystem"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public IParticleSystem(String name, BoundingBox?BoundingBox = null)
        {
            this.BoundingBox = BoundingBox;
            if (String.IsNullOrEmpty(name))
            {
                ActiveLogger.LogMessage("ParticleSystem name cannot be null/empty", LogLevel.FatalError);
                throw new Exception("ParticleSystem name cannot be null/empty");
            }

            this.Name = name;
        }
 /// <summary>
 /// Gets the particle system.
 /// </summary>
 /// <param name="particleSystemName">Name of the particle system.</param>
 /// <returns></returns>
 public override IParticleSystem GetParticleSystem(string particleSystemName)
 {
     if (ParticleSystem.ContainsKey(particleSystemName))
     {
         return(ParticleSystem[particleSystemName]);
     }
     else
     {
         ActiveLogger.LogMessage("ParticleMessage: " + particleSystemName + " Not Found, returning NULL", LogLevel.Warning);
         return(null);
     }
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Stops the sound
        /// </summary>
        public virtual void Stop(bool imediately = true)
        {
#if DEBUG
            if (!isAdded)
            {
                ActiveLogger.LogMessage("Cant Play/Stop/Pause/Resume a 3D Sound before adding it to the world, Action ignored", LogLevel.RecoverableError);
                return;
            }
#endif

            soundEngineInstance.Stop(imediately);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Gets the camera by name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public ICamera GetCamera(String name)
        {
            int camIndex = _cameras.FindIndex(delegate(CameraDescription t) { return(t.name == name); });

            if (camIndex == -1)
            {
                ActiveLogger.LogMessage("Camera not found in Camera Manager, are you sure you added it ?!", LogLevel.RecoverableError);
                return(null);
            }

            return(_cameras[camIndex].cam);
        }
        /// <summary>
        /// Add A Sound Effect to the Repo
        /// Sounds are shared here
        /// </summary>
        /// <param name="musicNamePath">filepath</param>
        /// <param name="musicName">Name used to refer to this effect latter</param>
        /// <param name="volume">between 0 - 1</param>
        /// <param name="pitch">between -1 to 1 (octaves)</param>
        /// <param name="pan">between -1 to 1 (left - right)</param>
        /// <param name="isLooped">if set to <c>true</c> [is looped].</param>
        public void AddSoundToRepository(string musicNamePath, String musicName, float volume = 1, float pitch = 0, float pan = 0, bool isLooped = false)
        {
            System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(musicNamePath));
            System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(musicName));
            SimpleSoundEffect sse = new SimpleSoundEffect(manager, musicNamePath, volume, pitch, pan, isLooped);

            if (musics.ContainsKey(musicName))
            {
                ActiveLogger.LogMessage("Already contains this song " + musicName + " , Overwriting", LogLevel.Warning);
            }
            musics[musicName] = sse;
        }
Ejemplo n.º 30
0
        public void EvaluateTestes(String path, String logPath = null, String pathToScreenShot = null)
        {
            if (Path.IsPathRooted(path) == false)
            {
                path = Path.Combine(Environment.CurrentDirectory, path);
            }
            Assembly     u        = Assembly.LoadFile(path);
            IList <Type> Screens  = new List <Type>();
            IList <Type> AlgClass = new List <Type>();

            foreach (var item in u.GetTypes())
            {
                foreach (var att in item.GetCustomAttributes(false))
                {
                    if (att is TesteVisualScreen)
                    {
                        Screens.Add(item);
                    }
                    if (att is TesteAlgorithmClass)
                    {
                        AlgClass.Add(item);
                    }
                }
            }

            List <IScreen> screens = new List <IScreen>();

            foreach (var item in Screens)
            {
                screens.Add((IScreen)Activator.CreateInstance(item));
            }

            InitialEngineDescription InitialEngineDescription = InitialEngineDescription.Default();

            InitialEngineDescription.Logger = new logger(logPath);
            InitialEngineDescription.UnhandledException_Handler =
                (a, b) =>
            {
                ActiveLogger.LogMessage("Fatal Error: " + b.ExceptionObject, LogLevel.FatalError);
                Environment.Exit(-1);
            };

            EngineStuff EngineStuff = new EngineStuff(ref InitialEngineDescription,
                                                      (a) =>
            {
                a.AddScreen(new AlgoMainTest(AlgClass, screens, pathToScreenShot));
            }
                                                      );

            EngineStuff.Run();
            Environment.Exit(0);
        }