public virtual bool Deserialize(object data) { JObject jmat = data as JObject; if (jmat == null) { return(false); } if (jmat["Blend"] != null) { BlendMode = ConvertBlendType(jmat["Blend"].Value <string>()); } if (jmat["Texture"] != null) { string relative_filename = jmat["Texture"].Value <string>().ToLower(); // todo : 텍스처 로딩 //Texture.LoadFile(CFileSystem.Inst.AppPath + Path.DirectorySeparatorChar +) } else { // todo : 빈텍스처 등록 } if (jmat["DepthTest"] != null) { IsDepthTest = jmat["DepthTest"].Value <bool>(); } if (jmat["Face"] != null) { FaceMode = ConvertFaceModeType(jmat["Face"].Value <string>()); } if (jmat["LinkedSubset"] != null) { LinkedSubsetName = jmat["LinkedSubset"].Value <string>().ToLower(); } else { return(false); } if (jmat["DiffColor"] != null) { DiffuseColor = CJsonConverter.ConvertColor(jmat["DiffColor"].Value <JArray>()); } return(true); }
public bool Deserialize(object data) { if (data is BinaryReader) { BinaryReader br = data as BinaryReader; Vector3 trans = Vector3.Zero; Vector3 rot = Vector3.Zero; Vector3 scale = Vector3.One; CBinaryConverter.Read(br, out trans); CBinaryConverter.Read(br, out rot); CBinaryConverter.Read(br, out scale); LclTranslate = trans; Quaternion qx = Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(rot.X)); Quaternion qy = Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(rot.Y)); Quaternion qz = Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(rot.Z)); LclRotation = qz * qy * qx; LclScaling = scale; } else if (data is JObject) { JObject jkf = data as JObject; if (jkf == null) { return(false); } if (jkf["LT"] == null || jkf["LS"] == null || jkf["LR"] == null) { return(false); } LclTranslate = CJsonConverter.ConvertVector3(jkf["LT"].Value <JArray>()); LclScaling = CJsonConverter.ConvertVector3(jkf["LS"].Value <JArray>()); Vector3 rot = CJsonConverter.ConvertVector3(jkf["LR"].Value <JArray>()); Quaternion qx = Quaternion.FromAxisAngle(Vector3.UnitX, MathHelper.DegreesToRadians(rot.X)); Quaternion qy = Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(rot.Y)); Quaternion qz = Quaternion.FromAxisAngle(Vector3.UnitZ, MathHelper.DegreesToRadians(rot.Z)); LclRotation = qz * qy * qx; } else { return(false); } return(true); }
public virtual bool Serialize(ref object writer) { if (writer is JObject) { JObject jmat = writer as JObject; jmat.Add("Blend", BlendMode.ToString()); //jmat.Add("Texture", Texture.Keyname); jmat.Add("DepthTest", IsDepthTest); jmat.Add("Face", FaceMode.ToString()); jmat.Add("LinkedSubset", LinkedSubsetName.ToLower()); jmat.Add("DiffColor", CJsonConverter.ConvertColor(DiffuseColor)); } else { return(false); } return(true); }
public bool Deserialize(object data) { if (data is BinaryReader) { BinaryReader br = data as BinaryReader; BoneIndex = br.ReadInt32(); CBinaryConverter.Read(br, out Position); CBinaryConverter.Read(br, out Normal); CBinaryConverter.Read(br, out Texcoord); } else if (data is JObject) { JObject jv = data as JObject; if (jv["Pos"] != null) { Position = CJsonConverter.ConvertVector3(jv["Pos"].Value <JArray>()); } if (jv["Nor"] != null) { Normal = CJsonConverter.ConvertVector3(jv["Nor"].Value <JArray>()); } if (jv["UV"] != null) { Texcoord = CJsonConverter.ConvertVector2(jv["UV"].Value <JArray>()); } if (jv["BI"] != null) { BoneIndex = jv["BI"].Value <int>(); } } else { return(false); } return(true); }