CreateEntity() public méthode

Create an Entity (instance of a discrete mesh).
public CreateEntity ( string name, Axiom.Core.Mesh mesh ) : Entity
name string The name to be given to the entity (must be unique).
mesh Axiom.Core.Mesh The mesh to use.
Résultat Entity
Exemple #1
0
        public Arena(SceneManager pSceneManager, Int32 pScale, Int32 pNumAdditionalGrids)
        {
            var random = new Random();
            var topgrid = pSceneManager.CreateEntity("grid top", "grid.mesh");
            var topgridnode = pSceneManager.RootSceneNode.CreateChildSceneNode("grid top");

            topgridnode.Position = new Vector3(0, 0, -10);
            topgridnode.Orientation = Quaternion.FromAxes(Vector3.UnitX, Vector3.UnitZ, Vector3.NegativeUnitY);
            topgridnode.Scale = new Vector3(pScale, 1, pScale);
            topgridnode.AttachObject(topgrid);

            Width = (Int32)(topgrid.BoundingBox.Size.x * pScale);
            Height = (Int32)(topgrid.BoundingBox.Size.z * pScale);

            Right = Width / 2;
            Bottom = Height / 2;
            Left = -Right;
            Top = -Bottom;

            for (var i = 1; i <= pNumAdditionalGrids; i++)
            {
                var grid = pSceneManager.CreateEntity("grid" + i, "grid.mesh");
                var gridnode = pSceneManager.RootSceneNode.CreateChildSceneNode("grid" + i);

                gridnode.Position = new Vector3(
                    random.Next(-pScale / 5, pScale / 5),
                    random.Next(-pScale / 5, pScale / 5),
                    -10 - pScale * i / 10);
                gridnode.Orientation = Quaternion.FromAxes(
                    Vector3.UnitX,
                    Vector3.UnitZ,
                    Vector3.NegativeUnitY);
                gridnode.Scale = new Vector3(
                    pScale + i * random.Next(pScale / 8, pScale / 4),
                    1,
                    pScale + i * random.Next(pScale / 8, pScale / 4));
                gridnode.AttachObject(grid);
            }
        }
Exemple #2
0
        public Ship(SceneManager pSceneManager, Controller pController)
            : base(pController)
        {
            var name = Methods.GenerateUniqueID.ToString();

            Node = pSceneManager.RootSceneNode.CreateChildSceneNode(name);
            MeshNode = Node.CreateChildSceneNode();
            MeshNode.Orientation = new Quaternion(0.5, 0.5, -0.5, -0.5);
            MeshNode.AttachObject(pSceneManager.CreateEntity(name, "ship_assault_1.mesh"));

            UpgradeGroup = new UpgradeGroup
            {
                CannonAutoFire = { Level = 10 },
                CannonMultiFire = { Level = 10 },
                CannonSpeed = { Level = 7 },
                CannonPower = { Level = 5 }
            };

            cannon = new Cannon(this);
            UpgradeGroup.UpgradeCannon(ref cannon, UpgradeGroup);
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sceneMgr"></param>
		private void SetupBody( SceneManager sceneMgr )
		{
			// create main model
			bodyNode = sceneMgr.RootSceneNode.CreateChildSceneNode( Vector3.UnitY * CharHeight );
			bodyEnt = sceneMgr.CreateEntity( "SinbadBody", "Sinbad.mesh" );
			bodyNode.AttachObject( bodyEnt );

			// create swords and attach to sheath
			sword1 = sceneMgr.CreateEntity( "SinbadSword1", "Sword.mesh" );
			sword2 = sceneMgr.CreateEntity( "SinbadSword2", "Sword.mesh" );
			bodyEnt.AttachObjectToBone( "Sheath.L", sword1 );
			bodyEnt.AttachObjectToBone( "Sheath.R", sword2 );

			// create a couple of ribbon trails for the swords, just for fun
			NamedParameterList paras = new NamedParameterList();
			paras[ "numberOfChains" ] = "2";
			paras[ "maxElements" ] = "80";
			swordTrail = (RibbonTrail)sceneMgr.CreateMovableObject( "SinbadRibbon", "RibbonTrail", paras );
			swordTrail.MaterialName = "Examples/LightRibbonTrail";
			swordTrail.TrailLength = 20;
			swordTrail.IsVisible = false;
			sceneMgr.RootSceneNode.AttachObject( swordTrail );

			for ( int i = 0; i < 2; i++ )
			{
				swordTrail.SetInitialColor( i, new ColorEx( 1, 0.8f, 0 ) );
				swordTrail.SetColorChange( i, new ColorEx( 0.75f, 0.25f, 0.25f, 0.25f ) );
				swordTrail.SetWidthChange( i, 1 );
				swordTrail.SetInitialWidth( i, 0.5f );
			}

			keyDirection = Vector3.Zero;
			verticalVelocity = 0;

		}
Exemple #4
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);
        }
Exemple #5
0
        public void OnLoad()
        {
            // Create patch with positions, normals, and 1 set of texcoords
            var patchDeclaration = HardwareBufferManager.Instance.CreateVertexDeclaration();
            patchDeclaration.AddElement(0, 0, VertexElementType.Float3, VertexElementSemantic.Position);
            patchDeclaration.AddElement(0, 12, VertexElementType.Float3, VertexElementSemantic.Normal);
            patchDeclaration.AddElement(0, 24, VertexElementType.Float2, VertexElementSemantic.TexCoords, 0);

            var patchVertices = new PatchVertex[9];

            patchVertices[0].X = -500;
            patchVertices[0].Y = 200;
            patchVertices[0].Z = -500;
            patchVertices[0].Nx = -0.5f;
            patchVertices[0].Ny = 0.5f;
            patchVertices[0].Nz = 0;
            patchVertices[0].U = 0;
            patchVertices[0].V = 0;

            patchVertices[1].X = 0;
            patchVertices[1].Y = 500;
            patchVertices[1].Z = -750;
            patchVertices[1].Nx = 0;
            patchVertices[1].Ny = 0.5f;
            patchVertices[1].Nz = 0;
            patchVertices[1].U = 0.5f;
            patchVertices[1].V = 0;

            patchVertices[2].X = 500;
            patchVertices[2].Y = 1000;
            patchVertices[2].Z = -500;
            patchVertices[2].Nx = 0.5f;
            patchVertices[2].Ny = 0.5f;
            patchVertices[2].Nz = 0;
            patchVertices[2].U = 1;
            patchVertices[2].V = 0;

            patchVertices[3].X = -500;
            patchVertices[3].Y = 0;
            patchVertices[3].Z = 0;
            patchVertices[3].Nx = -0.5f;
            patchVertices[3].Ny = 0.5f;
            patchVertices[3].Nz = 0;
            patchVertices[3].U = 0;
            patchVertices[3].V = 0.5f;

            patchVertices[4].X = 0;
            patchVertices[4].Y = 500;
            patchVertices[4].Z = 0;
            patchVertices[4].Nx = 0;
            patchVertices[4].Ny = 0.5f;
            patchVertices[4].Nz = 0;
            patchVertices[4].U = 0.5f;
            patchVertices[4].V = 0.5f;

            patchVertices[5].X = 500;
            patchVertices[5].Y = -50;
            patchVertices[5].Z = 0;
            patchVertices[5].Nx = 0.5f;
            patchVertices[5].Ny = 0.5f;
            patchVertices[5].Nz = 0;
            patchVertices[5].U = 1;
            patchVertices[5].V = 0.5f;

            patchVertices[6].X = -500;
            patchVertices[6].Y = 0;
            patchVertices[6].Z = 500;
            patchVertices[6].Nx = -0.5f;
            patchVertices[6].Ny = 0.5f;
            patchVertices[6].Nz = 0;
            patchVertices[6].U = 0;
            patchVertices[6].V = 1;

            patchVertices[7].X = 0;
            patchVertices[7].Y = 500;
            patchVertices[7].Z = 500;
            patchVertices[7].Nx = 0;
            patchVertices[7].Ny = 0.5f;
            patchVertices[7].Nz = 0;
            patchVertices[7].U = 0.5f;
            patchVertices[7].V = 1;

            patchVertices[8].X = 500;
            patchVertices[8].Y = 200;
            patchVertices[8].Z = 800;
            patchVertices[8].Nx = 0.5f;
            patchVertices[8].Ny = 0.5f;
            patchVertices[8].Nz = 0;
            patchVertices[8].U = 1;
            patchVertices[8].V = 1;

            _patch = MeshManager.Instance.CreateBezierPatch("Bezier1", ResourceGroupManager.DefaultResourceGroupName, patchVertices, patchDeclaration, 3, 3, 5, 5, VisibleSide.Both, BufferUsage.StaticWriteOnly, BufferUsage.DynamicWriteOnly, true, true);
            _patch.Subdivision = 1.0f;

            _scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance");
            _scene.ClearScene();

            _patchEntity = _scene.CreateEntity("Entity1", "Bezier1");
            _camera = _scene.CreateCamera("MainCamera");



            var mat = (Material)MaterialManager.Instance.Create("test", ResourceGroupManager.DefaultResourceGroupName);
            var pass = mat.GetTechnique(0).GetPass(0);
            pass.LightingEnabled = false;


            _patchEntity.MaterialName = mat.Name;

            _scene.RootSceneNode.AttachObject(_patchEntity);

            _camera.LookAt(Vector3.Zero);
            _camera.Near = 5;
            _camera.AutoAspectRatio = true;

            var vp = _root.AutoWindow.AddViewport(_camera, 0, 0, 1.0f, 1.0f, 100);
            vp.BackgroundColor = ColorEx.CornflowerBlue;

        }