Typemasks information?
by FruitBatInShades · in Torque Game Engine · 02/01/2005 (3:08 am) · 5 replies
Can someone help me try and understand typemasks? I cannot find them in the documentation. I assume they denote what type of objects causes an onCollision event, is that correct?
1. Is there a list of the default masks?
2. Can you create a mask for your own object types?
3. How do I check what type of object I collided with in onCollision?
4. My items only fire onCollision when they hit a player, how do i specify what they should collide with?
Thanks
1. Is there a list of the default masks?
2. Can you create a mask for your own object types?
3. How do I check what type of object I collided with in onCollision?
4. My items only fire onCollision when they hit a player, how do i specify what they should collide with?
Thanks
#2
02/01/2005 (6:14 am)
Thanks Thomas, that may be a little bit ahead of me! I am trying to define what things will collide with in script. I have a ItemData object that is not reporting a collision with anything other than the player. It obviously is colliding with terrain and interiors because it bounces off, but i do not get a collision event.datablock ItemData(Grenade)
{
category = "Grenades";
shapeFile = "starter.fps/data/shapes/Grenade.dts";
mass = 0.7;
friction = 1;
elasticity = 0.3; //how much bounce 0.1 = none, 1 = funny
repairAmount = 50;
maxDamage = 0.2;
directDamage = 1;
damageRadius = 20;
radiusDamage = 1;
areaImpulse = 200;
dynamicType = $TypeMasks::DamagableItemObjectType | $TypeMasks::TerrainObjectType;
explosion = CrossbowExplosion;
fadeIn = 0;
rotate = true;
};
function Grenade::onCOllision(%this,%obj,%col)
{
// THIS IS ONLY EVER GETS CALLED WHEN THE ITEM COLLIDES WITH A PLAYER!
// I NEED TO KNOW WHEN IT COLLIDES WITH TERRAIN, DTS OR INTERIORS
echo("Grenade::onCollision");
//%col.dump();
}
#3
It might be possible to manipulate the item type mask for the collision from script, but I dont know about that.
Best would simply to hack the engine sources
02/01/2005 (7:33 am)
The onCollision callback is only called from the engine when the (in the C++ engine) defined object types are in collision. So the filtering doesnt take place in script.It might be possible to manipulate the item type mask for the collision from script, but I dont know about that.
Best would simply to hack the engine sources
#4
02/01/2005 (8:18 am)
Fruitbat, rolls up sleeves, prays to the computer gods and start to mess with the engine!!!
#5
02/01/2005 (8:35 am)
Ineteresting... in Item.cc items are set to collide with the following types, but there is no call back peformed!const U32 sClientCollisionMask = (TerrainObjectType | InteriorObjectType |
StaticShapeObjectType | VehicleObjectType |
PlayerObjectType | StaticTSObjectType);
const U32 sServerCollisionMask = (sClientCollisionMask);
Torque Owner Thomas \"Man of Ice\" Lund
They are as you suspect - a type name for objects.
1)
objectTypes.h line 39 and forward
main.cc from line 338 and forward for console exposure
2)
Yes. Just add to the above lists and use it
Typically you define the object type in the constructor for the class (not the datablock).
E.g. for a player:
Player::Player() { mTypeMask |= PlayerObjectType;3)
I cant remember for sure - but the object that you collided with has a method where you can retrieve its type mask - then you check if a certain object type is part of that mask
4)
For projectiles, you just add the type to one of the types defined in projectile.cc
const U32 Projectile::csmStaticCollisionMask = TerrainObjectType | InteriorObjectType | StaticObjectType; const U32 Projectile::csmDynamicCollisionMask = PlayerObjectType | VehicleObjectType | DamagableItemObjectType;The difference between the 2 are if things should recieve damage or not when a projectile explodes.