Page 1 of 1

3rd Person [1st Post]

Posted: Fri Jun 08, 2007 7:48 pm
by Joseph
Hello Irrlicht Community!!

My name is Joseph and this is my first post. I am going to explain what I am hoping to achieve fully so I don't make my first ever post look n00bish. Right, I am very interested in Irrlicht and am learning it quite well! I have been using a program called Game Maker since 2005 and thought I would start learning C++!

Right, on the Game Maker Forums people usually make you examples rather than post code snippets so I don't know if what I'm going to ask is unusual to this community. I am wanting to know if anyone on here would be good enough to create me a very simple third person camera, all I am asking is for a Dev Project file with just the simple sydney model, no movement or anything..just the camera placed behind sydney and in third person perspective.

I am hoping what I am asking is not wrong! If people on here don't create example files then I would be happy with code snippets but with some information on how to use them as I am still a beginner. I believe everyone has to start somewhere and everyone has the right to learn. I have chosen to learn how to use Irrlicht.

Is anyone prepared to do this for me? I would be forever in your debt.

Joseph

Posted: Fri Jun 08, 2007 7:55 pm
by MasterGod
You sound like a really nice person although I cant help you.

But Good Luck learning Irrlicht - I'm doing so too..

Posted: Fri Jun 08, 2007 8:00 pm
by Joseph
MasterGod wrote:You sound like a really nice person although I cant help you.

But Good Luck learning Irrlicht - I'm doing so too..
Thank you, I don't just come to forums to learn and be riddled with n00bs, I like to come and make friends. I like to work as an individual but also know there is the community I can rely on. I am told I am a good friend. Just who I am :)

Joseph

Posted: Fri Jun 08, 2007 9:09 pm
by Dances
This is much simpler than you think. Just make the a camera (not an FPS one) and make it a child of your sydney node and it will follow her wherever she goes.

You can also find camera coding in the snippets area of the forum. There are various 3rd person cameras there.

Posted: Fri Jun 08, 2007 10:11 pm
by Joseph
Dances wrote:This is much simpler than you think. Just make the a camera (not an FPS one) and make it a child of your sydney node and it will follow her wherever she goes.

You can also find camera coding in the snippets area of the forum. There are various 3rd person cameras there.
Will I need to position the camera? And if yes what would i need to do?

Cheers
Joseph

Posted: Fri Jun 08, 2007 10:27 pm
by Dances
When you create and it is a child, setting its position will be relative to your character... as if your character were always at 0,0,0, no matter where it is, for the camera. The camera will always keep its position relative to the character.

Posted: Sat Jun 09, 2007 6:46 am
by linkoraclehero
Ehm... but wouldn't this ignore Sydney's rotation and always face Sydney from the same direction?

I.E.:

Sydney is facing north; Camera is facing north.
Sydney turns south; Camera still facing south, same position relative to Sydney; Sydney now faces camera.

If you do a search, there IS 3rd person camera nodes.

Posted: Sat Jun 09, 2007 8:30 am
by Joseph
linkoraclehero wrote:Ehm... but wouldn't this ignore Sydney's rotation and always face Sydney from the same direction?

I.E.:

Sydney is facing north; Camera is facing north.
Sydney turns south; Camera still facing south, same position relative to Sydney; Sydney now faces camera.

If you do a search, there IS 3rd person camera nodes.
Yea I'll specify that when you rotate sydney, the camera rotates with her :D This is proofing to be more difficult then I thought!

I did do a search before I came hree and read every page, unfortunately they either; don't work, or the links are dead : :shock:

Joseph

Posted: Sat Jun 09, 2007 9:42 am
by Virion
when sydney is moving...

sydney's
new x coordinate - old x coordinate = a
new y coordinate - old y coordinate = b

camera's
x coordinate = x coordinate + a
y coordinate = y coordinate + b

maybe this should work?...

Posted: Sat Jun 09, 2007 11:19 am
by Joseph
Virion wrote:when sydney is moving...

sydney's
new x coordinate - old x coordinate = a
new y coordinate - old y coordinate = b

camera's
x coordinate = x coordinate + a
y coordinate = y coordinate + b

maybe this should work?...
That sounds like a probable solution. Would anyone be willing in making me an example? I work better by example, I am a visual learner :)

If not I would like more help, kinda like a step by step :)

Joseph

Posted: Sat Jun 09, 2007 3:27 pm
by bitplane
Here's a nice way to do a 3rd person camera-

add a dummy transformation node as a child of the node you wish to follow, this is the camera's "where I would like to be" position.

each frame, get the camera's old position ("where i last was") and make a new position based on the direction to the dummy node and speed of your camera ("where i would like to be next frame")

now draw a line from the mesh you are looking at, to the "where i would like to be next frame" position, and collide this with the world's triangle selector. then set this as your camera position.

the result will be a camera that will follow behind your mesh in a nice smooth fashion rather than being glued behind it. you can change the angle and desired distance by moving the dummy node around, but the camera will never get stuck behind a wall - it will move closer to your target if there's not much space.

you could also use another dummy node and do a cam->setTarget on it's absolute position each frame, so the centre of the screen is always where the player is shooting or whatever location is of interest

Posted: Sat Jun 09, 2007 10:38 pm
by Joseph
bitplane wrote:Here's a nice way to do a 3rd person camera-

add a dummy transformation node as a child of the node you wish to follow, this is the camera's "where I would like to be" position.

each frame, get the camera's old position ("where i last was") and make a new position based on the direction to the dummy node and speed of your camera ("where i would like to be next frame")

now draw a line from the mesh you are looking at, to the "where i would like to be next frame" position, and collide this with the world's triangle selector. then set this as your camera position.

the result will be a camera that will follow behind your mesh in a nice smooth fashion rather than being glued behind it. you can change the angle and desired distance by moving the dummy node around, but the camera will never get stuck behind a wall - it will move closer to your target if there's not much space.

you could also use another dummy node and do a cam->setTarget on it's absolute position each frame, so the centre of the screen is always where the player is shooting or whatever location is of interest
Wow that sounds difficult!

Could you possibly make me an example of that? That would be simply amazing, if I had PayPal I would pay someone for the example but I am only 15 and not very wealthy to be honest.

I'm just in need of help so I can continue learning :(

Joseph

Posted: Mon Jun 11, 2007 10:40 am
by MasterGod
Maybe before trying something like that try again understand 100% the tutorials and make a lot of simple programs with what you have learned from the examples, then when you will be more experienced it will be less difficult to understand what he said and actually do it Yourself!

Well, this is what I do..

Posted: Mon Jun 11, 2007 3:29 pm
by Joseph
MasterGod wrote:Maybe before trying something like that try again understand 100% the tutorials and make a lot of simple programs with what you have learned from the examples, then when you will be more experienced it will be less difficult to understand what he said and actually do it Yourself!

Well, this is what I do..
Thanks :)
I think that is the best idea, I'll read through the tutorials again :D I'm starting to get things now, I can do the hello world and quake map myself, almost the movement all by myself too :D

Getting there lol

Joseph

Posted: Mon Jun 11, 2007 8:53 pm
by Dorth

Code: Select all

	LineFromTargetToOptimal.start = TargetLocation;
	LineFromTargetToOptimal.end = OptimalPosition->getPosition();
	vector3df Intersection;
	triangle3df CollidedTriangle;
	if (Camsmgr->getSceneCollisionManager()->getCollisionPoint( LineFromTargetToOptimal, CollisionSelector, Intersection, CollidedTriangle)) 
	{
		GoingToPosition->setPosition(Intersection);
	} else
	{
		GoingToPosition->setPosition(OptimalPosition->getPosition());
	}

Code: Select all

	ITriangleSelector* CollisionSelector;
	vector3df TargetLocation;
	line3d<f32> LineFromTargetToOptimal;
	ISceneNode* OptimalPosition,* GoingToPosition;
	IrrlichtDevice* CamDevice;
	ISceneManager* Camsmgr;
The rest off the code is well setup (at least I'm petty sure) and I've checked everything's value at least twice.

the getCollisionPoint( LineFromTargetToOptimal, CollisionSelector, Intersection, CollidedTriangle) is the part that keep making the application crash either on read or later, depending of the Irr lib I use.

And yes this is based on Bitplane's technique and if it works well I'll post the whole thing ^^

Anyone seeing my mistake'd be very kind to point me to it, thank you very much ^^