method simplification

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent 10cd0af99a
commit 7d5f7cfef5
3 changed files with 51 additions and 57 deletions
+4 -4
View File
@@ -347,6 +347,7 @@ connectNodes vbModelReader.cpp /^ void VbModelReader::connectNodes(){$/;" f clas
construct mesh.cpp /^ void Mesh::construct(){$/;" f class:vb01::Mesh typeref:typename:void
controller animationChannel.h /^ AnimationController *controller = nullptr;$/;" m class:vb01::AnimationChannel typeref:typename:AnimationController *
controller skeleton.h /^ AnimationController *controller = nullptr;$/;" m class:vb01::Skeleton typeref:typename:AnimationController *
createBones vbModelReader.cpp /^ void VbModelReader::createBones(Skeleton *skeleton, vector<string> &meshData){$/;" f class:vb01::VbModelReader typeref:typename:void
createSkybox root.cpp /^ void Root::createSkybox(string textures[6]){$/;" f class:vb01::Root typeref:typename:void
cross vector.h /^ Vector3 cross(Vector3 v){return Vector3(y * v.z - v.y * z, z * v.x - x * v.z, x * v.y - v.x * /;" f struct:vb01::Vector3 typeref:typename:Vector3
cur_x stb_image.h /^ int cur_x, cur_y;$/;" m struct:__anon84e4e8861308 typeref:typename:int
@@ -753,15 +754,14 @@ ratio stb_image.h /^ int flags, bgindex, ratio, transparent, eflags;$/;" m str
raw_coeff stb_image.h /^ void *raw_data, *raw_coeff;$/;" m struct:__anon84e4e8860808::__anon84e4e8860908 typeref:typename:void **
raw_data stb_image.h /^ void *raw_data, *raw_coeff;$/;" m struct:__anon84e4e8860808::__anon84e4e8860908 typeref:typename:void *
read stb_image.h /^ int (*read) (void *user,char *data,int size); \/\/ fill 'data' with 'size' bytes. re/;" m struct:__anon84e4e8860208 typeref:typename:int (*)(void * user,char * data,int size)
readAnimations vbModelReader.cpp /^ void VbModelReader::readAnimations(Skeleton *skeleton, int animationStartLine, int endLine){$/;" f class:vb01::VbModelReader typeref:typename:void
readBones vbModelReader.cpp /^ void VbModelReader::readBones(Skeleton *skeleton, int boneStartLine, int numBones){$/;" f class:vb01::VbModelReader typeref:typename:void
readAnimations vbModelReader.cpp /^ void VbModelReader::readAnimations(Skeleton *skeleton, vector<string> &meshData){$/;" f class:vb01::VbModelReader typeref:typename:void
readFaces vbModelReader.cpp /^ void VbModelReader::readFaces($/;" f class:vb01::VbModelReader typeref:typename:void
readFile util.cpp /^ void readFile(string path, vector<string> &lines, int firstLine, int lastLine){$/;" f namespace:vb01 typeref:typename:void
readLights vbModelReader.cpp /^ void VbModelReader::readLights(int startLine, int endLine){$/;" f class:vb01::VbModelReader typeref:typename:void
readMeshes vbModelReader.cpp /^ void VbModelReader::readMeshes(int startLine, int endLine){$/;" f class:vb01::VbModelReader typeref:typename:void
readShapeKeys vbModelReader.cpp /^ void VbModelReader::readShapeKeys(int shapeKeyStartLine, int numShapes){$/;" f class:vb01::VbModelReader typeref:typename:void
readSkeletons vbModelReader.cpp /^ void VbModelReader::readSkeletons(int startLine, int endLine){$/;" f class:vb01::VbModelReader typeref:typename:void
readVertexGroups vbModelReader.cpp /^ void VbModelReader::readVertexGroups(string *groups, int vertexGroupStartLine, int numBones){$/;" f class:vb01::VbModelReader typeref:typename:void
readSkeleton vbModelReader.cpp /^ void VbModelReader::readSkeleton(int startLine, int endLine){$/;" f class:vb01::VbModelReader typeref:typename:void
readVertexGroups vbModelReader.cpp /^ void VbModelReader::readVertexGroups(string *groups, vector<string> &meshData, int numBones){$/;" f class:vb01::VbModelReader typeref:typename:void
readVertices vbModelReader.cpp /^ void VbModelReader::readVertices($/;" f class:vb01::VbModelReader typeref:typename:void
read_from_callbacks stb_image.h /^ int read_from_callbacks;$/;" m struct:__anon84e4e8860308 typeref:typename:int
recip quaternion.h /^ inline Quaternion recip(){return conj()\/getLengthSq();}$/;" f class:vb01::Quaternion typeref:typename:Quaternion
+41 -47
View File
@@ -22,7 +22,7 @@ namespace vb01{
getObjectBounds(meshBracketIds, skeletonBracketIds, lightBracketIds);
for(int i = 0; i < skeletonBracketIds.size() / 2; i++)
readSkeletons(skeletonBracketIds[i * 2], skeletonBracketIds[i * 2 + 1]);
readSkeleton(skeletonBracketIds[i * 2], skeletonBracketIds[i * 2 + 1]);
for(int i = 0; i < meshBracketIds.size() / 2; i++)
readMeshes(meshBracketIds[i * 2], meshBracketIds[i * 2 + 1]);
for(int i = 0; i < lightBracketIds.size() / 2; i++)
@@ -89,9 +89,7 @@ namespace vb01{
model->attachChild(node);
}
void VbModelReader::readBones(Skeleton *skeleton, int boneStartLine, int numBones){
vector<string> meshData;
readFile(path, meshData, boneStartLine, boneStartLine + numBones);
void VbModelReader::createBones(Skeleton *skeleton, vector<string> &meshData){
vector<string> ikRelationships;
for(string line : meshData){
@@ -144,19 +142,17 @@ namespace vb01{
}
}
void VbModelReader::readAnimations(Skeleton *skeleton, int animationStartLine, int endLine){
void VbModelReader::readAnimations(Skeleton *skeleton, vector<string> &meshData){
AnimationController *controller = skeleton->getAnimationController();
string animName = "";
Bone *animBone = nullptr;
Animation::KeyframeGroup::KeyframeChannel::Type type;
vector<string> meshData;
readFile(path, meshData, animationStartLine, endLine + 1);
for(string l : meshData){
int colonId = getCharId(l, ':');
string preColon = l.substr(0, colonId);
for(string line : meshData){
int colonId = getCharId(line, ':');
string preColon = line.substr(0, colonId);
if(preColon == "animationName"){
string postColon = l.substr(colonId + 2, string::npos);
string postColon = line.substr(colonId + 2, string::npos);
animName = postColon;
controller->addAnimation(new Animation(animName));
continue;
@@ -178,7 +174,7 @@ namespace vb01{
KeyframeInterpolation interp;
KeyframeChannel channel;
if(l == "}")
if(line == "}")
break;
else if(preColon == "pos_x" || preColon == "pos_y" || preColon == "pos_z" || preColon == "rot_w" || preColon == "rot_x" || preColon == "rot_y" || preColon == "rot_z"){
if(preColon == "pos_x")
@@ -203,7 +199,7 @@ namespace vb01{
int numData = 3;
string data[numData];
getLineData(l, data, numData);
getLineData(line, data, numData);
float value = atof(data[0].c_str()), frame = atoi(data[1].c_str());
interp = (KeyframeInterpolation)atoi(data[2].c_str());
@@ -222,7 +218,7 @@ namespace vb01{
}
}
void VbModelReader::readSkeletons(int startLine, int endLine){
void VbModelReader::readSkeleton(int startLine, int endLine){
vector<string> meshData;
readFile(path, meshData, startLine + 1, startLine + 7);
string name = meshData[0].substr(getCharId(meshData[0], ':') + 2, string::npos);
@@ -238,9 +234,13 @@ namespace vb01{
Skeleton *skeleton = new Skeleton(name);
skeletons.push_back(skeleton);
readBones(skeleton, boneStartLine, numBones);
meshData.clear();
readFile(path, meshData, boneStartLine, boneStartLine + numBones);
createBones(skeleton, meshData);
readAnimations(skeleton, animationStartLine, endLine);
meshData.clear();
readFile(path, meshData, animationStartLine, endLine + 1);
readAnimations(skeleton, meshData);
}
@@ -248,12 +248,9 @@ namespace vb01{
vector<Vector3> &vertPos,
vector<Vector3> &vertNorm,
vector<float> &vertWeights,
int vertexStartLine,
int numVertices,
vector<string> &meshData,
int numBones
){
vector<string> meshData;
readFile(path, meshData, vertexStartLine, vertexStartLine + numVertices);
for(string line : meshData){
int numData = 6 + numBones;
string data[numData];
@@ -272,20 +269,15 @@ namespace vb01{
vector<Vector3> &vertPos,
vector<Vector3> &vertNorm,
vector<float> &vertWeights,
int faceStartLine,
int numFaces,
int numVertsPerFace,
vector<string> &meshData,
int numBones,
Mesh::Vertex *vertices,
u32 *indices
){
int i = 0;
vector<string> meshData;
readFile(path, meshData, faceStartLine, faceStartLine + numFaces * numVertsPerFace);
for(string line : meshData){
for(int i = 0; i < meshData.size(); i++){
int numData = 9;
string data[numData];
getLineData(line,data,numData);
getLineData(meshData[i], data, numData);
int index = atoi(data[0].c_str());
Vector2 uv = Vector2(atof(data[1].c_str()), atof(data[2].c_str()));
@@ -309,14 +301,10 @@ namespace vb01{
vertices[i] = vert;
indices[i] = i;
i++;
}
}
void VbModelReader::readVertexGroups(string *groups, int vertexGroupStartLine, int numBones){
vector<string> meshData;
readFile(path, meshData, vertexGroupStartLine, vertexGroupStartLine + numBones);
void VbModelReader::readVertexGroups(string *groups, vector<string> &meshData, int numBones){
groups = new string[numBones];
for(int i = 0; i < numBones; i++){
groups[i] = meshData[i];
@@ -324,8 +312,6 @@ namespace vb01{
}
void VbModelReader::readShapeKeys(int shapeKeyStartLine, int numShapes){
vector<string> meshData;
readFile(path, meshData, shapeKeyStartLine, shapeKeyStartLine + numShapes);
for(int i = 0; i < numShapes; i++){
}
}
@@ -334,18 +320,12 @@ namespace vb01{
vector<string> meshData;
readFile(path, meshData, startLine + 1, startLine + 8);
string nameLine = meshData[0], parentLine = meshData[4], skeletonLine = meshData[5], numElementsLine = meshData[6];
int skeletonLineColonId = getCharId(skeletonLine, ':');
string skeletonName = skeletonLine.substr(skeletonLineColonId + 2, string::npos);
int parentLineColonId = getCharId(parentLine, ':');
string parent = parentLine.substr(parentLineColonId + 2, string::npos);
string nameLine = meshData[0];
int nameLineColonId = getCharId(nameLine, ':');
string preColonNameLine = nameLine.substr(0, nameLineColonId);
string postColonNameLine = nameLine.substr(nameLineColonId + 2, string::npos);
string numElementsLine = meshData[6];
int numElementsColonId = getCharId(numElementsLine, ':');
string numElementsPreColon = numElementsLine.substr(0, numElementsColonId);
string numElementsPostColon = numElementsLine.substr(numElementsColonId + 2, string::npos);
@@ -354,6 +334,9 @@ namespace vb01{
getLineData(numElementsPostColon, data, 4);
string name = postColonNameLine;
string parentLine = meshData[4];
int parentLineColonId = getCharId(parentLine, ':');
string parent = parentLine.substr(parentLineColonId + 2, string::npos);
relationships.push_back(postColonNameLine + " " + parent);
const int numVertsPerFace = 3;
@@ -372,14 +355,25 @@ namespace vb01{
u32 *indices = new u32[numFaces * numVertsPerFace];
string *groups = new string[numBones];
meshData.clear();
readFile(path, meshData, vertexStartLine, vertexStartLine + numVertices);
readVertices(vertPos, vertNorm, vertWeights, meshData, numBones);
readVertices(vertPos, vertNorm, vertWeights, vertexStartLine, numVertices, numBones);
meshData.clear();
readFile(path, meshData, faceStartLine, faceStartLine + numFaces * numVertsPerFace);
readFaces(vertPos, vertNorm, vertWeights, meshData, numBones, vertices, indices);
readFaces(vertPos, vertNorm, vertWeights, faceStartLine, numFaces, numVertsPerFace, numBones, vertices, indices);
meshData.clear();
readFile(path, meshData, vertexGroupStartLine, vertexGroupStartLine + numBones);
readVertexGroups(groups, meshData, numBones);
readVertexGroups(groups, vertexGroupStartLine, vertexGroupStartLine + numBones);
meshData.clear();
readFile(path, meshData, shapeKeyStartLine, shapeKeyStartLine + numShapes);
readShapeKeys(shapeKeyStartLine, numShapes);
readShapeKeys(shapeKeyStartLine, shapeKeyStartLine + numShapes);
string skeletonLine = meshData[5];
int skeletonLineColonId = getCharId(skeletonLine, ':');
string skeletonName = skeletonLine.substr(skeletonLineColonId + 2, string::npos);
Skeleton *skeleton = nullptr;
for(Skeleton *sk : skeletons)
+6 -6
View File
@@ -22,12 +22,12 @@ namespace vb01{
void getObjectBounds(std::map<int, int>&, std::map<int, int>&, std::map<int, int>&);
void connectNodes();
void readBones(Skeleton*, int, int);
void readAnimations(Skeleton*, int, int);
void readSkeletons(int, int);
void readVertices(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<float>&, int, int, int);
void readFaces(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<float>&, int, int, int, int, Mesh::Vertex*, u32*);
void readVertexGroups(std::string*, int, int);
void createBones(Skeleton*, std::vector<std::string>&);
void readAnimations(Skeleton*, std::vector<std::string>&);
void readSkeleton(int, int);
void readVertices(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<float>&, std::vector<std::string>&, int);
void readFaces(std::vector<Vector3>&, std::vector<Vector3>&, std::vector<float>&, std::vector<std::string>&, int, Mesh::Vertex*, u32*);
void readVertexGroups(std::string*, std::vector<std::string>&, int);
void readShapeKeys(int, int);
void readMeshes(int, int);
void readLights(int, int);