How to store camera position to variable?
How to store camera position to variable?
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
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
Re: How to store camera position to variable?
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#a15xfreakk 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
int x = camera->getPosition().x
Last edited by zeno60 on Sun Jan 27, 2008 11:21 pm, edited 1 time in total.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: How to store camera position to variable?
getPosition() returns a irr::core::vector3df, not an int.xfreakk wrote:ive tried int x = camera->getPosition but it didnt work
http://irrlicht.sourceforge.net/docu/cl ... _node.html
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.
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.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Do it like this:
or
Code: Select all
irr::core::vector3df camPos( camera->getAbsolutePosition() );
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.
i use raknet, maybe we can collaborate in the future. set up a game net api on top of irrlicht.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
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
raknet sucks because of its licence.
Try to use a free library like enet.
Try to use a free library like enet.
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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.
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
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
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
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])
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
-
- Posts: 107
- Joined: Sat Nov 04, 2006 9:42 pm
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...
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
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
**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.
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
}
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.
-
- Posts: 107
- Joined: Sat Nov 04, 2006 9:42 pm
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.
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...
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...