MY Custom MIS Exporter, with mild success
by Cinder Games · 04/04/2006 (10:07 pm) · 13 comments
I spent the past couple days writing a MIS exporter for Lightwave 3D. I wanted this to same me tons and TONS of time with my project. I'm making my "levels" with strickly DTS objects i create in lightwave. What this enables me to do is, after exporting a shape to DTS...... to place and arrage as many copies of any DTS objects i have wherever i like with a precision that i feel Torque's UI lacks. Not to mention multiple viewports or any of that.
Basically i can use all the tools that Lightwave offers to place objects. It feels more natural to use it as well.
I hit some hurdles early on with converting lightwave Euler Angles(Heading, Pitch, Bank) into lightwaves Quaternion Angles (X Y Z A). that took me almost a night to do. Then followed by issues with determing what lightwave calls UP and what torque thinks is UP, so i spent some time syncing the Axis. And what i have so far is impressive to me at least. Here's some pics.
Here's a shot of some brick shaped items in lightwave

and here they are in Torque. I tried to match up the angles, but it's not quite there visually.

But everything appears to rotate and translate how i like.
So far i only have it working with static shapes. But the possibilies are far from limited. I can use lightwave to also make paths for bots, or other objects.
When i am a little futher down the road, i'll release this little LScript files for anyone else to use.
Basically i can use all the tools that Lightwave offers to place objects. It feels more natural to use it as well.
I hit some hurdles early on with converting lightwave Euler Angles(Heading, Pitch, Bank) into lightwaves Quaternion Angles (X Y Z A). that took me almost a night to do. Then followed by issues with determing what lightwave calls UP and what torque thinks is UP, so i spent some time syncing the Axis. And what i have so far is impressive to me at least. Here's some pics.
Here's a shot of some brick shaped items in lightwave

and here they are in Torque. I tried to match up the angles, but it's not quite there visually.

But everything appears to rotate and translate how i like.
So far i only have it working with static shapes. But the possibilies are far from limited. I can use lightwave to also make paths for bots, or other objects.
When i am a little futher down the road, i'll release this little LScript files for anyone else to use.
About the author
#2
04/04/2006 (10:18 pm)
Lightwave Dave? nah, haven't contacted him about it. I try not to bother other people, especially since i usually don't know what i'm talking about :) This is actually my very first "plugin" i wrote for Lightwave. I have never used it's LScript before, but i found it to be so so similar to torquescript. I have plans to include lights(already works for positions and rotations) but i'll just have to get around to grabbing the RGB values for them. Then after that... hmmm what do i need to have it do after that?
#3
But its kind of interesting idea though. I still dont quite understand the need, but then I dont use lightwave I use the world editor.
04/05/2006 (2:13 am)
Is it just me Ramen, or do those shots not match up properly. Particularly the orientation of the top left boulder seems to be different.But its kind of interesting idea though. I still dont quite understand the need, but then I dont use lightwave I use the world editor.
#4
04/05/2006 (6:57 am)
I have a feeling the reason the shots do not look the same is due to the FOV angle, Torque uses a default one of 90 degrees, and although I don't know Lightwave, most other modelling software doesnt use a 90 degree FOV.
#5
I think the 'need' is workflow simplification more than anything. While I love being able to load meshes into 3D World Studio, I really don't like having to make my levels, export them and then completely reconstruct them in the world editor all over again. A .mis exporter in a polysoup app would be nice if your levels were mainly DTS objects (say, with the RTS kit or somesuch).
I am hoping that with the mesh loading features of Constructor, we will be able to write a .mis exporter for it so that we can load our levels and decorative meshes in one fell swoop!
It would be nice if it would make my game for me, too.
04/05/2006 (7:29 am)
@PhilI think the 'need' is workflow simplification more than anything. While I love being able to load meshes into 3D World Studio, I really don't like having to make my levels, export them and then completely reconstruct them in the world editor all over again. A .mis exporter in a polysoup app would be nice if your levels were mainly DTS objects (say, with the RTS kit or somesuch).
I am hoping that with the mesh loading features of Constructor, we will be able to write a .mis exporter for it so that we can load our levels and decorative meshes in one fell swoop!
It would be nice if it would make my game for me, too.
#6
The only thing that is kind of uncool about doing it for Lightwave is a limitation of the application itself. The Layout and Modeler are two seperate apps. So if you are using the layout program for this right now then its kind of limited because you cannot actually create any geometry in that app. If you do it in modeler well the issue there is that since its all poly soup in modeler and LW doesnt really have the concept of a single object type container that apps like Maya and Max have. So youd have to figure out a way of setting up groups or what not.
Ramen:
Well the orientation worked well enough. The script I gave you hasnt given me any issues when creating my MIS files. If there are any ways to improve on the precision though then please hit me up so I can put it into my app as well.
04/05/2006 (1:15 pm)
Yup is all about pipelining. The less you have to switch between applications to work on something the more time you have at actually kicking out stuff. Right now I have workflow for creating my geometry for DTS's, laying them out, creating almost any entity type/placething them(or being able to add entity types easily), changing their values, and exporting (DTSs and MIS file) everything with a single mouse click all within Maya. Also it allows you to create a really simple version of your dts files really fast for placement and all. Test it out for gameplay and then res-up your geo to final versions when your ready.The only thing that is kind of uncool about doing it for Lightwave is a limitation of the application itself. The Layout and Modeler are two seperate apps. So if you are using the layout program for this right now then its kind of limited because you cannot actually create any geometry in that app. If you do it in modeler well the issue there is that since its all poly soup in modeler and LW doesnt really have the concept of a single object type container that apps like Maya and Max have. So youd have to figure out a way of setting up groups or what not.
Ramen:
Well the orientation worked well enough. The script I gave you hasnt given me any issues when creating my MIS files. If there are any ways to improve on the precision though then please hit me up so I can put it into my app as well.
#7
Plus lets say i want to have an area that looks like a tornado hit it. How do you do that with torque? I'll simply run some physics effects in lightwave, and bam. everything is scattered about in torque with a push of a button.
@Juan, Lightwave isn't limited like you think. You can run both Layout and Modeler at the same time. They are synced, so any changes made in either program are automatically updated. I feel having two apps is actually better anyhow. Less buttons on screen mostly.
Overhead as best as i can get....


It does seems like it's got some angle issues now that i look at it like this. I'll need to investigate and find out. :) Thanks for pointing that out Phil.
Edit
Seems to be related to bank :( Everything matches up perfectly until i apply some bank angle to it in LW.
04/05/2006 (4:03 pm)
Yes. Pipelining is the main reason i want to do this. I find it 1000 times easier to simple make a small change, hit a button, then load up torque and the level is arranged how i like.Plus lets say i want to have an area that looks like a tornado hit it. How do you do that with torque? I'll simply run some physics effects in lightwave, and bam. everything is scattered about in torque with a push of a button.
@Juan, Lightwave isn't limited like you think. You can run both Layout and Modeler at the same time. They are synced, so any changes made in either program are automatically updated. I feel having two apps is actually better anyhow. Less buttons on screen mostly.
Overhead as best as i can get....


It does seems like it's got some angle issues now that i look at it like this. I'll need to investigate and find out. :) Thanks for pointing that out Phil.
Edit
Seems to be related to bank :( Everything matches up perfectly until i apply some bank angle to it in LW.
#8
04/05/2006 (5:58 pm)
UGH, further exploration leads down the path of Gimbal Lock causing the issues. Wonder how i'm gonna fix this.
#9
04/06/2006 (8:16 am)
Yea, for any 3d artist, editing in their home app is much more intuitive than screwing with Torque's world editor that sometimes can screw up. :)
#10
04/10/2006 (4:57 pm)
Ramen here's how I output orientation to DirectX from LW - is this different to what you do? is torque different? // set rotation data
f.write("\t\tOrientation\t=\t",obj.getRotation(frame).x);
f.write(",");
f.write(obj.getRotation(frame).y);
f.write(",");
f.write(obj.getRotation(frame).z); f.nl();
#11
Here's my LS file. feel like checking it out? while it's not creating full blown MIS files yet, it's creating some shape chunks. the created file can then be called in torque and it will generate those objects.
To test, select an object(s) in Layout, run the script.
What happening is something odd when you rotate on 3 axis. any two seems fine, but when a third is put in the loop, it doesn't act right.
04/10/2006 (5:01 pm)
generic
{
scene = Scene();
s = scene.getSelect();
arraysize = size(s);
//Open File
filename="J:\torqueagain\example\starter.fps\server\scripts\test.cs";
file = File(filename,"w") || error("Couldn't open output file!");
//Main loop for selected objects
for(selitem = 1; selitem<= arraysize; selitem++){
itemname = s[selitem].name;
obj= Mesh(itemname);
//check for a paranthesis
paranth = strright(itemname,1);
//if we have one, we need to crop the last three characters for the datablock name
if(paranth == ")"){
newlen=itemname.size();
newlen-=4;
datablockname = strsub(itemname,1,newlen);
}
else
datablockname = itemname;
pos= obj.getPosition(0);
rot = obj.getRotation(0);
scl = obj.getScaling(0);
// Convesion to Quaterions
MPI = 3.14159265358979323846;
//Heading
radX=((rot.x * MPI) / (180));
//Pitch
radY=((rot.y * MPI) / (180));
//Bank
radZ=((rot.z * MPI) / (180));
// radY -= radY*2;
c1 = cos(radY/2);
s1 = sin(radY/2);
c2 = cos(radZ/2);
s2 = sin(radZ/2);
c3= cos(radX/2);
s3 = sin(radX/2);
c1c2 = c1*c2;
s1s2 = s1*s2;
w =c1c2*c3 - s1s2*s3;
x =c1c2*s3 + s1s2*c3;
y =s1*c2*c3 + c1*s2*s3;
z =c1*s2*c3 - s1*c2*s3;
angle = 2 * (acos((c1*c2*c3) - (s1*s2*s3)));
//Keeping the angle a degree
angle = (angle*180)/MPI;
norm = (x*x)+(y*y)+(z*z);
if (norm < 0.001){
x=1;
y=z=0;
}
else {
norm = sqrt(norm);
x = x / norm;
y = y / norm;
z = z / norm;
}
x = round(x,4);
y = round(y,4);
z = round(z,4);
// //Pitch //Bank //Heading
result = (string(y) + " " + string(z) + " " + string(x) + " " + string(angle));
// xresult = ("Pitch: " + string(rot.y) + " Bank: " + string(rot.z) + " Heading: " + string(rot.x) + " " + string(angle));
fixedpos= string(pos.x) + " " + string(pos.z) + " " + string(pos.y);
file.writeln("new StaticShape() {");
// file.writeln(" Xrotation = \""+xresult+"\"\;");
file.writeln(" rotation = \""+result+"\"\;");
file.writeln(" position = \""+fixedpos+"\"\;");
file.writeln(" Scale = \""+scl+"\"\;");
file.writeln(" dataBlock = \""+datablockname+"\"\;");
file.writeln("}\;");
}
file.close();
//error(result);
}Here's my LS file. feel like checking it out? while it's not creating full blown MIS files yet, it's creating some shape chunks. the created file can then be called in torque and it will generate those objects.
To test, select an object(s) in Layout, run the script.
What happening is something odd when you rotate on 3 axis. any two seems fine, but when a third is put in the loop, it doesn't act right.
#12
04/10/2006 (5:47 pm)
excellent i'll check it out and see how it goes.
#13
04/10/2006 (6:52 pm)
Feel free to hit me up on AIM using Ramen Sama. or ramensama at yahoo.com for Yahoo messenger. Maybe we can figure it out together.
Employee David Montgomery-Blake
David MontgomeryBlake