summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-04-06 21:10:36 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-04-06 21:10:36 +0200
commit21fb3fbcaf9e557fd382991350b84672e659a18d (patch)
tree18614becb32e7ba7a575622f7714b1cbe5f4ac84
parentbe8a026915b794285333ffab24a8dee3c30d1340 (diff)
Dual pattern test.
-rw-r--r--application.cpp3
-rw-r--r--application.h1
-rwxr-xr-xassimp.cpp107
3 files changed, 109 insertions, 2 deletions
diff --git a/application.cpp b/application.cpp
index c05f30a..a1b9d22 100644
--- a/application.cpp
+++ b/application.cpp
@@ -124,7 +124,7 @@ void Application::main_loop(void) {
ARMarkerInfo* marker_info;
int marker_num;
- if(arDetectMarker(dataPtr, 100, &marker_info, &marker_num) < 0) {
+ if(arDetectMarker(dataPtr, 50, &marker_info, &marker_num) < 0) {
throw(std::runtime_error("arDetectMarker() failed."));
}
@@ -139,6 +139,7 @@ void Application::main_loop(void) {
glDepthFunc(GL_LEQUAL);
patt->update(marker_info, marker_num);
+ patt2->update(marker_info, marker_num);
glDisable( GL_DEPTH_TEST );
diff --git a/application.h b/application.h
index 5befce1..17fe011 100644
--- a/application.h
+++ b/application.h
@@ -19,6 +19,7 @@ class Application {
public:
Pattern* patt;
+ Pattern* patt2;
Application();
~Application();
diff --git a/assimp.cpp b/assimp.cpp
index f5aab14..aea1187 100755
--- a/assimp.cpp
+++ b/assimp.cpp
@@ -19,7 +19,7 @@ class FiskPattern : public Pattern {
Texture** textures;
public:
- FiskPattern() : Pattern("patt.jon") {
+ FiskPattern() : Pattern("patterns/m1.patt") {
scene = importer->ReadFile("tewi.x", 0);
if(scene) {
@@ -107,6 +107,106 @@ class FiskPattern : public Pattern {
}
};
+class MarisaPattern : public Pattern {
+ private:
+ const aiScene* scene;
+
+ Texture** textures;
+
+ public:
+ MarisaPattern() : Pattern("patterns/m2.patt") {
+ scene = importer->ReadFile("kirisame_marisa.x", 0);
+
+ if(scene != NULL) {
+ std::cout << "Loaded model: " << scene->mNumMeshes << " meshes, " << scene->mNumMaterials << " materials." << std::endl;
+ for(int i = 0; i < scene->mNumMaterials; i++) {
+ aiMaterial* material = scene->mMaterials[i];
+
+ std::cout << "Material " << i << ": " << material->mNumProperties << " properties." << std::endl;
+
+ for(int j = 0; j < material->mNumProperties; j++) {
+ aiMaterialProperty* property = material->mProperties[j];
+
+ std::cout << " " << std::string(property->mKey.data, property->mKey.length) << ": " << std::string(property->mData, property->mDataLength) << std::endl;
+ }
+
+ }
+
+ for(int i = 0; i < scene->mNumMeshes; i++) {
+ aiMesh* mesh = scene->mMeshes[i];
+
+ std::cout << "Mesh " << i << ": mMaterialIndex = " << mesh->mMaterialIndex << ", mNumBones = " << mesh->mNumBones << std::endl;
+
+ }
+
+ } else {
+ std::cerr << "Failed to import model." << std::endl << importer->GetErrorString() << std::endl;
+ }
+
+ Texture* tex_head = new TextureSDL("Ma-head.tga");
+ Texture* tex_1 = new TextureSDL("Marisa-1.bmp");
+ Texture* tex_B = new TextureSDL("B.spa");
+ Texture* tex_2 = new TextureSDL("Marisa-2.tga");
+ Texture* tex_S = new TextureSDL("S.spa");
+
+ textures = new Texture*[8];
+
+ //textures[0] = tex_head;
+ //textures[1] = tex_1;
+ //textures[2] = tex_B;
+ //textures[3] = tex_1;
+ //textures[4] = tex_B;
+ //textures[5] = tex_2;
+ //textures[6] = tex_1;
+ //textures[7] = tex_2;
+
+ textures[0] = tex_head; // face
+ textures[1] = tex_1; // body + hat
+ textures[2] = tex_B; // buttons
+ textures[3] = tex_2; // skirt, arms, hair, legs
+ textures[4] = tex_S; // accessories
+
+ patt_width = 10.0;
+ }
+
+ protected:
+ virtual void draw() {
+ double gl_para[16];
+ arglCameraView(patt_trans_kake, gl_para, 1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixd(gl_para);
+
+ //glTranslatef(0.0, -8.0, 0.0);
+
+ glRotatef(90, 1, 0, 0);
+ glRotatef(180, 0, 1, 0);
+
+ //glColor4f(1, 0, 0, 0.5);
+ glPolygonMode(GL_FRONT, GL_FILL);
+
+ for(int i = 0; i < scene->mNumMeshes; i++) { // scene->mNumMeshes
+ aiMesh* mesh = scene->mMeshes[i];
+
+ glBindTexture(GL_TEXTURE_2D, textures[i]->tex());
+
+ for(int j = 0; j < mesh->mNumFaces; j++) {
+ aiFace* face = &mesh->mFaces[j];
+
+ glBegin(GL_POLYGON);
+ for(int k = 0; k < face->mNumIndices; k++) {
+ aiVector3D* texcoord = &mesh->mTextureCoords[0][face->mIndices[k]];
+ glTexCoord2f(texcoord->x, 2 - texcoord->y);
+ aiVector3D* vertice = &mesh->mVertices[face->mIndices[k]];
+ glVertex3f(vertice->x, vertice->y, vertice->z);
+ }
+ glEnd();
+ }
+ }
+
+ }
+};
+
int main(int argc, char **argv) {
try {
Application* app = new Application();
@@ -116,6 +216,11 @@ int main(int argc, char **argv) {
app->patt = new FiskPattern();
+ Assimp::Importer _importer2;
+ importer = &_importer2;
+
+ app->patt2 = new MarisaPattern();
+
app->run();
} catch(std::runtime_error e) {
std::cerr << "Exception caught: " << e.what() << std::endl;