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


C# Scene.GetSceneNode方法代码示例

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


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

示例1: ProjectedShadowSample

    public ProjectedShadowSample(Microsoft.Xna.Framework.Game game)
    : base(game)
    {
      SampleFramework.IsMouseVisible = false;
      var delegateGraphicsScreen = new DelegateGraphicsScreen(GraphicsService)
      {
        RenderCallback = Render,
      };
      GraphicsService.Screens.Insert(0, delegateGraphicsScreen);

      // Create a new empty scene.
      _scene = new Scene();
      Services.Register(typeof(IScene), null, _scene);

      // Add a custom game object which controls the camera.
      _cameraObject = new CameraObject(Services);
      _cameraObject.ResetPose(new Vector3F(-8, 6, 8), -ConstantsF.PiOver4, -0.4f);
      GameObjectService.Objects.Add(_cameraObject);

      // Add a default light setup (ambient light + 3 directional lights).
      var defaultLightsObject = new DefaultLightsObject(Services);
      GameObjectService.Objects.Add(defaultLightsObject);

      // Get the main directional light.
      _mainDirectionalLightNode = ((LightNode)_scene.GetSceneNode("KeyLight"));

      // Add a ground plane model to the scene graph.
      var grid = ContentManager.Load<ModelNode>("Ground/Ground").Clone();
      grid.ScaleLocal = new Vector3F(0.3f);
      _scene.Children.Add(grid);

      // Add a tank model to the scene graph.
      var tank = ContentManager.Load<ModelNode>("Tank/tank").Clone();
      _scene.Children.Add(tank);

      // Remember the mesh nodes of tank node.
      _tankMeshNodes = tank.GetSubtree().Where(n => n is MeshNode).ToArray();

      // Create the renderers.
      _meshRenderer = new MeshRenderer();

      var spriteFont = UIContentManager.Load<SpriteFont>("UI Themes/BlendBlue/Default");
      _debugRenderer = new DebugRenderer(GraphicsService, spriteFont);

      _projectedShadowRenderer = new ProjectedShadowRenderer(GraphicsService)
      {
        // The plane onto which the shadows are projected. It is positioned a bit above the ground
        // plane to avoid z-fighting.
        ShadowedPlane = new Plane(new Vector3F(0, 1, 0), 0.01f),

        // The shadow color is a transparent black.
        ShadowColor = new Vector4F(0, 0, 0, 0.4f),

        // The light position is set in Update().
        //LightPosition = ...
      };
    }
开发者ID:,项目名称:,代码行数:57,代码来源:

示例2: ProjectedShadowSample2

    public ProjectedShadowSample2(Microsoft.Xna.Framework.Game game)
    : base(game)
    {
      SampleFramework.IsMouseVisible = false;
      var delegateGraphicsScreen = new DelegateGraphicsScreen(GraphicsService)
      {
        RenderCallback = Render,
      };
      GraphicsService.Screens.Insert(0, delegateGraphicsScreen);

      // The dude model uses a new ProjectedShadowSkinned.fx effect. This effect contains new 
      // parameters 'ShadowMatrix' and 'ShadowColor' which are not yet supported. When an mesh is 
      // loaded via the content manager, effect bindings are automatically created. This is done
      // by effect interpreters and effect binders. The graphics service uses several predefined
      // effect interpreter and binder classes to support the most common effect parameters. E.g.
      // the SceneEffectInterpreter and SceneEffectBinder handle parameters like 'World', 'View',
      // 'ViewProjection', 'CameraPosition', 'FogColor', etc. (see also class 
      // SceneEffectParameterSemantics).
      // We can add new effect interpreters/binders or we can add an entry to an existing 
      // interpreter/binder. Let's add entries to the standard SceneEffectInterpreter which creates 
      // meta-data for the new parameters:
      var sceneEffectInterpreter = GraphicsService.EffectInterpreters.OfType<SceneEffectInterpreter>().First();
      sceneEffectInterpreter.ParameterDescriptions.Add(
        "ShadowMatrix",
        (parameter, index) => new EffectParameterDescription(parameter, "ShadowMatrix", index, EffectParameterHint.Global));
      sceneEffectInterpreter.ParameterDescriptions.Add(
        "ShadowColor",
        (parameter, index) => new EffectParameterDescription(parameter, "ShadowColor", index, EffectParameterHint.Global));

      // Add entries to the standard SceneEffectBinder which create DelegateParameterBindings for 
      // the new parameters. The delegate bindings use callback methods to compute the parameter
      // value.
      var sceneEffectBinder = GraphicsService.EffectBinders.OfType<SceneEffectBinder>().First();
      sceneEffectBinder.MatrixBindings.Add(
        "ShadowMatrix",
        (effect, parameter, data) => new DelegateParameterBinding<Matrix>(effect, parameter, GetShadowMatrix));
      sceneEffectBinder.Vector4Bindings.Add(
        "ShadowColor",
        (effect, parameter, data) => new DelegateParameterBinding<Vector4>(effect, parameter, GetShadowColor));

      // Create a new empty scene.
      _scene = new Scene();
      Services.Register(typeof(IScene), null, _scene);

      // Add a custom game object which controls the camera.
      _cameraObject = new CameraObject(Services);
      _cameraObject.ResetPose(new Vector3F(-2, 2, 2), -ConstantsF.PiOver4, -0.4f);
      GameObjectService.Objects.Add(_cameraObject);

      // Add a default light setup (ambient light + 3 directional lights).
      var defaultLightsObject = new DefaultLightsObject(Services);
      GameObjectService.Objects.Add(defaultLightsObject);

      // Get the main directional light.
      _mainDirectionalLightNode = ((LightNode)_scene.GetSceneNode("KeyLight"));

      // Add a ground plane model to the scene graph.
      var grid = ContentManager.Load<ModelNode>("Ground/Ground").Clone();
      grid.ScaleLocal = new Vector3F(0.3f);
      _scene.Children.Add(grid);

      // Add a dude model to the scene graph.
      var dude = ContentManager.Load<ModelNode>("DudeWithProjectedShadow/Dude").Clone();
      dude.PoseWorld = new Pose(Matrix33F.CreateRotationY(ConstantsF.Pi));
      SampleHelper.EnablePerPixelLighting(dude);
      _scene.Children.Add(dude);

      // Start walk animation.
      StartDudeAnimation(dude);

      // Create the renderers.
      _meshRenderer = new MeshRenderer();

      _shadowColor = new Vector4(0, 0, 0, 0.4f);
    }
开发者ID:,项目名称:,代码行数:75,代码来源:


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