C++从函数错误中返回GLM矩阵:的左侧必须具有类/结构/并集



我正试图从Java中使用的函数返回GLM矩阵,但在C++中,它给了我一个"错误C2228:'.createTransformationMatrix'的左侧必须具有class/struct/union"

头文件

#ifndef MATHS_H
#define MATHS_H
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glew.h> 
#include <string>
#include <vector>
class Maths
{
public:
static glm::mat4 createTransformationMatrix(glm::vec3 translation, float 
       rx, float ry,float rz, float scale);
};
#endif

CPP文件

#include"Maths.h"
glm::mat4 createTransformationMatrix(glm::vec3 translation, float rx, float   
     ry,float rz, float scale){
        glm::mat4 model = glm::mat4();
        //Do transformations
        return model;
 }

当我像这样从外部类调用这个函数时,就会出现错误。我不知道为什么这样做会出错。

 glm::mat4 transformation = glm::mat4();
     transformation = Maths.createTransformationMatrix(      
 glm::vec3(entity.getPosition()),1,1,1,1);

与Java相比,在C++中使用静态成员的语法有点不同。在类名和静态成员名之间,必须使用作用域运算符::,如下所示:

transformation = Maths::createTransformationMatrix(
    glm::vec3(entity.getPosition()),1,1,1,1);

最新更新