Game Development Community

Prefab Point of Origin

by Dusty Monk · in Torque 3D Professional · 01/26/2011 (2:33 pm) · 10 replies

When creating prefabs in T3D, does anyone know if there is a way to specify one of the object's point of origin as the prefab's point of origin -- rather than it taking the centerpoint of the collected objects in the prefab as it's origin point?

If there isn't -- then I would like to put this on the wishlist for Final T3D if possible.

Here's a usage case: In my level, I've placed a building. Now around the building I've placed potted plants, lights, benches, literally dozens of accessory items to accent the building. I bundle all the objects together and create a prefab out of it.

Now, say I've already placed dozens of such buildings on the level, and I want to replace all of them with my new prefab package. This would be a 5 second text search & replace on the mission file if the prefabs location point was the *same* as the building. But it's not, and so even if I do the text search and replace, I still have to go through and tweak each and every prefab's location t get it positioned correctly.

And actually, this is pretty much the usage case for just about every instance of prefab I use, and I use them a LOT. In pretty much every case, what I really want is to pick a particular object in the prefab, and have that object's origin point serve as the prefab's origin point, rather than some arbitary center point made from the collected objects.

Just a thought..

Dusty

About the author

Dusty Monk is founder and president of Windstorm Studios, an independant game studio. Formerly a sr. programmer at Ensemble Studios, Dusty has worked on AAA titles such as Age of Empires II & III, and Halo Wars.


#1
01/26/2011 (2:45 pm)
Somebody clever (i think konrad as usual maybe) made a code mod for prefabs to set the largest dominant object as the focus that may be what you are looking for, if not it seems an idea place to start your own modifications.

sorry i dont remember any other details and i suck at searching for stuff i really do
#2
01/26/2011 (2:52 pm)
www.garagegames.com/community/blogs/view/20629

//not specifically what you wanted but perhaps it would suit the purpose.
#3
01/26/2011 (3:57 pm)
ty eb, thats the one i saw.
#4
01/26/2011 (4:14 pm)
Thanks for the link! That will certainly do the trick! Glad to see I'm not the only one for which this makes the most sense.. :)

Dusty
#5
01/26/2011 (6:23 pm)
I'll get this into 1.1 final... default to Center, with options for First and Largest.
#6
01/26/2011 (6:58 pm)
Outstanding!

One quick question and comment. One modification I made to Konrad's resource was to exclude light objects. They are almost always the thing with the biggest extent, but there is never a case where the light object is the thing I want to be the anchor -- in all cases it's what I'v put the lights around.

I think if you can specify first object, instead of biggest, this will nicely work around that problem, but my question is is there a way to specify which object is first in the prefab? The only operations I know are convert selection to prefab, and explode prefab. Would the order in which you select them specify first, or will there by any way to re-arrange the items in a prefab after it's created, so you can specify which object is the first object in the prefab?

Thanks in advance,

Dusty
#7
01/26/2011 (8:22 pm)
Quote:exclude light objects
Good point... i should exclude everything that has a global bounds or is clearly non-visible like lights.

Quote:Would the order in which you select them specify first
Yea... i think that would be the way to define which is first in the prefab.

#8
01/27/2011 (1:25 am)
@Tom: I am completely ignorant as to the use of prefabs in T3D, and have not yet read any of that C'code, but this seems time to postulate a inquiry of ignorance.

How easy would it be to scan the prefab for something with a name, such as "ANCHOR" as to place the Prefab Point of Origin?
#9
01/27/2011 (8:02 am)
@Caylo - It could be possible... i'll make sure to look if there is some other trick i could implement in there, but the focus is more on bugs than features for 1.1 final.
#10
01/27/2011 (1:44 pm)
Yes, I agree, focus on bugs!


I ask about naming an ANCHOR Point of Origin for Prefabs because the other methods listed here are only feasible in specific situations (fail in complex prefabs what require complicated selection of objects).

So if your expecting to get any extra prefab fine tuning into 1.1Final, it should be more encompassing feature tuning then use of "Center, First or Largest", as none of those options solves the real problem of better functionality or flexibility. Many editors offer the option of user-placeable Prefab Point of Origin, what is often overly complex and difficult to use.
A naming system would be the most flexible option (with a default to Center).