Esempio n. 1
0
        protected void InitLights(ColourValue c1, ColourValue c2)
        {
            Billboard    lightbillboard;
            BillboardSet lightbillboardset = sceneMgr.CreateBillboardSet(name + "_lights", 1);

            lightbillboardset.MaterialName = "Effects/Flare";

            if (!EngineConfig.LowDetails)
            {
                lightbillboard = lightbillboardset.CreateBillboard(-9.2f, 12.5f, -5.1f - 47.5f, c1);
                lightbillboard.SetDimensions(2, 2);

                Light light = sceneMgr.CreateLight(name + "_light1");
                light.Type = Light.LightTypes.LT_POINT;


                light.SetAttenuation(30.0f, 0.0f, 1.0f, 0.00f);


                light.DiffuseColour  = new ColourValue(0.5f, 0.0f, 0.0f);
                light.SpecularColour = new ColourValue(0.05f, 0.05f, 0.05f);
                light.CastShadows    = true;


                SceneNode lightNode = mainNode.CreateChildSceneNode(new Vector3(-9.2f, 12.5f, -4.0f - 5.1f - 47.5f));

                lightNode.AttachObject(light);
            }

            lightbillboard = lightbillboardset.CreateBillboard(-10.7f, 12.3f, 12.6f - 47.5f, c2);
            lightbillboard.SetDimensions(2, 2);

            mainNode.AttachObject(lightbillboardset);
            //sceneMgr.ShowBoundingBoxes = true;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="position"></param>
        /// <param name="xScale"></param>
        /// <param name="yScale"></param>
        /// <param name="color"></param>
        /// <param name="texcoordIndexU"></param>
        /// <param name="texcoordsIndexV"></param>
        public void CreateBillboard(Vector3 position, float xScale, float yScale, ColorEx color, short texcoordIndexU, short texcoordsIndexV)
        {
            if (mRenderMethod == BillboardMethod.Accelerated)
            {
                StaticBillboard bb = new StaticBillboard();
                bb.Position        = position;
                bb.XScale          = xScale;
                bb.YScale          = yScale;
                bb.TextCoordIndexU = texcoordIndexU;
                bb.TextCoordIndexV = texcoordsIndexV;

                uint packedColor = (uint)Root.Singleton.RenderSystem.ConvertColor(color);
                bb.Color = packedColor;
                mBillboardBuffer.Add(bb);
            }
            else
            {
                Billboard bb = mFallbackSet.CreateBillboard(position);
                bb.SetDimensions(xScale, yScale);
                bb.TexcoordRect = new RectangleF(
                    texcoordIndexU * mUFactor,
                    texcoordsIndexV * mVFactor,
                    (texcoordIndexU + 1) * mUFactor,
                    (texcoordsIndexV + 1) * mVFactor);

                bb.Color = color;
            }
        }
 public DecayableBillboard(BillboardSet billboardSet, Vector3 position, Vector2 dimension, float timeToLive)
 {
     this.BillboardSet = billboardSet;
     Billboard = BillboardSet.CreateBillboard(position);
     Billboard.TexcoordRect = new FloatRect(0, 0, 1, 1);
     this.Dimension = dimension;
     this.TimeToLive = timeToLive;
     this.Alive = true;
 }
Esempio n. 4
0
        protected void InitLight(SceneNode parent, ColourValue c1, Vector3 localPosition, Vector2 size)
        {
            Billboard    lightbillboard;
            BillboardSet lightbillboardset =
                sceneMgr.CreateBillboardSet(parent.Name + "_lights" + c1.ToString() + "_" + localPosition.ToString(), 1);

            lightbillboardset.MaterialName = "Effects/Flare";
            lightbillboard = lightbillboardset.CreateBillboard(localPosition, c1);
            lightbillboard.SetDimensions(size.x, size.y);
            parent.AttachObject(lightbillboardset);
        }
Esempio n. 5
0
        private Light AddLight(string name, Vector3 pos, ColorEx color, LightType type)
        {
            Light l = scene.CreateLight(name);

            l.Position = pos;
            l.Type     = type;
            l.Diffuse  = color;
            l.SetAttenuation(1000000f, 0f, 0, 0.0000001f);          // Make lights go a long way
            Billboard lightBoard = lightSet.CreateBillboard(pos, color);

            lightNode.Lights.Add(l);
            return(l);
        }
Esempio n. 6
0
        protected void InitLightFlare(ColourValue c1, Vector3 localPosition, Vector2 scale)
        {
            lightBillboardSet = sceneMgr.CreateBillboardSet("EnemyInstallation" + tileID + "_lightflare", 1);
            lightBillboardSet.MaterialName = "Effects/Flare";
            lightBillboard = lightBillboardSet.CreateBillboard(localPosition, c1);
            lightBillboard.SetDimensions(scale.x, scale.y);
            installationNode.AttachObject(lightBillboardSet);

            light      = sceneMgr.CreateLight("EnemyInstallation" + tileID + "_light");
            light.Type = Light.LightTypes.LT_POINT;
            light.SetAttenuation(25.0f, 0.0f, 1.0f, 0.00f);
            light.DiffuseColour  = c1;
            light.SpecularColour = new ColourValue(0.05f, 0.05f, 0.05f);
            light.CastShadows    = false;
            SceneNode lightNode = installationNode.CreateChildSceneNode(localPosition);

            lightNode.AttachObject(light);
        }
Esempio n. 7
0
        /// <summary>
        /// Creates the element in the world. It automatically
        /// sets up the mesh and the node.</summary>
        protected virtual void Initialise(RenderQueueGroupID renderGroup, string materialName, Vec3 scale)
        {
            mBillboardSet = SceneManager.Instance.CreateBillboardSet(2);
            mBillboardSet.CastShadows = false;
            mBillboardSet.RenderQueueGroup = renderGroup;
            mBillboardSet.MaterialName = materialName;
            mBillboardSet.DefaultSize = new Vec2(1, 1);

            // Attaches the mesh on a node
            if (mBillboardSet.ParentSceneNode == null)
            {
                mNode = new SceneNode();
                mNode.Attach(mBillboardSet);
            }
            else
                mNode = mBillboardSet.ParentSceneNode;

            // Sets up the node (Position, Scale and Rotation)
            mBillboardSet.CreateBillboard(Vec3.Zero);
            mNode.Position = Vec3.Zero;
            mNode.Scale = scale;

            mMainLight = SceneManager.Instance.CreateLight();
            mMainLight.Type = RenderLightType.Directional;
            mMainLight.AllowStaticLighting = false;
            mMainLight.CastShadows = true;
            mMainLight.Position = new Vec3(0, 0, 150);
        }
Esempio n. 8
0
        void SetupTrailLights()
        {
            sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
            Vector3 dir = new Vector3(-1, -1, 0.5f);

            dir.Normalise();
            Light l = sceneMgr.CreateLight("light1");

            l.Type      = Light.LightTypes.LT_DIRECTIONAL;
            l.Direction = dir;

            NameValuePairList pairList = new NameValuePairList();

            pairList["numberOfChains"] = "2";
            pairList["maxElements"]    = "80";
            RibbonTrail trail = (RibbonTrail)(
                sceneMgr.CreateMovableObject("1", "RibbonTrail", pairList));

            trail.MaterialName = "Examples/LightRibbonTrail";
            trail.TrailLength  = 400;

            sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(trail);

            // Create 3 nodes for trail to follow
            SceneNode animNode = sceneMgr.RootSceneNode.CreateChildSceneNode();

            animNode.Position = new Vector3(50, 30, 0);
            Animation anim = sceneMgr.CreateAnimation("an1", 14);

            anim.SetInterpolationMode(Animation.InterpolationMode.IM_SPLINE);
            NodeAnimationTrack track = anim.CreateNodeTrack(1, animNode);
            TransformKeyFrame  kf    = track.CreateNodeKeyFrame(0);

            kf.Translate = new Vector3(50, 30, 0);
            kf           = track.CreateNodeKeyFrame(2);
            kf.Translate = new Vector3(100, -30, 0);
            kf           = track.CreateNodeKeyFrame(4);
            kf.Translate = new Vector3(120, -100, 150);
            kf           = track.CreateNodeKeyFrame(6);
            kf.Translate = new Vector3(30, -100, 50);
            kf           = track.CreateNodeKeyFrame(8);
            kf.Translate = new Vector3(-50, 30, -50);
            kf           = track.CreateNodeKeyFrame(10);
            kf.Translate = new Vector3(-150, -20, -100);
            kf           = track.CreateNodeKeyFrame(12);
            kf.Translate = new Vector3(-50, -30, 0);
            kf           = track.CreateNodeKeyFrame(14);
            kf.Translate = new Vector3(50, 30, 0);

            AnimationState animState = sceneMgr.CreateAnimationState("an1");

            animState.Enabled = true;
            mAnimStateList.Add(animState);

            trail.SetInitialColour(0, 1.0f, 0.8f, 0);
            trail.SetColourChange(0, 0.5f, 0.5f, 0.5f, 0.5f);
            trail.SetInitialWidth(0, 5);
            trail.AddNode(animNode);

            // Add light
            Light l2 = sceneMgr.CreateLight("l2");

            l2.DiffuseColour = (trail.GetInitialColour(0));
            animNode.AttachObject(l2);

            // Add billboard
            BillboardSet bbs = sceneMgr.CreateBillboardSet("bb", 1);

            bbs.CreateBillboard(Vector3.ZERO, trail.GetInitialColour(0));
            bbs.MaterialName = "Examples/Flare";
            animNode.AttachObject(bbs);

            animNode          = sceneMgr.RootSceneNode.CreateChildSceneNode();
            animNode.Position = new Vector3(-50, 100, 0);
            anim = sceneMgr.CreateAnimation("an2", 10);
            anim.SetInterpolationMode(Animation.InterpolationMode.IM_SPLINE);
            track        = anim.CreateNodeTrack(1, animNode);
            kf           = track.CreateNodeKeyFrame(0);
            kf.Translate = new Vector3(-50, 100, 0);
            kf           = track.CreateNodeKeyFrame(2);
            kf.Translate = new Vector3(-100, 150, -30);
            kf           = track.CreateNodeKeyFrame(4);
            kf.Translate = new Vector3(-200, 0, 40);
            kf           = track.CreateNodeKeyFrame(6);
            kf.Translate = new Vector3(0, -150, 70);
            kf           = track.CreateNodeKeyFrame(8);
            kf.Translate = new Vector3(50, 0, 30);
            kf           = track.CreateNodeKeyFrame(10);
            kf.Translate = new Vector3(-50, 100, 0);

            animState         = sceneMgr.CreateAnimationState("an2");
            animState.Enabled = true;
            mAnimStateList.Add(animState);

            trail.SetInitialColour(1, 0.0f, 1.0f, 0.4f);
            trail.SetColourChange(1, 0.5f, 0.5f, 0.5f, 0.5f);
            trail.SetInitialWidth(1, 5);
            trail.AddNode(animNode);

            // Add light
            l2 = sceneMgr.CreateLight("l3");
            l2.DiffuseColour = trail.GetInitialColour(1);
            animNode.AttachObject(l2);

            // Add billboard
            bbs = sceneMgr.CreateBillboardSet("bb2", 1);
            bbs.CreateBillboard(Vector3.ZERO, trail.GetInitialColour(1));
            bbs.MaterialName = "Examples/Flare";
            animNode.AttachObject(bbs);
        }
Esempio n. 9
0
        protected override void CreateScene()
        {
            // set ambient light off
//			scene.AmbientLight = new ColorEx(.5f, .5f, .5f);
            scene.AmbientLight = ColorEx.Black;

            // TODO: Check based on caps
            int currentAtheneMaterial = 0;

            // fixed light, dim
            if (showSunlight)
            {
                sunLight          = scene.CreateLight("SunLight");
                sunLight.Type     = LightType.Directional;
                sunLight.Position = new Vector3(1000, 1250, 500);
                sunLight.SetSpotlightRange(30, 50);
                Vector3 dir = -sunLight.Position;
                dir.Normalize();
                sunLight.Direction = dir;
                sunLight.Diffuse   = new ColorEx(0.65f, 0.65f, 0.68f);
                sunLight.Specular  = new ColorEx(0.9f, 0.9f, 1);
            }

            // point light, movable, reddish
            light          = scene.CreateLight("Light2");
            light.Diffuse  = minLightColor;
            light.Specular = ColorEx.White;
            light.SetAttenuation(8000, 1, .0005f, 0);

            // create light node
            lightNode = scene.RootSceneNode.CreateChildSceneNode("MovingLightNode");
            lightNode.AttachObject(light);

            // create billboard set
            BillboardSet bbs = scene.CreateBillboardSet("LightBBS", 1);

            bbs.MaterialName = "Examples/Flare";
            Billboard bb = bbs.CreateBillboard(Vector3.Zero, minLightColor);

            // attach to the scene
            lightNode.AttachObject(bbs);

            // create controller, after this is will get updated on its own
            WaveformControllerFunction func =
                new WaveformControllerFunction(WaveformType.Sine, 0.75f, 0.5f);

            LightWibbler val = new LightWibbler(light, bb, minLightColor, maxLightColor, minFlareSize, maxFlareSize);

            ControllerManager.Instance.CreateController(val, func);

            lightNode.Position = new Vector3(300, 250, -300);

            // create a track for the light
            Animation anim = scene.CreateAnimation("LightTrack", 20);

            // spline it for nice curves
            anim.InterpolationMode = InterpolationMode.Spline;
            // create a track to animate the camera's node
            AnimationTrack track = anim.CreateNodeTrack(0, lightNode);

            // setup keyframes
            AddKey(track, 0, new Vector3(300, 250, -300));
            AddKey(track, 2, new Vector3(150, 300, -250));
            AddKey(track, 4, new Vector3(-150, 350, -100));
            AddKey(track, 6, new Vector3(-400, 200, -200));
            AddKey(track, 8, new Vector3(-200, 200, -400));
            AddKey(track, 10, new Vector3(-100, 150, -200));
            AddKey(track, 12, new Vector3(-100, 75, 180));
            AddKey(track, 14, new Vector3(0, 250, 300));
            AddKey(track, 16, new Vector3(100, 350, 100));
            AddKey(track, 18, new Vector3(250, 300, 0));
            AddKey(track, 20, new Vector3(300, 250, -300));

            // create a new animation state to track this
            animState           = scene.CreateAnimationState("LightTrack");
            animState.IsEnabled = true;

            // Make light node look at origin, this is for when we
            // change the moving light to a spotlight
            lightNode.SetAutoTracking(true, scene.RootSceneNode);

//             lightSphereNode = scene.RootSceneNode.CreateChildSceneNode();
//             lightSphere = scene.CreateEntity("LightSphere", "tiny_cube.mesh");
//             lightSphereNode.AttachObject(lightSphere);
//             lightSphereNode.Position = new Vector3(300, 260, -300);

//             // create a track for the light sphere
//          Animation animSphere = scene.CreateAnimation("LightSphereTrack", 20);
//          // spline it for nice curves
//          animSphere.InterpolationMode = InterpolationMode.Spline;
//          // create a track to animate the camera's node
//          AnimationTrack trackSphere = animSphere.CreateTrack(0, lightSphereNode);
//          // setup keyframes
//             for (int i = 0; i <= 10; i++) {
//                 Vector3 v = track.KeyFrames[i].Translate;
//                 v.y += 10;
//                 key = trackSphere.CreateKeyFrame(i * 2);
//                 key.Translate = v;
//             }

//          // create a new animation state to track this
//          animSphereState = scene.CreateAnimationState("LightSphereTrack");
//          animSphereState.IsEnabled = true;

//          // Make light node look at origin, this is for when we
//          // change the moving light to a spotlight
//          lightSphereNode.SetAutoTracking(true, scene.RootSceneNode);

            Mesh mesh = MeshManager.Instance.Load("athene.mesh");

            short srcIdx, destIdx;

            // the athene mesh requires tangent vectors
            if (!mesh.SuggestTangentVectorBuildParams(out srcIdx, out destIdx))
            {
                mesh.BuildTangentVectors(srcIdx, destIdx);
            }

            SceneNode node;             //= scene.RootSceneNode.CreateChildSceneNode();
//			athene = scene.CreateEntity("Athene", "athene.mesh");
//			athene.MaterialName = atheneMaterials[currentAtheneMaterial];
//			node.AttachObject(athene);
//			node.Translate(new Vector3(0, -20, 0));
//			node.Yaw(90);

            Entity ent = null;

            node             = scene.RootSceneNode.CreateChildSceneNode();
            ent              = scene.CreateEntity("Column1", "column.mesh");
            ent.MaterialName = "Examples/Rockwall";
            node.AttachObject(ent);
            node.Translate(new Vector3(200, 0, -200));

            node             = scene.RootSceneNode.CreateChildSceneNode();
            ent              = scene.CreateEntity("Column2", "column.mesh");
            ent.MaterialName = "Examples/Rockwall";
            node.AttachObject(ent);
            node.Translate(new Vector3(200, 0, 200));

            node             = scene.RootSceneNode.CreateChildSceneNode();
            ent              = scene.CreateEntity("Column3", "column.mesh");
            ent.MaterialName = "Examples/Rockwall";
            node.AttachObject(ent);
            node.Translate(new Vector3(-200, 0, -200));

            node             = scene.RootSceneNode.CreateChildSceneNode();
            ent              = scene.CreateEntity("Column4", "column.mesh");
            ent.MaterialName = "Examples/Rockwall";
            node.AttachObject(ent);
            node.Translate(new Vector3(-200, 0, 200));

            scene.SetSkyBox(true, "Skybox/Stormy", 3000);

            Plane plane = new Plane(Vector3.UnitY, -100);

            MeshManager.Instance.CreatePlane(
                "MyPlane", plane, 1500, 1500, 20, 20, true, 1, 5, 5, Vector3.UnitZ);

            Entity planeEnt = scene.CreateEntity("Plane", "MyPlane");

            planeEnt.MaterialName = "Examples/Rockwall";
            planeEnt.CastShadows  = false;
            scene.RootSceneNode.CreateChildSceneNode().AttachObject(planeEnt);

            if (Root.Instance.RenderSystem.Name.StartsWith("Axiom Direct"))
            {
                // In D3D, use a 1024x1024 shadow texture
                scene.SetShadowTextureSettings(1024, 2, PixelFormat.L16);
            }
            else
            {
                // Use 512x512 texture in GL since we can't go higher than the window res
                scene.SetShadowTextureSettings(512, 2, PixelFormat.L16);
            }

//          scene.ShadowColor = new ColorEx(0.5f, 0.5f, 0.5f);
            scene.ShadowColor = ColorEx.Black;

            scene.ShadowFarDistance = 1000f;

            // in case infinite far distance is not supported
            camera.Far = 100000;

            debugTextDelay        = int.MaxValue;
            scene.ShadowTechnique = shadowTechniques[currentShadowTechnique];
            ApplyShadowTechnique();
        }
Esempio n. 10
0
        protected void CreateRibbons()
        {
            viewport.BackgroundColor = ColorEx.Black;
            float scale = 100f;

            scene.AmbientLight = new ColorEx(0.5f, 0.5f, 0.5f);
            //scene.SetSkyBox(true, "Examples/SpaceSkyBox", 20f * oneMeter);
            Vector3 dir = new Vector3(-1f, -1f, 0.5f);

            dir.Normalize();
            Light light1 = scene.CreateLight("light1");

            light1.Type      = LightType.Directional;
            light1.Direction = dir;

            // Create a barrel for the ribbons to fly through
            Entity    barrel     = scene.CreateEntity("barrel", "barrel.mesh");
            SceneNode barrelNode = scene.RootSceneNode.CreateChildSceneNode();

            barrelNode.ScaleFactor = 5f * Vector3.UnitScale;
            barrelNode.AttachObject(barrel);

            RibbonTrail trail = new RibbonTrail("DemoTrail", "numberOfChains", 2, "maxElementsPerChain", 80);

            trail.MaterialName = "Examples/LightRibbonTrail";
            trail.TrailLength  = scale * 400f;
            scene.RootSceneNode.CreateChildSceneNode().AttachObject(trail);

            // Create 3 nodes for trail to follow
            SceneNode animNode = scene.RootSceneNode.CreateChildSceneNode();

            animNode.Position = scale * new Vector3(50f, 30f, 0);
            Animation anim = scene.CreateAnimation("an1", 14);

            anim.InterpolationMode = InterpolationMode.Spline;
            NodeAnimationTrack track = anim.CreateNodeTrack(1, animNode);
            TransformKeyFrame  kf    = track.CreateNodeKeyFrame(0);

            kf.Translate = scale * new Vector3(50f, 30f, 0f);
            kf           = track.CreateNodeKeyFrame(2);
            kf.Translate = scale * new Vector3(100f, -30f, 0f);
            kf           = track.CreateNodeKeyFrame(4);
            kf.Translate = scale * new Vector3(120f, -100f, 150f);
            kf           = track.CreateNodeKeyFrame(6);
            kf.Translate = scale * new Vector3(30f, -100f, 50f);
            kf           = track.CreateNodeKeyFrame(8);
            kf.Translate = scale * new Vector3(-50f, 30f, -50f);
            kf           = track.CreateNodeKeyFrame(10);
            kf.Translate = scale * new Vector3(-150f, -20f, -100f);
            kf           = track.CreateNodeKeyFrame(12);
            kf.Translate = scale * new Vector3(-50f, -30f, 0f);
            kf           = track.CreateNodeKeyFrame(14);
            kf.Translate = scale * new Vector3(50f, 30f, 0f);

            AnimationState animState = scene.CreateAnimationState("an1");

            //animState.Enabled = true;
            animStateList = new List <AnimationState>();
            animStateList.Add(animState);

            trail.SetInitialColor(0, 1.0f, 0.8f, 0f, 1.0f);
            trail.SetColorChange(0, 0.5f, 0.5f, 0.5f, 0.5f);
            trail.SetInitialWidth(0, scale * 5f);
            trail.AddNode(animNode);

            // Add light
            Light light2 = scene.CreateLight("light2");

            light2.Diffuse = trail.GetInitialColor(0);
            animNode.AttachObject(light2);

            // Add billboard
            BillboardSet bbs = scene.CreateBillboardSet("bb", 1);

            bbs.CreateBillboard(Vector3.Zero, trail.GetInitialColor(0));
            bbs.MaterialName = "flare";
            animNode.AttachObject(bbs);

            animNode          = scene.RootSceneNode.CreateChildSceneNode();
            animNode.Position = scale * new Vector3(-50f, 100f, 0f);
            anim = scene.CreateAnimation("an2", 10);
            anim.InterpolationMode = InterpolationMode.Spline;
            track        = anim.CreateNodeTrack(1, animNode);
            kf           = track.CreateNodeKeyFrame(0);
            kf.Translate = scale * new Vector3(-50f, 100f, 0f);
            kf           = track.CreateNodeKeyFrame(2);
            kf.Translate = scale * new Vector3(-100f, 150f, -30f);
            kf           = track.CreateNodeKeyFrame(4);
            kf.Translate = scale * new Vector3(-200f, 0f, 40f);
            kf           = track.CreateNodeKeyFrame(6);
            kf.Translate = scale * new Vector3(0f, -150f, 70f);
            kf           = track.CreateNodeKeyFrame(8);
            kf.Translate = scale * new Vector3(50f, 0f, 30f);
            kf           = track.CreateNodeKeyFrame(10);
            kf.Translate = scale * new Vector3(-50f, 100f, 0f);

            animState = scene.CreateAnimationState("an2");
            //animState.setEnabled(true);
            animStateList.Add(animState);

            trail.SetInitialColor(1, 0.0f, 1.0f, 0.4f, 1.0f);
            trail.SetColorChange(1, 0.5f, 0.5f, 0.5f, 0.5f);
            trail.SetInitialWidth(1, scale * 5f);
            trail.AddNode(animNode);


            // Add light
            Light light3 = scene.CreateLight("l3");

            light3.Diffuse = trail.GetInitialColor(1);
            animNode.AttachObject(light3);

            // Add billboard
            bbs = scene.CreateBillboardSet("bb2", 1);
            bbs.CreateBillboard(Vector3.Zero, trail.GetInitialColor(1));
            bbs.MaterialName = "flare";
            animNode.AttachObject(bbs);
        }
Esempio n. 11
0
        protected override void CreateScene()
        {
            // set some ambient light
            scene.AmbientLight = new ColorEx(1, 0.1f, 0.1f, 0.1f);

            // set a basic skybox
            scene.SetSkyBox(true, "Skybox/Space", 5000.0f);

            // create the ogre head
            Entity ogre = scene.CreateEntity("OgreHead", "ogrehead.mesh");

            // attach the ogre to the scene
            scene.RootSceneNode.AttachObject(ogre);

            // create nodes for the billboard sets
            redYellowLightsNode = scene.RootSceneNode.CreateChildSceneNode();
            greenBlueLightsNode = scene.RootSceneNode.CreateChildSceneNode();

            // create a billboard set for creating billboards
            redYellowLights = scene.CreateBillboardSet("RedYellowLights", 20);
            redYellowLights.MaterialName = "Particles/Flare";
            redYellowLightsNode.AttachObject(redYellowLights);

            greenBlueLights = scene.CreateBillboardSet("GreenBlueLights", 20);
            greenBlueLights.MaterialName = "Particles/Flare";
            greenBlueLightsNode.AttachObject(greenBlueLights);

            // red light billboard in off set
            Vector3 redLightPos = new Vector3(78, -8, -70);

            redLightBoard = redYellowLights.CreateBillboard(redLightPos, ColorEx.Black);

            // yellow light billboard in off set
            Vector3 yellowLightPos = new Vector3(-4.5f, 30, -80);

            yellowLightBoard = redYellowLights.CreateBillboard(yellowLightPos, ColorEx.Black);

            // blue light billboard in off set
            Vector3 blueLightPos = new Vector3(-90, -8, -70);

            blueLightBoard = greenBlueLights.CreateBillboard(blueLightPos, ColorEx.Black);

            // green light billboard in off set
            Vector3 greenLightPos = new Vector3(50, 70, 80);

            greenLightBoard = greenBlueLights.CreateBillboard(greenLightPos, ColorEx.Black);

            // red light in off state
            redLight          = scene.CreateLight("RedLight");
            redLight.Position = redLightPos;
            redLight.Type     = LightType.Point;
            redLight.Diffuse  = ColorEx.Black;
            redYellowLightsNode.AttachObject(redLight);

            // yellow light in off state
            yellowLight          = scene.CreateLight("YellowLight");
            yellowLight.Type     = LightType.Point;
            yellowLight.Position = yellowLightPos;
            yellowLight.Diffuse  = ColorEx.Black;
            redYellowLightsNode.AttachObject(yellowLight);

            // green light in off state
            greenLight          = scene.CreateLight("GreenLight");
            greenLight.Type     = LightType.Point;
            greenLight.Position = greenLightPos;
            greenLight.Diffuse  = ColorEx.Black;
            greenBlueLightsNode.AttachObject(greenLight);

            // blue light in off state
            blueLight          = scene.CreateLight("BlueLight");
            blueLight.Type     = LightType.Point;
            blueLight.Position = blueLightPos;
            blueLight.Diffuse  = ColorEx.Black;
            greenBlueLightsNode.AttachObject(blueLight);

            // create controller function
            redLightFlasher =
                new LightFlasherControllerValue(redLight, redLightBoard, ColorEx.Red);
            yellowLightFlasher =
                new LightFlasherControllerValue(yellowLight, yellowLightBoard, ColorEx.Yellow);
            greenLightFlasher =
                new LightFlasherControllerValue(greenLight, greenLightBoard, ColorEx.Green);
            blueLightFlasher =
                new LightFlasherControllerValue(blueLight, blueLightBoard, ColorEx.Blue);

            // set up the controller value and function for flashing
            redLightFunc    = new WaveformControllerFunction(WaveformType.Sine, 0, 0.5f, 0, 1);
            yellowLightFunc = new WaveformControllerFunction(WaveformType.Triangle, 0, 0.25f, 0, 1);
            greenLightFunc  = new WaveformControllerFunction(WaveformType.Sine, 0, 0.25f, 0.5f, 1);
            blueLightFunc   = new WaveformControllerFunction(WaveformType.Sine, 0, 0.75f, 0.5f, 1);

            // set up the controllers
            ControllerManager.Instance.CreateController(redLightFlasher, redLightFunc);
            ControllerManager.Instance.CreateController(yellowLightFlasher, yellowLightFunc);
            ControllerManager.Instance.CreateController(greenLightFlasher, greenLightFunc);
            ControllerManager.Instance.CreateController(blueLightFlasher, blueLightFunc);
        }
Esempio n. 12
0
        /// <summary>
        /// Buduje testow¹ scenê
        /// </summary>
        public override void CreateScene()
        {
            //float cameraDistance = 50.0f;
            // mgr.LoadWorldGeometry("Terrain.xml");
            //sceneMgr.AmbientLight = ColourValue.Black; ; //; new ColourValue(1.0f, 1.0f, 1.0f);


            // Set the material
            sceneMgr.SetSkyBox(true, "Skybox/Morning", 5000);
            sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
            // create a default point light


            Light light = sceneMgr.CreateLight("MainLight");

            light.Type           = Light.LightTypes.LT_DIRECTIONAL;
            light.Position       = new Vector3(0, 1000, 0);
            light.Direction      = new Vector3(0, -5, 0);
            light.DiffuseColour  = new ColourValue(1.0f, 1.0f, 1.0f);
            light.SpecularColour = new ColourValue(0.05f, 0.05f, 0.05f);

            // OCEAN
            Plane plane = new Plane();

            plane.normal = Vector3.UNIT_Y;
            plane.d      = 0;
            MeshManager.Singleton.CreatePlane("OceanPlane",
                                              ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
                                              5000, 5000, 10, 10, true, 1, 10, 10, Vector3.UNIT_Z);

            Entity ocean = sceneMgr.CreateEntity("Ocean", "OceanPlane");

            ocean.SetMaterialName("Ocean2_HLSL");
            ocean.CastShadows = false;

            sceneMgr.RootSceneNode.AttachObject(ocean);
            // OCEAN

            ViewHelper.AttachAxes(sceneMgr, sceneMgr.RootSceneNode, 0.001f);


            // CARRIER
            Entity carrier2 = minimapMgr.CreateEntity("Carrier", "Carrier.mesh");


            Entity carrier        = sceneMgr.CreateEntity("Carrier", "Carrier.mesh");
            Entity carrierAerial1 = sceneMgr.CreateEntity("CarrierAerial1", "Aerial1.mesh");
            Entity carrierAerial2 = sceneMgr.CreateEntity("CarrierAerial2", "Aerial2.mesh");

            Entity lWaterTrail = sceneMgr.CreateEntity("LWaterTrail", "TwoSidedPlane.mesh");

            lWaterTrail.CastShadows = false;
            lWaterTrail.SetMaterialName("Effects/WaterTrail");

            Entity rWaterTrail = sceneMgr.CreateEntity("RWaterTrail", "TwoSidedPlane.mesh");

            rWaterTrail.CastShadows = false;
            rWaterTrail.SetMaterialName("Effects/WaterTrail");

            carrierNode = sceneMgr.RootSceneNode.CreateChildSceneNode("Carrier");
            carrierNode.AttachObject(carrier);

            carrierAerial1Node = carrierNode.CreateChildSceneNode("carrierAerial1Node", new Vector3(-8.6f, 9.1f, 5.7f));
            carrierAerial1Node.AttachObject(carrierAerial1);

            carrierAerial2Node =
                carrierNode.CreateChildSceneNode("carrierAerial2Node", new Vector3(-10.7f, 4.0f, 12.6f));
            carrierAerial2Node.AttachObject(carrierAerial2);


            lCarrierWaterTrailNode =
                carrierNode.CreateChildSceneNode("lCarrierWaterTrailNode", new Vector3(-4.6f, -4.8f, -40.0f));
            lCarrierWaterTrailNode.AttachObject(lWaterTrail);
            lCarrierWaterTrailNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Math.HALF_PI);
            lCarrierWaterTrailNode.Scale(2.0f, 1f, 1.5f);

            rCarrierWaterTrailNode =
                carrierNode.CreateChildSceneNode("rCarrierWaterTrailNode", new Vector3(4.6f, -4.8f, -40.0f));
            rCarrierWaterTrailNode.AttachObject(rWaterTrail);
            rCarrierWaterTrailNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Math.HALF_PI);
            rCarrierWaterTrailNode.Scale(2.0f, 1f, 1.5f);


            carrierNode.Translate(new Vector3(100, 5, 0));
            carrierNode.SetDirection(Vector3.UNIT_X);

            // CARRIER


            // ISLAND1

            /*   Entity island = sceneMgr.CreateEntity("Island1", "Island3.mesh");
             *
             * islandNode = sceneMgr.RootSceneNode.CreateChildSceneNode("Island1");
             * islandNode.AttachObject(island);
             * islandNode.Translate(new Vector3(-100, 1.35f, 0));
             * islandNode.SetDirection(Vector3.UNIT_X);*/

            // ISLAND2

            /*    Entity island2 = sceneMgr.CreateEntity("Island2", "Island2.mesh");
             *
             * island2Node = sceneMgr.RootSceneNode.CreateChildSceneNode("Island2");
             * island2Node.AttachObject(island2);
             * island2Node.Translate(new Vector3(-170, -0.35f, 0));
             * island2Node.SetDirection(Vector3.UNIT_X);*/

            // ISLAND3
            Entity island3 = sceneMgr.CreateEntity("Island3", "Island5.mesh");

            island3Node = sceneMgr.RootSceneNode.CreateChildSceneNode("Island3");
            island3Node.AttachObject(island3);
            island3Node.Translate(new Vector3(-460, 1.35f, 0));
            island3Node.SetDirection(Vector3.UNIT_X);

            // ISLAND4
            Entity island6 = sceneMgr.CreateEntity("Island6", "Island6.mesh");

            islandNode = sceneMgr.RootSceneNode.CreateChildSceneNode("Island6");
            islandNode.AttachObject(island6);
            islandNode.Translate(new Vector3(-200, 5.35f, 0));
            islandNode.SetDirection(Vector3.UNIT_X);


            float rot, xpos, zpos, ypos;

            // WOODEN BUNKER INSTALLATION
            gunEmplacementNode = islandNode.CreateChildSceneNode("GunEmplacement", new Vector3(0.0f, 1.1f, 5.0f));

            Entity sandbags = sceneMgr.CreateEntity("Sandbags", "Sandbags.mesh");

            gunEmplacementNode.AttachObject(sandbags);

            woodenBunkerNode = gunEmplacementNode.CreateChildSceneNode("WoodenBunkerNode", new Vector3(0, 0.0f, 4.0f));
            Entity woodenBunker = sceneMgr.CreateEntity("WoodenBunker", "Bunker.mesh");

            // woodenBunker.SetMaterialName("Concrete"); // aby by³ betonowy
            woodenBunkerNode.AttachObject(woodenBunker);

            Entity flakBase = sceneMgr.CreateEntity("FlakBase", "FlakBase.mesh");

            gunEmplacementNode.AttachObject(flakBase);

            flakBarrel     = sceneMgr.CreateEntity("FlakBarrel", "FlakBarrel.mesh");
            flakBarrelNode = gunEmplacementNode.CreateChildSceneNode("FlakBarrelNode", new Vector3(0, 0.5f, 0));
            flakBarrelNode.AttachObject(flakBarrel);
            // WOODEN BUNKER INSTALLATION


            // PALM TREES
            SceneNode palmNode;
            Entity    palm;


            for (int i = 0; i < 150; i++)
            {
                palm = sceneMgr.CreateEntity("Palm" + i, "PalmTree.mesh");
                rot  = Math.RangeRandom(-90.0f, 90.0f);
                zpos = Math.RangeRandom(-200.0f, 200.0f);
                xpos = Math.RangeRandom(-10.0f, 10.0f);
                ypos = Math.RangeRandom(0.1f, 0.3f);

                palmNode = islandNode.CreateChildSceneNode("PalmNode" + i, new Vector3(xpos, ypos, zpos));
                palmNode.Rotate(Vector3.UNIT_Y, rot);
                palmNode.Scale(1, Math.RangeRandom(0.9f, 1.1f), 1);
                palmNode.AttachObject(palm);
            }
            //islandNode.Scale(2.0f, 2.0f, 2.0f);
            // PALM TREES


            // JAPAN FLAG
            Entity japanFlag = sceneMgr.CreateEntity("JapanFlag", "JapanFlag.mesh");

            japanFlagNode = islandNode.CreateChildSceneNode("JapanFlagNode", new Vector3(0, 1, -5));
            japanFlagNode.Rotate(Vector3.UNIT_Y, Math.PI);
            japanFlagNode.AttachObject(japanFlag);

            japanFlagState         = japanFlag.GetAnimationState("idle");
            japanFlagState.Enabled = true;
            japanFlagState.Loop    = true;
            // JAPAN FLAG


            // TENT - just for fun
            // ???

            Entity tent = sceneMgr.CreateEntity("Tent", "Barracks.mesh");

            tentNode = islandNode.CreateChildSceneNode("TentNode", new Vector3(0, 1, 17));
            tentNode.AttachObject(tent);
            // TENT


            // SOLDIERS
            SceneNode soldierNode;
            Entity    soldier;

            soldiersState = new AnimationState[15];
            for (int i = 0; i < soldiersState.Length; i++)
            {
                soldier = sceneMgr.CreateEntity("Soldier" + i, "Soldier.mesh");
                if (i % 3 == 0)
                {
                    soldier.SetMaterialName("General");
                }

                rot  = Math.RangeRandom(-30.0f, 30.0f);
                zpos = Math.RangeRandom(-10.0f, 20.0f);
                xpos = Math.RangeRandom(-0.0f, 1.0f);
                ypos = 0.8f;

                soldierNode =
                    SceneMgr.RootSceneNode.CreateChildSceneNode("SoldierNode" + i, new Vector3(xpos, ypos, zpos));
                soldierNode.Rotate(Vector3.UNIT_Y, rot);
                soldierNode.AttachObject(soldier);


                switch (i % 3)
                {
                case 0:
                    soldiersState[i] = soldier.GetAnimationState("run");
                    break;

                case 1:
                    soldiersState[i] = soldier.GetAnimationState("die1");
                    break;

                case 2:
                    soldiersState[i] = soldier.GetAnimationState("die2");
                    break;
                }
                soldiersState[i].Loop    = true;
                soldiersState[i].Enabled = true;
            }
            //islandNode.Scale(0.7f, 0.7f, 0.7f);

            // SOLDIERS


            /*d
             * BillboardSet skies =  SceneManager.CreateBillboardSet("Sky",1);
             * skies.MaterialName = "Skyplane/Morning";
             * Billboard sky = skies.CreateBillboard(new Vector3(0.0f, 0.0f, -100.0f));
             * SceneManager.RootSceneNode.AttachObject(skies);
             */


//////////////////////////////////////////////////////
// A6M

            /*
             * a6m = sceneMgr.CreateEntity("A6M", "A6M.mesh");
             * a6mNode = sceneMgr.RootSceneNode.CreateChildSceneNode("EnemyNode");
             * a6mNode.AttachObject(a6m);
             *
             *
             * // AIRSCREW
             * enemyAirscrewNode = a6mNode.CreateChildSceneNode("EnemyAirscrew", new Vector3(0.0f, 0.0f, -5.70f));
             *
             * Entity enemyAirscrew = sceneMgr.CreateEntity("EnemyAirscrew", "Airscrew.mesh");
             * enemyAirscrew.SetMaterialName("A6M/Airscrew");
             * enemyAirscrew.CastShadows = false;
             * enemyAirscrewNode.AttachObject(enemyAirscrew);
             * // AIRSCREW
             *
             *
             * a6mNode.LookAt(Vector3.NEGATIVE_UNIT_X, Node.TransformSpace.TS_WORLD);
             *
             *
             * a6mNode.Scale(new Vector3(0.5f, 0.5f, 0.5f));
             * a6mNode.Position = new Vector3(0, 13.0f, 0);
             * ViewHelper.AttachAxes(sceneMgr, a6mNode, 1.5f);
             */
// A6M
//////////////////////////////////////////////////////


//////////////////////////////////////////////////////
// P47
            p47        = sceneMgr.CreateEntity("P47Body", "P47Body.mesh");
            playerNode = sceneMgr.RootSceneNode.CreateChildSceneNode("PlayerNode", new Vector3(350, 0, 0));


            p47OuterNode = playerNode.CreateChildSceneNode("OuterNode");
            p47InnerNode = p47OuterNode.CreateChildSceneNode("InnerNode");
            p47InnerNode.AttachObject(p47);

            p47OuterNode.Scale(new Vector3(0.5f, 0.5f, 0.5f));
            p47OuterNode.LookAt(Vector3.NEGATIVE_UNIT_X, Node.TransformSpace.TS_WORLD);


            // SMOKE

            ParticleSystem smokeSystem = sceneMgr.CreateParticleSystem("SmokeSystem", "Smokes/Smoke");

            SceneNode smokeNode = playerNode.CreateChildSceneNode("Smoke", new Vector3(0.0f, 0.0f, 3.0f));

            smokeSystem.GetEmitter(0).Direction = new Vector3(0.0f, 0.0f, 1.0f);

            smokeNode.AttachObject(smokeSystem);

            // SMOKE


            // ANIMATION
            // p47AnimationState = p47.GetAnimationState("manual");
            // p47AnimationState.Loop = true;
            // p47AnimationState.Enabled = true;
            // ANIMATION


            // BLADE
            bladeNode = p47InnerNode.CreateChildSceneNode("Blade", new Vector3(0.0f, 0.0f, -7.0f));
            Entity p47Blade = sceneMgr.CreateEntity("Blade", "P47Blade.mesh");

            bladeNode.AttachObject(p47Blade);
            p47Blade.Visible = false; // tylko kiedy niskie obroty
            // BLADE


            // AIRSCREW
            Entity airscrew = sceneMgr.CreateEntity("Airscrew", "Airscrew.mesh");

            airscrew.CastShadows = false;
            bladeNode.AttachObject(airscrew);
            // AIRSCREW


            // GUNHIT

            Entity lGunHit = sceneMgr.CreateEntity("LGunHit", "TwoSidedPlane.mesh");

            lGunHit.CastShadows = false;
            lGunHit.SetMaterialName("Effects/GunHit");

            Entity rGunHit = sceneMgr.CreateEntity("RGunHit", "TwoSidedPlane.mesh");

            rGunHit.CastShadows = false;
            rGunHit.SetMaterialName("Effects/GunHit");


            lGunHitNode = p47InnerNode.CreateChildSceneNode("lGunHitNode", new Vector3(-4.0f, -0.5f, -4.2f));
            lGunHitNode.AttachObject(lGunHit);
            lGunHitNode.Rotate(Vector3.NEGATIVE_UNIT_Z, Math.HALF_PI);
            lGunHitNode.Scale(0.5f, 0.5f, 0.7f);

            rGunHitNode = p47InnerNode.CreateChildSceneNode("rGunHitNode", new Vector3(4.0f, -0.5f, -4.2f));
            rGunHitNode.AttachObject(rGunHit);
            rGunHitNode.Rotate(Vector3.NEGATIVE_UNIT_Z, Math.HALF_PI);
            rGunHitNode.Scale(0.5f, 0.5f, 0.7f);
            // GUNHIT


            // WHEELS

            lWheelNode =
                p47InnerNode.CreateChildSceneNode("LeftWheel", new Vector3(-3.0f, -1.6f, -2.3f),
                                                  new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X));
            Entity lWheel = sceneMgr.CreateEntity("lWheel", "Wheel.mesh");

            lWheelNode.AttachObject(lWheel);


            rWheelNode =
                p47InnerNode.CreateChildSceneNode("RightWheel", new Vector3(3.0f, -1.6f, -2.3f),
                                                  new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X));
            rWheelNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Math.DegreesToRadians(180));
            Entity rWheel = sceneMgr.CreateEntity("rWheel", "Wheel.mesh");

            rWheelNode.AttachObject(rWheel);


            rearWheelNode =
                p47OuterNode.CreateChildSceneNode("RearWheel", new Vector3(0.0f, -0.6f, 5.3f),
                                                  new Quaternion(Math.DegreesToRadians(20), Vector3.UNIT_X));
            // rearWheelNode.Rotate(Vector3.NEGATIVE_UNIT_Y, Mogre.Math.DegreesToRadians(180));

            Entity rearWheel = sceneMgr.CreateEntity("rearWheele", "Wheel.mesh");

            rearWheelNode.AttachObject(rearWheel);
            rearWheelNode.Scale(0.7f, 0.7f, 0.7f);

            // WHEELS


            // ViewHelper.AttachAxes(sceneMgr, p47InnerNode, 1.5f);
            playerNode.Position = new Vector3(0, 10.0f, 0);


            // p47Animation = new PlaneAnimationManager(0, new PlayerPlaneViewnew Wof.Model.Level.Planes.Plane(),this,playerNode,);
            // p47Animation.enableAll();


            // p47Animation.switchTo(PlaneAnimationManager.AnimationType.IDLE);
            // p47Animation.Enabled = false;


            // CAMERA


            cameraNode = playerNode.CreateChildSceneNode("Camera");
            cameraNode.AttachObject(camera);

            cameraNode.Translate(new Vector3(0, 0, 100));

            //   sceneMgr.RootSceneNode.AttachObject(camera);


// P47
//////////////////


            // CHMURY
            BillboardSet clouds1 = sceneMgr.CreateBillboardSet("Clouds1");

            clouds1.MaterialName = "Effects/Cloud1";

            for (int i = -11; i < 11; i += 2)
            {
                Billboard cloud1 = (Billboard)clouds1.CreateBillboard(i * 10, 100 + Math.RangeRandom(-50, 50), -500);
                cloud1.SetDimensions(200 + Math.RangeRandom(-i, i), 100 + Math.RangeRandom(-i, 0));
                cloud1.Rotation = Math.DegreesToRadians(Math.RangeRandom(5, 5));
            }
            sceneMgr.RootSceneNode.AttachObject(clouds1);


            BillboardSet clouds2 = sceneMgr.CreateBillboardSet("Clouds2");

            clouds2.MaterialName = "Effects/Cloud2";

            for (int i = -10; i < 10; i += 2)
            {
                Billboard cloud2 = clouds2.CreateBillboard(i * 100, 100 + Math.RangeRandom(-50, 50), -500);
                cloud2.SetDimensions(200 + Math.RangeRandom(-i, i), 100 + Math.RangeRandom(-i, 0));
                cloud2.Rotation = Math.DegreesToRadians(Math.RangeRandom(5, 5));
            }
            sceneMgr.RootSceneNode.AttachObject(clouds2);
        }
Esempio n. 13
0
        void setupLighting()
        {
            /****/
            // Set ambient light
            mSceneManager.SetAmbientLight(Converter.GetColor(0.2f, 0.2f, 0.2f));
            // Point light, movable, reddish
            mLight = mSceneManager.CreateLight("Light2");
            mLight.SetDiffuseColour(mMinLightColour);
            mLight.SetSpecularColour(1.0f, 1.0f, 1.0f);
            mLight.SetAttenuation(8000.0f, 1.0f, 0.0005f, 0.0f);

            // Create light node
            mLightNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode("MovingLightNode");
            mLightNode.AttachObject(mLight);
            // create billboard set
            BillboardSet bbs = mSceneManager.CreateBillboardSet("lightbbs", 1);

            bbs.SetMaterialName("Examples/Flare");
            Billboard bb = bbs.CreateBillboard(0, 0, 0, mMinLightColour);

            // attach
            mLightNode.AttachObject(bbs);



            // create controller, after this is will get updated on its own
            mWFCF   = new WaveformControllerFunction(WaveformType.Sine, 0.0f, 0.5f);
            mCFFPtr = new ControllerFunctionFloatPtr(mWFCF);

            mLightWibbler = new LightWibbler(mLight, bb, mMinLightColour, mMaxLightColour, mMinFlareSize, mMaxFlareSize);
            mCVFPtr       = new ControllerValueFloatPtr(mLightWibbler.mCVFH);

            ControllerManager contMgr = ControllerManager.GetSingleton();

            mLightCtlFlt = contMgr.CreateController(contMgr.GetFrameTimeSource(), mCVFPtr, mCFFPtr);

            mLightNode.SetPosition(new Vector3(300, 250, -300));


            // Create a track for the light
            Animation anim = mSceneManager.CreateAnimation("LightTrack", 20.0f);

            // Spline it for nice curves
            anim.SetInterpolationMode(Animation.InterpolationMode.Spline);
            // Create a track to animate the camera's node
            NodeAnimationTrack track = anim.CreateNodeTrack(0, mLightNode);
            // Setup keyframes
            TransformKeyFrame key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(0.0f)).Handle, false);              // A startposition

            key.SetTranslate(new Vector3(300.0f, 550.0f, -300.0f));

            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(2.0f)).Handle, false);             //B
            key.SetTranslate(new Vector3(150.0f, 600.0f, -250.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(4.0f)).Handle, false);             //C
            key.SetTranslate(new Vector3(-150.0f, 650.0f, -100.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(6.0f)).Handle, false);             //D
            key.SetTranslate(new Vector3(-400.0f, 500.0f, -200.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(8.0f)).Handle, false);             //E
            key.SetTranslate(new Vector3(-200.0f, 500.0f, -400.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(10.0f)).Handle, false);            //F
            key.SetTranslate(new Vector3(-100.0f, 450.0f, -200.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(12.0f)).Handle, false);            //G
            key.SetTranslate(new Vector3(-100.0f, 400.0f, 180.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(14.0f)).Handle, false);            //H
            key.SetTranslate(new Vector3(0.0f, 250.0f, 600.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(16.0f)).Handle, false);            //I
            key.SetTranslate(new Vector3(100.0f, 650.0f, 100.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(18.0f)).Handle, false);            //J
            key.SetTranslate(new Vector3(250.0f, 600.0f, 0.0f));
            key = new TransformKeyFrame(KeyFrame.getCPtr(track.CreateKeyFrame(20.0f)).Handle, false);            //K == A
            key.SetTranslate(new Vector3(300.0f, 550.0f, -300.0f));
            // Create a new animation state to track this
            mAnimState = mSceneManager.CreateAnimationState("LightTrack");
            mAnimState.SetEnabled(true);
            /****/
        }
Esempio n. 14
0
        private void SetupLighting()
        {
            scene.AmbientLight = new ColorEx(0.2f, 0.2f, 0.2f);
            Light = scene.CreateLight("Light2");
            Light.DiffuseColour = MinLightColour;
            Light.SetAttenuation(8000, 1, 0.0005f, 0);
            Light.SpecularColour = new ColorEx(1, 1, 1);

            LightNode = scene.RootSceneNode.CreateChildSceneNode("MovingLightNode");
            LightNode.AttachObject(Light);
            //create billboard set

            BillboardSet bbs = scene.CreateBillboardSet("lightbbs", 1);

            bbs.SetMaterialName("Examples/Flare");
            Billboard bb = bbs.CreateBillboard(new Vector3(0, 0, 0), MinLightColour);

            LightNode.AttachObject(bbs);

            mLightController = new LightGrassWibbler(Light, bb, MinLightColour, this.MaxLightColour, MinFlareSize, MaxFlareSize);

            // create controller, after this is will get updated on its own
            //WaveformControllerFunction func = new WaveformControllerFunction(WaveformType.Sine, 0.0f, 0.5f);

            //ControllerManager.Instance.CreateController(val, func);

            LightNode.Position = new Vector3(300, 250, -300);

            Animation anim = scene.CreateAnimation("LightTrack", 20);

            //Spline it for nce curves
            anim.SetInterpolationMode(Animation.InterpolationMode.IM_SPLINE);// = Mogre.Animation.InterpolationMode.IM_SPLINE;
            //create a srtack to animte the camera's node
            NodeAnimationTrack track = anim.CreateNodeTrack(0, LightNode);
            //setup keyframes
            TransformKeyFrame key = track.CreateNodeKeyFrame(0);

            key.Translate = new Vector3(300, 550, -300);
            key           = track.CreateNodeKeyFrame(2);  //B
            key.Translate = new Vector3(150, 600, -250);
            key           = track.CreateNodeKeyFrame(4);  //C
            key.Translate = new Vector3(-150, 650, -100);
            key           = track.CreateNodeKeyFrame(6);  //D
            key.Translate = new Vector3(-400, 500, -200);
            key           = track.CreateNodeKeyFrame(8);  //E
            key.Translate = new Vector3(-200, 500, -400);
            key           = track.CreateNodeKeyFrame(10); //F
            key.Translate = new Vector3(-100, 450, -200);
            key           = track.CreateNodeKeyFrame(12); //G
            key.Translate = new Vector3(-100, 400, 180);
            key           = track.CreateNodeKeyFrame(14); //H
            key.Translate = new Vector3(0, 250, 600);
            key           = track.CreateNodeKeyFrame(16); //I
            key.Translate = new Vector3(100, 650, 100);
            key           = track.CreateNodeKeyFrame(18); //J
            key.Translate = new Vector3(250, 600, 0);
            key           = track.CreateNodeKeyFrame(20); //K == A
            key.Translate = new Vector3(300, 550, -300);
            // Create a new animation state to track this

            AnimState         = scene.CreateAnimationState("LightTrack");
            AnimState.Enabled = true;
        }