Image Datablock Question
by Drew Hitchcock · in Torque Game Engine · 07/28/2004 (3:39 pm) · 6 replies
Is it possible to "derive" a ShapeBaseImageData datablock from another ShapeBaseImageData datablock?
Basically, I want one image to inerit all of another image's properties, like its state information and its ammo/projectile information, but I want to specify a unique shape and mountpoint for each derived copy. This way, I could have weapons that act the same way, but look different based on where they attach to the model. I have a system like this working, but right now I have separate datablocks for each position, and if I could figure this out, it would greatly reduce the amount of redundant code I have, and would make it less tedious to add and modify weapons.
I THINK that if this were any other sort of thing, I could swap in a single datablock when I called new, with something like
In that case, I could just put everything into datablock_to_get_default_stuff_from, and override the model and mountpoint to whatever I want. At least, I think it works like this.
But for images, you don't really call new, as far as i know, you just call mountImage. So is there any way I can do this without making a mostly identical datablock for each different position?
Basically, I want one image to inerit all of another image's properties, like its state information and its ammo/projectile information, but I want to specify a unique shape and mountpoint for each derived copy. This way, I could have weapons that act the same way, but look different based on where they attach to the model. I have a system like this working, but right now I have separate datablocks for each position, and if I could figure this out, it would greatly reduce the amount of redundant code I have, and would make it less tedious to add and modify weapons.
I THINK that if this were any other sort of thing, I could swap in a single datablock when I called new, with something like
%mything = new Thingie()
{
dataBlock = datablock_to_get_default_stuff_from;
shapeFile = "~/path/to/the_shape.dts";
mountPoint = 1;
}In that case, I could just put everything into datablock_to_get_default_stuff_from, and override the model and mountpoint to whatever I want. At least, I think it works like this.
But for images, you don't really call new, as far as i know, you just call mountImage. So is there any way I can do this without making a mostly identical datablock for each different position?
About the author
#3
new staticshape(%boardSpaceName : gameSpace)
{
datablock = gameSpace;
shapeFile = $gamepieceDirectory @ $currentPieceShapeFile;
category = "takenSpace";
position = %X SPC %Y SPC "0";
strength = $currentPieceStrength;
playerOwner = $currentPlayer;
};
However, it refuses to change the shapeFile from the default that was in the original gameSpace datablock. And if I remove the datablock = line, then I get an error stating that it cannot register the object. (Also, this problem still occures if I replace my globals under shapeFile with a directory and file.)
Any ideas?
Thanks in advance,
-Dave C.
09/07/2004 (10:57 pm)
Heya... I'm trying to do something sorta like this, only I'm doing it with a staticshape like this:new staticshape(%boardSpaceName : gameSpace)
{
datablock = gameSpace;
shapeFile = $gamepieceDirectory @ $currentPieceShapeFile;
category = "takenSpace";
position = %X SPC %Y SPC "0";
strength = $currentPieceStrength;
playerOwner = $currentPlayer;
};
However, it refuses to change the shapeFile from the default that was in the original gameSpace datablock. And if I remove the datablock = line, then I get an error stating that it cannot register the object. (Also, this problem still occures if I replace my globals under shapeFile with a directory and file.)
Any ideas?
Thanks in advance,
-Dave C.
#4
I might be confused about what you're trying to do.
09/07/2004 (11:20 pm)
Does this work?%boardSpaceName = new staticshape()
{
datablock = gameSpace;
shapeFile = $gamepieceDirectory @ $currentPieceShapeFile;
category = "takenSpace";
position = %X SPC %Y SPC "0";
strength = $currentPieceStrength;
playerOwner = $currentPlayer;
};I might be confused about what you're trying to do.
#5
09/07/2004 (11:28 pm)
Wait, is gameSpace a datablock or a staticshape?
#6
Thx for the help, though!
09/13/2004 (12:45 pm)
No, that didn't work either, however I found a work around for it. And gameSpace was a datablock.Thx for the help, though!
Torque Owner Sam Guffey
datablock ShapeBaseImageData(CrossbowImage) { // Basic Item properties shapeFile = "~/data/shapes/weapons/crossbow/weapon.dts"; emap = true; // Specify mount point & offset for 3rd person, and eye offset // for first person rendering. mountPoint = 0; eyeOffset = "0.1 0.4 -0.6"; correctMuzzleVector = false; className = "WeaponImage"; // Projectile && Ammo. item = Crossbow; ammo = CrossbowAmmo; projectile = CrossbowProjectile; projectileType = Projectile; // Initial start up state stateName[0] = "Preactivate"; stateTransitionOnLoaded[0] = "Activate"; stateTransitionOnNoAmmo[0] = "NoAmmo"; // Activating the gun. Called when the weapon is first // mounted and there is ammo. stateName[1] = "Activate"; stateTransitionOnTimeout[1] = "Ready"; stateTimeoutValue[1] = 0.6; stateSequence[1] = "Activate"; // Ready to fire, just waiting for the trigger stateName[2] = "Ready"; stateTransitionOnNoAmmo[2] = "NoAmmo"; stateTransitionOnTriggerDown[2] = "Fire"; // Fire the weapon. Calls the fire script which does // the actual work. stateName[3] = "Fire"; stateTransitionOnTimeout[3] = "Reload"; stateTimeoutValue[3] = 0.2; stateFire[3] = true; stateRecoil[3] = LightRecoil; stateAllowImageChange[3] = false; stateSequence[3] = "Fire"; stateScript[3] = "onFire"; stateSound[3] = CrossbowFireSound; // Play the relead animation, and transition into stateName[4] = "Reload"; stateTransitionOnNoAmmo[4] = "NoAmmo"; stateTransitionOnTimeout[4] = "Ready"; stateTimeoutValue[4] = 0.8; stateAllowImageChange[4] = false; stateSequence[4] = "Reload"; stateEjectShell[4] = true; stateSound[4] = CrossbowReloadSound; stateName[5] = "NoAmmo"; stateTransitionOnAmmo[5] = "Reload"; stateSequence[5] = "NoAmmo"; stateTransitionOnTriggerDown[5] = "DryFire"; // No ammo dry fire stateName[6] = "DryFire"; stateTimeoutValue[6] = 1.0; stateTransitionOnTimeout[6] = "NoAmmo"; stateSound[6] = CrossbowFireEmptySound; };Now we create a new image as a child of the original crossbow.dataBlock ShapeBaseImage(CrossbowImage_2 : CrossbowImage) { shapeFile = "~/data/shapes/weapons/crossbow/weapon_2.dts"; mountPoint = 2; // Projectile && Ammo. item = Crossbow_2; ammo = CrossbowAmmo_2; projectile = CrossbowProjectile_2; };Image2 will use all the properties of the original, but it will use a different shapeFile, item, mountPoint, ammo and projectile.. Inheriting from a parent will save alot of space when creating new images and such, this method can be used for all datablocks.