Game Development Community

SetTransform() problems

by John Vanderbeck · in Torque Game Engine · 04/29/2004 (5:32 pm) · 26 replies

I was working on implementing controls for moving the loaded object in the new show tool today when I ran into some problems. I move the camera/shapes via setTransform().

When I call it on a loaded Play object, the play vanishes then suddenly falls from the sky at the new location.

When I call it on a TSStatic, absolutely nothing happens. Everything runs without an error, but the shape doesn't move.
Page «Previous 1 2
#1
04/29/2004 (6:00 pm)
The interesting thing is, with the TSStatic, is the Transform IS moving. I have echo statements that echo the current position and the new position of each movement call. The transform is changing and the changes are indeed being seen by the next movement call. So the objects transform IS moving, but the object ISN'T.
#2
04/29/2004 (6:02 pm)
I bet it has something to do with the networking. Are you changing the transform on the clientside, or serverside?

Remember that for you to SEE any changes, you're going to have to change the client side transform, and for you to make any real permanent changes, you will have to change the server side transform. In other words, you have to change them both. :)

(I highly doubt that changes in transform of statics is sent over the network. That is why it would work for players and not for statics. But then again, I could be totally wrong here. Worth checking into at least.)
#3
04/29/2004 (6:04 pm)
Serverside via a CommandToServer().

Do I need to do something to have the server update clients?
#4
04/29/2004 (6:06 pm)
Yes. Call the commandToServer via a keybinding, then run the same code on the client (out of the function that you bind the key to) that you run via the commandToServer. It's a bit hackish maybe, but it works for me for other similar situations.

Edit: I meant commandToServer.

Edit 2 (after thinking for a second): Alternatively, I suppose you could do a commandToClient (or to all clients) from the commandToServer to run the same code that you just ran on the server. That would probably be a more proper way to handle it.
#5
04/29/2004 (6:11 pm)
Heh either way it seems hacky gah.

I'll add a commandToClient() in to pass the new transform though and see if that works.
#6
04/29/2004 (6:12 pm)
This is REAL hacky because if you have multiple clients youd have to try and progate it to all of them. Man that sucks. Thankfully I don't have multiple clients.
#7
04/29/2004 (6:17 pm)
Ok well I added a commandToClient to send the new transform to the client and update it locally, but it made no difference :(
#8
04/29/2004 (6:34 pm)
Well, first of all, this is a show tool you're working on, so you dont really need to worry about multiple clients. :)

That REALLY doesnt make any sense. Check the rendering function of the static shape to see what matrix it is using for the transform. Then try manually setting it to different values to make sure you have the right matrix. Then make sure you are modifying that matrix on both the client and the server. If THAT doesnt work, I dont know what to tell you. :-/
#9
04/30/2004 (6:47 am)
@John

I've been wrestling with the EXACT same problem for the last few days and was going to post a question on it when I just saw your post here. I've isolated it to the fact that the Static objects only seem to ghost to the client once upon initialization.

I've only got one player, one static object, and the camera in a mission. If I set a break point in NetConnection::writeGhostPacket and follow it through, it processes all three items the first time but only the Player after that. I haven't been able to track down what is dropping the others out after the first pass. They are still in the ghosted objects array and look to have the same flags set. So what our SetTransform code is doing is setting it on one side and never reaching the other. I don't like the ClientCommand option either so I've been looking at the network code.

I think we need someone who knows the networking to pipe in and explain this.

@Anyone

What can we do to get Static objects to ghost too (short of changing all our Static objects to player objects!)?

[EDIT: FYI, unlike John I'm doing this in game (not in the show tool) and it exhibits the same issues. That is, I use Set Transform to change a static object to the location of a player and the values change but it continues to draw in the original position).
#10
04/30/2004 (6:53 am)
Why dont you guys inspect what happens in the mission editor when you select a static object and move it with the mouse? Surely, and least for John, there should be a good solution in there.
#11
04/30/2004 (7:08 am)
@Josh

The editor does this in the source code instead of in script. That isn't an option for me.
#12
04/30/2004 (11:02 am)
Wow. I dont know how I would be able to survive without looking at the source. Since this is posted on the Private SDK forums, I'm going to assume you've purchased Torque. In this case, I would suggest learning a little C++ so that you can at least READ what is going on in the source. It makes everything ALOT easier.

If you dont want to for some reason, well, that's your choice, but I think it will make all your work alot harder. Good luck either way! :)
#13
04/30/2004 (11:15 am)
Lol Its not that I can't mess with the source. I've been programming for over 15 years.

It is because this application must be developed completely on the scrpit side so as to assure it works properly with stock Torque.
#14
04/30/2004 (12:48 pm)
Same thing for me. I know C++ very well. The NetConnection code I've been looking at **is** in the source. I'm assuming at this point that the issue has to do with the fact that the Static object is based off of SceneObject (like Melv's replication fx objects) and the player is off of GameBase.

Since GameBase is itself based off SceneObject further down it's heirarchy I'm figuring there has to be something that the player is inheriting from the GameBase class that's doing the position updating which the Static object doesn't get because it's based directly off of ScebneObject.

@Josh

Thanks, I didn't think of that. I'll check out what the editor is doing and maybe expose that to my scripts. I don't have the stock Torque limitation that John does.
#15
05/01/2004 (6:24 am)
I decided to just make a paradigm shift here and instead of using static objects i'm using Items now. They move fine :p Only downside is that they have physics so you can't move the object up and down (If you do it just falls back down :p).
#16
05/01/2004 (6:50 am)
I've looked into the editor code and all roads lead back to the SceneObject::setTransform function in the C++. This is the exact same code that the SetTransform() script is calling whether it's a Player object or a Static object.

So, it's back to the drawing board for me - gotta be something in the Player class or on of its parents that's not in the SceneObject.

Since Items move properly maybe I'll look into what's different between that and a Static object for another angle to find my missing link...
#17
05/01/2004 (7:03 am)
Guys,

The problem your running into is that the network layer's 'dirty' bit mask is not being told that an update has occurred (which is done with a call to setMaskBits()). Almost all descendants of ShapeBase reimplement setTransform to something similar to this:

void ::setTransform(const MatrixF& mat)
{
//do some stuff...

Parent::setTransform(mat);
setMaskBits(PositionMask);
}

TSStatic is still using the default setTransform defined in SceneObject (which does nothing).

What I haven't been able to figure out is why any shape that moves on the server side wouldn't want to update the client, that appears to be what this code is trying to avoid otherwise the call to setMaskBits should be in SceneObject.

To make a long story short you'll need to implement the ShapeBase style setTransform in any object that needs to move on the client side.

Hope this helps!

-John
#18
05/01/2004 (9:05 am)
Hey Hey... double post. :)

Post.

:)

- Melv.
#19
05/01/2004 (9:14 am)
Quote:
Hope this helps,

- Melv.

Quote:
Hope this helps!

-John

Now that's scary... :)

-John
#20
05/01/2004 (11:06 am)
It sure is! :)

- Melv.
Page «Previous 1 2