Game Development Community

Object groupings.

by Peterjohn Griffiths · in Torque Game Engine · 01/01/2007 (3:19 pm) · 18 replies

I have had a look around and can't find anything on how to create an object grouping.
I need to make three 3d object move as a group so that if one is moved in the editor or ingame to others will follow and move relative.
This is normaly done by grouping objects together and moving the group but I can't find out how this is done in torque.
Many thanks for any help on this.
Pejayuk.

#1
01/01/2007 (4:33 pm)
In the world editor this can be done by putting the objects inside a SimGroup,
and then moving the SimGroup.

outside of the editor however, as far as i know there is no built-in way to do this;
you need to move each one individually.
#2
01/01/2007 (5:37 pm)
Thanks Orion Elenzil,
I only realy need to move them as a group in the editor, although it would be nice to have this functionality in the game aswell, I can do without it.
I have tried that, and if it would work it would be just what I needed.
I created a SimGroup called Test and placed three WayPointMakers inside the SimGroup. But how am I supposed to move the SimGroup?. When I click on the SimGroup Test in the menu, the objects arn't selected and there is no Gizmo to move them with?.
Many thanks again.
#3
01/07/2007 (12:18 pm)
Sorry to bump this, but I realy need to moves objects as a group, even if only one of the objects is selected.
Anyone got any ideas.
Many thanks.
#4
01/09/2007 (5:18 pm)
I have found just what I needed in this resource
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9093
It alters torque to relate to postions localy and by parent objects.
So if you move or rotate a parent, all child objects translate aswell keeping their position relative to the parent and not the world.
This is what you would expect from a game engine and I am supprised to not find this in tourque.
This means you mount one object to another as a child of the parent.
Job done.
Thanks to all who have tried to help.
#5
01/09/2007 (10:25 pm)
As Orion said, you can easily do this in the editor in stock.

In addition, you can mount objects to other objects.

I'm really not sure what it is you think is missing to be honest.
#6
01/10/2007 (12:26 am)
OK, this is what I am doing, step by step.
In TGE Torque 1.5.
In the mission editor (F11) I select the world editor creator and create a simgroup called test.
I then create a trigger and a waypointmarker and move them into the simgroup test.
I then select the simgroup test but the objects gizmo doesn't show. None of the items are selected.
I can select the items inside the simgroup individualy and move them individualy but not as a group without selecting all the items first. If I move one of the items the rest don't follow. It seems like there is no translation to the other object in the simgroup.
I have tried this in the world editor creator and world editor instector but neither give me the ability to move them as a group without selecting all the items first.
This group translation functionality was missing in 1.4 and I was hoping it would be added to 1.5 after reading about the work being done at GG on localposition and localrotation in relation to the parent instead of always using the world position and rotations.
Was it added? If so I think I am missing something.
Many thanks
#7
01/10/2007 (12:39 am)
I think we might be talking about two differnt things here.
Do you mean move the simgroup folder position in the world EditorTree control?.
I mean selecting the trigger and waypointmarker in the 3dworld and moving them in the 3dworld as a group. If you move the triggers position or rotate it, the waypointmarker should move position and rotate relative to the trigger as its in the same group.
A bit like putting the player model and an arrow into a group, positioning the arrow at the player head with local position and rotation and then when the player moves forward the arrow follows it so its still sticking in the players head. Same with when the player rotates, the arrow rotates around the player and is still sticking in his head.
This might be the confusion.
I believe what I am trying to achieve is called translation in trigonometry or group translation in other game engines, but its been a while since I touched a different engine as torque is so much better than the others I have used.
Its also been a while since I have used trigonometry, vectors and all this stuff. Fealing very rusty.

Torque is great by the way and I'm loving every moment, even this problem. :+}
#8
01/10/2007 (8:18 am)
Just select the objects you want to move all at once...
#9
01/10/2007 (9:47 am)
Yeah, but Stephen, this may be unrelated, but doing it that way, and then trying to get everything on the same plane using the numerical input (x y z) it only moves or affects the first object you selected. Making it very hard to get things to line up, because you need to copy and paste to each objects, witch sometimes leads to a crash because of the copy and paste.

Say your doing a city street, and all the buildings need to be at the same hight, Shift select them all, and enter hight, bam, one building moved, you must now copy and paste that hight to all objects (and risk crashing). You cant just grab them all in a group, and type in "10" and have them all be at 10 hight.

This just compounds when you try to line up DIff that form a build able dungeon... you get it all lined up perfectly, then realize you need the lower them by 5 points to fit right in the terrain....

Guess what you have to do.

Same for rotation, same for the rest..

It is a clunky way of arranging objects, if you want them to be uniform and exact in the x y z or rotation directions.

Basically, other than click and drag (witch is no were near precise) ... you cant position a group of selected objects to an exact position based on that group. It will only affect the first object of the group you selected if you want to enter an XyZ.

This is really annoying when using Interiors and trying to line them up...

I hope that made sense.
#10
01/10/2007 (2:56 pm)
The child parent relationship setup in the above posted recourse
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9093
should fix this problem as all child objects use local position and local rotation so when the parent is moved all child objects world position and rotation is updated acording to their translation to the parent + local position and rotation.
I am currently implementing this into my build, but Torque 1.5's sceneObject.cc is a bit different to 1.4 and it currently has a few errors I am trying to fix.
I will post my results here and in the resource to let you know how I have got on.
Many thanks
#11
01/11/2007 (2:00 am)
I have got this working and its just fantastic. :+}
There are a few small issues that need fixing but nothing complex.
I aim to make the whole engine to use local postion and rotation instead of global position and rotation and bring it up to speed.
Next I am going to try renaming the normal position and rotation methods to globalposition and globalrotation methods. I will then move the localpostion and localrotation methods to position and roation making the default method to be local but still leaving the global if its ever required.
Next I plan to amend the editor to add any item added to a mission as a child of the "SimGroup - MissionGroup" object and change the world EditorTree to show grouped items differently and allow them to be selected as a group with a single click to the parent. I will also need to amend the SimGroup item so that all children are selected when the SimGroup is selected.
This will mean that every sceneobject will be a child of another object and proper grouping and local position/rotation will occur in refference to its parent object.
After that I plan to change the world editor creator I plan to add a new grouping that allows you to write a script to create standard groups. When selected the group will be created for you and all the relavant code can also be put into this script. I will probably call it something like objectgroups or something.
I have already had a poke around the editor code and can't see it as a problem, but may take a while to do.

After thought:....
I will also need to change all sceneobjects in current missions and the default mission file to be a child of an object, otherwise it might not work the same.

Some ideas on its advantages:...
An idea would be to have the shell of a car, add doors, wings, bonet etc as seperate objects and group them on the shell of the car as the parent. The only network traffic is the position and rotation of the shell of the car as the clients will move the child items in relation to the parent (Shell of the car). We can then have the doors, wings and bonnet as child items and code them on the client to react to being damaged and have them animate being dented etc, and have the damage level sent over the network to everyone else when they are hit (This will be very small info.). When the door, wing or bonnet it highly damaged, we can un group it and send it flying around as a missiongroup object and allow its moved to be sent over the network making cars crash into it and have it bouncing around with Torque physics.

Another example is a crate that breaks. Six sides grouped together in a trigger object. When the trigger is boken (Something crashes into it or explodes causing X amount of damage) the six sides are moved out of the trigger group into the missiongroup and the objects are moved indipendantly from each other using Torque physics. All this from one broadcast string across the network to trigger it.

What about having changable player parts. Heads, bodys, Legs etc. So that people can customize their player models without the need for modeling programs. The grouping system would make this very easy to implement. I have seen this in worlds 3d chat years ago and people loved it.

These are just off the top of my head so there are going to be a lot more interesting things we can do.
Anyone got any thoughts?
#12
01/11/2007 (3:50 am)
This sounds amazing! Can it really be done? This would be more impressive then getting Torque to render fancy sparkling water...
#13
01/11/2007 (4:35 am)
Sure it can be done, its not going to happen over night but shouldn't be more that a month or two depending on what problems are encountered and what help I get over comming them.
Its way more that I need but am looking at it as a learning experiance and something else I can give back to the community that has helped me so many times.
Anthony Lovell and others have already done a huge part of this in the resource http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9093
I'm so glad they (Anthony Lovell and others) have this resource done already as my maths is rusty (Hats off to you guys. A big thumbs up), although my math is getting better with all the torque stuff Ive been getting done lately.
I will be trying to take it a step further and integrate it better into the torque editor and scripts so that it can be utilized in a wide range of things.
Loads of 3d engines use local position and rotation. And I think its about time Torque got it aswell.
I'm sure others might do a getter job than myself, but I am determined to get this into torque and if nobody else is going to do it, I will give it my best.
#14
01/11/2007 (4:53 am)
Here is something I could do with answering.
If an object is network aware like a car player object, does it only transmit its new location to the other clients when it moves or would it transmit its new location if something its was on moved its location.
Example, a car is on a ferry and the ferry is moving along a path. The car would follow as its a child of the ferry. The ferry would be updating all its clients of its new local position in the mission group but would the car also be notifying the clients of its new global position as its local position is still the same.
Just a thought.
If it does, I would need to also take a look at changing this to lower the network traffic.
#15
01/15/2007 (11:20 pm)
Progress update:
I have just started working on this and managed to fix a few bugs in the code. I now have the child objects moving relative to the parent object and the child objects local postion and rotation are updated when it is added.
I am currently stuck on how the editor updates the object when its moved using the gizmo. I can't seem to find the function call so am having to try and code around it by getting the setTransform function to test if the object is a child, and if it is, have it call the setLocalTransform instead. I think this might be the best place to put the code anyway.
I will keep you posted on my progress soon.
#16
01/16/2007 (10:53 am)
Ah, i have fiddled with that before, find:
void WorldEditor::on3DMouseDragged(const Gui3DMouseEvent & event)

then look for:
// do stuff
switch(mCurrentMode)
{
case Move:


from the file:
worldeditor.cc
#17
01/16/2007 (10:26 pm)
Thanks Caylo,
Although I didn't need to edit any code in worldeditor.cc, the functions helped me track down the error I was looking for.
I found the error in the function "void SceneObject::setTransform(const MatrixF& mat)".
I found that child objects needed their localtransform setting from the newly set transform so added the following after the line "setRenderTransform(mat);".
//If this is a child object we need to update the local transform.
	if (getParent() != NULL) {
		//Con::errorf("SceneObject::setTransform on child object.");
		calcLocalTransformFromTransform();
	}
Now setTransform updates the localTransform and vis versa when using the editors Gizmo or when set through code.
Wheyhey!.
I have also moved the code from setTransform to setGlobalTransform and created a new setTransform function to handle child objects differently. I did the same for setPosition aswell.

Next I need to look into how the scene object transmits it self over the network.
I need to make child objects refrain from transmitting their new transform when its set and add code to allow the child to transmit new localtransform across the network instead.
This will cutdown on the network traffic. At the moment every child is transmitting its new transform when ever the parents transform is moved. This isn't needed and is a waste of network traffic as the client will move the child when it moves the parent as the parent calls the function "void SceneObject::onParentTransformChanged()" on the child object when the parents transform is changed and this function updates the transform of the child using the localtransform.
We do however need to update the child on the clients if the localtransform is changed and this will in turn update the childs transform using the new localtransform.
Can anyone point me in the direction of the code that transmits the sceneObject over the network?.
#18
01/18/2007 (12:01 am)
After reading up on how the network code works (OMG my brain hurts), the vehicle code always had problems keeping up across networks with 12 odd people all moving at 50 odd MPH. I may look into this aswell after I have finished with this.
I also found a better way to get around the interpolateTick issues
These are small steps but all in the right direction. It will be nearly a month before I can test the code out with 12 or more players, thats when our next uklanparty meet is happening and we alway test out the code there.
Next I want to test out the vehicle on a moving object as its parent and see how it moves localy and over a network, I can only test with two machines though.
I am going to call this whole thing when its finished "Scriptable Network Object Groupings" (SNOG) LOL.