Camera* FBXLoader::ConstructCamera(KFbxNode* node) { KFbxCamera* cam; GLfloat* look; int test; KFbxVector4 tmp; Camera* camera; camera = new Camera(); cam = (KFbxCamera*) node->GetNodeAttribute(); look = new GLfloat[3]; camera->SetWidth(cam->AspectWidth.Get()); camera->SetHeight(cam->AspectHeight.Get()); camera->SetFov(cam->FieldOfView.Get()); camera->SetFar(cam->FarPlane.Get()); camera->SetNear(cam->NearPlane.Get()); camera->SetUpV(cam->UpVector.Get()); look[0] = cam->InterestPosition.Get()[0]; look[1] = cam->InterestPosition.Get()[1]; look[2] = cam->InterestPosition.Get()[2]; tmp[0] = look[0] - cam->Position.Get()[0]; tmp[1] = look[1] - cam->Position.Get()[1]; tmp[2] = look[2] - cam->Position.Get()[2]; tmp.Normalize(); camera->SetForw(tmp); if (cam->ProjectionType.Get() == KFbxCamera::eORTHOGONAL) test = 0; else test = 1; delete [] look; return (camera); }
Object* FBXLoader::GetAttributeTypeName(KFbxNode* pNode, KFbxNodeAttribute::EAttributeType type) { Object* Obj; Camera* Cam; fbxDouble3 trans; Scene* scene; KFbxVector4 tmp; Obj = NULL; Cam = NULL; // tmp = new KFbxVector4(); // if (strcmp(pNode->GetName(), "spawn") == 0) // std::cout<<"toto"<<std::endl; if (type == KFbxNodeAttribute::eUNIDENTIFIED) { // std::cout<<"pNode->GetName() "<<pNode->GetName()<<std::endl; return (Obj); } else if (type == KFbxNodeAttribute::eNULL) { if (strcmp(pNode->GetName(), "spawn") == 0) { scene = Scene::GetInstance(); trans = pNode->LclTranslation.Get(); Cam = new Camera(); Cam->InitPos(trans[0], trans[1], trans[2]); scene->AddCam(Cam); } else if (strcmp(pNode->GetName(), "Camera001.Target") == 0) { scene = Scene::GetInstance(); // std::cout<<"size "<< // tmp[0] = trans[0] - (*scene->GetCamList())[2]->GetCam()->GetOriginX(); // tmp[1] = trans[1] - (*scene->GetCamList())[2]->GetCam()->GetOriginY(); // tmp[2] = trans[2] - (*scene->GetCamList())[2]->GetCam()->GetOriginZ(); // tmp.Normalize(); // (*scene->GetCamList())[2]->SetForw(tmp); } std::cout<<"pNode->GetName() "<<pNode->GetName()<<std::endl; trans = pNode->LclTranslation.Get(); std::cout<<"x,y,z"<<trans[0]<<" "<<trans[0]<<" "<< trans[2]<<std::endl; return (Obj); } else if (type == KFbxNodeAttribute::eMARKER) return (Obj); else if (type == KFbxNodeAttribute::eSKELETON) return (Obj); else if (type == KFbxNodeAttribute::eMESH) { Obj = this->ConstructBatch(pNode->GetMesh()); return (Obj); } else if (type == KFbxNodeAttribute::eNURB) return (Obj); else if (type == KFbxNodeAttribute::ePATCH) return (Obj); else if (type == KFbxNodeAttribute::eCAMERA) { scene = Scene::GetInstance(); trans = pNode->LclTranslation.Get(); Cam = this->ConstructCamera(pNode); // std::cout<<"pNode->GetName() "<<pNode->GetName()<<std::endl; if (Cam != NULL) { // if (strcmp(pNode->GetName(), "spawn") == 0) // std::cout<<"toto"<<std::endl; std::cout<<"cam"<<std::endl; std::cout<<"x,y,z"<<trans[0]<<" "<<trans[0]<<" "<< trans[2]<<std::endl; Cam->InitPos(trans[0], trans[1], trans[2]); tmp[0] = (-36.8353) - trans[0]; tmp[1] = (-36.8353) - trans[1]; tmp[2] = 17.2166 - trans[2]; tmp.Normalize(); std::cout<<"tmp "<<tmp[0]<<" "<<tmp[1]<<" "<<tmp[2]<<std::endl; Cam->SetForw(tmp); scene->AddCam(Cam); } return (NULL); } else if (type == KFbxNodeAttribute::eCAMERA_STEREO) return (Obj); else if (type == KFbxNodeAttribute::eCAMERA_SWITCHER) return (Obj); else if (type == KFbxNodeAttribute::eLIGHT) return (Obj); else if (type == KFbxNodeAttribute::eOPTICAL_REFERENCE) { std::cout<<"pNode->GetName() "<<pNode->GetName()<<std::endl; return (Obj); } else if (type == KFbxNodeAttribute::eOPTICAL_MARKER) return (Obj); else if (type == KFbxNodeAttribute::eNURBS_CURVE) return (Obj); else if (type == KFbxNodeAttribute::eTRIM_NURBS_SURFACE) return (Obj); else if (type == KFbxNodeAttribute::eBOUNDARY) return (Obj); else if (type == KFbxNodeAttribute::eNURBS_SURFACE) return (Obj); else if (type == KFbxNodeAttribute::eSHAPE) return (Obj); else if (type == KFbxNodeAttribute::eLODGROUP) return (Obj); else if (type == KFbxNodeAttribute::eSUBDIV) return (Obj); return (Obj); }