Game Development Community

A way to import a dae as separate models?

by Kyrah Abattoir · in Game Design and Creative Issues · 04/12/2013 (2:32 pm) · 11 replies

I've been toying with city generators and torque, thing is, loding them as a single model is kind of a bad idea, is there a way to load each "model" in a .dae as it's own object in torque?

Obviously i want to avoid exporting each building as it's own and placing them back by hand...

#1
04/12/2013 (2:48 pm)
You would have to seperate them indivdualy and press export, if you are lucky he keeps the coordinates and you don't have to place them back by hand. After that you could make prefabs in Torque. But a few hours of placing things by hand is nothing compared to what you spend elsewhere.
#2
04/12/2013 (3:32 pm)
well when it's a few hundred buildings (testing) as a single dae, torque crash on import.

I will try what you suggested... On a side note is there a tool to split daes automatically?
#3
04/12/2013 (3:54 pm)
You likely will not have 100 different buildings, maybe it is just 10 different buildings, so you export 10 and multiply them.
#4
04/12/2013 (4:29 pm)
for "testing" i do have a few hundred :) i'm toying with city generators to get a feel for things, it's not ment to be a final project but automatically splitting per models would really be handy...
#5
04/12/2013 (4:37 pm)
I think you're running into the poly limit issue from a while back on your DAE import - I know that's not real useful, but it is a known issue.

Perhaps a stand-alone script or program to handle breaking up the models? I might be able to work something out there. Are the buildings each individually assigned their own nodes or is it just one monolithic model?
#6
04/13/2013 (1:13 pm)
A script to break the model up would be nice, some way to save the offset of the object for placing it back into torque would be handy too.

If you can come up with something it would be most useful.

I think they have teir own nodes, in max they are separate objects and the dae import in T3D does see them as distinct nodes i believe.
#7
05/28/2013 (5:17 pm)
Not sure if this thread is still active, but the way that I handle this is to write an export script from my 3D program, that cycles through my entire city and exports them one building at a time into individual objects.

As long as they all have the same coordinates in the game engine, the city will appear exactly as it does in the modeler.
#8
05/28/2013 (9:43 pm)
"Not sure if this thread is still active, but the way that I handle this is to write an export script from my 3D program, that cycles through my entire city and exports them one building at a time into individual objects. "

@Dion,
which 3d program u using?
any chance to have a very simple script as an example?

then i can create one. rather then searching here and there for starting material.
#9
05/31/2013 (1:32 pm)
I use modo, one of the features that it has in the export is the ability to only export visible models, so I build a simple predictable hierarchy into my city models. Here's the script that I use...


#perl
#modo to Torque export script using layer visibility to break models
#into separate objects

@layers = lxq("query layerservice layers ? fg");
lx("pref.value units.system game");
lx("pref.value units.gameScale 1.0");
lx("user.value sceneio.collada.save.hidden.items false");

$itemNum = lxq("query sceneservice item.N ? all");

$fileName = lxq("query sceneservice scene.name ? fg");
$fileFullPath = lxq("query sceneservice scene.file ? fg");
$childSet = "";
$childRemember = "";
@pathSplit = split(/$fileName/,$fileFullPath);
@fileLists = ();
@idLists = ();

lx("select.drop item");

for($i = 0;$i < $itemNum; $i++){
	$thisType = lxq("query sceneservice item.type ? $i");
	if($thisType eq "groupLocator"){
		$stringTest = lxq("query sceneservice item.name ? $i");
		$baseTest = substr($stringTest, -4);
		if($baseTest eq "Base"){
			$itemID = lxq("query sceneservice item.id ? $i");
			lx("select.subItem $itemID set mesh");
			lx("layer.setVisibility $itemID allOff");
			lx("select.drop item");
			$stringTest = substr($stringTest,0 , -4);
			push(@fileLists,$stringTest);
			push(@idLists,$itemID);
		}
	}
}

$count = 0;
foreach $file(@fileLists){
	$outPath = "$pathSplit[0]$file.dae";
	lx("select.subItem $idLists[$count] set mesh");
	lx("layer.setVisibility $idLists[$count] true");
	@collisionChildren = lxq("query sceneservice item.children ? $idLists[$count]");
	
	foreach $child(@collisionChildren){
			$childTestName = lxq("query sceneservice item.name ? $child");
			$childTest = substr($childTestName, -9);
			if($childTest eq "Collision"){
				$childSet = $child;
			}
			
	}
	
	if($childSet ne ""){
		lx("select.subItem $childSet set mesh");
		$childRemember = lxq("query sceneservice item.name ? $childSet");
		lx("item.name {ColMesh-1} mesh");
	}
	
	
	lx("!scene.saveAs {$outPath} COLLADA_141 true");
	
	if($childRemember ne ""){
		lx("item.name {$childRemember} mesh");
		lx("select.subItem $idLists[$count] set mesh");
	}
	
	lx("layer.setVisibility $idLists[$count] allOff");
	lx("select.drop item");
	$childSet = "";
	$childRemember = "";
	$count++;
}

#item.channel locator$visible allOff

It also saves all of these files to the same directory as the base file, so I put my main file into the torque game shape etc... directory and the entire city will update with every run of the script
#10
05/31/2013 (4:38 pm)
modo and perl.
2 completely new things to me.i will try out with demo version,if demo one support plugin/external scripts

anyway thanks for the script
#11
06/03/2013 (3:23 pm)
Yeah, the demo version is completely unnerfed, scripts and everything work with it...