Example #1
0
        public ShapesArea(Config config)
        {
            m_gl = new GlWidget (this, config);

            AddEvents (	(int)(Gdk.EventMask.Button1MotionMask |
                        Gdk.EventMask.Button2MotionMask |
                        Gdk.EventMask.ButtonPressMask |
                        Gdk.EventMask.ButtonReleaseMask |
                        Gdk.EventMask.VisibilityNotifyMask) );
            Realized += new EventHandler (OnRealize);
            ConfigureEvent += new ConfigureEventHandler (OnConfigure);
            ExposeEvent += new ExposeEventHandler (OnExpose);

            ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress);
            ButtonReleaseEvent += new ButtonReleaseEventHandler (OnButtonRelease);
            MotionNotifyEvent += new MotionNotifyEventHandler (OnMotionNotify);

            MapEvent += new MapEventHandler (OnMap);
            UnmapEvent += new UnmapEventHandler (OnUnmap);
            VisibilityNotifyEvent += new VisibilityNotifyEventHandler (OnVisibilityNotify);
            KeyPressEvent += new KeyPressEventHandler (OnKeyPress);

            int i = 0;
            shapeArray = new ShapeProp [9];
            shapeArray[i++] = new ShapeProp ("Cube");
            shapeArray[i++] = new ShapeProp ("Sphere");
            shapeArray[i++] = new ShapeProp ("Cone");
            shapeArray[i++] = new ShapeProp ("Torus");
            shapeArray[i++] = new ShapeProp ("Tetrahedron");
            shapeArray[i++] = new ShapeProp ("Octahedron");
            shapeArray[i++] = new ShapeProp ("Dodecahedron");
            shapeArray[i++] = new ShapeProp ("Icosahedron");
            shapeArray[i  ] = new ShapeProp ("Teapot");
            shape_current = i;
            mat_current = (MaterialProp)materialList[0];

            /*
            * Popup menu.
            */
            CreatePopupMenu ();
            ButtonPressEvent += new ButtonPressEventHandler (OnButtonPressPopupMenu);
        }
Example #2
0
 private void OnChangeMaterial(object o, EventArgs args)
 {
     for (int i = 0; i < materialList.Count; i++)
         if (o == ((MaterialProp)materialList[i]).menu_item) {
             mat_current = (MaterialProp)materialList[i];
             return;
         }
     InitView ();
 }
Example #3
0
        static ShapesArea()
        {
            // Read the XML file for material definition
            // No error handling

            // Open XML file in System.Xml.XmlDocument class
            XmlDocument materials = new XmlDocument ();
            Stream stream = File.OpenRead ("materials.xml");
            materials.Load (stream);
            stream.Close ();

            // Use System.Xml.XPath.XPathNavigator to navigate the document
            XPathNavigator nav = materials.CreateNavigator ();
            XPathNodeIterator mat_iter = nav.Select ("/materials/MaterialProp");
            while (mat_iter.MoveNext ()) {
                MaterialProp prop = new MaterialProp ();
                XPathNavigator mat_nav = mat_iter.Current;
                prop.name = mat_nav.GetAttribute ("name", "");
                XPathNodeIterator matattr_iter;

                matattr_iter = mat_nav.Select ("ambient");
                matattr_iter.MoveNext ();
                prop.ambient = MaterialProp.Decode4V(matattr_iter.Current.Value);

                matattr_iter = mat_nav.Select ("diffuse");
                matattr_iter.MoveNext ();
                prop.diffuse = MaterialProp.Decode4V(matattr_iter.Current.Value);

                matattr_iter = mat_nav.Select ("specular");
                matattr_iter.MoveNext ();
                prop.specular = MaterialProp.Decode4V(matattr_iter.Current.Value);

                matattr_iter = mat_nav.Select ("shininess");
                matattr_iter.MoveNext ();
                prop.shininess = (float)Double.Parse(matattr_iter.Current.Value);

                materialList.Add (prop);
            }
        }