Game Development Community

Creating an interior as an object

by Malcolm · in Torque Game Engine · 09/21/2006 (7:48 am) · 14 replies

Hi Guys,
I was wondering whether it is possible to create an interior as an object and then grab a handle to the interior so that I can run transforms on it.
I tried to create an interior with the keyboard m key however darn thing didn't appear.
Thanks in advance.
Mal.

#1
09/21/2006 (8:11 am)
Are you talking about placing an interior using the editor?

Then yes, just click and place it then move it around with its "Gizmo". (The X Y Z thing).

Or are you talking about making one from a program like quark or 3Dworldsutdio?
#2
09/21/2006 (4:41 pm)
No sorry,
I'm talking about placing an interior through script as a new object and then
transforming it.
Cheers
Mal
#3
09/21/2006 (9:41 pm)
In the game dynamically to be more precise.
#4
09/21/2006 (9:55 pm)
If you look in the mission files, the placement of the interiors is just a call to "new" for the interior object class. You can do that yourself, in script, as much as you want. The call to "new" returns the actual handle to the object.
#5
09/22/2006 (1:33 am)
Thanks J\"hplus\" W,
I was doing that however I was using %handle = new etc...
Maybe I need to user the global identifier $handle.
I then bound a couple of keys to the move function to apply a transform to the interior, the problem was that when I started the game the interior didn't seem to appear.
I'll post the script I used a little later when I'm home to see if I'm doing something wrong with that.
Cheers
Mal
#6
09/22/2006 (1:02 pm)
Hi All,
Thanks so much for your advice, I appreciate it. I worked it out thanks to J\"hplus\" W.

This script worked, so if you ever want to move an interior this works. The only draw back was that when your model is standing in the interior and it is moved the model stays where it is and your model goes through the wall as the interior passes. Bit dodgy.

Any way the reason I wanted to know this was so that I could use interiors as my massive ship, this way, players and NPC's could walk around inside the ship logging into navigation, tactical or engines. I saw a post the other night stating that you can use a shape with a portal on it, or series of portals for the windows, which appears to be inside the shape object. The player feels like they have entered the big space ship but they haven't.

//------------------------------------
// Mals moving interior
//------------------------------------


function InsertTestCruiser()
{
%cruiser = new InteriorInstance() {
position = "-64.2065 -423.404 -0.2";
rotation = "1 0 0 0";
scale = "1 1 1";
interiorFile = "~/data/interiors/box.dif";
useGLLighting = "0";
showTerrainInside = "0";
};
return %cruiser;
}

$myCruiser = InsertTestCruiser();

function MoveInterior(%cruiser, %dist, %angle, %scale)
{
%xfrm = %cruiser.getTransform();
%lx = getword(%xfrm,0);
%ly = getword(%xfrm,1);
%lz = getword(%xfrm,2);
%rx = getword(%xfrm,3);
%ry = getword(%xfrm,4);
%rz = getword(%xfrm,5);
%lx += %dist; // set to new x position
%angle += 1.0;
%rd = %angle;

%cruiser.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %rz SPC %rd);
}

Thanks again all,
PS: If anyone goes ahead and works out, or knows,how to fix the player going through the walls of the interior, drop it in.
Cheers
Mal
#7
10/01/2006 (8:14 pm)
So does anyone know how to stop the player from moving through walls when the interior is moved?
As the interior moves the player stays where he is until he is outside of the interior. Collisions don't seem
to move with the interior or something like that.
hmmm
#8
10/02/2006 (4:19 am)
There is a thread for moving platforms here somewhere that may hold the clues you need. It's a pathable platform that moves along a path. The player rides it.
Do a search for "moving platform" and you should find it.
#9
10/03/2006 (11:07 pm)
Thanks Mike I do remember it, that might help me cheers.
#10
10/12/2006 (8:14 am)
You might also want to look at class PathedInterior, and its functions setPathPosition() and setTargetPosition(). I haven't used it, so I don't know how robust it is. Note that this can only move an interior, though, it can't actually rotate it like you'd do with a "real" animation.
#11
10/13/2006 (1:56 am)
Yep, thanks hplus. I'm thinking of tackling it all a different way because it seems too many people are going for the huge space sim with landing on planets. I've scaled it all down into a map based game now with an edge. Cheers for your help.
#12
10/13/2006 (6:17 am)
Couldnt you do the above code something like this:

%angle +=1;
%newVector(%dist @ "0 0 0 0 0");
%xfrm = %cruiser.setTransform(addVector(%cruiser.getTransform(), %newVector));
%xfrm = setField( %xfrm , 5, %angle);


or...

edit: in the code you have


if anything you should take out %ry and %rd, cause they arent really needed...right?

function MoveInterior(%cruiser, %dist, %angle, %scale)
{
%xfrm = %cruiser.getTransform();
%lx = getword(%xfrm,0);
%ly = getword(%xfrm,1);
%lz = getword(%xfrm,2);
%rx = getword(%xfrm,3);
%rz = getword(%xfrm,5);
%lx += %dist; // set to new x position
%angle += 1.0;

%cruiser.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %rz SPC %angle);
}
#13
10/14/2006 (7:31 am)
Nice, I probably could. My sample was just a quick and dirty play with script that I extracted from the 3D Game programming All in One book and customed it a little. I'm all for improvement, thanks mb.
#14
10/15/2006 (3:51 pm)
I think i meant to put: %newVector = (%dist @ "0 0 0 0 0");