本文整理汇总了C++中Tokenizer::GetToken方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokenizer::GetToken方法的具体用法?C++ Tokenizer::GetToken怎么用?C++ Tokenizer::GetToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer::GetToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool Animation::Load(char* file){
Tokenizer token;
if(!token.Open(file)){
return false;
}
while(1) {
char temp[256];
token.GetToken(temp);
if (strcmp(temp, "range") == 0) {
time_start = token.GetFloat();
time_end = token.GetFloat();
}
else if (strcmp(temp, "numchannels") == 0) {
numofchannel = token.GetInt();
clist = new Channel[numofchannel];
for(int i=0; i<numofchannel; i++){
token.FindToken("channel");
token.GetToken(temp);
if (strcmp(temp, "{") == 0) {
// clist[i].time_start = time_start;
// clist[i].time_end = time_end;
clist[i].Load(&token);
}
}
}
else if(strcmp(temp, "}") == 0){
token.Close();
return true;
}
else
token.SkipLine();
}
}
示例2: Load
bool Skin::Load(const char *file) {
//if (tex) texture = BMPImage();
Tokenizer token;
token.Open(file);
int idx;
token.FindToken("positions");
idx = token.GetInt();
token.FindToken("{");
float x;
float y;
float z;
for (int i = 0; i < idx; i++) {
vertices.push_back(Vertex());
draw.push_back(Vertex());
x = token.GetFloat();
y = token.GetFloat();
z = token.GetFloat();
vertices[i].setPosition(Vector3(x, y, z));
draw[i].setPosition(Vector3());
}
token.FindToken("normals");
token.FindToken("{");
for (int i = 0; i < idx; i++) {
x = token.GetFloat();
y = token.GetFloat();
z = token.GetFloat();
vertices[i].setNormal(Vector3(x, y, z));
draw[i].setNormal(Vector3());
}
if (tex) {
token.FindToken("texcoords");
token.FindToken("{");
for (int i = 0; i < idx; i++) {
x = token.GetFloat();
y = token.GetFloat();
vertices[i].setTexCoord(Vector3(x, y, 0));
draw[i].setTexCoord(Vector3(x, y, 0));
}
}
token.FindToken("skinweights");
token.FindToken("{");
for (int i = 0; i < idx; i++) {
int numJoints = token.GetInt();
vector<skinWeight> inner;
for (int j = 0; j < numJoints; j++) {
int joint = token.GetInt();
float w = token.GetFloat();
inner.push_back(skinWeight(joint, w));
}
weights.push_back(inner);
}
if (tex) {
token.FindToken("material");
token.FindToken("{");
token.FindToken("texture");
char temp[256];
token.GetToken(temp);
texFileName = temp;
//LoadGLTextures(load);
}
token.FindToken("triangles");
idx = token.GetInt();
token.FindToken("{");
for (int i = 0; i < idx; i++) {
triangles.push_back(Triangle());
x = token.GetInt();
y = token.GetInt();
z = token.GetInt();
triangles[i].Init(&draw[x], &draw[y], &draw[z]);
triangles[i].Init(x, y, z);
}
token.FindToken("bindings");
idx = token.GetInt();
token.FindToken("{");
for (int i = 0; i < idx; i++) {
token.FindToken("{");
float ax = token.GetFloat();
float ay = token.GetFloat();
float az = token.GetFloat();
float bx = token.GetFloat();
float by = token.GetFloat();
float bz = token.GetFloat();
float cx = token.GetFloat();
//.........这里部分代码省略.........
示例3: Load
bool Skin::Load(const char* file, Skeleton* skel){
filename = file;
Skel = skel;
Tokenizer t;
t.Open(file);
if(DEBUG)
printf("Skeleton %s", Skel->GetFileName());
while(1){
char temp[256];
t.GetToken(temp);
//------ Load Vertex Positions ------
if(strcmp(temp,"positions")==0){
numVerts = t.GetInt();
vertices = std::vector<Vertex *>(numVerts);
updatedVertices = std::vector<Vertex *>(numVerts);
t.FindToken("{");
int n = 0;
if(DEBUG)
printf("positions %d\n", numVerts);
while(n < numVerts){
vertices[n] = new Vertex();
vertices[n]->SetPosition(t.GetFloat(), t.GetFloat(), t.GetFloat());
if(DEBUG){
Vector3 pos = vertices[n]->GetPosition();
printf("\t%f %f %f\n", pos.x, pos.y, pos.z);
}
updatedVertices[n] = new Vertex();
updatedVertices[n]->SetPosition(vertices[n]->GetPosition());
n++;
}
//------ Load Vertex Normals ------
} else if(strcmp(temp, "normals")==0){
t.GetInt();
t.FindToken("{");
int n = 0;
if(DEBUG)
printf("normals %d\n", numVerts);
while(n < numVerts){
vertices[n]->SetNormal(t.GetFloat(), t.GetFloat(), t.GetFloat());
updatedVertices[n]->SetNormal(vertices[n]->GetNormal());
if(DEBUG){
Vector3 norm = vertices[n]->GetNormal();
printf("\t%f %f %f\n", norm.x, norm.y, norm.z);
}
n++;
}
//------ Load Skin Weights ------
} else if(strcmp(temp, "skinweights")==0){
t.GetInt();
t.FindToken("{");
int n = 0;
if(DEBUG)
printf("skinweights %d\n", numVerts);
while(n < numVerts){
int numAttachments = t.GetInt();
vertices[n]->numAttachments = numAttachments;
updatedVertices[n]->numAttachments = numAttachments;
if(DEBUG)
printf("\t%d ", numAttachments);
int a = 0;
while(a < numAttachments){
int jointNum = t.GetInt();
float weight = t.GetFloat();
vertices[n]->skinweights[a] = weight;
vertices[n]->joints[a] = jointNum;
updatedVertices[n]->skinweights[a] = weight;
updatedVertices[n]->joints[a] = jointNum;
a++;
if(DEBUG)
printf("%d %f ", jointNum, weight);
}
if(DEBUG)
printf("\n");
n++;
}
//------ Load Triangles ------
} else if(strcmp(temp, "triangles")==0){
numTriangles = t.GetInt();
triangles = std::vector<Triangle *>(numTriangles);
t.FindToken("{");
int n = 0;
if(DEBUG)
printf("triangles %d\n", numTriangles);
while(n < numTriangles){
triangles[n] = new Triangle();
triangles[n]->SetVertices(t.GetInt(), t.GetInt(), t.GetInt());
if(DEBUG){
Triangle *t = triangles[n];
printf("\t%d %d %d\n", t->GetVertex1(), t->GetVertex2(), t->GetVertex3());
}
n++;
}
//------ Load Binding Matrices ------
} else if(strcmp(temp, "bindings")==0){
//.........这里部分代码省略.........
示例4: Load
bool Channel::Load(Tokenizer &token) {
char temp[256];
token.FindToken("extrapolate");
for (int j = 0; j < 2; j++) {
token.GetToken(temp);
if (strcmp(temp, "constant") == 0) {
extrap[j] = 'k';
} else if (strcmp(temp, "linear") == 0) {
extrap[j] = 'l';
} else if (strcmp(temp, "cycle") == 0) {
extrap[j] = 'c';
} else if (strcmp(temp, "cycle_offset") == 0) {
extrap[j] = 'o';
} else if (strcmp(temp, "bounce") == 0) {
extrap[j] = 'b';
}
}
token.FindToken("keys");
int numKeys = token.GetInt();
token.FindToken("{");
for (int i = 0; i < numKeys; i++) {
Keyframe newKeyframe = Keyframe();
newKeyframe.Time = token.GetFloat();
newKeyframe.Value = token.GetFloat();
token.GetToken(temp);
if (strcmp(temp, "flat") == 0) {
newKeyframe.RuleIn = 'f';
newKeyframe.TangentIn = 0;
} else if (strcmp(temp, "linear") == 0) {
newKeyframe.RuleIn = 'l';
} else if (strcmp(temp, "smooth") == 0) {
newKeyframe.RuleIn = 's';
} else {
newKeyframe.RuleIn = 'f';
newKeyframe.RuleIn = atof(temp);
}
token.GetToken(temp);
if (strcmp(temp, "flat") == 0) {
newKeyframe.RuleOut = 'f';
newKeyframe.TangentOut = 0;
} else if (strcmp(temp, "linear") == 0) {
newKeyframe.RuleOut = 'l';
} else if (strcmp(temp, "smooth") == 0) {
newKeyframe.RuleOut = 's';
} else {
newKeyframe.RuleOut = 'f';
newKeyframe.TangentOut = atof(temp);
}
keyframes.push_back(newKeyframe);
}
startTime = keyframes[0].Time;
endTime = keyframes[keyframes.size()-1].Time;
preCompute();
return true;
}