protected override void OnLoad(EventArgs e) { // Initialize GL settings GPUCapabilities.Initialize(); GLState.DepthTest = true; GLState.CullFace = true; GLState.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.OneMinusDstAlpha); 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, 200); camera.Target = new Vector3(0, 0, -1); camera.SetAsCurrent(); // Use this camera for rendering // Set up PackageManager PackageManager.BasePath = "../../Assets/"; // Load shaders ShaderManager.LoadCollection("Shaders/collection.xml"); var shader = ShaderManager.Get("cubemappedmodel"); // Load texture textures = new TextureManager(); var texture = textures.Get("Textures/cubemap.tex", true); texture.Quality.Mipmaps = true; // Load up a mesh MeshManager meshManager = new MeshManager(); var mesh = meshManager.Get("Meshes/sphere.mesh", true); // Construct a model from shader, texture and mesh, with default material model = new Model() { Shader = shader, Texture = texture, Mesh = mesh, Material = new Material() }; // set up rendering queue renderQueue = new RenderQueue(); renderQueue.AllowInstancing = false; }
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; }
void LoadMeshStuff() { // Set up camera camera = new Camera(this); camera.Perspective(Width, Height, (float)Math.PI / 4, 1f, 1000); camera.Position = new Vector3(0, 20, 200); camera.Target = new Vector3(0, 0, 0); camera.SetAsCurrent(); // Use this camera for rendering // Set up PackageManager PackageManager.BasePath = "../../Assets/"; // Load shaders var modelshader = ShaderManager.Get("transparentmodel"); // Load texture textures = new TextureManager(); var texture = textures.Get("Textures/lucymetal.tex", true); texture.Quality.Mipmaps = true; // Load up a mesh MeshManager meshManager = new MeshManager(); var mesh = meshManager.Get("Meshes/lucy.mesh", true); var lucyMaterial = new Material(); lucyMaterial.Textures.Add("textureSampler", texture); lucyMaterial.ShaderProgram = modelshader; // Construct a model from shader, texture and mesh, with default material model = new Model() { Mesh = mesh, Material = lucyMaterial }; // set up rendering queue renderQueue = new RenderQueue() { AllowInstancing = false }; }
protected override void OnLoad(EventArgs e) { // Initialize GL settings GPUCapabilities.Initialize(); GLState.DepthTest = true; GLState.CullFace = true; GLState.BlendFunc(BlendingFactorSrc.SrcColor, BlendingFactorDest.OneMinusSrcAlpha); 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, 200); camera.Target = new Vector3(0, 0, 0); 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/lucymetal.tex", true); texture.Quality.Mipmaps = true; var groundtexture = textures.Get("Textures/concreteslabs.tex", true); groundtexture.Quality.Mipmaps = true; groundtexture.Quality.TextureWrapMode = TextureWrapMode.Repeat; // Load up a mesh MeshManager meshManager = new MeshManager(); var mesh = meshManager.Get("Meshes/lucy.mesh", true); var groundmesh = meshManager.Get("Meshes/plane.mesh", true); var modelMaterial = new Material() { ShaderProgram = ShaderManager.Get("transparentmodel"), Transparent = false, UniformData = new List<IUniformData>() { new UniformDataVector4() { Name = "color", Data = new Vector4(1,1,1,0.75f), }, new UniformDataFloat() { Name = "specularIntensity", Data = 0.5f, } } }; modelMaterial.Textures.Add("textureSampler", texture); // Construct a model from shader, texture and mesh, with default material model = new Model() { Mesh = mesh, Material = modelMaterial }; var modelMaterial2 = modelMaterial.Copy(); modelMaterial2.Transparent = true; // Construct a model from shader, texture and mesh, with default material model2 = new Model() { Mesh = mesh, Material = modelMaterial2 }; var groundMaterial = modelMaterial.Copy(); groundMaterial.Textures["textureSampler"] = groundtexture; // Construct a model from shader, texture and mesh, with default material groundplane = new Model() { Mesh = groundmesh, Material = groundMaterial }; model.Transform.Position += new Vector3(1, 0, 0); model2.Transform.Position += new Vector3(-1, 0, 0); groundplane.Transform.Position += new Vector3(0, -1, 0); // set up rendering queue renderQueue = new RenderQueue(); renderQueue.AllowInstancing = false; }