/// <summary> /// When the scene starts it creates all the needed objects that are required by default /// </summary> internal void OnLoad() { QPrefs.Load().Wait(); CreatorQueue = new Queue <QEntity>(); DestroyQueue = new Queue <QBehavior>(); Window = new QWindow(Engine); SpriteRenderer = new QSpriteRenderer(Engine); GuiRenderer = new QGuiRenderer(Engine); Content = new QContentManager(Engine); Entities = new QEntityManager(Engine); Physics = new QPhysics(); List <IQLoad> Loaders = new List <IQLoad>(); //Use this method to load textures before the scene starts to compile all of them //so that the megatexture only has to be created once per scene so that there //is no delay when objects spawn, but totally optional if you have a better system BehaviorScriptLoader(Loaders); foreach (var loader in Loaders) { ((QBehavior)loader).SetName(); ((QBehavior)loader).Parent = QEntity.GetEntity(); loader.OnLoad(new QLoadContent(Engine, Content)); QEntity.FreeEntity(((QBehavior)(loader)).Parent); } Accumulator = new QAccumulator(); Coroutine = new QCoroutine(); Instantiate(Console = new QConsole()); Instantiate(Debug = new QDebug()); Instantiate(Camera = new QCamera()); CheckQueue(); DebugView = new QDebugView(Physics.PhysicsWorld); DebugView.LoadContent(Engine.GraphicsDevice, Engine.Content); Load(); }
QTextureAtlas(QEngine engine, QContentManager contentManager, List <QTexture> textures) { Engine = engine; ContentManager = contentManager; Textures = textures; CreateAtlas(); }
internal QTexture(QContentManager manager, Texture2D t) { _texture = t; Manager = manager; }
/// <summary> /// Measures how many atlases are needed depending on the system /// </summary> /// <param name="manager"></param> /// <returns></returns> static List <List <QTexture> > AtlasesNeeded(QContentManager manager) { //number of atlases int atlasCount = 0; //how big the texture can get before resettting int textureMaxWidth = 0; //how big the texture can get before resettting int textureMaxHeight = 0; //the height needed for the current atlas; last one will always be the shortest int biggestHeight = 0; int totalWidth = 0; //If the current system is high quality we can use bigger textures because of max limits on textures if (QEngine.IsHighQuality) { textureMaxWidth = HighQualityWidth; textureMaxHeight = HightQualityHeight; } else { textureMaxWidth = LowQualityWidth; textureMaxHeight = LowQualityHeight; } //finds the width all the textures take up side by side, and finds the biggest ones height foreach (var texture in manager.Textures.Values) { totalWidth += texture.Width; if (texture.Height > biggestHeight) { biggestHeight = texture.Height; } } int rowsNeeded = (int)Math.Round((double)totalWidth / textureMaxHeight) + 1; int totalHeight = rowsNeeded * biggestHeight; //gives us the sheets needed but without remainder atlasCount = totalHeight / textureMaxHeight; //then gives use the actual remainder int remainder = totalHeight % textureMaxHeight; //if the remainder exist then we need another texture if (remainder > 0) { atlasCount++; } var ListOfListOfTextures = new List <List <QTexture> >(); for (int i = 0; i < atlasCount; i++) { ListOfListOfTextures.Add(new List <QTexture>()); } var textures = manager.Textures.ToList(); QVector2 pos = QVector2.Zero; int tSheet = 0; for (int i = 0; i < textures.Count; i++) { var t = textures[i].Value; pos.X += t.Width; if (pos.X > textureMaxWidth) { pos.X = 0; pos.Y += biggestHeight; } if (pos.Y > textureMaxHeight) { tSheet++; } ListOfListOfTextures[tSheet].Add(t); } return(ListOfListOfTextures); }
internal QLoadContent(QEngine engine, QContentManager cm) { this.cm = cm; this.engine = engine; }