Reputation: 61
I'm experiencing with OpenGL and I built and edit a Vector3 header that works perfectly that works with struct Vector3
but the problem starts when I tried create a Vector3 zero = Vector3(0,0,0)
variable, the compiler doesn't let me build due to the compiling order so I copied a new Vector3 library from Internet and I get this error: "Vector3 does not name a type"
. I suppose is cause the order of compiling, I'll share where I get the error and the libraries. First this is the 2 files I'm using http://leetnightshade.com/c-vector3-class I'm only using Vector3.cpp and Vector3.h, and this code is made from me and is where I get the error (this is a header file called by the main.cpp file named GameObject.h):
#include "Vector3.h"
GLfloat cube[] =
{
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f
};
GLfloat Space3D_X[] =
{
0.0f, 0.0f, -100,
0.0f, 0.0f, 100
};
GLfloat Space3D_Y[] =
{
-100.0f, 0.0f, 0.0f,
100.0f, 0.0f, 0.0f
};
typedef struct GameObject
{
int ID, parent;
Vector3 position; ///<<<--------------------------HERE I GET THE ERROR VECTOR3 DOES NOT NAME A TYPE
Quaternion rotation;
};
struct GameObject GameObjects[65536];
class Natives
{
public:
int GameObjectsCount = 0;
inline int CreateCube (Vector3 _position, Quaternion _rotation, int _parent)
{
GameObjects[GameObjectsCount].ID = GameObjectsCount;
GameObjects[GameObjectsCount].parent = _parent;
GameObjects[GameObjectsCount].position = _position;
GameObjects[GameObjectsCount].rotation = _rotation;
GameObjectsCount ++;
return GameObjectsCount-1;
}
inline void SetGameObjectParent (int _gameObject, int _parent)
{
Vector3 _tempPos = GameObjects[_gameObject].position;
Quaternion _tempRot = GameObjects[_gameObject].rotation;
GameObjects[_gameObject].parent = _parent; /*** ATTACH GM TO OTHER GM WITHOUT CHANGE POSITION ***/
GameObjects[_gameObject].position.x = -(GameObjects[_parent].position.x - _tempPos.x); /*** IF YOU WANT TO ATTACH IT CHAING POSITION JUST ***/
GameObjects[_gameObject].position.z = -(GameObjects[_parent].position.z - _tempPos.z); /*** OVERWRITE THE PARENT WITH OOP SYNTAX ***/
GameObjects[_gameObject].rotation.rx = _tempRot.rx;
GameObjects[_gameObject].rotation.ry = _tempRot.ry;
GameObjects[_gameObject].rotation.rz = _tempRot.rz;
}
};
Natives native;
Focus on the 4 lines of struct GameObject that is where I get the error in the Vector3 position; line. I think I explain myself correctly. I made a scheme if you don't understand well http://gyazo.com/77189bef5576b047de5271f1b7d2d881. Thanks for Read.
Upvotes: 0
Views: 68
Reputation: 98416
The Vector3
library you link uses namespace _Warp
, so you should use it this way:
_Warp::Vector3 position;
PS: Be wary of any third-party library that uses reserved names as identifiers, because the writers may not know what they are doing. _Warp
is a reserved name for the compiler (it starts with _
plus uppercase) and should not be used by library or program code.
Upvotes: 1