Page 2 of 8

Posted: Mon Jan 12, 2004 11:33 pm
by powerpop
boogle - when you get the TR style camera working let me know - that is the style i would like to have in my app! - i hope to release a raindrop animator soon - i love opensource, its so much more fun than everything only happening inside the walls of a corporation!!

i did this sorta, but mine isn't the best way i'm sure...

Posted: Tue Jan 13, 2004 6:22 pm
by buhatkj
i just set the cam up a certain distance from the character then bound it to the player by making their scenenode the parent of the camera, the trouble is i have to keep resetting the camera target every time the player moves, and that causes wierd jitters if the framerate isnt high enough.(these are most offensive when seen in fullscreen mode) i think the sceneNode Animator thinger is a good idea, just to smoothe it out, so not every little bounce and jitter the character makes is reflected by the camera. i almast want it to be so that i can give the camera a "threshhold" so that unless the player moves > a certain distance the cam stays where it is...
-Ted

Posted: Tue Jan 13, 2004 8:00 pm
by qwe
or what if the camera's parent wasn't the player, but it would respond when the character moves and it wouldn't be as stiff and unyielding... I'm thinking of doing an animator with smooth acceleration. And also having the camera "breathe"(move slightly) even when the character isn't moving. :?

Posted: Tue Jan 13, 2004 8:27 pm
by keless
qwe, you just gave me an interesting idea.

what if the camera was as you described. a seperate agent, which merely tried to keep the player in view. With its own 'breathing'-- perhaps it could try stalking the player too-- watching him from the rooftops, jumping from ledge to ledge.

then half way thru the game, a plot-twist. the game switches to first person, and you find out that there really is something stalking the player, and you've merely been seeing thru its eyes. some sort of shade, or demon. then he has to fight it. lol, im weird I know. :lol:

not wierd, imaginative

Posted: Tue Jan 13, 2004 8:51 pm
by buhatkj
naw dude, thats not wierd, its really cool!

Posted: Wed Jan 14, 2004 2:55 am
by Boogle
Cool idea Keless..

Buhatkj: You aren't supposed to set the player as the parent. The camera should have no parent node.

Qwe: Cool idea. I think it would fit more into my TR cam when I get it working. The first version of the TR I release will have smooth acceleration for rotation, and perhaps it won't be too hard to work in smooth acceleration for movement as well..

The TR cam will be basic at first, but there's a whole lot that could be added to it: Points of Interest to try to keep in camera view (eg a point around a corner), other nodes to try to, or always, keep in view (eg current target enemy), probably a bunch of other things.

The Breathing/Jittering would be best as an additional animator which could be attached to the camera after the base animator is. I think this would provide the best separation of code and you could put it on other nodes in your game as well if you want.

Posted: Wed Jan 14, 2004 3:11 am
by qwe
Boogle: yes. from CSceneNodeAnimatorFlyCircle I derived CSceneNodeAnimatorFlyEllipse. I was thinking about having a short but wide ellipse behind the player character, along which the camera moves very slowly.

I was also thinking of having the camera accelerate to follow the player, instead of just statically following him/her.

I would also want to detect collisions so the camera doesn't wander off into a wall or something :-X

Posted: Wed Jan 14, 2004 3:36 am
by Boogle
Cool

The SWG camera (the one currently available) handles collision detection just by putting a collisionAnimator on it (as I do in my example code). Feel free to add the acceleration stuff if you want to the current camera if you need that. I'm going to leave my version as is because I wanted that camera to be more of a 'viewpoint camera' then an action camera. The TR cam will be more of an action camera.

waitasec...

Posted: Wed Jan 14, 2004 3:35 pm
by buhatkj
set the camera to be the parent of the player? interesting, but i dunno if it would move right.....

i set the player to have no parent, and the camera up to be the child of the player...

Posted: Wed Jan 14, 2004 5:25 pm
by Boogle
No parenting!

Don't set the camera as child or parent of anything. If you set the player as child of something, you'll likely have to update the camera code to use getAbsolutePosition() rather than getPosition() when determining the position of the player.

Posted: Wed Jan 21, 2004 3:13 am
by powerpop
okay, i think i am going crazy - i have been using Boogles character objects without a problem in my main loop - i just moved the code into a separate Player object, put in the two include files (camera and player), moved over all the calls correctly (double checked) - it compiles fine but the linker chokes on the two classes - it says

pingirr error LNK2001: unresolved external symbol "class CSceneNodeAnimator3PPlayer * playerAnim" (?playerAnim@@3PAVCSceneNodeAnimator3PPlayer@@A)

and the same for the camera class - the obj files for CSceneNodeAnimator3PPlayer - same as before

why in the WORLD would it not find the classes at link time now?

i am stumped, i have tried every variation i can think of

here is my code from the method that sets up the camera, etc inside my player object - the two .h files are included above this at the top of the file:

Code: Select all

			CSceneNodeAnimator3PCamera *camAnim;
			
			player->setVisible(true);
			player->setPosition(x,y,z);

			irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode();
			camera->setPosition(irr::core::vector3df(300,300,700));

			// Create triangle selector for world (copied from collision example)
			irr::scene::IMetaTriangleSelector * worldselector = smgr->createMetaTriangleSelector();
			for( MapList::iterator it = spotMap.begin(); it != spotMap.end(); ++it )
				{
				Block* b = it->second;
				irr::scene::ITriangleSelector* s = smgr->createTriangleSelectorFromBoundingBox(b->node); 
				b->node->setTriangleSelector(s); 
				worldselector->addTriangleSelector(s); 
				s->drop(); 
				}

			// Create the camera animator
			camAnim = new CSceneNodeAnimator3PCamera(smgr,device->getCursorControl(),player->node,50,180,10,irr::core::vector3df(0,20,0));
			camera->addAnimator(camAnim);
			camAnim->drop();

			// Add collision response to camera (second, because order is important!)
			irr::scene::ISceneNodeAnimator *cameraCollision = smgr->createCollisionResponseAnimator(
				worldselector,camera,irr::core::vector3df(3,5,3),
				irr::core::vector3df(0,0,0), 0.0f,
				irr::core::vector3df(0,5,0));
			camera->addAnimator(cameraCollision);
			cameraCollision->drop();

			// Create the player animator
			irr::scene::ISceneNodeAnimator* playerAnim = new CSceneNodeAnimator3PPlayer(smgr,camera,camAnim);
			player->node->addAnimator(playerAnim);
			playerAnim->drop();

			// Add collision response to player (copied from collision example)
			irr::core::vector3df playerDimensions = player->mesh->getBoundingBox().MaxEdge - player->mesh->getBoundingBox().MinEdge;
			irr::scene::ISceneNodeAnimator *playerCollision = smgr->createCollisionResponseAnimator(worldselector,player->node,playerDimensions/2.0f);
			player->node->addAnimator(playerCollision);
			playerCollision->drop();

Posted: Wed Jan 21, 2004 3:31 am
by keless
did you do a make clean first?

Posted: Wed Jan 21, 2004 8:04 am
by powerpop
completely clean - this is really wierd - i have gone through line by line - i just cant figure out why the compiler would not complain and then the linker would when the obj files are right there as they always were

grrrrr

Posted: Wed Jan 21, 2004 10:39 am
by Homer
i have exactly the same problem. would be nice if someone could find a reason for this because i'm no c++ pro.

thx in advance

Posted: Wed Jan 21, 2004 10:52 am
by powerpop
i found the problem in my code - it has to do with namespaces - i have ping as a namespace - when i had the 3PPlayer and 3PCamera in my main cpp file there was no namespace clash - but when i moved it into a class that used the ping namespace the linker could not find the class definition - so the answer for me was to wrap the camera and player 3P files in my namespace - then when they compile they match the rest of my code