compile Irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dennisbarnes
Posts: 12
Joined: Sun Aug 19, 2007 1:11 am
Location: Atlanta Ga U.S.A

compile Irrlicht

Post by dennisbarnes »

Hello this is the frist time I try to compile Irrlicht using code block
when i try to run the program I get 1 errors and 5 warnings Can some one help me
thankyou


Project : Irrlicht Project
Compiler : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : C:\irrlicht\myproject\
--------------------------------------------------------------------------------
Switching to target: default
GamePathManager.cpp
source\ai\GamePathManager.cpp(23) : error C2084: function 'CGamePathManager::CGamePathManager(void)' already has a body
c:\irrlicht\myproject\source\ai\GamePathManager.h(23) : see previous definition of '__ctor'
source\ai\GamePathManager.cpp(60) : warning C4018: '<' : signed/unsigned mismatch
source\ai\GamePathManager.cpp(164) : warning C4018: '<' : signed/unsigned mismatch
source\ai\GamePathManager.cpp(229) : warning C4244: 'argument' : conversion from 'int' to 'irr::f32', possible loss of data
source\ai\GamePathManager.cpp(229) : warning C4244: 'argument' : conversion from 'int' to 'irr::f32', possible loss of data
source\ai\GamePathManager.cpp(229) : warning C4244: 'argument' : conversion from 'int' to 'irr::f32', possible loss of data
Process terminated with status 1 (0 minutes, 5 seconds)
1 errors, 5 warnings
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

This is not an error from compiling Irrlicht, but from compiling an app using Irrlicht.
You seem to have a body in both the .h and .cpp file. But it's your code, we don't know it.
lukrop
Posts: 27
Joined: Wed Aug 29, 2007 10:28 am
Location: Vienna, Austria

Post by lukrop »

this is irrWizard code... check if you got the latest version and then try it again or delete one of the two bodys (normally the body is in the .cpp file and not in the .h file)
dennisbarnes
Posts: 12
Joined: Sun Aug 19, 2007 1:11 am
Location: Atlanta Ga U.S.A

Post by dennisbarnes »

Hello when you said delete one of the two body

did you mean one of the CGamePathManager::CGamePathManager()
as the body


#include "GamePathManager.h"


//! Default constructor
CGamePathManager::CGamePathManager()
{
}

//! Default destructor
CGamePathManager::CGamePathManager()
{
}

//! About interface function for manager
void CGamePathManager::About()
{

}

//! Load interface function for manager
bool CGamePathManager::Init()
{
// Use a very small memory block to stress the pather
pather = new MicroPather( this, 20 );
return true;
}

//! Perform interface function for manager
bool CGamePathManager::Update()
{
return true;
}

//! Destroy interface function for manager
bool CGamePathManager::Clear()
{

adjacentNodes->clear();
waypoints.clear();
pather->Reset();
return false;
}

//! Returns the node number for a given element in the path created by the
//! Pather.
int CGamePathManager::getPathFor(int index)
{
if (index < path.size())
return (int)path[index];
else
return 0;

}

//! Returns a pointer to the Path vector created by the pather, this contains
//! all of the waypoints (vector3df) from the current node to the target.
void* CGamePathManager::getPath(int index)
{
return &path[index];
}

//! Returns an adjacent node to tyhe node specified
void* CGamePathManager::getAdjacentNode(int node)
{
return (void*) ( 1 );
}

//! Returns the least cost estimate from any 2 given nodes. For this implementation
//! all costs are considered the same, ie 1. For RTS games that might weight paths
//! differently, ie water could equal 5 and uneven or sloped terain 3 for example. The
//! shortest route in that situation may not the the most optimal one.
float CGamePathManager::LeastCostEstimate( void* nodeStart, void* nodeEnd )
{
return 1;
}

//! Builds a list of adjacent neighbours and their costs, again, for this implementaion
//! all costs are considered equal, ie 1 (see above)
void CGamePathManager::AdjacentCost( void* node, std::vector< StateCost > *neighbors )
{
for (irr::u32 loop=0; loop < adjacentNodes[(int) node].size(); loop++)
{
StateCost nodeCost = { (void*) adjacentNodes[(int) node][loop], 1 };
neighbors->push_back( nodeCost );
}
}

//! Used for debuging the Pather, not implemented.
void CGamePathManager::PrintStateInfo( void* node )
{
// implement here
}

//! Calls the Pather to solve. Given the start node and the end node, the sequence of nodes
//! from start to end will be written to the std::vector &path.
int CGamePathManager::calculatePath(int startNode, int endNode)
{
float totalCost;
int result = pather->Solve( (void*)startNode, (void*)endNode, &path, &totalCost );
return result;
}

//! Returns the waypoint at a given position in the waypoint list
irr::core::vector3df CGamePathManager::getWaypointAt(int index)
{
for (irr::u32 i=0; i < waypoints.size(); i++) {
if (i == index)
return waypoints;
}
}

//! Returns the node number at any given waypoint.
int CGamePathManager::getWaypointNode(irr::core::vector3df waypoint)
{
for (irr::u32 i=0; i < waypoints.size(); i++) {
if (waypoints == waypoint)
return i;
}
return 0;
}

//! Returns the nearest node to any given point, generally the players camera. The
//! Pather requires a target node, and the player will very rarely be exaclty at
//! any given node. This function scans the list of nodes calculating the distance
//! between, returning the shortest one.
int CGamePathManager::getNearestWaypointNode(const irr::core::vector3df pos)
{
irr::f64 m_iClosestDistance = 64000;
irr::f64 m_iCurrentDistance = 64000;
int m_iNodeIndex = 0;

for (irr::u32 i=0; i < waypoints.size(); i++)
{
m_iCurrentDistance = pos.getDistanceFrom(waypoints);
if (m_iCurrentDistance < m_iClosestDistance)
{
m_iClosestDistance = m_iCurrentDistance;
m_iNodeIndex = i;
}
}
return m_iNodeIndex;
}

//! Returns the furthest node to any given point, generally the players camera,
//! see above. This function would be used for enemy evade behaviour.
int CGamePathManager::getFurthestWaypointNode(const irr::core::vector3df pos)
{
irr::f64 m_iFurthestDistance = 0;
irr::f64 m_iCurrentDistance = 0;
int m_iNodeIndex = 0;

for (int i=0; i < waypoints.size(); i++)
{
m_iCurrentDistance = pos.getDistanceFrom(waypoints);
if (m_iCurrentDistance > m_iFurthestDistance)
{
m_iFurthestDistance = m_iCurrentDistance;
m_iNodeIndex = i;
}
}
return m_iNodeIndex;
}

//! Adds an adjacent node for a specified node. To be set as part of the initialisation
//! process in the game level state Init{} function.
void CGamePathManager::setAdjacentNode(int node, int value)
{
adjacentNodes[node].push_back(value);
}

//! Adds a waypoint to the list of waypoints. This needs to be done in order, ie the first
//! waypoint added will be 0, then 1,2,3,4 etc. To be set as part of the initialisation
//! process in the game level state Init{} function.
void CGamePathManager::setWaypoint(irr::core::vector3df waypoint)
{
waypoints.push_back(waypoint);
}

//! returns a random waypoint (unoccupied would also be nice)
irr::core::vector3df CGamePathManager::getRandomWaypoint()
{
return getWaypointAt(rand() % waypoints.size());
}

//! Read in navGraph using xml file
//!<Nodes value="NavGraph">
//! <Node id="0" posX="110" posY="-9" posZ="86">
//! <AdjacentNode id="1" cost="1"/>
//! <AdjacentNode id="16" cost="1"/>
//! </Node>
//!</Nodes>
bool CGamePathManager::loadNavGraph(const char *fileName)
{
TiXmlDocument doc;
TiXmlAttribute *attr;

if(!doc.LoadFile(fileName))
{
cout <<"\n Error while loading NavGraph"<<endl;
cout <<"NavGraph file malformed or is not there"<<endl;
cout <<doc.ErrorDesc()<<" at line :"<<doc.ErrorRow()<<endl;
return false;
}

TiXmlNode * iNode = doc.FirstChild( "Nodes" );
if( iNode != NULL )
{
// Node
TiXmlNode * node = iNode->FirstChild( "Node" );
while( node != NULL )
{
TiXmlElement* NodeValue = node->ToElement();
TiXmlAttribute * attr=NodeValue->FirstAttribute();
// node attributes
setWaypoint(irr::core::vector3df(convertToInt(NodeValue->Attribute("posX")),
convertToInt(NodeValue->Attribute("posY")),
convertToInt(NodeValue->Attribute("posZ"))));
// Adjacent Node
TiXmlNode * adjacentNode = node->FirstChild("AdjacentNode");
while ( adjacentNode != NULL)
{
TiXmlElement* AdjacentNodeValue =
adjacentNode->ToElement();
TiXmlAttribute* adjAttr=AdjacentNodeValue->FirstAttribute();
// Adjacentnode attributes
setAdjacentNode(convertToInt(NodeValue->Attribute("id")),convertToInt(AdjacentNodeValue->Attribute("id")));
adjacentNode = node->IterateChildren( "AdjacentNode", adjacentNode );
}
node = iNode->IterateChildren( "Node", node );
}
}
cout << "Loaded NavGraph from " << fileName <<endl;
return true;
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess you want the second constructor become a destructor. Also note that empty constructors and destructor are default constructed by the compiler, so it's better to avoid those. You only need them if you want to change virtuality (of the destructor), make them private, or really initialise or destroy something (which should be definitely done in most cases, e.g. you might call Init and Clear).
Post Reply