AddChild() public method

public AddChild ( SceneNode child ) : void
child SceneNode
return void
示例#1
0
        private AnimatedMeshSceneNode IrrMeshLoad(IrrParseLib.IrrDatas _datas, SceneManager _smgr, SceneNode _node, string _prefix)
        {
            string prefix = string.Empty;

            if (!string.IsNullOrEmpty(_prefix))
            {
                prefix = _prefix;

                try
                {
                    string copy = workDirectory + prefix + _datas.Mesh.Param.Mesh;
                    if (!File.Exists(copy))
                        System.IO.File.Copy(workDirectory + _datas.Mesh.Param.Mesh, copy);
                }
                catch (Exception e)
                {
                    Reference.Log.Error("IrrMeshLoad", e);
                }
            }

            AnimatedMesh mesh = _smgr.GetMesh(workDirectory + prefix + _datas.Mesh.Param.Mesh);
            AnimatedMeshSceneNode node = _smgr.AddAnimatedMeshSceneNode(mesh);
            Reference.Log.Info("[LOADING MESH]: " + workDirectory + prefix + _datas.Mesh.Param.Mesh);

            // Set material.
            for (int i = 0; i < node.MaterialCount; i++)
            {
                if (i < _datas.Materials.Count)
                {
                    node.GetMaterial(i).MaterialType = (MaterialType)_datas.Materials[i].Type;
                    node.GetMaterial(i).BackfaceCulling = _datas.Materials[i].BackfaceCulling;
                    node.GetMaterial(i).FogEnable = _datas.Materials[i].FogEnable;
                    node.GetMaterial(i).GouraudShading = _datas.Materials[i].GouraudShading;
                    node.GetMaterial(i).Lighting = _datas.Materials[i].Lighting;
                    node.GetMaterial(i).NormalizeNormals = _datas.Materials[i].NormalizeNormals;
                    node.GetMaterial(i).Shininess = _datas.Materials[i].Shininess;
                    node.GetMaterial(i).ZBuffer = (uint)_datas.Materials[i].ZBuffer;
                    node.GetMaterial(i).ZWriteEnable = _datas.Materials[i].ZWriteEnable;
                    node.GetMaterial(i).Wireframe = _datas.Materials[i].Wireframe;
                }
            }

            _node.AddChild(node);

            if (_datas.Childs != null)
            {
                foreach (IrrParseLib.IrrDatas datas in _datas.Childs)
                {
                    IrrMeshLoad(datas, _smgr, node, _prefix);
                }
            }

            return node;
        }
示例#2
0
        private AnimatedMeshSceneNode IrrMeshLoad(IrrParseLib.IrrDatas _datas, SceneManager _smgr, SceneNode _node, string _prefix)
        {
            string prefix = string.Empty;

            if (string.IsNullOrEmpty(_prefix) == false)
            {
                prefix = _prefix;

                try
                {
                    string copy = workDirectory + prefix + _datas.Mesh.Param.Mesh;
                    if (!File.Exists(copy))
                        System.IO.File.Copy(workDirectory + _datas.Mesh.Param.Mesh, copy);
                }
                catch (Exception e)
                {
                    Reference.Log.Error("IrrMeshLoad", e);
                }
            }

            AnimatedMesh mesh = _smgr.GetMesh(prefix + _datas.Mesh.Param.Mesh);
            AnimatedMeshSceneNode node = _smgr.AddAnimatedMeshSceneNode(mesh);

            // Set material.
            for (int i = 0; i < node.MaterialCount; i++)
            {
                if (i < _datas.Materials.Count)
                {
                    node.GetMaterial(i).MaterialType = (MaterialType)_datas.Materials[i].Type;
                    node.GetMaterial(i).BackfaceCulling = _datas.Materials[i].BackfaceCulling;
                    node.GetMaterial(i).FogEnable = _datas.Materials[i].FogEnable;
                    node.GetMaterial(i).GouraudShading = _datas.Materials[i].GouraudShading;
                    node.GetMaterial(i).Lighting = _datas.Materials[i].Lighting;
                    node.GetMaterial(i).NormalizeNormals = _datas.Materials[i].NormalizeNormals;
                    node.GetMaterial(i).Shininess = _datas.Materials[i].Shininess;
                    node.GetMaterial(i).ZBuffer = (uint)_datas.Materials[i].ZBuffer;
                    node.GetMaterial(i).ZWriteEnable = _datas.Materials[i].ZWriteEnable;
            #if YK_VIDEO_WIREFRAME
                    node.GetMaterial(i).Wireframe = true;
            #else
                    node.GetMaterial(i).Wireframe = _datas.Materials[i].Wireframe;
            #endif

                    // [YK:NEXT]
                    //node.GetMaterial(i).AmbientColor = _datas.Materials[i].Ambient;
                    //node.GetMaterial(i).DiffuseColor = _datas.Materials[i].Diffuse;
                    //node.GetMaterial(i).SpecularColor = _datas.Materials[i].Specular;
                    //node.GetMaterial(i).EmissiveColor = _datas.Materials[i].Emissive;
                }
            }

            _node.AddChild(node);

            if (_datas.Childs != null)
            {
                foreach (IrrParseLib.IrrDatas datas in _datas.Childs)
                {
                    IrrMeshLoad(datas, _smgr, node, _prefix);
                }
            }

            return node;
        }