about the wowLikecamera in irrwizard

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
superpop
Posts: 21
Joined: Mon May 14, 2007 1:17 pm

about the wowLikecamera in irrwizard

Post by superpop »

I refer to this link
http://irrlicht.sourceforge.net/phpBB2 ... p?t=24054
The first problem is:

first, i use the fpscamera,i walk on the map and Note the current location,so i exit ,and i set the

Character Node at the position i noted.when i enter the game again,I found that it is not at the
position I set.
code

Code: Select all

// add irr::scene::IAnimatedMeshSceneNode* Character

void CGameStateLevel01::Init(CGameManager* pManager)
{
	.....
	Character = pManager->getSceneManager()->addAnimatedMeshSceneNode(pManager->getSceneManager()-

>getMesh("media/sydney.md2"));
Character->setMaterialFlag(video::EMF_LIGHTING, false); 
	Character->setFrameLoop(160, 183); 
	Character->setAnimationSpeed(40);       
	Character->setMD2Animation(scene::EMAT_STAND); 
	Character->setRotation(core::vector3df(0,270.0f,0)); 
	Character->setMaterialTexture(0,pManager->getDriver()->getTexture("media/sydney.bmp")); 
	Character->setPosition(core::vector3df(-838,118,-383)) ; 


	/*
	i added a IGUIStaticText to display some information,i use this to get the current player node
	*/
	pManager->setActivePlayerNode(Character);

	.....

}
the second problem is:
I use a third-person camera.When I had just entered the game,i can see the ground,But when I press the left

mouse button and move,the screen is a gray, the other can not see anything. i press the arrow keys,my

StaticText display my character node is moving .

code:

Code: Select all

// load map data
void CGamePlayState::loadMap(CGameManager* pManager, const c8* map, core::vector3df mapPosition, 

core::vector3df camPosition)
{		
	
	m_Selector = 0;
	
	scene::IAnimatedMesh* mesh = pManager->getSceneManager()->getMesh(map);
	scene::ISceneNode* node = 0;
	if (mesh)
		node = pManager->getSceneManager()->addOctTreeSceneNode(mesh->getMesh(0));
	if (node) 
	{
		node->setPosition(mapPosition);
        m_Selector = pManager->getSceneManager()->createOctTreeTriangleSelector(
            mesh->getMesh(0), node, 128);
		node->setTriangleSelector(m_Selector);
		m_Selector->drop();
	}
	pManager->setMetaSelector();
	pManager->getMetaSelector()->addTriangleSelector(m_Selector);
	....
}

void CGameStateLevel01::Init(CGameManager* pManager)
{
	CGamePlayState::Init(pManager);	
	
	CGamePlayState::loadMap(pManager, "aepyra.bsp", core::vector3df(-300,-144,-249),core::vector3df

(108,140,-140));

	CGamePlayState::setCamera(pManager,core::vector3df(-1,50,122));
	setCamera(pManager,core::vector3df(-1,50,122));
    
	// add player node
	Character = pManager->getSceneManager()->addAnimatedMeshSceneNode(pManager->getSceneManager()-

>getMesh("media/sydney.md2"));
	pManager->setActivePlayerNode(Character);
	

	irr::scene::ITriangleSelector* characterSelector = pManager->getSceneManager()-

>createTriangleSelectorFromBoundingBox(Character); 
	if(characterSelector) 
		pManager->getMetaSelector()->addTriangleSelector(characterSelector);

	scene::ISceneNodeAnimator* anim = pManager->getSceneManager()->createCollisionResponseAnimator( 
		pManager->getMetaSelector(), Character, core::vector3df(60,100,60), 
		core::vector3df(0,0,0), 
		core::vector3df(0,50,0)); 
	Character->addAnimator(anim);     
	anim->drop();

	Character->setMaterialFlag(video::EMF_LIGHTING, false); 
	Character->setFrameLoop(160, 183); 
	Character->setAnimationSpeed(40);       
	Character->setMD2Animation(scene::EMAT_STAND); 
	Character->setRotation(core::vector3df(0,270.0f,0)); 
	Character->setMaterialTexture(0,pManager->getDriver()->getTexture("media/sydney.bmp")); 
	Character->setPosition(core::vector3df(-838,118,-383)) ; 

}

void CGameStateLevel01::setCamera(CGameManager* pManager,core::vector3df camPosition)
{
	// add camera 
	pCamera = pManager->getSceneManager()->addCameraSceneNode(); 
	pCamera->setPosition(camPosition);
	pCamera->setTarget(core::vector3df(0,-32,0)); 
	pCamera->setFarValue(3000.0f); 
}
Post Reply