protected override Texture2D loadTexture(ushort id, string name, string file) { using (var fs = new FileStream(file, FileMode.Open)) using (var image = (Bitmap)Bitmap.FromStream(fs)) { // Fix up the Image to match the expected format image.RGBToBGR(); var data = new byte[image.Width * image.Height * 4]; BitmapData bitmapData = image.LockBits(new System.Drawing.Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); if (bitmapData.Stride != image.Width * 4) { throw new NotImplementedException(); } Marshal.Copy(bitmapData.Scan0, data, 0, data.Length); image.UnlockBits(bitmapData); var texture = new XnaTexture2D(_graphics, image.Width, image.Height); texture.SetData(data); return(new Texture2D(id, name, texture)); } //return new Texture2D(id, name, new XnaTexture2D(_graphics, 1, 1)); }
public void ReplaceTexture(Texture2D oldTexture, Texture2D newTexture) { if (DisplayedTexture == oldTexture) { DisplayedTexture = newTexture; } }
public static new void LoadStaticContent(string contentManagerName) { if (string.IsNullOrEmpty(contentManagerName)) { throw new System.ArgumentException("contentManagerName cannot be empty or null"); } Super_Marios_Bros.Screens.GameScreen.LoadStaticContent(contentManagerName); // Set the content manager for Gum var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper(); contentManagerWrapper.ContentManagerName = contentManagerName; RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper; // Access the GumProject just in case it's async loaded var throwaway = GlobalContent.GumProject; #if DEBUG if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager) { HasBeenLoadedWithGlobalContentManager = true; } else if (HasBeenLoadedWithGlobalContentManager) { throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global. This can lead to a lot of bugs"); } #endif tiled = FlatRedBall.TileGraphics.LayeredTileMap.FromTiledMapSave("content/screens/world1level1/tiled.tmx", contentManagerName); tiles = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/screens/world1level1/tiles.png", contentManagerName); CustomLoadStaticContent(contentManagerName); }
public static void UnloadStaticContent() { if (LoadedContentManagers.Count != 0) { LoadedContentManagers.RemoveAt(0); mRegisteredUnloads.RemoveAt(0); } if (LoadedContentManagers.Count == 0) { if (Rock1 != null) { Rock1 = null; } if (Rock2 != null) { Rock2 = null; } if (Rock3 != null) { Rock3 = null; } if (Rock4 != null) { Rock4 = null; } } }
public NavWindow(GameObject.MapEntities.Actors.Player Player, Microsoft.Xna.Framework.Graphics.Texture2D tex) { this.WM = Gameplay.WindowManager; this.Player = Player; this.Width = 276; this.Height = 300; this.AnchorRight = true; Placename = new GUI.Controls.RichTextDisplay("World", 256, 20, WM) { Y = 0, X = 4 }; GUI.Controls.TextureContainer texcont = new GUI.Controls.TextureContainer(tex, WM) { Y = 20, X = 4 }; Coords = new GUI.Controls.RichTextDisplay("loading...", 256, 20, WM) { Y = 280, X = 4 }; this.AddControl(texcont); this.AddControl(Placename); this.AddControl(Coords); }
private void button2_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "XNB files (*.xnb) | *.xnb;"; if (ofd.ShowDialog() == DialogResult.OK && ofd.FileName.Contains(Game1.rootContent)) { String temp1 = ofd.FileName.Replace(Game1.rootContent, ""); temp1 = temp1.Substring(0, temp1.IndexOf(".")); sheetTex = Game1.contentManager.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(temp1); texLoc = temp1; } else if (ofd.ShowDialog() == DialogResult.OK && !ofd.FileName.Contains(Game1.rootContent)) { MessageBox.Show("Please select a file inside the Game's Content folder."); } if (sheetTex != null) { label5.Text = "OK."; label4.Text = ofd.FileName; } else { label5.Text = "NOT OK."; } }
/// <summary> /// Loads a <see cref="Microsoft.Xna.Framework.Graphics.Texture2D"/> from a file path. /// </summary> /// <param name="path"></param> public GameTexture(string path) { using Stream fontStream = SadConsole.Game.Instance.OpenStream(path); _texture = Microsoft.Xna.Framework.Graphics.Texture2D.FromStream(SadConsole.Host.Global.GraphicsDevice, fontStream); _resourcePath = path; }
private byte[] TextureToPng(Microsoft.Xna.Framework.Graphics.Texture2D tex) { var bmp = new Bitmap(tex.Width, tex.Height, PixelFormat.Format32bppArgb); var bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat); IntPtr ptr = bmpData.Scan0; var data = new byte[tex.Width * tex.Height * 4]; tex.GetData(data); for (int i = 0; i < data.Length; i += 4) { var swap = data[i]; data[i] = data[i + 2]; data[i + 2] = swap; } Marshal.Copy(data, 0, ptr, bmpData.Stride * bmpData.Height); bmp.UnlockBits(bmpData); using (var mem = new MemoryStream()) { bmp.Save(mem, ImageFormat.Png); return(mem.ToArray()); } }
public static void UnloadStaticContent() { if (LoadedContentManagers.Count != 0) { LoadedContentManagers.RemoveAt(0); mRegisteredUnloads.RemoveAt(0); } if (LoadedContentManagers.Count == 0) { if (MainShip1 != null) { MainShip1 = null; } if (MainShip2 != null) { MainShip2 = null; } if (MainShip3 != null) { MainShip3 = null; } if (MainShip4 != null) { MainShip4 = null; } } }
private void CustomInitialize() { // let's make usre foldered stuff is working Texture2D texture = Folder1_Slug; Scene scene = GlobalContent.FolderInGlobalContent_SceneFileInFolder; }
public static void LoadStaticContent(string contentManagerName) { if (string.IsNullOrEmpty(contentManagerName)) { throw new System.ArgumentException("contentManagerName cannot be empty or null"); } // Set the content manager for Gum var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper(); contentManagerWrapper.ContentManagerName = contentManagerName; RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper; // Access the GumProject just in case it's async loaded var throwaway = GlobalContent.GumProject; #if DEBUG if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager) { HasBeenLoadedWithGlobalContentManager = true; } else if (HasBeenLoadedWithGlobalContentManager) { throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global. This can lead to a lot of bugs"); } #endif BackgroundSprite = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/screens/islandscreen/backgroundsprite.png", contentManagerName); Pirates.Entities.UI.Button.LoadStaticContent(contentManagerName); CustomLoadStaticContent(contentManagerName); }
public static void GetFileWidthAndHeightOrDefault(this IRenderableIpso ipso, out float fileWidth, out float fileHeight) { // to prevent divide-by-zero issues fileWidth = 32; fileHeight = 32; Microsoft.Xna.Framework.Graphics.Texture2D texture = null; if (ipso is Sprite) { texture = ((Sprite)ipso).Texture; } else if (ipso is GraphicalUiElement && ((GraphicalUiElement)ipso).RenderableComponent is Sprite) { var sprite = ((GraphicalUiElement)ipso).RenderableComponent as Sprite; texture = sprite.Texture; } if (texture != null) { fileWidth = texture.Width; fileHeight = texture.Height; } }
private void SetTextureOnCurrentModelMeshPart(Texture2D texture) { if (mComboBox.SelectedObject != null) { ModelMeshPart mmp = mComboBox.SelectedObject as ModelMeshPart; if (!ContainingModel.RenderOverrides.ContainsKey(mmp)) { ContainingModel.RenderOverrides.Add(mmp, new List <RenderOverrides>()); } List <RenderOverrides> overrides = ContainingModel.RenderOverrides[mmp]; if (overrides.Count == 0) { overrides.Add(new RenderOverrides()); } overrides[0].AlternateTexture = texture; overrides[0].AllowNullTexture = texture == null; UpdateDefaultOrCustom(); } }
private void UpdateDefaultOrCustom() { ModelMeshPart mmp = null; if (mComboBox != null) { mmp = mComboBox.SelectedObject as ModelMeshPart; } if (mmp == null) { mCustomOrDefault.Text = ""; } else { Texture2D textureToSet = mmp.Texture; bool wasSet = false; if (ContainingModel.RenderOverrides.ContainsKey(mmp)) { if (ContainingModel.RenderOverrides[mmp].Count != 0) { wasSet = true; mCustomOrDefault.Text = "Custom"; } } if (!wasSet) { mCustomOrDefault.Text = "Default"; } } }
public static void LoadStaticContent(string contentManagerName) { if (string.IsNullOrEmpty(contentManagerName)) { throw new System.ArgumentException("contentManagerName cannot be empty or null"); } // Set the content manager for Gum var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper(); contentManagerWrapper.ContentManagerName = contentManagerName; RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper; // Access the GumProject just in case it's async loaded var throwaway = GlobalContent.GumProject; #if DEBUG if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager) { HasBeenLoadedWithGlobalContentManager = true; } else if (HasBeenLoadedWithGlobalContentManager) { throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global. This can lead to a lot of bugs"); } #endif empty_building = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/screens/mainmenu/empty_building.png", contentManagerName); AbbatoirIntergradeAnimation = FlatRedBall.FlatRedBallServices.Load <FlatRedBall.Graphics.Animation.AnimationChainList>(@"content/screens/mainmenu/abbatoirintergradeanimation.achx", contentManagerName); AbbatoirIntergradeText = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/screens/mainmenu/abbatoirintergradetext.png", contentManagerName); blue_eye = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/screens/mainmenu/blue_eye.png", contentManagerName); Gum.Wireframe.GraphicalUiElement.IsAllLayoutSuspended = true; MainMenuGum = new FlatRedBall.Gum.GumIdb(); MainMenuGum.LoadFromFile("content/gumproject/screens/mainmenugum.gusx"); MainMenuGum.AssignReferences(); Gum.Wireframe.GraphicalUiElement.IsAllLayoutSuspended = false; MainMenuGum.Element.UpdateLayout(); MainMenuGum.Element.UpdateLayout(); CustomLoadStaticContent(contentManagerName); }
public static void GetFileWidthAndHeight(this IPositionedSizedObject ipso, out float fileWidth, out float fileHeight) { fileWidth = 0; fileHeight = 0; Microsoft.Xna.Framework.Graphics.Texture2D texture = null; if (ipso is Sprite) { texture = ((Sprite)ipso).Texture; } else if (ipso is GraphicalUiElement && ((GraphicalUiElement)ipso).RenderableComponent is Sprite) { var sprite = ((GraphicalUiElement)ipso).RenderableComponent as Sprite; texture = sprite.Texture; } if (texture != null) { fileWidth = texture.Width; fileHeight = texture.Height; } }
/// <summary> /// Creates a Texture from <see cref="Microsoft.Xna.Framework.Graphics.Texture2D"/> data. /// </summary> /// <param name="monoGameTexture"><see cref="Microsoft.Xna.Framework.Graphics.Texture2D"/> data loaded in MonoGame's format.</param> public Texture(Texture2D monoGameTexture) { SetData(null); MonoGameTexture = monoGameTexture; _height = 0; _width = 0; }
public ElementInfo( Microsoft.Xna.Framework.Graphics.Texture2D texture2D, string config, object sprite ) : base(sprite) { Texture = texture2D; m_config = config; Locate = new Vector2( texture2D.Width / 2, texture2D.Height / 2 ); }
public override void Draw(Texture2D texture, Point point) { XnaTexture2D xnaTexture = texture.GetTexture as XnaTexture2D; XnaPoint xnaPoint = new XnaPoint(point.X, point.Y); this.spriteBatch.Draw(xnaTexture, xnaPoint.ToVector2()); }
public Texture2D(string name, MG_Texture2D inner, OriginType originType) : base(name) { this.inner = inner; switch (originType) { case OriginType.TopRight: this.Origin = new Point(this.Width, 0); break; case OriginType.BottomLeft: this.Origin = new Point(0, this.Height); break; case OriginType.BottomRight: this.Origin = new Point(this.Width, this.Height); break; case OriginType.Center: this.Origin = new Point(this.Width / 2, this.Height / 2); break; default: this.Origin = Point.Zero; break; } }
/// <summary> /// Sets the back buffer of the <see cref="D3D11Image"/>. /// </summary> /// <param name="texture">The Direct3D 11 texture to be used as the back buffer.</param> public void SetBackBuffer(Microsoft.Xna.Framework.Graphics.Texture2D texture) { ThrowIfDisposed(); var previousBackBuffer = _backBuffer; // Create shared texture on Direct3D 9 device. _backBuffer = _d3D9.GetSharedTexture(texture); if (_backBuffer != null) { // Set texture as new back buffer. using (Surface surface = _backBuffer.GetSurfaceLevel(0)) { Lock(); SetBackBuffer(D3DResourceType.IDirect3DSurface9, surface.NativePointer); Unlock(); } } else { // Reset back buffer. Lock(); SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero); Unlock(); } if (previousBackBuffer != null) { previousBackBuffer.Dispose(); } }
/// <summary> /// Creates a bitmap from file path, <see cref="System.Drawing.Bitmap">System.Drawing.Bitmap</see>, or dimensions. /// An exception will be thrown if loading fails. /// </summary> /// <param name="fileName">The file name of the desired bitmap file.</param> public Bitmap(string fileName) { Utils.UsageData.StartUsage("bmp"); string[] exts = new string[] { "", ".jpg", ".jpeg", ".bmp", ".png" }; string[] paths = new string[] { Paths.Root, Paths.RTP }; try { string validName = Paths.FindValidPath(fileName, paths, exts); FileStream stream = new FileStream(validName, FileMode.Open); _systemBitmap = new System.Drawing.Bitmap(stream); stream.Close(); stream = new FileStream(validName, FileMode.Open); texture = Microsoft.Xna.Framework.Graphics.Texture2D.FromStream(Game_Player.Graphics.GraphicsDevice, stream); stream.Close(); Utils.UsageData.EndUsage("bmp"); //Console.WriteLine(Utils.UsageData.GetTotalUsage("bmp")); return; } catch { MsgBox.Show("Cannot load image '" + fileName + "'."); throw new Exception("Cannot load image '" + fileName + "'."); } }
public static void UnloadStaticContent() { if (LoadedContentManagers.Count != 0) { LoadedContentManagers.RemoveAt(0); mRegisteredUnloads.RemoveAt(0); } if (LoadedContentManagers.Count == 0) { if (FRB_icon != null) { FRB_icon = null; } if (Veilstone_Corner_Moon_Stone != null) { Veilstone_Corner_Moon_Stone = null; } if (something != null) { something = null; } if (Bariguess != null) { Bariguess = null; } if (adiamond != null) { adiamond = null; } if (RollingSlotsforall != null) { RollingSlotsforall = null; } } }
/// <summary> /// /// </summary> /// <param name="graphicsManager">The <see cref="Komodo.Core.Engine.Graphics.GraphicsManager"/> is needed to generate a Texture, as the <see cref="Microsoft.Xna.Framework.Graphics.GraphicsDevice"/> is needed to generate a <see cref="Microsoft.Xna.Framework.Graphics.Texture2D"/>.</param> private void CreateMonoGameTexture(GraphicsManager graphicsManager) { var graphicsDevice = graphicsManager.GraphicsDeviceManager.GraphicsDevice; MonoGameTexture = new Texture2D(graphicsDevice, _width, _height); MonoGameTexture.SetData(GetData()); }
private static Sprite CreateRightTwoHandedArmSprite(Microsoft.Xna.Framework.Graphics.Texture2D armRightTexture) { return(new Sprite(armRightTexture) { Position = new Vector2(8, -17), Origin = new Vector2(0.5f, 0.5f) }); }
private static Sprite CreateHeadSprite(Microsoft.Xna.Framework.Graphics.Texture2D headTexture) { return(new Sprite(headTexture) { Position = new Vector2(-0, -20), Origin = new Vector2(0.5f, 1) }); }
internal void SetHexPos(int X, int Y, Microsoft.Xna.Framework.Graphics.Texture2D tex) { CalcHexPos(X, Y); HexY = Convert.ToInt32(Math.Floor(Yhex / tex.Height)); HexX = Convert.ToInt32(Math.Floor(Xhex / tex.Height)); //HexX = Convert.ToInt32(Xhex / tex.Width); }
private static Sprite CreateChestSprite(Microsoft.Xna.Framework.Graphics.Texture2D chestTexture) { return(new Sprite(chestTexture) { Position = new Vector2(3, -22), Origin = new Vector2(0.5f, 0.5f) }); }
private static Sprite CreateLegsSprite(Microsoft.Xna.Framework.Graphics.Texture2D legsTexture) { return(new Sprite(legsTexture) { Position = new Vector2(0, 0), Origin = new Vector2(0.5f, 0.75f) }); }
public Button(string p1, int p2, int p3, Microsoft.Xna.Framework.Graphics.Texture2D texture2D) { // TODO: Complete member initialization this.p1 = p1; this.p2 = p2; this.p3 = p3; this.texture2D = texture2D; }
public static Microsoft.Xna.Framework.Graphics.Texture2D cropTexture2D(Microsoft.Xna.Framework.Graphics.GraphicsDevice GraphicsDevice, Microsoft.Xna.Framework.Graphics.Texture2D originalTexture, Microsoft.Xna.Framework.Rectangle sourceRectangle) { Microsoft.Xna.Framework.Graphics.Texture2D cropTexture = new Microsoft.Xna.Framework.Graphics.Texture2D(GraphicsDevice, sourceRectangle.Width, sourceRectangle.Height); Microsoft.Xna.Framework.Color[] data = new Microsoft.Xna.Framework.Color[sourceRectangle.Width * sourceRectangle.Height]; originalTexture.GetData(0, sourceRectangle, data, 0, data.Length); cropTexture.SetData(data); return cropTexture; }
public FloorMaterial(string name, Texture top, Texture bottom) { this.name = name; this.top = top.Copy(); this.bottom = bottom.Copy(); diffuseMap = Editor.ContentLoader.CreateTexture2D( Texture.BlendImages(bottom.GetBitmap(), top.GetBitmap())); }
public VirtualTexture(Texture2D texture, XnaRectangle uvBounds) { if (texture == null) { throw new ArgumentNullException("texture"); } XnaTexture = texture; Bounds = uvBounds; }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo,factory, contentManager); Picking picking = new Picking(this); this.AddScreenUpdateable(picking); perlim = factory.CreateTexture2DPerlinNoise(512, 512, 0.03f, 3f, 0.5f, 1); to = new TerrainObject(factory,perlim, Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 2, 2); //TerrainObject to = new TerrainObject(factory,"..\\Content\\Textures\\Untitled",Vector3.Zero,Matrix.Identity,MaterialDescription.DefaultBepuMaterial(),2,1); TerrainModel stm = new TerrainModel(factory, to,"TerrainName","..\\Content\\Textures\\Terraingrass", "..\\Content\\Textures\\rock", "..\\Content\\Textures\\sand", "..\\Content\\Textures\\snow"); DeferredTerrainShader shader = new DeferredTerrainShader(TerrainType.MULTITEXTURE); DeferredMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, stm, to); this.World.AddObject(obj3); #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion this.World.CameraManager.AddCamera(new CameraFirstPerson(true,GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); ///O PICKING FUNCIONA APENAS COM OBJETOS QUE TENHAM CORPO FISICO REAL !!! ///OS GHOST E OS DUMMY NUNCA SERAO SELECIONADOS ///Para ser informado a todo frame sobre as colisoes do raio, basta utilizar o outro construtor picking.OnPickedLeftButton += new OnPicked(onPick); }
static void DefaultReplaceTexture(Texture2D oldTexture, Texture2D newTexture) { foreach (SpriteGrid sg in SceneSaving.SpriteGrids) sg.ReplaceTexture(oldTexture, newTexture); // If necessary replace textures on the UI //if (GuiData.ToolsWindow.currentTextureDisplay.UpOverlayTexture == oldTexture) //{ // GuiData.ToolsWindow.currentTextureDisplay.SetOverlayTextures(newTexture, null); //} FlatRedBallServices.ReplaceFromFileTexture2D(oldTexture, newTexture, mContentManager); //GuiData.ListWindow.Add(newTexture); }
public AI() { numOfAis++; setTex(Activity1.game.LoadContent("Player Animations/idle")); setPos(generatePoint().getPos()); setPos(new Vector2(getPos().X - 3, getPos().Y - 3)); target = generatePoint(); setDefaultCenter(); gameObjects.Add(this); waypoint = findDistance(findPoints()); setRotation(findRotation(waypoint)); done = false; tChk = 50; walking = new Microsoft.Xna.Framework.Graphics.Texture2D[] { Activity1.game.LoadContent("Player Animations/idle"), Activity1.game.LoadContent("Player Animations/anim1") , Activity1.game.LoadContent("Player Animations/anim2"),Activity1.game.LoadContent("Player Animations/anim3"),Activity1.game.LoadContent("Player Animations/anim4")}; alive = true; }
/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/> protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext) { // if the device changed, call Warm() if ((state.DeviceUniqueIndex != Character.gd)) { this.WarmShader(state); ic = true; } // Force updating if the instance has changed this.vreg_change = (this.vreg_change | ic); this.preg_change = (this.preg_change | ic); this.vbreg_change = (this.vbreg_change | ic); this.vireg_change = (this.vireg_change | ic); // Set the value for attribute 'viewPoint' this.vreg_change = (this.vreg_change | state.SetViewPointVector4(ref this.vreg[12], ref this.sc0)); // Set the value for attribute 'world' this.vreg_change = (this.vreg_change | state.SetWorldMatrix(ref this.vreg[8], ref this.vreg[9], ref this.vreg[10], ref this.vreg[11], ref this.sc1)); // Set the value for attribute 'worldViewProj' this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[4], ref this.vreg[5], ref this.vreg[6], ref this.vreg[7], ref this.sc2)); // Set the value for global 'ShadowMapProjection' this.vreg_change = (this.vreg_change | state.SetGlobalMatrix4(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], Character.gid0, ref this.gc0)); // Set the value for global 'AmbientDiffuseSpecularScale' this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[15], Character.gid1, ref this.gc1)); // Set the value for global 'EnvironmentSH' this.preg_change = (this.preg_change | state.SetGlobalVector4(this.preg, 0, 9, Character.gid2, ref this.gc2)); // Set the value for global 'RgbmImageRenderScale' this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[9], Character.gid3, ref this.gc3)); // Set the value for global 'ShadowMapSize' this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[10], Character.gid4, ref this.gc4)); // Set the value for global 'SkinLightScatter' this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[11], Character.gid5, ref this.gc5)); // Set the value for global 'SunDirection' this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[13], Character.gid6, ref this.gc6)); // Set the value for global 'SunRgbIntensity' this.preg_change = (this.preg_change | state.SetGlobalVector4(ref this.preg[12], Character.gid7, ref this.gc7)); // Set the value for global 'SunSpecularPowerIntensity' this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[14], Character.gid8, ref this.gc8)); // Set the value for global 'UseAlbedoOcclusionShadow' this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[16], Character.gid9, ref this.gc9)); // Assign global textures this.CubeRgbmTexture = state.GetGlobalTextureCube(Character.tid0); this.ShadowTexture = state.GetGlobalTexture2D(Character.tid1); // Assign pixel shader textures and samplers if ((ic | this.ptc)) { state.SetPixelShaderSamplers(this.ptx, this.pts); this.ptc = false; } if ((this.vreg_change == true)) { Character.fx.vs_c.SetValue(this.vreg); this.vreg_change = false; ic = true; } if ((this.preg_change == true)) { Character.fx.ps_c.SetValue(this.preg); this.preg_change = false; ic = true; } if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending)) { ic = (ic | state.SetBlendMatricesDirect(Character.fx.vsb_c, ref this.sc3)); } if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing)) { this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc4)); if ((this.vireg_change == true)) { Character.fx.vsi_c.SetValue(this.vireg); this.vireg_change = false; ic = true; } } // Finally, bind the effect if ((ic | ec)) { state.SetEffect(this, ref Character.fx, ext); } }
/// <summary>Set a shader texture of type 'Texture2D' by global unique ID, see <see cref="Xen.Graphics.ShaderSystem.ShaderSystemBase.GetNameUniqueID"/> for details.</summary><param name="state"/><param name="id"/><param name="value"/> protected override bool SetTextureImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, int id, Microsoft.Xna.Framework.Graphics.Texture2D value) { if ((DrawVelocityParticles_LinesGpuTex_UserOffset.gd != state.DeviceUniqueIndex)) { this.WarmShader(state); } if ((id == DrawVelocityParticles_LinesGpuTex_UserOffset.tid0)) { this.PositionTexture = value; return true; } if ((id == DrawVelocityParticles_LinesGpuTex_UserOffset.tid2)) { this.VelocityTexture = value; return true; } if ((id == DrawVelocityParticles_LinesGpuTex_UserOffset.tid3)) { this.UserTexture = value; return true; } return false; }
public static void LoadStaticContent(string contentManagerName) { ContentManagerName = contentManagerName; #if DEBUG if (contentManagerName == FlatRedBallServices.GlobalContentManager) { HasBeenLoadedWithGlobalContentManager = true; } else if (HasBeenLoadedWithGlobalContentManager) { throw new Exception("This type has been loaded with a Global content manager, then loaded with a non-global. This can lead to a lot of bugs"); } #endif if (IsStaticContentLoaded == false) { IsStaticContentLoaded = true; lock (mLockObject) { if (!mHasRegisteredUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("ResistorStampStaticUnload", UnloadStaticContent); mHasRegisteredUnload = true; } } bool registerUnload = false; if (!FlatRedBallServices.IsLoaded<Scene>(@"content/entities/resistorstamp/resistorscn.scnx", ContentManagerName)) { registerUnload = true; } ResistorScn = FlatRedBallServices.Load<Scene>(@"content/entities/resistorstamp/resistorscn.scnx", ContentManagerName); if (!FlatRedBallServices.IsLoaded<Texture2D>(@"content/resistor256.png", ContentManagerName)) { registerUnload = true; } Resistor256 = FlatRedBallServices.Load<Texture2D>(@"content/resistor256.png", ContentManagerName); if (registerUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { lock (mLockObject) { if (!mHasRegisteredUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("ResistorStampStaticUnload", UnloadStaticContent); mHasRegisteredUnload = true; } } } CustomLoadStaticContent(contentManagerName); } }
public static void UnloadStaticContent() { IsStaticContentLoaded = false; mHasRegisteredUnload = false; if (Capacitor != null) { Capacitor = null; } if (SceneFile2 != null) { SceneFile2.RemoveFromManagers(ContentManagerName != "Global"); SceneFile2 = null; } if (CapacitorCollisionFile != null) { CapacitorCollisionFile.RemoveFromManagers(ContentManagerName != "Global"); CapacitorCollisionFile = null; } }
/// <summary>Set a shader texture of type 'Texture2D' by global unique ID, see <see cref="Xen.Graphics.ShaderSystem.ShaderSystemBase.GetNameUniqueID"/> for details.</summary><param name="state"/><param name="id"/><param name="value"/> protected override bool SetTextureImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, int id, Microsoft.Xna.Framework.Graphics.Texture2D value) { if ((DrawBillboardParticles_BillboardCpu.gd != state.DeviceUniqueIndex)) { this.WarmShader(state); } if ((id == DrawBillboardParticles_BillboardCpu.tid4)) { this.DisplayTexture = value; return true; } return false; }
protected override void DoLoadAsset(AssetHelper assetHelper) { if (name == null) { return; } if (tex == null) { tex = assetHelper.LoadAsset<Microsoft.Xna.Framework.Graphics.Texture2D>(name); } }
internal Texture(int _width, int _height) { tex = new Microsoft.Xna.Framework.Graphics.Texture2D(Application.Instance.GraphicsDevice, _width, _height, false, Microsoft.Xna.Framework.Graphics.SurfaceFormat.Color); }
internal Texture(Microsoft.Xna.Framework.Graphics.Texture2D t) { tex = t; }
public static void UnloadStaticContent() { IsStaticContentLoaded = false; mHasRegisteredUnload = false; if (ResistorScn != null) { ResistorScn.RemoveFromManagers(ContentManagerName != "Global"); ResistorScn = null; } if (Resistor256 != null) { Resistor256 = null; } }
public void InitializeSprite(Texture2D texture, int row, int column) { this.SpriteSheetRow = row; this.SpriteSheetColumn = column; SpriteInstance = new Sprite(); this.X = column * (int)MappingEnum.TileWidth; this.Y = -(row * (int)MappingEnum.TileHeight); SpriteInstance.Texture = texture; SpriteInstance.PixelSize = 0.5f; SpriteInstance.TopTexturePixel = row * (int)MappingEnum.TileHeight; SpriteInstance.LeftTexturePixel = column * (int)MappingEnum.TileWidth; SpriteInstance.BottomTexturePixel = (row + 1) * (int)MappingEnum.TileHeight; SpriteInstance.RightTexturePixel = (column + 1) * (int)MappingEnum.TileWidth; SpriteManager.AddSprite(SpriteInstance); SpriteInstance.AttachTo(this, false); }
public override void SetOverlayTextures(Texture2D upTexture, Texture2D downTexture) { mUpTexture = upTexture; mDownTexture = downTexture; if (IsPressed && mDownTexture != null) { mOverlayTexture = mDownTexture; } else if (!IsPressed && mUpTexture != null) { mOverlayTexture = mUpTexture; } }
/// <summary>Set a shader texture of type 'Texture2D' by global unique ID, see <see cref="Xen.Graphics.ShaderSystem.ShaderSystemBase.GetNameUniqueID"/> for details.</summary><param name="state"/><param name="id"/><param name="value"/> protected override bool SetTextureImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, int id, Microsoft.Xna.Framework.Graphics.Texture2D value) { if ((RgbmDecodeBloomPass.gd != state.DeviceUniqueIndex)) { this.WarmShader(state); } if ((id == RgbmDecodeBloomPass.tid0)) { this.InputTexture = value; return true; } return false; }
public static void LoadStaticContent(string contentManagerName) { ContentManagerName = contentManagerName; #if DEBUG if (contentManagerName == FlatRedBallServices.GlobalContentManager) { HasBeenLoadedWithGlobalContentManager = true; } else if (HasBeenLoadedWithGlobalContentManager) { throw new Exception("This type has been loaded with a Global content manager, then loaded with a non-global. This can lead to a lot of bugs"); } #endif if (IsStaticContentLoaded == false) { IsStaticContentLoaded = true; lock (mLockObject) { if (!mHasRegisteredUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("CapacitorPlatformCopyCopyStaticUnload", UnloadStaticContent); mHasRegisteredUnload = true; } } bool registerUnload = false; if (!FlatRedBallServices.IsLoaded<Texture2D>(@"content/entities/capacitorplatform/capacitor.png", ContentManagerName)) { registerUnload = true; } Capacitor = FlatRedBallServices.Load<Texture2D>(@"content/entities/capacitorplatform/capacitor.png", ContentManagerName); if (!FlatRedBallServices.IsLoaded<Scene>(@"content/entities/capacitorplatform/scenefile2.scnx", ContentManagerName)) { registerUnload = true; } SceneFile2 = FlatRedBallServices.Load<Scene>(@"content/entities/capacitorplatform/scenefile2.scnx", ContentManagerName); if (!FlatRedBallServices.IsLoaded<ShapeCollection>(@"content/entities/capacitorplatform/capacitorcollisionfile.shcx", ContentManagerName)) { registerUnload = true; } CapacitorCollisionFile = FlatRedBallServices.Load<ShapeCollection>(@"content/entities/capacitorplatform/capacitorcollisionfile.shcx", ContentManagerName); if (registerUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { lock (mLockObject) { if (!mHasRegisteredUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("CapacitorPlatformCopyCopyStaticUnload", UnloadStaticContent); mHasRegisteredUnload = true; } } } CustomLoadStaticContent(contentManagerName); } }
/// <summary>Set a shader texture of type 'Texture2D' by global unique ID, see <see cref="Xen.Graphics.ShaderSystem.ShaderSystemBase.GetNameUniqueID"/> for details.</summary><param name="state"/><param name="id"/><param name="value"/> protected override bool SetTextureImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, int id, Microsoft.Xna.Framework.Graphics.Texture2D value) { if ((DrawVelocityBillboardParticlesColour_GpuTex3D.gd != state.DeviceUniqueIndex)) { this.WarmShader(state); } if ((id == DrawVelocityBillboardParticlesColour_GpuTex3D.tid0)) { this.PositionTexture = value; return true; } if ((id == DrawVelocityBillboardParticlesColour_GpuTex3D.tid1)) { this.ColourTexture = value; return true; } if ((id == DrawVelocityBillboardParticlesColour_GpuTex3D.tid2)) { this.VelocityTexture = value; return true; } if ((id == DrawVelocityBillboardParticlesColour_GpuTex3D.tid4)) { this.DisplayTexture = value; return true; } return false; }
/// <summary> /// Gets the texture. /// </summary> /// <param name="imageIndex">Index of the image.</param> public Microsoft.Xna.Framework.Graphics.Texture2D LoadTexture2d(Microsoft.Xna.Framework.Graphics.GraphicsDevice device, ushort imageIndex) { var image = this.Images[imageIndex]; var bitmap = image.Plain; uint[] imgData = new uint[bitmap.Width * bitmap.Height]; Microsoft.Xna.Framework.Graphics.Texture2D texture = new Microsoft.Xna.Framework.Graphics.Texture2D(device, bitmap.Width, bitmap.Height); unsafe { BitmapData origdata = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat); uint* byteData = (uint*)origdata.Scan0; for (int i = 0; i < imgData.Length; i++) { imgData[i] = (byteData[i] & 0x000000ff) << 16 | (byteData[i] & 0x0000FF00) | (byteData[i] & 0x00FF0000) >> 16 | (byteData[i] & 0xFF000000); } bitmap.UnlockBits(origdata); } texture.SetData(imgData); return texture; }