mount observer camera to another client's avatar
by Zachary Seldess · in Torque Game Engine · 05/22/2009 (7:41 pm) · 9 replies
Hi all,
Is there any way to mount the observer camera from one client onto the eye node of another client's (or server) avatar? I'm not having much luck. First, setting the client's control object to the desired avatar: %client.setControlObject(%otheravatar);
Then trying to mount through %otheravatar.mountObject(%observerID, %mountPoint);
But Torque either does nothing or crashes when I call that.
What I really want to be able to do is mount 2 or 3 clients' observer cameras to the same avatar. Any help would be greatly appreciated.
best,
Zachary
Is there any way to mount the observer camera from one client onto the eye node of another client's (or server) avatar? I'm not having much luck. First, setting the client's control object to the desired avatar: %client.setControlObject(%otheravatar);
Then trying to mount through %otheravatar.mountObject(%observerID, %mountPoint);
But Torque either does nothing or crashes when I call that.
What I really want to be able to do is mount 2 or 3 clients' observer cameras to the same avatar. Any help would be greatly appreciated.
best,
Zachary
About the author
Recent Threads
#2
That's almost what I'm looking for - and good to know about. But the problem is it doesn't cause the camera to rotate along with the avatar to which it is orbiting.
Try mounting one client's player (with control object set to the player) to another client: (%onePlayer.mountObject(%otherPlayer, %mountPoint);
You'll see that as you move the mountee, the mounted moves, AND it rotates along with the mountee as well. This doesn't seem to happen when calling setOrbitMode(). So what I want is the behavior of what I'm getting when I mount one avatar to another, but I want to do it the observer camera instead. Any ideas?
best,
Zachary
05/22/2009 (9:18 pm)
Thanks Chris,That's almost what I'm looking for - and good to know about. But the problem is it doesn't cause the camera to rotate along with the avatar to which it is orbiting.
Try mounting one client's player (with control object set to the player) to another client: (%onePlayer.mountObject(%otherPlayer, %mountPoint);
You'll see that as you move the mountee, the mounted moves, AND it rotates along with the mountee as well. This doesn't seem to happen when calling setOrbitMode(). So what I want is the behavior of what I'm getting when I mount one avatar to another, but I want to do it the observer camera instead. Any ideas?
best,
Zachary
#3
Well, if you want to do it the right way, I'm afraid you'll have to edit the C++ source. camera.cpp & camera.h are what you want to look at. (pay attention mostly to process tick, you can easily add the desired effect there... probably add a new mode)
However, if you want a quickfix without modifying source code, you could just make a player that has an invisible shape and just mount it like you've found that works.
05/22/2009 (11:32 pm)
I see what you're talking about.Well, if you want to do it the right way, I'm afraid you'll have to edit the C++ source. camera.cpp & camera.h are what you want to look at. (pay attention mostly to process tick, you can easily add the desired effect there... probably add a new mode)
However, if you want a quickfix without modifying source code, you could just make a player that has an invisible shape and just mount it like you've found that works.
#4
Mounting the camera to another object needs to reorganize your ghosting.
I've done things like that and got tons of sync loss in player/AI animation,weapon animation and projectile.
Then i needed the rewrite the whole scheme - believe me,there is a lot to do,not only in you camera's code.
05/23/2009 (4:59 am)
You are not rotating it,because you need to set the control object.Mounting the camera to another object needs to reorganize your ghosting.
I've done things like that and got tons of sync loss in player/AI animation,weapon animation and projectile.
Then i needed the rewrite the whole scheme - believe me,there is a lot to do,not only in you camera's code.
#5
05/23/2009 (7:07 am)
Quote:because you need to set the control object.It seems like he wants no control object - or, in effect, the control object is the camera, but it is mounted to a player so the user has no control over it.
#6
That's basically right. But if I'm mounting avatar to avatar, I don't even have to overtly call setcontrolObject();, doesn't matter if I do or don't. All I need to call is
%player1.mountObject(%player2, %mountPointOnPlayer1);
and the player2 avatar attaches to player 1, translates with the player, and rotates around the z axis when player1 turns left/right. But I still have control of player2's rotation and forward vector, if I want it.
Here's a quick demo of that behavior:
http://www.zacharyseldess.com/sampleVids/avatarMount1.mov
So one thing I'm trying to do is simply attach the observer camera to player1, rather than player2's avatar, and get the same behavior as above. That's primarily why I originally posted.
But there is one other important problem. As you can see in that vid, player2's orientation vector is not controlled entirely by the forward vector of player1. What I really need is for the orientation of the attached camera to tilt and roll according to the pitch of player1's head. So if player2's forward vector is offset 90 degrees from player1, when player 1 looks up or down, player2's head rolls left or right.
I pretty much understand the math involved, actually. But I just need to find a way for the engine to allow this behavior. At this point, I'm leaning towards doing it all in script, but any advice would be great. See this video for an example of the camera behavior I'm talking about. The display window shows 4 viewports representing, from left to right, frontview, rightview, backview, sideview. This should make the point clear:
http://www.zacharyseldess.com/sampleVids/quad_view.mov
best,
Zachary
05/23/2009 (8:12 am)
Daniel, That's basically right. But if I'm mounting avatar to avatar, I don't even have to overtly call setcontrolObject();, doesn't matter if I do or don't. All I need to call is
%player1.mountObject(%player2, %mountPointOnPlayer1);
and the player2 avatar attaches to player 1, translates with the player, and rotates around the z axis when player1 turns left/right. But I still have control of player2's rotation and forward vector, if I want it.
Here's a quick demo of that behavior:
http://www.zacharyseldess.com/sampleVids/avatarMount1.mov
So one thing I'm trying to do is simply attach the observer camera to player1, rather than player2's avatar, and get the same behavior as above. That's primarily why I originally posted.
But there is one other important problem. As you can see in that vid, player2's orientation vector is not controlled entirely by the forward vector of player1. What I really need is for the orientation of the attached camera to tilt and roll according to the pitch of player1's head. So if player2's forward vector is offset 90 degrees from player1, when player 1 looks up or down, player2's head rolls left or right.
I pretty much understand the math involved, actually. But I just need to find a way for the engine to allow this behavior. At this point, I'm leaning towards doing it all in script, but any advice would be great. See this video for an example of the camera behavior I'm talking about. The display window shows 4 viewports representing, from left to right, frontview, rightview, backview, sideview. This should make the point clear:
http://www.zacharyseldess.com/sampleVids/quad_view.mov
best,
Zachary
#7
*Not actually, but IMO it's the best way.
05/23/2009 (10:57 am)
Okay, I have no idea what's going on in that second video :P, but I see what you're going for. To do a quick and dirty test, try %player.mountObject(%observerCamera,0) somewhere and see if that works. This will mount the camera to the mount0 node, which isn't exactly what you want, but if this works then you can eventually modify it to mount on the eye node (would require source changes, but hey, so does everything* worthwhile).*Not actually, but IMO it's the best way.
#8
Thanks. That doesn't work, as I explained in my original post. So it looks like I'll be mounting avatars to avatars for the time being, or altering the engine code (which I'll need to hire out for - I'm not fluent enough in C++).
best,
Zachary
P.S. - That second video was just showing eventual effect I'm going for in mounting 3 avatars/cameras to a 4th. That's a vid of a 3D WASD navigator that I made a while back, that simultaneously shows front, right, back, and left side views as you fly around - allowing for total surround viewing.
05/24/2009 (10:14 am)
Hi Daniel,Thanks. That doesn't work, as I explained in my original post. So it looks like I'll be mounting avatars to avatars for the time being, or altering the engine code (which I'll need to hire out for - I'm not fluent enough in C++).
best,
Zachary
P.S. - That second video was just showing eventual effect I'm going for in mounting 3 avatars/cameras to a 4th. That's a vid of a 3D WASD navigator that I made a while back, that simultaneously shows front, right, back, and left side views as you fly around - allowing for total surround viewing.
#9
Without looking in any more detail at the problem, I would advise against getting someone else to fix your problem for you. I had no C++ experience when I began with Torque (a little of Conitec's c-script, but no real coding), and I've become reasonably proficient by implementing resources and reading code. Have a go at implementing the advanced camera resource, just to start learning and working with the camera.
To point you in the right direction after you find your feet, the Player class (and possibly ShapeBase itself) has a method called getCameraTransform, which is used to, as you might expect, get the camera transform for the shape. I'd make a new script function for the observer camera which attaches the camera to a Player using this function.
I might have a go at implementing this, since I'll probably need the feature for my game anyway (observer mode and all that).
Oh, and if you're not using the source code, then paying for the licence wasn't very useful ;).
About the video - I sort of got what it was, but wouldn't really have figured it out if I hadn't already known ;P.
05/24/2009 (12:46 pm)
You did, I'm sorry. That'll teach me again to read carefully.Without looking in any more detail at the problem, I would advise against getting someone else to fix your problem for you. I had no C++ experience when I began with Torque (a little of Conitec's c-script, but no real coding), and I've become reasonably proficient by implementing resources and reading code. Have a go at implementing the advanced camera resource, just to start learning and working with the camera.
To point you in the right direction after you find your feet, the Player class (and possibly ShapeBase itself) has a method called getCameraTransform, which is used to, as you might expect, get the camera transform for the shape. I'd make a new script function for the observer camera which attaches the camera to a Player using this function.
I might have a go at implementing this, since I'll probably need the feature for my game anyway (observer mode and all that).
Oh, and if you're not using the source code, then paying for the licence wasn't very useful ;).
About the video - I sort of got what it was, but wouldn't really have figured it out if I hadn't already known ;P.
Torque 3D Owner Chris Cain
Edit:
To be even more helpful, I found it in TDN for you