DotNet编程-星光伴我行

滴滴真谛 水滴石穿

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

源码下载地址:

http://code.msdn.microsoft.com/Babylon-3D-engine-f0404ace/sourcecode?fileId=21297&pathId=1744047981

http://code.msdn.microsoft.com/Babylon-3D-engine-f0404ace

 

开发调试软件环境:

Silverlight_Developer.exe(文件版本5.0.64010.0), Silverlight5_Tools , Microsoft Express Blend Preview For Silverlight  , VS.NET 2010。以上软件均要装英文版的。

DXSDK_Jun10.exe

 

源码:

/Files/furenjun/Babylon.rar

 

Introduction

This sample shows a full 3D realtime engine with some advanced features and an integrated collisions system.

Live sample : http://david.blob.core.windows.net/babylon/Babylon.html

Building the Sample

You need to install ShaderBuildTaskSetup.msi which is present in the folder Babylon/BuildTask in order to compile shaders.
For vertex shaders, you must name the files *.vs.hlsl and set Build Action to VertexShader.
For pixel shaders, you must name the files *.ps.hlsl and set Build Action to PixelShader.

Update : Integration of the new Babylon.Toolkit : http://babylontoolkit.codeplex.com.
Update : New version integrate the new Effect class and the Importer using Nova (http://www.vertice.fr) for 3dsMax.

Description

The engine provides support for:

  • Collisions
  • Diffuse channel
  • Ambient channel
  • Textures (including light maps)
  • Per-pixel & per-vertex shader
  • Models/cameras and lights 

 

 

 

Sample of the drawing phase:

复制代码
C#
Edit|Remove
        void OnDraw(object sender, DrawEventArgs e) 
        { 
            if (engine.Device == null) 
            { 
                engine.Device = e.GraphicsDevice; 
            } 
 
            engine.BeginFrame(e); 
 
            if (scene != null && scene.ActiveCamera != null) 
            { 
                scene.Render(); 
 
                lock (moves) 
                { 
                    foreach (MoveDirection move in moves) 
                    { 
                        scene.ControlManager.CheckKeyboard(move, e.DeltaTime.TotalMilliseconds); 
                    } 
                } 
            } 
 
            engine.EndFrame(); 
        }

The engine provides a user control to quickly integrate a rendering in yours projects:

 

复制代码
XAML
Edit|Remove
<Babylon:BabylonSurface x:Name="babylonSurface"/>
To use compiled shaders, Babylon use a class called Effect. With this class, you can affect shader's variables by name:
复制代码
C#
Edit|Remove
            var eff = new Effect(engine.Device, "Babylon", "Engine/Shaders/pervertex"); 
 
            eff.SetConstant("World", World); 
            eff.SetConstant("levels", 1.0f, 0.5f, 0, 1.3f); 
 
            eff.Apply();
Effect.Apply() affects vertex and pixel shaders to the device. The effect class is autonomous and can be used in your own application as long as you use ShaderBuildTask to compile your shaders.
You can also get an EffectParameter and use it to set values:
复制代码
C#
Edit|Remove
EffectParameter positionParameter = effect.GetParameter("Position"); 
positionParameter.SetValue(new Vector3(0, 1, 0));
To build an effect, you must provide the name of the assembly where the shaders belong and the path of the shader in the project.

Source Code Files

  • Babylon.zip

More Information

For more information, please contact davca@microsoft.com or go to http://blogs.msdn.com/b/eternalcoding

 

 

posted on 2011-08-18 16:55  DotNet编程  阅读(1546)  评论(1编辑  收藏  举报