Axiom3D学习日记 3.Cameras, Lights, and Shadows

Camera 相机:

相机基础知识不写了,需要注意的是:axiom目前不支持同时操作多个相机.

创建,设置位置基本操作.

_camera  =  _scene.CreateCamera("MainCamera");
_camera.Position = new Vector3(0, 10, 200);
_camera.LookAt(Vector3.Zero);

_camera.Near = 5;决定了相机可视范围.

ViewPort(视口)

当要显示多个窗口时候用,这个我不怎么需要,就不写了.

Shadows in Axiom(重点来了)

Axiom有3种不同阴影.

    1. 纹理阴影:计算成本最低的一种.
    2. Modulative Stencil Shadows:较第三种没那么密集
    3. Additive Stencil Shadows:会叠加计算每个灯光的阴影,对GPU来说是比较大的负担.

遗憾的是:Axiom不支持软阴影,如果需要软阴影,需要自己写顶点和片段程序.

使用阴影非常容易:

scene.AmbientLight   = ColorEx.Black;
scene.ShadowTechnique = ShadowTechnique.StencilAdditive;

Entity ent = scene.CreateEntity("ninja", "ninja.mesh");
ent.CastShadows = true;
scene.RootSceneNode.CreateChildSceneNode().AttachObject(ent);

灯光:

灯光类型:

    1. Point (LightType.Point) - 点光源,各个方向.
    2. Spotlight (LightType.Spotlight) - 聚光灯
    3. Directional (LightType.Directional) - 平行光

创建灯:

Light pointLight = scene.CreateLight("pointLight");
pointLight.Type     = LightType.Point;
pointLight.Position = new Vector3(0, 150, 250);

pointLight.DiffuseColor  = ColorEx.Red;
pointLight.SpecularColor = ColorEx.Red;
Light spotLight = scene.CreateLight("spotLight");
spotLight.Type           = LightType.SpotLight;
spotLight.DiffuseColor  = ColorEx.Blue;
spotLight.SpecularColor = ColorEx.Blue;
spotLight.Direction = new Vector3(-1, -1, 0);
spotLight.Position  = new Vector3(300, 300, 0);

 

posted @ 2015-11-30 16:44  NNiiccoo  阅读(281)  评论(0编辑  收藏  举报

去Yes