Example #1
0
        protected override void KeyClicked(KeyEvent e)
        {
            switch (e.KeyCode)
            {
            case KeyCode.Y:
                myLine.updatePoint(2, new Vector3(160.0f, -50.0f, 160.0f));
                if (myLine.getNumPoints() == (UInt32)5)
                {
                    myLine.addPoint(new Vector3(0.0f, 50.0f, 0.0f));
                }

                myLine.drawLines();
                break;

            case KeyCode.U:
                myLine.updatePoint(2, new Vector3(160.0f, 9.6f, 160.0f));
                if (myLine.getNumPoints() > (UInt32)5)
                {
                    myLine.deletePoint(5);                               //the sixth point
                }
                myLine.drawLines();
                break;

            default:
                base.KeyClicked(e);
                break;
            }
        }
Example #2
0
        protected override void CreateScene()
        {
            mSceneManager.SetSkyBox(true, "Examples/CloudyNoonSkyBox");

            mLog = LogManager.Singleton.createLog("DemoCustomObjects.log", false, true);
            mLog.LogMessage(string.Format("DemoCustomObjects log {0}", System.DateTime.Now));

            create4LineDebugOverLay();
            Show4LineDebugOverLay();

            Entity    e;
            SceneNode n;


            Plane plane = new Plane();

            plane.Normal.x = 0;
            plane.Normal.y = 1;
            plane.Normal.z = 0;
            plane.D        = 0;
            MeshManager.GetSingleton().CreatePlane("Myplane", "General", plane,
                                                   14500, 14500, 10, 10, true, 1, 50, 50, Vector3.UnitZ);
            e = mSceneManager.CreateEntity("plane", "Myplane");
            e.SetMaterialName("Examples/GrassFloor");
            e.SetCastShadows(false);
            n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Myplane");
            n.AttachObject(e);


            //##MyLine3D test
            mLog.LogMessage("test line 0");
            myLine = new myLine3D();
            mLog.LogMessage("test line 1");
            myLine.addPoint(new Vector3(0.0f, 9.6f, 0.0f));
            myLine.addPoint(new Vector3(160.0f, 9.6f, 0.0f));
            myLine.addPoint(new Vector3(160.0f, 9.6f, 160.0f));
            myLine.addPoint(new Vector3(0.0f, 9.6f, 160.0f));
            myLine.addPoint(new Vector3(0.0f, 9.6f, 0.0f));
            mLog.LogMessage("test line 2");
            myLine.drawLines();

            mLog.LogMessage("test line 3");
            n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Line1");
            mLog.LogMessage("test line 4");
            n.AttachObject(myLine);
            mLog.LogMessage("test line 5");
            n.SetPosition(0.0f, 200.0f, 0.0f);
            //##

            /***/
            //## bill board chain
            mLog.LogMessage("test BBC 1");
            mBBC = new DemoCustomObjects.myBillBoardChain(mCamera, 1000);
            mBBC.setMaterial("DemoCustomObjects/smoketrail");
            for (int i = 0; i < 500; i++)
            {
                myBillBoardChainElement ce = new myBillBoardChainElement(
                    new Vector3((float)Math.Sin((double)i / 100.0 * 2.0 * Math.PI),
                                (float)Math.Cos((double)i / 100.0 * 2.0 * Math.PI),
                                (float)i / 100.0f),
                    0.1f,
                    (float)i / 10.0f,
                    Converter.GetColor(1.0f, 1.0f, 1.0f));
                mBBC.addChainElement(ce);
            }
            mBBC.updateBoundingBox();
            // Add it to the scene
            n = mSceneManager.GetRootSceneNode().CreateChildSceneNode("BBC");
            n.AttachObject(mBBC);
            n.SetPosition(0.0f, 100.0f, 0.0f);
            n.SetScale(50.0f, 50.0f, 50.0f);
            mLog.LogMessage("test BBC 2");
            //##
            /***/


            mCamera.Move(new Vector3(0, 300, 600));
            mCamera.LookAt = new Vector3(0, 0, -600);

            SetDebugCaption(2, "keys: Y updates and adds a new point");
            SetDebugCaption(3, "     U updates and deletes the new point");
        }