private void IrrFileTCPRequestToAssetServer_recursive(IrrParseLib.IrrDatas _datas, string _directory, bool fetchTextures) { IrrFileCreateCache(_datas.Mesh.Param.Mesh, _directory); if (fetchTextures) { // Request texture - note no JPEG2000 conversion occurs here. foreach (IrrParseLib.IrrMaterial material in _datas.Materials) { IrrFileCreateCache(material.Texture1, _directory); IrrFileCreateCache(material.Texture2, _directory); IrrFileCreateCache(material.Texture3, _directory); IrrFileCreateCache(material.Texture4, _directory); } } if (_datas.Childs != null) { foreach (IrrParseLib.IrrDatas datas in _datas.Childs) IrrFileTCPRequestToAssetServer_recursive(datas, _directory, fetchTextures); } }
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; }
/// <summary> /// Request asset from IrrDatas by TCP. /// </summary> /// <param name="_datas">IrrDatas</param> /// <param name="_directory"></param> /// <param name="fetchTextures"></param> public void IrrFileTCPRequestToAssetServer_toplevel(IrrParseLib.IrrDatas _datas, string _directory, bool fetchTextures) { IrrFileCreateCache(_datas.Mesh.Param.Name + ".xml", _directory); IrrFileTCPRequestToAssetServer_recursive(_datas, _directory, fetchTextures); }
private bool CheckAsset(IrrParseLib.IrrDatas _datas, bool checkTextures) { bool flag = CheckAssetFileExsists(_datas.Mesh.Param.Mesh); if (!flag) return flag; if (checkTextures) { foreach (IrrMaterial material in _datas.Materials) { flag &= CheckAssetFileExsists(material.Texture1); flag &= CheckAssetFileExsists(material.Texture2); flag &= CheckAssetFileExsists(material.Texture3); flag &= CheckAssetFileExsists(material.Texture4); } } if (!flag || _datas.Childs == null) return flag; foreach (IrrParseLib.IrrDatas datas in _datas.Childs) { if (!CheckAsset(datas, checkTextures)) return false; } return flag; }
private bool IsDownloadAllAsset(IrrParseLib.IrrDatas _datas, bool checkTextures) { return CheckAsset(_datas, checkTextures); }
/// <summary> /// Load to scene from Irrlicht file. /// </summary> /// <param name="_datas">IrrDatas</param> /// <param name="_smgr">Scene Manager</param> /// <param name="_vObj">VObject</param> /// <param name="_Entities">VObject list</param> public AnimatedMeshSceneNode IrrFileLoad(IrrParseLib.IrrDatas _datas, SceneManager _smgr, VObject _obj, string _prefix) { _obj.MeshNode = IrrMeshLoad(_datas, _smgr, _obj.Node, _prefix); // Copy base param. _obj.BaseParam = _datas.Mesh.Param; // Create animation key. _datas.CreateAnimationKey(workDirectory); foreach (IrrParseLib.KeyframeSet key in _datas.AnimationKey.Keys) { if (!_obj.FrameSetList.ContainsKey(key.Name)) _obj.FrameSetList.Add(key.Name, new IrrParseLib.KeyframeSet(key.Name, key.AnimationSpeed, key.StartFrame, key.EndFrame)); } _obj.MeshNode.Position = new Vector3D(_obj.BaseParam.Position[0], _obj.BaseParam.Position[1], _obj.BaseParam.Position[2]); _obj.MeshNode.Rotation = new Vector3D(_obj.BaseParam.Rotation[0], _obj.BaseParam.Rotation[1], _obj.BaseParam.Rotation[2]); _obj.MeshNode.Scale = new Vector3D(_obj.BaseParam.Scale[0], _obj.BaseParam.Scale[1], _obj.BaseParam.Scale[2]); return _obj.MeshNode; }
private void IrrFileTCPRequestToAssetServer_recursive(IrrParseLib.IrrDatas _datas, SLProtocol _slProtocol, bool _root, string _directory) { IrrFileTCPRequestToAssetServer_recursive(_datas, _slProtocol, _root, _directory, true); }
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; }
private void IrrFileRequestToAssetServer(IrrParseLib.IrrDatas _datas, SLProtocol _slProtocol, bool _root) { string filename = System.IO.Path.GetFileNameWithoutExtension(_datas.Mesh.Param.Mesh); UUID uuid = new UUID(filename); // Request mesh. _slProtocol.RequestAsset(uuid, AssetType.Object, true); // Request texture. foreach (IrrParseLib.IrrMaterial material in _datas.Materials) { if (material.Texture1 != string.Empty) { filename = System.IO.Path.GetFileNameWithoutExtension(material.Texture1); uuid = new UUID(filename); _slProtocol.RequestAsset(uuid, AssetType.Texture, true); } if (material.Texture2 != string.Empty) { filename = System.IO.Path.GetFileNameWithoutExtension(material.Texture2); uuid = new UUID(filename); _slProtocol.RequestAsset(uuid, AssetType.Texture, true); } if (material.Texture3 != string.Empty) { filename = System.IO.Path.GetFileNameWithoutExtension(material.Texture3); uuid = new UUID(filename); _slProtocol.RequestAsset(uuid, AssetType.Texture, true); } if (material.Texture4 != string.Empty) { filename = System.IO.Path.GetFileNameWithoutExtension(material.Texture4); uuid = new UUID(filename); _slProtocol.RequestAsset(uuid, AssetType.Texture, true); } } if (_datas.Childs != null) { foreach (IrrParseLib.IrrDatas datas in _datas.Childs) IrrFileRequestToAssetServer(datas, _slProtocol, false); } }
private bool CheckAsset(IrrParseLib.IrrDatas _datas, bool checkTextures) { string fileName = string.Empty; bool flag = true; // Check mesh. fileName = _datas.Mesh.Param.Mesh.ToLower(); if (!System.IO.File.Exists(workDirectory + @"\" + fileName)) { flag = false; } if (checkTextures) { // Check material. foreach (IrrMaterial material in _datas.Materials) { if (material.Texture1 != string.Empty) { fileName = material.Texture1.ToLower(); if (!System.IO.File.Exists(workDirectory + @"\" + fileName)) { flag = false; break; } } if (material.Texture2 != string.Empty) { fileName = material.Texture2.ToLower(); if (!System.IO.File.Exists(workDirectory + @"\" + fileName)) { flag = false; break; } } if (material.Texture3 != string.Empty) { fileName = material.Texture3.ToLower(); if (!System.IO.File.Exists(workDirectory + @"\" + fileName)) { flag = false; break; } } if (material.Texture4 != string.Empty) { fileName = material.Texture4.ToLower(); if (!System.IO.File.Exists(workDirectory + @"\" + fileName)) { flag = false; break; } } } } if (flag) { if (_datas.Childs != null) { foreach (IrrParseLib.IrrDatas datas in _datas.Childs) { if (!CheckAsset(datas, checkTextures)) { flag = false; break; } } } } return flag; }
public void IrrFileTCPRequestToAssetServer_toplevel(IrrParseLib.IrrDatas _datas, SLProtocol _slProtocol, string _directory, bool fetchTextures) { // Request animation file. if (_datas.Mesh.Param.Name != string.Empty) { IrrFileCreateCache(_datas.Mesh.Param.Name + ".xml", _directory); } IrrFileTCPRequestToAssetServer_recursive(_datas, _slProtocol, true, _directory, fetchTextures); }
/// <summary> /// Request asset from IrrDatas by TCP. /// </summary> /// <param name="_datas">IrrDatas</param> /// <param name="_slProtocol">SLProtocol</param> public void IrrFileTCPRequestToAssetServer_toplevel(IrrParseLib.IrrDatas _datas, SLProtocol _slProtocol, string _directory) { IrrFileTCPRequestToAssetServer_toplevel(_datas, _slProtocol, _directory, true); }
/// <summary> /// Request asset from IrrDatas. /// </summary> /// <param name="_datas">IrrDatas</param> /// <param name="_slProtocol">SLProtocol</param> public void IrrFileRequestToAssetServer(IrrParseLib.IrrDatas _datas, SLProtocol _slProtocol) { IrrFileRequestToAssetServer(_datas, _slProtocol, true); }