本文整理汇总了C++中Tokenizer::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokenizer::Open方法的具体用法?C++ Tokenizer::Open怎么用?C++ Tokenizer::Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer::Open方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 Skeleton::Load(const char *file) {
Tokenizer token;
token.Open(file);
token.FindToken("balljoint");
// Parse tree
Root = new Joint("Root");
Root->Load(token);
// Finish
token.Close();
return true;
}
示例3: Load
bool Skeleton::Load(const char *file){
filename = file;
Tokenizer token;
token.Open(file);
token.FindToken("balljoint");
Root = new Joint();
Root->Load(token);
Root->Initialize();
token.Close();
NumberJoints();
currentJointNum = 0;
currentJoint = joints[0];
return true;
}
示例4: Load
bool Skin::Load(const char *file) {
WorldMtx.Identity();
Tokenizer * token = new Tokenizer();
token->Open(file);
token->FindToken("balljoint");
// Parse tree
root = new Joint();
root->Load(*token);
//Finish
token->Close();
return true;
}
示例5: morph
bool Skin::morph(const char *file) {
Tokenizer token;
token.Open(file);
int count;
token.FindToken("positions");
count = token.GetInt();
token.FindToken("{");
float x;
float y;
float z;
int vIdx;
for (int i = 0; i < count; i++) {
vIdx = token.GetInt();
x = token.GetFloat();
y = token.GetFloat();
z = token.GetFloat();
vertices[vIdx].setPosition(Vector3(x, y, z));
}
token.FindToken("normals");
token.FindToken("{");
for (int i = 0; i < count; i++) {
vIdx = token.GetInt();
x = token.GetFloat();
y = token.GetFloat();
z = token.GetFloat();
vertices[vIdx].setNormal(Vector3(x, y, z));
}
// Finish
token.Close();
return true;
}
示例6: 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){
//.........这里部分代码省略.........
示例7: 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();
//.........这里部分代码省略.........