当前位置: 首页>>代码示例>>C#>>正文


C# Scene.ComputeAbsoluteTransforms方法代码示例

本文整理汇总了C#中Scene.ComputeAbsoluteTransforms方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.ComputeAbsoluteTransforms方法的具体用法?C# Scene.ComputeAbsoluteTransforms怎么用?C# Scene.ComputeAbsoluteTransforms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scene的用法示例。


在下文中一共展示了Scene.ComputeAbsoluteTransforms方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadMapFromScene

        /// <summary>
        /// We assume that scene represents level.
        /// </summary>
        /// <param name="scene"></param>
        void ReadMapFromScene( ContentManager content, Scene scene, bool createRendMeshes )
        {
            //	create entity list :
            instances	=	new List<MeshInstance>();

            //	compute absolute transforms :
            var transforms	= new Matrix[ scene.Nodes.Count ];
            scene.ComputeAbsoluteTransforms( transforms );

            //	iterate through the scene's nodes :
            for ( int i=0; i<scene.Nodes.Count; i++) {

                var node	=	scene.Nodes[ i ];
                var world	=	transforms[ i ];
                var name	=	node.Name;
                var mesh	=	node.MeshIndex < 0 ? null : scene.Meshes[ node.MeshIndex ];

                if (name.StartsWith("startPoint")) {
                    Spawn("startPoint", 0, world.TranslationVector, 10 );
                    continue;
                }

                if (name.StartsWith("camera")) {
                    Spawn("camera", 0, world );
                }

                if (mesh!=null) {
                    AddStaticCollisionMesh( mesh, world );

                    if (createRendMeshes) {
                        var mi		= new MeshInstance( content.Game.RenderSystem, scene, mesh );
                        mi.World	= world;

                        instances.Add( mi );
                    }
                }
            }

            Random	r = new Random();

            for (int i=0; i<100; i++) {
                Spawn("box", 0, Vector3.Up * 400 + r.GaussRadialDistribution(20,2), 0 );
            }// */

            ///Spawn("mist", 0, Vector3.Up * 5, 0);
        }
开发者ID:demiurghg,项目名称:ShooterDemo,代码行数:50,代码来源:MPWorld.Map.cs

示例2: LoadContent

		void LoadContent ()
		{
			masterView.Instances.Clear();

			//-------------------------------------

			masterView.ParticleSystem.Images	=	Game.Content.Load<TextureAtlas>(@"sprites\particles|srgb");

			//-------------------------------------

			scene		=	Game.Content.Load<Scene>( @"scenes\testScene" );

			var transforms = new Matrix[ scene.Nodes.Count ];
			scene.ComputeAbsoluteTransforms( transforms );

			var defMtrl		=	Game.RenderSystem.DefaultMaterial;
			var materials	=	scene.Materials.Select( m => Game.Content.Load<MaterialInstance>( m.Name, defMtrl ) ).ToArray();
			
			for ( int i=0; i<scene.Nodes.Count; i++ ) {
			
				var meshIndex  = scene.Nodes[i].MeshIndex;
			
				if (meshIndex<0) {
					continue;
				}
				
				var inst   = new MeshInstance( Game.RenderSystem, scene, scene.Meshes[meshIndex], materials );
				inst.World = transforms[ i ];
			
				masterView.Instances.Add( inst );
			}


			//-------------------------------------

			animScene =	Game.Content.Load<Scene>(@"scenes\testAnim");
			animInstances.Clear();

			transforms = new Matrix[ animScene.Nodes.Count ];
			animScene.ComputeAbsoluteTransforms( transforms );

			materials	=	animScene.Materials.Select( m => Game.Content.Load<MaterialInstance>( m.Name, defMtrl ) ).ToArray();
			
			for ( int i=0; i<animScene.Nodes.Count; i++ ) {
			
				var meshIndex  = animScene.Nodes[i].MeshIndex;
			
				if (meshIndex<0) {
					continue;
				}
				
				var inst   = new MeshInstance( Game.RenderSystem, animScene, animScene.Meshes[meshIndex], materials );
				inst.World = transforms[ i ];

				animInstances.Add( new Tuple<MeshInstance,int>( inst, i ) );
			
				masterView.Instances.Add( inst );
			}

			//-------------------------------------

			skinScene =	Game.Content.Load<Scene>(@"scenes\testSkin");
			skinInstances.Clear();

			transforms = new Matrix[ skinScene.Nodes.Count ];
			skinScene.ComputeAbsoluteTransforms( transforms );

			materials	=	skinScene.Materials.Select( m => Game.Content.Load<MaterialInstance>( m.Name, defMtrl ) ).ToArray();
			
			for ( int i=0; i<skinScene.Nodes.Count; i++ ) {
			
				var meshIndex  = skinScene.Nodes[i].MeshIndex;
			
				if (meshIndex<0) {
					continue;
				}

				for (int j = 0; j<8; j++) {
				
					var inst   = new MeshInstance( Game.RenderSystem, skinScene, skinScene.Meshes[meshIndex], materials );
					inst.World = transforms[ i ] * Matrix.Translation(0,3,10) * Matrix.RotationY(MathUtil.Pi*2/8.0f * j);
				
					skinInstances.Add( new Tuple<MeshInstance,int>( inst, i ) );

					if (inst.IsSkinned) {
						var bones = new Matrix[skinScene.Nodes.Count];
						skinScene.GetAnimSnapshot( 8, bones );
						skinScene.ComputeBoneTransforms( bones, inst.BoneTransforms );
					}

					masterView.Instances.Add( inst );
				}
			}

			//-------------------------------------

			masterView.HdrSettings.BloomAmount	=	0.05f;
			masterView.HdrSettings.DirtAmount	=	0.95f;
			masterView.HdrSettings.DirtMask1	=	Game.Content.Load<DiscTexture>("bloomMask|srgb");
			masterView.HdrSettings.DirtMask2	=	null;//GameEngine.Content.Load<DiscTexture>("bloomMask2");
//.........这里部分代码省略.........
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:101,代码来源:CustomGameInterface.cs

示例3: ModelLayer

		public ModelLayer(Game engine, DVector2 lonLatPosition, string fileName, int maxInstancedCount = 0) : base(engine)
		{
			model = engine.Content.Load<Scene>(fileName);

			transforms = new Matrix[model.Nodes.Count];
			model.ComputeAbsoluteTransforms(transforms);

			LonLatPosition	= lonLatPosition;

			Transparency = 1.0f;

			constData	= new ConstDataStruct();
			modelBuf	= new ConstantBuffer(Game.GraphicsDevice, typeof(ConstDataStruct));
			shader		= Game.Content.Load<Ubershader>("globe.Model.hlsl");
			
			factory		= shader.CreateFactory( typeof(ModelFlags), Primitive.TriangleList, VertexInputElement.FromStructure<VertexColorTextureTBNRigid>(), BlendState.AlphaBlend, RasterizerState.CullCW, DepthStencilState.Default);
			factoryXray = shader.CreateFactory( typeof(ModelFlags), Primitive.TriangleList, VertexInputElement.FromStructure<VertexColorTextureTBNRigid>(), BlendState.AlphaBlend, RasterizerState.CullCW, DepthStencilState.Default);
			
			if (maxInstancedCount > 0) {
				InstancedCountToDraw	= maxInstancedCount;
				InstancedDataCPU		= new InstancedDataStruct[maxInstancedCount];

				instDataGpu = new StructuredBuffer(engine.GraphicsDevice, typeof(InstancedDataStruct), maxInstancedCount, StructuredBufferFlags.None);
			}

			selectInfo = new SelectInfo[model.Nodes.Count];
			for (int i = 0; i < model.Nodes.Count; i++)
			{
				var meshindex = model.Nodes[i].MeshIndex;
				if (meshindex < 0) continue;

				selectInfo[i] = new SelectInfo
				{
					BoundingBox = model.Meshes[meshindex].ComputeBoundingBox(),
					MeshIndex = meshindex,
					NodeIndex = i,
					NodeName = model.Nodes[i].Name
				};
			}

		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:41,代码来源:ModelLayer.cs


注:本文中的Scene.ComputeAbsoluteTransforms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。