How to store camera position to variable?

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
xfreakk
Posts: 14
Joined: Thu Nov 15, 2007 1:58 pm

How to store camera position to variable?

Post by xfreakk »

Hi im have the basic framwork for a game and now i want to add networking code. I want to send the current player location over the network to a server. I know how to do the networking code sort of. but what i really need to understand is where does irrlicht store the current coordinates of the fps camera.

is it camera->updateabsoluteposition.
there is also camera->getPosition.x or y

ive tried int x = camera->getPosition but it didnt work

I need a simple way to store the current location in a variable and send it over a bitstream
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Re: How to store camera position to variable?

Post by zeno60 »

xfreakk wrote:Hi im have the basic framwork for a game and now i want to add networking code. I want to send the current player location over the network to a server. I know how to do the networking code sort of. but what i really need to understand is where does irrlicht store the current coordinates of the fps camera.

is it camera->updateabsoluteposition.
there is also camera->getPosition.x or y

ive tried int x = camera->getPosition but it didnt work

I need a simple way to store the current location in a variable and send it over a bitstream
If you look at the api you should see that getPosition is not a variable but a method (function): getPosition() which returns a vector3df. http://irrlicht.sourceforge.net/docu/cl ... e.html#a15

int x = camera->getPosition().x
Last edited by zeno60 on Sun Jan 27, 2008 11:21 pm, edited 1 time in total.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: How to store camera position to variable?

Post by randomMesh »

xfreakk wrote:ive tried int x = camera->getPosition but it didnt work
getPosition() returns a irr::core::vector3df, not an int.

http://irrlicht.sourceforge.net/docu/cl ... _node.html
xfreakk
Posts: 14
Joined: Thu Nov 15, 2007 1:58 pm

Post by xfreakk »

ah so thats why it was displaying a something like 0fffh or something neway thanks i was wondering thanks. Ill try to figure it out from here. I hope you dont have to hear from me again :)
xfreakk
Posts: 14
Joined: Thu Nov 15, 2007 1:58 pm

Post by xfreakk »

Hmm I still for the life of me can not figure this out and this just so happens to be the main problem for me right now.

If any of you know of a way to get the coordinates into variables that would be great. I checked the api but im pretty new and could not understand how i can do this.

Possible one the i can do though is just have the players actions get sent over to the server and then the clients camera rig function will handle when the other player is moving i guess.

**edit** well I dont want the the client to creat a whole camera i just want a mesh to move wherever the player is. Such is why i wanted to do it with coordinates instead of aforementioned way.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

Do it like this:

Code: Select all

irr::core::vector3df camPos( camera->getAbsolutePosition() );
or

Code: Select all

float x = camera->getAbsolutePosition().X;
float y = camera->getAbsolutePosition().Y;
float z = camera->getAbsolutePosition().Z;
Last edited by randomMesh on Mon Jan 28, 2008 6:18 pm, edited 1 time in total.
xfreakk
Posts: 14
Joined: Thu Nov 15, 2007 1:58 pm

Post by xfreakk »

Thank you your a life saver im gonna try to get it working.
There doesnt seem to be much networking code going around these forums. Im using Raknet... IrrNet wouldnt work for me for some reason i think i was missing the ENet Libs... but neway thanks a bunch :)
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

xfreakk wrote:Thank you your a life saver im gonna try to get it working.
There doesnt seem to be much networking code going around these forums. Im using Raknet... IrrNet wouldnt work for me for some reason i think i was missing the ENet Libs... but neway thanks a bunch :)
i use raknet, maybe we can collaborate in the future. set up a game net api on top of irrlicht.
Image
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

raknet sucks because of its licence.
Try to use a free library like enet.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

That's an astonishing statement, which I feel compelled to refute.

You may distribute, modify and use Raknet gratis in non-commercial products. Thus far, it's effectively the same as Enet.

If and only if you successfully complete and release a commercial product, then you choose how much to pay for a commercial Raknet license, with a minimum of $100. As ZOMG MONNAY==EVAL licenses go, that's about as EVAL as Mother Theresa.

Given the extra functionality that Raknet provides over Enet, you'd really have to value your time very very cheaply indeed to object to paying $100 for Raknet.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
xfreakk
Posts: 14
Joined: Thu Nov 15, 2007 1:58 pm

Post by xfreakk »

My sentiments exactly. Anyway i resolved the problem of storing coordinates thanks to Random Mesh
I resolved my other forum topic of spawning meshes. My code got so complex i didnt know where i should spawn meshes lol.

Anyway my networking code is so Amateurish. It stores the x y z as arrays
x[32] y[32] z[32]
And cheat client is hardcoded to be one of those arrays. The client writes packets for its data i.e

Code: Select all

pseudo code
datastream.write(x[0])
datastream.write(y[[0])
datastream.write(z[0])
and then it reads all the incoming data with different packet lines from each client.

This system is extremely primitive.
Do you guys think its good for now or is it sorta like learning the wrong way to begin with.

I will release a server client demo when im done.
I just borrowed the Camera code from Christian Clavet
So i need to redesign my own camera code.


The current system of how the networking is done
is with the coordinate system a mesh is used as placeholder on the clients machine.
--To Be Added--
Remaining networking code for coords
adding in rotation transformation code.
So that the mesh faces where the user is facing.
Controlling Animations so that while standing still the mesh isnt still animating or at least not a running animation lol.
--Possibly to be added--
updating network code so it doesnt have to be hardcoded into each client


@dlangdev
contact me on MSN Messenger at slicky11288@hotmail.com or AIM slicky11288
Frosty Topaz
Posts: 107
Joined: Sat Nov 04, 2006 9:42 pm

Post by Frosty Topaz »

I feel I should point out that the positions etc. in Irrlicht are all of the type irr::core::vector3df. They are floating point values. So you really shouldn't store/send them as ints. Unless you really want jumpy movement, or your scale is very large (ie one Irrlicht unit is one mm (~1/32")). Even if your scale is that large the conversion takes time you don't need to waste.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
xfreakk
Posts: 14
Joined: Thu Nov 15, 2007 1:58 pm

Post by xfreakk »

Thanks frosty. This is just early version. networking code is no more than a page right now. I have to figure out how to get floats to conver to Const Char i believe. Im not sure im gonna try using floats when i get home from the university.

Question for everyone. Does anyone know if the get target applies to animated meshes. I believe im using the right terminology. Basically I want to know if the current fps camera is looking at a spawned animated mesh.

Also if i set the animated meshes coords to variables does it update on every frame.

Heres my idea.
pseudo code

Code: Select all

void istargetaplayer
{
  get target
  cmp to coords of other players
  display on gui current target is Player ID based on the Player ID of the   packet that the coords were recieved from
}
 
**Please dont flame me for asking this question im at school till 2:00 EST and cant test out any theories of my own right now**
So if you have constructive information that would be nice. And Appreciated.

If i ever do produce a nice minigame of decent quality. Any persons who assisted are welcome to be announced in the credits if they want.
Just because i realize that if you guys are giving me code or helping me I did not do the code myself and therefore want all Parties mentioned if they so desire.
Frosty Topaz
Posts: 107
Joined: Sat Nov 04, 2006 9:42 pm

Post by Frosty Topaz »

I assume you're meaning to ask if it's possible to determine which scene node is at particular screen coordinates (ie the center). It should work for any scene node that has a bounding box I believe.

You can get the scene collision manager from the scene manager. It should have a function to get the scene node at some specified coordinates on screen. Check the API for details.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
Post Reply