Rss

A Basic Scene

Basic Square

Creating the Panel class, with a default resolution of 640, 480, and a caption.

using System;
using IRL.Core;               //The Icarus Rendering Layer (For OpenGL/DirectX/OpenGLES selection, or direct OpenGL access)
using ISE.Core;               //For coordinate systems,maths libs, colors
using ISE.Scenes;             //for panels, scenes, animation
using ISE.Scenes.Geometry;    //for some default 3D geometric shapes.
using ISE.Assets;             //for materials, textures, external models.

namespace Test.ISE
{
    /// <summary>
    /// This panel shows how to add some basic objects into a scene.
    /// </summary>
    public class MyPanel : Panel
    {
        public MyPanel() : base("Icarus Scene Engine 3.0 Panel: Basic Rendering", 640, 480) { }

Now we create some default geometry.

All standard 3D shapes included in Icarus are specified using a width, height and depth.

Spheres, Cylinders, Funnels, Boxes, Torus’, Cones, Capsules etc.. The shapes stretch to fit the bounds as specified. Some shapes may require additional parameters to control additional features, like the capsule’s radial percentage, or the funnel, which has two widths and heights, to specify the size of the starting hole and ending hole in the funnel.

Additional parameters indicate wireframe or solid rendering, coordinates for the shape, and may also include shape specific quality settings

        //                                           Width
        //                                             | Height
        //                                             |  |  Depth                                                  
        //                                             |  |  |                Coordinates
        Shape.Box   myBox            = new Shape.Box  (1, 1, 1,          new Vector(1, 0, 0));

        // Create the camera, specifying the Lens to use and the position
        // At least one camera MUST be present on a Panel (or underneath) to properly set the display, otherwise nothing will render.
        Camera myCamera = new Camera(new PerspectiveLens(45),  // 45 Degree Lens, 
                                                                         // default aspect ratio (aspect ratio of 0 means it's dynamic and follows the Window size), 
                                                                         // default Depth range of 1..64

                                                                         // Camera's Position:
                                                                        new Trajectory(new Vector(5, 5, 5),     // Camera's Eye        (where is it positioned)
                                                                                       new Vector(0, 0, 0),     // Camera's target     (where is it looking at)
                                                                                       new Vector(0, 1, 0)));   // Camera's Up Vector  (which way round is it)

Now that some objects are created, we set up the hierarchy of the objects

        public override void Initialise()
        {
            // Set the background color
            BackgroundColor = DefaultColors.blue;

            // Add the Camera to the Panel
            Add(myCamera);

            // Create an untextured flat colored material and assign it to the box.
            myBox.Material = new ColoredMaterial(DefaultColors.red);

            // Add the shapes to the Camera
            myCamera.Add(myBox);

        }        
    }

For the sake of inclusivity, we will also include the main initialisation routine for the panel

        
        ///
        /// The main entry point for the application. 
        ///
        static void Main(params string[] args) 
        {
           // Specify OpenGL2.0 as the Icarus Rendering Layer to use. 
           IR.Engine = new IRL.Core.GL20.RenderEngineGL20(); 

           // Create an OS-specific window 
           window = IR.Engine.NewWindow(640, 480, 1); 
           // The third number, 1, is the SCALE, i.e. for Retina displays, where the resolution is the same for Retina vs non-retina, but the scale is doubled. 

           // Create the Panel 
           AbstractPanel thispanel = new MyPanel(window.Width, window.Height); 

           // IMPORTANT! Assign the panel to the Window, or the window will render nothing. 
           window.Panel = thispanel; 

           window.Show(); // This command is MODAL, and will only return after the window is closed. 

           thispanel.Dispose(); 
           IR.Engine.Close(); 
        }
}

Like This Post? Share It

Previous Post

Next Post

Leave a Reply

Your email address will not be published. Required fields are marked *