void NavigationCell::debugDrawClassification( Ogre::Vector3 start, Ogre::Vector3 end )
{
    Ogre::Root *root = Ogre::Root::getSingletonPtr();
    Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
    Ogre::ManualObject* debug;
    Ogre::SceneNode* node;

    if( mgr->hasManualObject( "debugDrawClassification" ) )
        debug = mgr->getManualObject( "debugDrawClassification" );
    else
    {
        debug = mgr->createManualObject( "debugDrawClassification" );
        node = mgr->getRootSceneNode()->createChildSceneNode();
        node->attachObject( debug );
        node->translate( 0, 1, 0 );
        debug->setQueryFlags( 0 );
        debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
    }

    debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_LIST );
    debug->position( start );
    debug->position( end );
    debug->end();

//    debugDrawCell( debug, "debug/yellow", "debug/blue" );
}
void NavigationCell::debugDrawCellAndNeigbours()
{
    Ogre::Root *root = Ogre::Root::getSingletonPtr();
    Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
    Ogre::ManualObject* debug;
    Ogre::SceneNode* debugNode;

    if( mgr->hasSceneNode( "debugDrawNode" ) )
    {
        debugNode = mgr->getSceneNode( "debugDrawNode" );
    }
    else
    {
        debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode" );
        debugNode->translate( 0, 1, 0 );    // Move up slightly to see lines better.
    }

    if( mgr->hasManualObject( "debugDraw" ) )
        debug = mgr->getManualObject( "debugDraw" );
    else
    {
        debug = mgr->createManualObject( "debugDraw" );
        debugNode->attachObject( debug );
        debug->setQueryFlags( 0 );
        debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
    }

    for( int i = 0; i < 3; i++ )
    {
        if( mLinks[i] )
        {
            debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_STRIP );
            debug->position( mLinks[i]->mVertices[0] );
            debug->position( mLinks[i]->mVertices[1] );
            debug->position( mLinks[i]->mVertices[2] );
            debug->position( mLinks[i]->mVertices[0] );
            debug->end();
        }
    }

    debug->begin( "debug/yellow", Ogre::RenderOperation::OT_LINE_STRIP );
    debug->position( mVertices[0].x, mVertices[0].y+1, mVertices[0].z );
    debug->position( mVertices[1].x, mVertices[1].y+1, mVertices[1].z );
    debug->position( mVertices[2].x, mVertices[2].y+1, mVertices[2].z );
    debug->position( mVertices[0].x, mVertices[0].y+1, mVertices[0].z );
    debug->end();

}
void NavigationMesh::setShow( bool show )
{
    Ogre::Root *root = Ogre::Root::getSingletonPtr();
    Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
    Ogre::ManualObject* debug;
    Ogre::SceneNode* debugNode;

    mShow = show;

    if( mgr->hasSceneNode( "debugDrawNode2" ) )
    {
        debugNode = mgr->getSceneNode( "debugDrawNode2" );
    }
    else
    {
        debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode2" );
        debugNode->translate( 0, 1, 0 );    // Move up slightly to see lines better.
    }

    if( mgr->hasManualObject( "debugDraw2" ) )
        debug = mgr->getManualObject( "debugDraw2" );
    else
    {
        debug = mgr->createManualObject( "debugDraw2" );
        debugNode->attachObject( debug );
        debug->setQueryFlags( 0 );
        debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
    }

    if( !mShow )
    {
        mgr->destroyManualObject( debug );
        return;
    }

    for( CellVector::iterator i = mCells.begin(); i != mCells.end(); i++ )
    {
        i->debugDrawCell( debug, "debug/yellow", "debug/blue" );
    }

    return;
}
示例#4
0
Tank* TankManager::createTank(const Ogre::Vector3& position, int side, Graph* pathFindingGraph, PathFinding mPathFinder){
	int tankNumber = tankSideA.size() + tankSideB.size();
	std::ostringstream oss1;
	oss1 << "tankbody" << tankNumber;

	Ogre::Entity* tankBody = mSceneMgr->createEntity(oss1.str(), "lpbody.mesh");
	tankBody->setCastShadows(true);

	std::ostringstream oss2;
	oss2 << "tankturret" << tankNumber;

	// Create tank turret entity
	Ogre::Entity* tankTurret = mSceneMgr->createEntity(oss2.str(), "lpturret.mesh");
	tankTurret->setCastShadows(true);

	std::ostringstream oss3;
	oss3 << "tankbarrel" << tankNumber;

	// Create tank barrel entity
	Ogre::Entity* tankBarrel = mSceneMgr->createEntity(oss3.str(), "lpbarrel.mesh");
	tankBarrel->setCastShadows(true);

	// Create a child scene node and attach tank body to it
	Ogre::SceneNode* mTankBodyNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
	mTankBodyNode->attachObject(tankBody);
	// Move it above the ground
	mTankBodyNode->translate(position.x, position.y + 13.f, position.z);

	if(side == 1){
		tankBody->setMaterialName("lp_tank_materialred");
		tankTurret->setMaterialName("lp_tank_materialred");
		tankBarrel->setMaterialName("lp_tank_materialred");

		mTankBodyNode->yaw(Ogre::Degree(180.f));
	}
	else if(side == 2)
	{
		tankBody->setMaterialName("lp_tank_materialblue");
		tankTurret->setMaterialName("lp_tank_materialblue");
		tankBarrel->setMaterialName("lp_tank_materialblue");
	}

	// Create a child scene node from tank body's scene node and attach the tank turret to it
	Ogre::SceneNode* mTankTurretNode = mTankBodyNode->createChildSceneNode();
	mTankTurretNode->attachObject(tankTurret);
	// Move it above tank body
	mTankTurretNode->translate(0.f, 3.f, 0.f);

	// Create a child scene node from tank turret's scene node and attach the tank barrel to it
	Ogre::SceneNode* mTankBarrelNode = mTankTurretNode->createChildSceneNode();
	mTankBarrelNode->attachObject(tankBarrel);
	// Move it to the appropriate position on the turret
	mTankBarrelNode->translate(-30.f, 10.f, -1.5f);

	//WEE ADDED HERE TO MAKE THE MANUAL OBJECT
		std::string pathName = "AStarPath" + std::to_string(tankNumber);
		Ogre::ManualObject* aStarPath = mSceneMgr->createManualObject(pathName);
		aStarPath->clear();
		aStarPath->setQueryFlags(0);
		mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(aStarPath);

	Tank* newTank = new Tank(mSceneMgr->createBillboardSet(), mSceneMgr->createBillboardSet(),
		mTankBodyNode, mTankTurretNode, mTankBarrelNode, this, pathFindingGraph, mPathFinder, aStarPath, side, mSceneMgr, tankBody, tankTurret, tankBarrel);

	newTank->resetAll();
	
	if (side == 1)
	{
		tankSideA.insert(newTank);
	} else if(side == 2){
		tankSideB.insert(newTank);
	}

	return newTank;
}