public classes_stat.KeyFrame ReadFrames(int frameIndex, int currentIndex, List <string> inputString) { List <MeshFromBinary> tempOutPutMesh = new List <MeshFromBinary>(); List <CameraFromBinary> tempOutPutCam = new List <CameraFromBinary>(); for (int i = currentIndex + 3; i < inputString.Count(); i++) { if (inputString[i].StartsWith("meshes")) { int count = strToInt(inputString[i]); for (int x = 0; x < count; x++) { MeshFromBinary temp = ReadMeshes(i, inputString); tempOutPutMesh.Add(temp); } } if (inputString[i].StartsWith("cameras")) { int count = strToInt(inputString[i]); for (int x = 0; x < count; x++) { tempOutPutCam.Add(ReadCameras(i, inputString)); } } if (inputString[i].StartsWith("frame")) { break; } } classes_stat.KeyFrame frame = new classes_stat.KeyFrame(frameIndex, tempOutPutMesh, tempOutPutCam); return(frame); }
private MeshFromBinary ReadMeshes(int currentIndex, List <string> inputString) { int tempCurrentIndex = 0; List <classes_stat.MyOwnVertexFormat> temp = new List <classes_stat.MyOwnVertexFormat>(); string name; Texture2D color = ContentTextures.crateTexture; Texture2D bump = ContentTextures.crateTexture; double bumpDepth = 0; List <Vector3> tmpPos = new List <Vector3>(); List <Vector3> tmpNor = new List <Vector3>(); List <Vector3> tmpTan = new List <Vector3>(); List <Vector2> tmpUV = new List <Vector2>(); int numberofvertices = 0; for (int i = currentIndex; i < inputString.Count(); i++) { if (inputString[i].StartsWith("name")) { name = ReadStringValue(inputString[i]); } if (inputString[i].StartsWith("color")) { string tmp = ReadStringValue(inputString[i]); System.IO.FileStream stream = new System.IO.FileStream(tmp, System.IO.FileMode.Open); color = Texture2D.FromStream(graphicsDevice, stream); stream.Close(); stream.Dispose(); //temp.Add(ReadStringValue()); } if (inputString[i].StartsWith("normalMap")) { string tmp = ReadStringValue(inputString[i]); System.IO.FileStream stream = new System.IO.FileStream(tmp, System.IO.FileMode.Open); bump = Texture2D.FromStream(graphicsDevice, stream); stream.Close(); stream.Dispose(); } if (inputString[i].StartsWith("bumpDepth")) { bumpDepth = strToDouble(inputString[i]); } if (inputString[i].StartsWith("vertices")) { numberofvertices = strToInt(inputString[i]); } if (inputString[i].StartsWith("v")) { tempCurrentIndex = (i - 1); break; } } for (int i = tempCurrentIndex; i < inputString.Count(); i++) { if (inputString[i].StartsWith("v")) { tmpPos.Add(ParseVector3(inputString[i])); } if (inputString[i].StartsWith("vn")) { tmpNor.Add(ParseVector3(inputString[i])); } if (inputString[i].StartsWith("t")) { tmpTan.Add(ParseVector3(inputString[i])); } if (inputString[i].StartsWith("vt")) { tmpUV.Add(ParseVector2(inputString[i])); } if (inputString[i].StartsWith("cameras")) { break; } if (inputString[i].StartsWith("name")) { break; } } for (int i = 0; i < numberofvertices; i++) { temp.Add(new classes_stat.MyOwnVertexFormat(tmpPos[i], tmpNor[i], tmpTan[i], tmpUV[i])); } MeshFromBinary mMesh; return(mMesh = new MeshFromBinary(graphicsDevice, temp, color, bump, bumpDepth)); }