C++ 相同的声明和类型编译器错误。(xyz*类型的参数与xyz*类型的参数不兼容)
在这里尝试创建一个基本类 头文件C++ 相同的声明和类型编译器错误。(xyz*类型的参数与xyz*类型的参数不兼容),c++,methods,C++,Methods,在这里尝试创建一个基本类 头文件 namespace Ogre { class Vector3; class SceneManager; class Entity; class Quaternion; } class RayCasting { public: bool RayCastFromPoint( const Ogre::Vector3 &point, const Ogre::Vector3 &no
namespace Ogre
{
class Vector3;
class SceneManager;
class Entity;
class Quaternion;
}
class RayCasting
{
public:
bool RayCastFromPoint(
const Ogre::Vector3 &point,
const Ogre::Vector3 &normal,
Ogre::Vector3 &result,
Ogre::SceneManager& scnMgrRef);
private:
void GetMeshInformation(
Ogre::Entity* entity,
Ogre::Vector3* vertices,
size_t &indexCount,
unsigned long* indices,
const Ogre::Vector3& position,
const Ogre::Quaternion& orient,
const Ogre::Vector3& scale
);
};
#include "RayCasting.h"
#include <OGRE/OgreMath.h>
#include <OgreRay.h>
#include <OgreSceneManager.h>
#include <OgreEntity.h>
#include <OgreSceneNode.h>
#include <OgreNode.h>
#include <OgreMath.h>
#include <OgreSubMesh.h>
#include <OgreSubEntity.h>
#include <OgreMesh.h>
#include <OGRE/OgreVector3.h>
bool RayCasting::RayCastFromPoint(
const Ogre::Vector3 & point,
const Ogre::Vector3 & normal,
Ogre::Vector3 & result,
Ogre::SceneManager& scnMgrRef)
{
// get the entity to check
Ogre::Entity *collEntity = static_cast<Ogre::Entity*>(rayQueryResult[index].movable);
// mesh data to retrieve
size_t indexCount;
Ogre::Vector3* vertices = new Ogre::Vector3();
unsigned long* indices;
// get the mesh information
GetMeshInformation(collEntity, vertices, indexCount, indices,
collEntity->getParentNode()->_getDerivedPosition() // Returns a const Vector3
collEntity->getParentNode()->_getDerivedOrientation(), // Returns a const Vector3
collEntity->getParentNode()->_getDerivedScale()); // Returns a const Vector3
...
}
void RayCasting::GetMeshInformation(
Ogre::Entity * entity,
Ogre::Vector3* vertices,
size_t & indexCount,
unsigned long * indices,
const Ogre::Vector3 & position,
const Ogre::Quaternion & orient,
const Ogre::Vector3 & scale)
{
...
}
源文件
namespace Ogre
{
class Vector3;
class SceneManager;
class Entity;
class Quaternion;
}
class RayCasting
{
public:
bool RayCastFromPoint(
const Ogre::Vector3 &point,
const Ogre::Vector3 &normal,
Ogre::Vector3 &result,
Ogre::SceneManager& scnMgrRef);
private:
void GetMeshInformation(
Ogre::Entity* entity,
Ogre::Vector3* vertices,
size_t &indexCount,
unsigned long* indices,
const Ogre::Vector3& position,
const Ogre::Quaternion& orient,
const Ogre::Vector3& scale
);
};
#include "RayCasting.h"
#include <OGRE/OgreMath.h>
#include <OgreRay.h>
#include <OgreSceneManager.h>
#include <OgreEntity.h>
#include <OgreSceneNode.h>
#include <OgreNode.h>
#include <OgreMath.h>
#include <OgreSubMesh.h>
#include <OgreSubEntity.h>
#include <OgreMesh.h>
#include <OGRE/OgreVector3.h>
bool RayCasting::RayCastFromPoint(
const Ogre::Vector3 & point,
const Ogre::Vector3 & normal,
Ogre::Vector3 & result,
Ogre::SceneManager& scnMgrRef)
{
// get the entity to check
Ogre::Entity *collEntity = static_cast<Ogre::Entity*>(rayQueryResult[index].movable);
// mesh data to retrieve
size_t indexCount;
Ogre::Vector3* vertices = new Ogre::Vector3();
unsigned long* indices;
// get the mesh information
GetMeshInformation(collEntity, vertices, indexCount, indices,
collEntity->getParentNode()->_getDerivedPosition() // Returns a const Vector3
collEntity->getParentNode()->_getDerivedOrientation(), // Returns a const Vector3
collEntity->getParentNode()->_getDerivedScale()); // Returns a const Vector3
...
}
void RayCasting::GetMeshInformation(
Ogre::Entity * entity,
Ogre::Vector3* vertices,
size_t & indexCount,
unsigned long * indices,
const Ogre::Vector3 & position,
const Ogre::Quaternion & orient,
const Ogre::Vector3 & scale)
{
...
}
及
问题2
GetMeshInformation(…,顶点…)抛出一个E0167错误,指出
cannot convert to incomplete class "const Ogre::Vector3" Ogre3DProjectTemplate E:\_PROGRAMMING\GEA-term2\Ogre_Projects\Tutorials2\Ogre3DProjectTemplate\RayCasting.cpp 91
问题3
此外,GetMeshInformation(…,…->_GetDerivedPosition(),…)行生成一个E0515错误声明
declaration is incompatible with "bool RayCasting::RayCastFromPoint(const Ogre::Vector3 &point, const Ogre::Vector3 &normal, Ogre::Vector3 &result, Ogre::SceneManager &scnMgrRef)" (declared at line 20 of "E:\_PROGRAMMING\GEA-term2\Ogre_Projects\Tutorials2\Ogre3DProjectTemplate\RayCasting.h") Ogre3DProjectTemplate E:\_PROGRAMMING\GEA-term2\Ogre_Projects\Tutorials2\Ogre3DProjectTemplate\RayCasting.cpp 29
`
*"cannot convert to incomplete class const Ogre::Vector3"*, despite the include being present in the Source file. The scale() method also throws this error.
简单来说,我的问题是:
什么。见鬼去吧。正在发生。显然,通过放弃并在头文件中包含OgreMath.h,可以解决头文件中转发声明Ogre::Vectrat的所有问题。1)除了提供消息外,请复制粘贴消息,而不是转述消息。2) 标题包含声明
void GetMeshInformation(…,Ogre::Vector3*顶点,…)
,而定义是void RayCasting::GetMeshInformation(…,Ogre::Vector3*&顶点,…)
(与索引的区别类似)。@AlgirdasPreidžius嘿,对不起。我已经粘贴了消息,这应该是最小的和完整的,但没有食人魔可能无法验证。我已经在2中做了更改,不敢相信我错过了,但这个问题仍然没有解决(请阅读链接)。例如,一些错误提示您转发声明的类,而不是在使用时定义的类。因此,即使定义在OGRE/OgreVector3.h
中,也不清楚这些定义是否在OGRE
名称空间中进行,它们在名称空间中被向前声明。