2016-07-01 24 views
6

Quat'ı glm'ye mat4'e dönüştürmeye çalışıyorum.Matris kullanılarak Quaternion to Matris

Benim kodudur: i programı çalıştırdığınızda

#include <iostream> 
#include<glm/glm.hpp> 
#include<glm/gtc/quaternion.hpp> 
#include<glm/common.hpp> 
using namespace std; 


int main() 
{ 
    glm::mat4 MyMatrix=glm::mat4(); 
    glm::quat myQuat; 

    myQuat=glm::quat(0.707107,0.707107,0.00,0.000); 
    glm::mat4 RotationMatrix = quaternion::toMat4(myQuat); 

    for(int i=0;i<4;++i) 
    { 
     for(int j=0;j<4;++j) 
     { 
      cout<<RotationMatrix[i][j]<<" "; 
     } 
     cout<<"\n"; 
    } 
    return 0; 
} 

o hata gösteriyor "hatası:‘Dördey’ilan edilmemiştir".

Bu konuda bana yardımcı olan var mı?

#include <glm/gtx/quaternion.hpp> 

Ve toMat4 ait ad düzeltmek:

+1

#include <glm/gtx/quaternion.hpp> mu gerektirmez

glm::mat4 RotationMatrix = glm::mat4_cast(myQuat); 

'Dördey :: toMat4'' glm :: Dördey olması gerekiyor :: toMat4'? – NathanOliver

cevap

8

include ekle

glm::mat4 RotationMatrix = glm::toMat4(myQuat); 

glm::toMat4() sadece glm ad alanına sahip you can seegtx/quaternion.hpp dosyasında bulunmaktadır

. Bir yan not olarak da

, C++, 14 olarak, iç içe ad alanları (örneğin glm :: Dördey :: toMat4) are not allowed.

0

meepzh cevabı yanı sıra, aynı zamanda böyle yapılabilir: