private void SetupColoredLights() { Texture2D text = TextureFromSprite(SpriteManager.Get("TBFlash_light")); light0.sprite = Sprite.Create(text, new Rect(0, 0, 128, 128), new Vector2(0.5f, 0.5f)); Material sharedMaterial = MaterialManager.Get("Portals", light0.sprite.texture); light0.color = new Color(1f, 0f, 0f, 0.1f); light0.transform.position = placeableObj.GetMarker("light2").worldPosition; light0.transform.localScale = new Vector2(2.3f, 2.3f); light0.enabled = true; light0.sharedMaterial = sharedMaterial; light0.gameObject.layer = UILevelSelector.LevelToLayer(placeableObj.iprefab.level + 1); light1.sprite = Sprite.Create(text, new Rect(0, 0, 128, 128), new Vector2(0.5f, 0.5f)); Material sharedMaterial2 = MaterialManager.Get("Portals", light1.sprite.texture); light1.color = new Color(0f, 1f, 0f, 0.1f); light1.transform.position = placeableObj.GetMarker("light1").worldPosition; light1.transform.localScale = new Vector2(2.3f, 2.3f); light1.enabled = true; light1.sharedMaterial = sharedMaterial2; light1.gameObject.layer = UILevelSelector.LevelToLayer(placeableObj.iprefab.level); DepthSort.SetupSingle(placeableObj, light0, -5f, false); DepthSort.SetupSingle(placeableObj, light1, -5f, false); SetupLightColors(currentDir == CurrentDir.One_To_Zero); }
protected override void OnLoad(EventArgs e) { // Initialize GL settings GPUCapabilities.Initialize(); GLState.DepthTest = true; GLState.AlphaBleding = false; GLState.CullFace = true; GL.ClearColor(0.25f, 0.25f, 0.25f, 1.0f); // Set up camera camera = new Camera(this); camera.Perspective(Width, Height, (float)Math.PI / 4, 1f, 1000); camera.Position = new Vector3(0, 20, 100); camera.Target = new Vector3(0, 0, -1); camera.SetAsCurrent(); // Set up PackageManager PackageManager.BasePath = "../../Assets/"; // Load shaders ShaderManager.LoadCollection("Shaders/collection.xml"); // Load texture textures = new TextureManager(); var texture = textures.Get("Textures/concreteslabs.tex", true); texture.Quality.Mipmaps = true; texture.Quality.TextureWrapMode = TextureWrapMode.Repeat; // Load up a mesh MeshManager meshManager = new MeshManager(); var mesh = meshManager.Get("Meshes/dragon.mesh", true); // Create base material materials = new MaterialManager(); materials.Insert("uniformexamplematerial.mat", new Material() { UniformData = new List<IUniformData>() { new UniformDataFloat() { Name = "time", Data = 0.0f }, new UniformDataVector2() { Name = "toffset", Data = Vector2.Zero }, new UniformDataVector4() { Name = "color", Data = Vector4.One } } }); // Construct a model from shader, texture and mesh, with default material model = new Model() { Shader = ShaderManager.Get("uniformexamplemodel"), Texture = texture, Mesh = mesh, Material = materials.Get("uniformexamplematerial.mat") }; model2 = new Model() { Shader = ShaderManager.Get("uniformexamplemodel"), Texture = texture, Mesh = mesh, Material = materials.Get("uniformexamplematerial.mat") }; model3 = new Model() { Shader = ShaderManager.Get("uniformexamplemodel"), Texture = texture, Mesh = mesh, Material = materials.Get("uniformexamplematerial.mat") }; model.Transform.Position += new Vector3(-1, 0.5f, 0); model2.Transform.Position += new Vector3(1, 0.5f, 0); model3.Transform.Position += new Vector3(0, -0.75f, 0); model.Transform.Rotation *= new Quaternion(0, (float)Math.PI, 0); // set up rendering queue renderQueue = new RenderQueue(); renderQueue.AllowInstancing = false; }