/// <summary> /// Constructs a ParallaxBackground object. Needs the display object for the camera position. /// </summary> /// <param name="texture"> /// A <see cref="Texture"/> /// </param> /// <param name="parallaxFactor"> /// A <see cref="System.Double"/> /// </param> /// <param name="display"> /// A <see cref="Display"/> /// </param> /// <param name="motionBlur"> /// A <see cref="System.Boolean"/> /// </param> public ParallaxBackground(Texture texture, double parallaxFactorX, double parallaxFactorY, Display display) { this.texture = texture; this.parallaxFactorX = parallaxFactorX; this.parallaxFactorY = parallaxFactorY; this.display = display; }
/// <summary> /// Constructs an enemy given the texture and AI (IEnemyBrain) /// </summary> /// <param name="texture">The texture for the enemy</param> /// <param name="enemyBrain">The AI for the enemy</param> /// <param name="position">The spawn point for this enemy</param> public Enemy(Texture texture, IEnemyBrain enemyBrain, Vector position) { _enemyBrain = enemyBrain; Sprite.Texture = texture; Sprite.SetPosition(position); RestartShootCountDown(); }
public Tile(string tileName, Texture texture, TileCollision tileCollision, Vector position) { TileName = tileName; TileCollision = tileCollision; Sprite.Texture = texture; Sprite.SetPosition(position); }
double _speed = 512; // pixels per second #endregion Fields #region Constructors public PlayerCharacter(TextureManager textureManager, BulletManager bulletManager) { _bulletManager = bulletManager; _bulletTexture = textureManager.Get("bullet"); _sprite.Texture = textureManager.Get("player_spaceship"); _sprite.SetScale(_scale, _scale); //_sprite.SetRotation(Math.PI / 2); }
public PlayerCharacter(TextureManager textureManager, BulletManager bulletManager) { _bulletManager = bulletManager; _bulletTexture = textureManager.Get("bullet"); _sprite.Texture = textureManager.Get("player_ship"); _sprite.SetScale(0.5, 0.5); // spaceship is quite big, scale it down. }
public Block(Texture texture) { _sprite.Texture = texture; DropSpeed = 30.0; Direction = new Vector(0, -1, 0); KeepAlive = true; _moveDistance = _sprite.GetWidth(); }
public Bullet(Texture bulletTexture) { _sprite.Texture = bulletTexture; // Some default values Dead = false; Direction = new Vector(1, 0, 0); Speed = 512;// pixels per second }
public void Initialize(Game game) { gameref = game; authorScreen = gameref.Resources.GetTexture("author-background"); titleScreen = gameref.Resources.GetTexture("title-background"); gameref.Display.CameraX = 0; gameref.Display.CameraY = 0; }
double x, y; //Where is the sprite rendered? #endregion Fields #region Constructors public Sprite(Texture tex) { texture = tex; currentAnimation = "NO_ANIMATION"; animations.Add(currentAnimation, new Animation()); animations[currentAnimation].AddFrame(0, 0, texture.Width, texture.Height, 0,0); Flipped = false; Scaling = 1; }
public Tile(string tileName, Texture texture, TileCollision tileCollision, double x, double y) { X = x; Y = y; TileName = tileName; TileCollision = tileCollision; Sprite.SetPosition(x, y); Sprite.Texture = texture; }
public Missile(Texture missileTexture, Vector direction) { Sprite.Texture = missileTexture; // Some default values Dead = false; Direction = direction; Speed = 512; // pixels per second Damage = 10; }
public Block(Texture texture, Vector scaler, Vector position) { _sprite.Texture = texture; DropSpeed = 30.0; Direction = new Vector(0, -1, 0); KeepAlive = true; _sprite.SetScale(scaler.X, scaler.Y); _sprite.SetPosition(position.X, position.Y); _moveDistance = _sprite.GetWidth(); }
/// <summary> /// Constructs an enemy given the texture and AI (IEnemyBrain) /// </summary> /// <param name="texture">The texture for the enemy</param> /// <param name="enemyBrain">The AI for the enemy</param> /// <param name="position">The spawn point for this enemy</param> public EastWestSkeleton(Texture texture, IEnemyBrain enemyBrain, Vector position) : base(texture, enemyBrain, position) { Health = 15; Damage = 10; Sprite.SetScale(1.8, 1.8); Speed = 200; MaxTimeToShoot = 12; MinTimeToShoot = 1; RestartShootCountDown(); }
public PlayerCharacter(TextureManager textureManager, MissileManager missileManager) { _missileManager = missileManager; _missileTexture = textureManager.Get("heart_missile"); Sprite.Texture = textureManager.Get("pixela_down"); _upTexture = textureManager.Get("pixela_up"); _downTexture = textureManager.Get("pixela_down"); _leftTexture = textureManager.Get("pixela_left"); _rightTexture = textureManager.Get("pixela_right"); Sprite.SetScale(Scale, Scale); Health = 20; }
public Enemy(TextureManager textureManager, EffectsManager effectsManager, BulletManager bulletManager) { Health = 50; _sprite.Texture = textureManager.Get("enemy_ship"); _sprite.SetScale(_scale, _scale); _sprite.SetRotation(Math.PI); _sprite.SetPosition(200, 0); _effectsManager = effectsManager; _bulletManager = bulletManager; _bulletTexture = textureManager.Get("bullet"); MaxTimeToShoot = 12; MinTimeToShoot = 1; RestartShootCountDown(); }
public Enemy(TextureManager textureManager, EffectsManager effectsManager, BulletManager bulletManager) { _bulletManager = bulletManager; _bulletTexture = textureManager.Get("bullet"); MaxTimeToShoot = 12; MinTimeToShoot = 1; RestartShootCountDown(); _effectsManager = effectsManager; Health = 50; // default health value. _sprite.Texture = textureManager.Get("enemy_ship"); _sprite.SetScale(0.3, 0.3); _sprite.SetRotation(Math.PI); // make it face the player _sprite.SetPosition(200, 0); // put it somewhere easy to see }
/// <summary> /// Create the sprite from a SpriteDescriptor object. This requires a reference to the resource manager to load the appropriate resource. /// </summary> /// <param name="spriteDesc"> /// A <see cref="SpriteDescriptor"/> /// </param> /// <param name="m"> /// A <see cref="ResourceManager"/> /// </param> public Sprite(SpriteDescriptor spriteDesc, ResourceManager m) { defaultAnimation = spriteDesc.DefaultAnimation; texture = m.GetTexture(spriteDesc.TextureName); currentAnimation = "NO_ANIMATION"; animations.Add(currentAnimation, new Animation()); animations[currentAnimation].AddFrame(0, 0, texture.Width, texture.Height, 0, 0); foreach (SpriteDescriptor.FrameDescriptor frame in spriteDesc.Frames) { if (!animations.ContainsKey(frame.animationName)) { animations.Add(frame.animationName, new Animation()); } animations[frame.animationName].AddFrame(frame.x, frame.y, frame.width, frame.height, frame.delay, frame.nextFrame); } Flipped = false; Scaling = 1; }
int totalLifetime; //How long this particle lives in total. #endregion Fields #region Constructors /// <summary> /// Construct a new particle. /// </summary> /// <param name="t"> /// A <see cref="Texture"/>. Texture used as a base for the particle. /// </param> /// <param name="position"> /// A <see cref="Vector"/>. Current position of the particle. /// </param> /// <param name="velocity"> /// A <see cref="Vector"/>. Velocity of the particle. /// </param> /// <param name="accelleration"> /// A <see cref="Vector"/>. Accelleration of the particle. /// </param> /// <param name="red"> /// A <see cref="System.Double"/>. Represents the amount of red color in the particle. Must be between 0.0 and 1.0 (inclusive). /// </param> /// <param name="green"> /// A <see cref="System.Double"/>. Represents the amount of green color in the particle. Must be between 0.0 and 1.0 (inclusive). /// </param> /// <param name="blue"> /// A <see cref="System.Double"/>. Represents the amount of blue color in the particle. Must be between 0.0 and 1.0 (inclusive). /// </param> /// <param name="alpha"> /// A <see cref="System.Double"/>. Represents the alpha value of the particle. Must be between 0.0 and 1.0 (inclusive). 0.0 means invisible, 1.0 means completely opaque. /// </param> /// <param name="gradualFade"> /// A <see cref="System.Boolean"/> /// </param> public Particle(Texture t, int timeToLive, Vector position, Vector velocity, Vector accelleration, double red, double green, double blue, double alpha, bool gradualFade, int size) { texture = t; this.position = position; this.velocity = velocity; this.accelleration = accelleration; this.timeToLive = timeToLive; this.totalLifetime = timeToLive; if (red < 0 || red > 1) { throw new ArgumentOutOfRangeException("Value of 'red' must be between 0.0 and 1.0."); } if (green < 0 || green > 1) { throw new ArgumentOutOfRangeException("Value of 'green' must be between 0.0 and 1.0."); } if (blue < 0 || blue > 1) { throw new ArgumentOutOfRangeException("Value of 'blue' must be between 0.0 and 1.0."); } if (alpha < 0 || alpha > 1) { throw new ArgumentOutOfRangeException("Value of 'alpha' must be between 0.0 and 1.0."); } this.red = red; this.blue = blue; this.green = green; this.alpha = alpha; startAlpha = alpha; this.gradualFade = gradualFade; this.size = size; }
public ScrollingBackground(Texture background) { _background.Texture = background; Speed = 0.15f; Direction = new Vector(1, 0, 0); }
internal Font(Texture texture, Dictionary<char, CharacterData> characterData, Dictionary<KernKey, int> kernData) { _texture = texture; _characterData = characterData; _kernData = kernData; }
void CreateReflectionTexture() { DestroyReflectionTexture(); Vec2i textureSize = GetRequiredReflectionTextureSize(); //create render texture string textureName = TextureManager.Instance.GetUniqueName( "WaterPlaneReflection" ); bool hdr = RendererWorld.Instance.DefaultViewport.GetCompositorInstance( "HDR" ) != null; reflectionTexture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize, 1, 0, hdr ? PixelFormat.Float16RGB : PixelFormat.R8G8B8, Texture.Usage.RenderTarget ); reflectionRenderTexture = reflectionTexture.GetBuffer().GetRenderTarget(); //create camera reflectionCamera = SceneManager.Instance.CreateCamera(); reflectionCamera.AllowFrustumTestMode = true; //add viewport reflectionViewport = reflectionRenderTexture.AddViewport( reflectionCamera ); reflectionViewport.ShadowsEnabled = false; reflectionViewport.MaterialScheme = MaterialSchemes.Low.ToString(); //add listener renderTargetListener = new ReflectionRenderTargetListener( this ); reflectionRenderTexture.AddListener( renderTargetListener ); reflectionRenderTexture.AutoUpdate = Visible; }
void DestroyReflectionTexture() { //remove reflectionTexture from material if( material != null ) material.RemoveReflectionMapFromMaterial(); if( reflectionViewport != null ) { reflectionViewport.Dispose(); reflectionViewport = null; } if( reflectionCamera != null ) { reflectionCamera.Dispose(); reflectionCamera = null; } if( renderTargetListener != null ) { reflectionRenderTexture.RemoveListener( renderTargetListener ); renderTargetListener.Dispose(); renderTargetListener = null; } reflectionRenderTexture = null; if( reflectionTexture != null ) { reflectionTexture.Dispose(); reflectionTexture = null; } }
public ParticleEngine(Texture texture, int maxParticles, Renderer renderer) { this.maxParticles = maxParticles; this.texture = texture; this.renderer = renderer; }
internal void DestroyViewport() { if (renderTargetListener != null) { RenderTarget renderTarget = texture.GetBuffer().GetRenderTarget(); renderTarget.RemoveListener(renderTargetListener); renderTargetListener.Dispose(); renderTargetListener = null; } if (viewport != null) { viewport.Dispose(); viewport = null; } if (camera != null) { camera.Dispose(); camera = null; } if (texture != null) { texture.Dispose(); texture = null; instance.preventTextureCreationRemainingFrames = 2; } initializedTextureSize = Vec2I.Zero; }
void DestroyRenderTarget() { if( renderTexture != null ) { // set output to background image Background = null; if( d3dImage != null ) { d3dImage.Lock(); d3dImage.SetBackBuffer( D3DResourceType.IDirect3DSurface9, IntPtr.Zero ); d3dImage.Unlock(); } if( renderTargetListener != null ) { renderTexture.RemoveListener( renderTargetListener ); renderTargetListener.Dispose(); renderTargetListener = null; } viewport.Dispose(); viewport = null; camera.Dispose(); camera = null; texture.Dispose(); texture = null; renderTexture = null; } }
bool CreateRenderTarget() { DestroyRenderTarget(); if( RendererWorld.Instance == null ) return false; Vec2I textureSize = GetDemandTextureSize(); if( textureSize.X < 1 || textureSize.Y < 1 ) return false; string textureName = TextureManager.Instance.GetUniqueName( "WPFRenderTexture" ); int hardwareFSAA = 0; if( !RendererWorld.InitializationOptions.AllowSceneMRTRendering ) { if( !int.TryParse( RendererWorld.InitializationOptions.FullSceneAntialiasing, out hardwareFSAA ) ) hardwareFSAA = 0; } texture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize, 1, 0, Engine.Renderer.PixelFormat.R8G8B8, Texture.Usage.RenderTarget, false, hardwareFSAA ); if( texture == null ) return false; currentTextureSize = textureSize; renderTexture = texture.GetBuffer().GetRenderTarget(); renderTexture.AutoUpdate = false; renderTexture.AllowAdditionalMRTs = true; camera = SceneManager.Instance.CreateCamera( SceneManager.Instance.GetUniqueCameraName( "UserControl" ) ); camera.Purpose = Camera.Purposes.MainCamera; //update camera settings camera.NearClipDistance = cameraNearFarClipDistance.Minimum; camera.FarClipDistance = cameraNearFarClipDistance.Maximum; camera.AspectRatio = (float)texture.Size.X / (float)texture.Size.Y; camera.FixedUp = cameraFixedUp; camera.Position = cameraPosition; camera.Direction = cameraDirection; camera.Fov = cameraFov; camera.ProjectionType = cameraProjectionType; camera.OrthoWindowHeight = cameraOrthoWindowHeight; viewport = renderTexture.AddViewport( camera ); //Initialize HDR compositor for HDR render technique if( EngineApp.RenderTechnique == "HDR" ) { viewport.AddCompositor( "HDR", 0 ); viewport.SetCompositorEnabled( "HDR", true ); } //Initialize Fast Approximate Antialiasing (FXAA) { bool useMRT = RendererWorld.InitializationOptions.AllowSceneMRTRendering; string fsaa = RendererWorld.InitializationOptions.FullSceneAntialiasing; if( ( useMRT && ( fsaa == "" || fsaa == "RecommendedSetting" ) && IsActivateFXAAByDefault() ) || fsaa == "FXAA" ) { if( RenderSystem.Instance.HasShaderModel3() ) InitializeFXAACompositor(); } } //add listener renderTargetListener = new ViewRenderTargetListener( this ); renderTexture.AddListener( renderTargetListener ); if( guiRenderer == null ) guiRenderer = new GuiRenderer( viewport ); else guiRenderer.ChangeViewport( viewport ); if( controlManager == null ) controlManager = new ScreenControlManager( guiRenderer ); //initialize D3DImage output if( d3dImageIsSupported && allowUsingD3DImage ) { // create a D3DImage to host the scene and monitor it for changes in front buffer availability if( d3dImage == null ) { d3dImage = new D3DImage(); d3dImage.IsFrontBufferAvailableChanged += D3DImage_IsFrontBufferAvailableChanged; CompositionTarget.Rendering += D3DImage_OnRendering; } // set output to background image Background = new ImageBrush( d3dImage ); // set the back buffer using the new scene pointer HardwarePixelBuffer buffer = texture.GetBuffer( 0, 0 ); GetD3D9HardwarePixelBufferData data = new GetD3D9HardwarePixelBufferData(); data.hardwareBuffer = buffer._GetRealObject(); data.outPointer = IntPtr.Zero; unsafe { GetD3D9HardwarePixelBufferData* pData = &data; if( !RenderSystem.Instance.CallCustomMethod( "Get D3D9HardwarePixelBuffer getSurface", (IntPtr)pData ) ) Log.Fatal( "Get D3D9HardwarePixelBuffer getSurface failed." ); } d3dImage.Lock(); d3dImage.SetBackBuffer( D3DResourceType.IDirect3DSurface9, data.outPointer ); d3dImage.Unlock(); } return true; }
private void CreateViewport() { int index = instance.views.IndexOf(this); DestroyViewport(); Vec2I textureSize = GetNeededTextureSize(); string textureName = TextureManager.Instance.GetUniqueName( string.Format("MultiViewRendering{0}", index)); PixelFormat format = PixelFormat.R8G8B8; int fsaa; if (!int.TryParse(RendererWorld.InitializationOptions.FullSceneAntialiasing, out fsaa)) fsaa = 0; texture = TextureManager.Instance.Create(textureName, Texture.Type.Type2D, textureSize, 1, 0, format, Texture.Usage.RenderTarget, false, fsaa); if (texture == null) { Log.Fatal("MultiViewRenderingManager: Unable to create texture."); return; } RenderTarget renderTarget = texture.GetBuffer().GetRenderTarget(); renderTarget.AutoUpdate = true; renderTarget.AllowAdditionalMRTs = true; //create camera camera = SceneManager.Instance.CreateCamera( SceneManager.Instance.GetUniqueCameraName(string.Format("MultiViewRendering{0}", index))); camera.Purpose = Camera.Purposes.MainCamera; //add viewport viewport = renderTarget.AddViewport(camera, 0); viewport.ShadowsEnabled = true; //Create compositor for HDR render technique bool hdrCompositor = RendererWorld.Instance.DefaultViewport.GetCompositorInstance("HDR") != null; if (hdrCompositor) { viewport.AddCompositor("HDR"); viewport.SetCompositorEnabled("HDR", true); } //FXAA antialiasing post effect bool fxaaCompositor = RendererWorld.Instance.DefaultViewport.GetCompositorInstance("FXAA") != null; if (fxaaCompositor) { viewport.AddCompositor("FXAA"); viewport.SetCompositorEnabled("FXAA", true); } //add listener renderTargetListener = new ViewRenderTargetListener(this); renderTarget.AddListener(renderTargetListener); initializedTextureSize = textureSize; }
public TileData(Texture texture) { _texture = texture; }
public Font(Texture texture, Dictionary<char, CharacterData> characterData) { this.texture = texture; this.characterData = characterData; }
//also angular 2nd moment public double Distance(Texture other) { return 0; }