Jump to content

HitBox resource help.


LoLJester

Recommended Posts

Hello,


I need help with this resource on GG's website: http://www.garagegames.com/community/resource/view/6538/ and the ported one on GitHub: https://github.com/Azaezel/Torque3D/tree/player_hitboxes_rev2


Only problem that I have with this resource is that, although the hitbox is recognized on preload, the rayCast won't hit (during runtime) a shape exported to COLLADA that has a "-1" (or any) level of detail mesh attached to an animated bone.

My hitbox is named HBa-1 and weighed to an animated head bone. I chose the "-1" level of detail so that the hitbox remains invisible during the game.

I know about the stock hitbox feature that uses the shape's divided bounding box as hitboxes, but it is not useful for big enemies that have one or two small vulnerable spots.

I use Unwrap3D to export to DAE or DTS.

Link to comment
Share on other sites

Have you accounted for the castRayEA defintiion, https://github.com/Azaezel/Torque3D/blob/player_hitboxes_rev2/Engine/source/ts/tsCollision.cpp#L255 ? Animated bone attachments should work... half the reason I chose to leave that as a visible LOD and just set the things to transparent our end was so it was easy to change the material back and check that 'yeah, these things are indeed moving, and yeah, that hit did hit...

Link to comment
Share on other sites

@Happenstance: How do you mean? The function requires a detail level. Zero (0) for visible meshes and one (1) for the collision and hitbox meshes.


@Azaezel: Yes I did that. The hitbox convex shape is there and gets animated... it is just not hit by the rayCast. If I detach the same hitbox shape from the bone, the rayCastEA hits.


@Duion: To whom is that question directed to?

Link to comment
Share on other sites

Question is, is it the C++ code that is not working or the scripts or the model formats.

Isn't it working at all or isn't it working in the specific model format you want to have? You don't need the meshes to have -1 detail for not being visible, I think you can just make meshes without a material, then they will be invisible as well. Just as an example.

Link to comment
Share on other sites

What do you mean with "attached to a bone" you mean probably being a child of a bone node.

Can you provide your player model? So we can have a look.

I assume you did it wrong since the way you normally do a player character and the way the default soldier is build, is that you have an armature and then below that your models including all LOD levels, so that each model ends up having an armature modifier that transforms the mesh according the the bone movement.

So at no point there is any mesh attached to a bone, there are only bones attached to bones which then can have bones or nodes for mount points, eye points etc.


Well its hard to explain, but just import the default soldier of the template and you will.


I did not try it but I think the hitboxes are supposed to be like a LOD version, since it is an LOD version like a collision level, so you would make it as a LOD version and place it to the other LOD versions, so it will get affected by the same armature modifier as everything else.

Link to comment
Share on other sites

Followup:

Still not sure what's up with the blender setup, but yeah. did confirm the resource as-uploaded functions, though not in conjunction with a few other tweaks, like the lazer one, or the tinkering with per-material effects we're working on internally via castrayRendered...


@LoLJester using anything like either of those, or it pretty much down to a setup migrane?

Link to comment
Share on other sites

@Azaezel

Will this be merged into the main branch? With like a switch so people can choose if they want the new system or the old one, the current system could use an upgrade. This would help working with it, since it is always a hassel to maintain lots of different versions.

Link to comment
Share on other sites

Apologies. for clarity, 3 potential issues sping to mind


1) some additional alterations I've done this end can break it, like in the vid, left a note to myself to correct it not handling castrayRendered. You using anything similar?


2) In addition, that 1 to -1 does touch a few spots that I'll need to dig out of the original commit. might be one of those.


3) If neither one of those seems to be causing the issue, It could be the tool you're using to export to dae not understanding meshes mounted to bones but not applied to em. (I know for instance my head artist uses max. Can't import most of his rigs to directly check because blender wigs out on the armatures. Though pretty sure the blender export form me in that first vid with the screwed up hitboxes was strictly an issue between keyboard and chair there that I've yet to hunt down...)

Link to comment
Share on other sites

@Azaezel: Were you able to get some information from your artist on how he set-up that character? What software did he export the model from and in what format? Is there a specific set-up that the model has to have? I believe the problem stems from how the character is exported to T3D. By the way, I'm using T3D 1.2, but I don't think that should matter.

Link to comment
Share on other sites

I think the problem comes from mixing collision and nodes (armature bone is a kind of node).

See, when looking for a node transform you get the root value and not the position it should take from the current animation.


I think that can be fixed using in the server

mShapeInstance->animateNodeSubtrees(true)

but I'm not really sure if that can be used in this resource. I'm still stuck with 3.8 so I can't help right now, sorry.

Also, no idea what are the side effects... If anybody knows a detriment of its use I would be grateful to know, thanks.


If you want to check if this is your issue, make a model being a single bone going up and down. Then attach the col-mesh to it and try the cast ray a)aiming to the visible position of the animated bone and b)aiming to where the bone is at the root.


As an extra, this is the code I've for the node experiments. Feel free to use it if you find it useful (but, not sure if it's usable for the new versions).

Inside source/T3D/shapeBase.h add before the end of the definition of class ShapeBase:

public:
  MatrixF getNodeTransformN(const String &nodeName);
  MatrixF getNodeTransform(const S32 nodeIdx);


Inside source/T3D/shapeBase.cpp just at the end:


MatrixF ShapeBase::getNodeTransformN(const String &nodeName)  
{  
  S32 nodeIdx = mShapeInstance->getShape()->findNode(nodeName);  

  return getNodeTransform(nodeIdx);  
}  

MatrixF ShapeBase::getNodeTransform(const S32 nodeIdx)  
{  
  MatrixF returnValue = MatrixF::Identity;
  if(nodeIdx != -1)  
  {  
     if (isServerObject() && mShapeInstance)  
        mShapeInstance->animateNodeSubtrees(true);  

     returnValue = mShapeInstance->mNodeTransforms[nodeIdx];
  }  

  MatrixF objectTransform = getTransform();

  Point3F nodeObjPos = returnValue.getPosition();
  nodeObjPos.convolve( getScale() );
  returnValue.setPosition(nodeObjPos);

  returnValue.mulL(objectTransform);

  return returnValue;
}  

DefineEngineMethod( ShapeBase, getNodeTransform, TransformF, (const char* nodeName),,
  "Get the transform of a named node in the shape.\n"
  "@param nodeName Name of the node to check.\n" 
  "@return The current transform of the node.\n" )
{
  return TransformF(object->getNodeTransformN(nodeName));  
}

---------------------------------------------------------------------------------------------------------------------


In source\T3D\shapeImage.cpp look inside of
void ShapeBase::getMountTransform( S32 index, const MatrixF &xfm, MatrixF *outMat )
for
        MatrixF mountTransform = mShapeInstance->mNodeTransforms[ni];
And add these lines before:

        if (isServerObject() && mShapeInstance)  
           mShapeInstance->animateNodeSubtrees(true);  

Link to comment
Share on other sites

@Azaezel: Were you able to get some information from your artist on how he set-up that character? What software did he export the model from and in what format? Is there a specific set-up that the model has to have? I believe the problem stems from how the character is exported to T3D. By the way, I'm using T3D 1.2, but I don't think that should matter.

 

3DS Max using the OpenCollada plugin.

https://github.com/KhronosGroup/OpenCOLLADA

Link to comment
Share on other sites

  • 3 weeks later...
Hello,


I need help with this resource on GG's website: http://www.garagegames.com/community/resource/view/6538/ and the ported one on GitHub: https://github.com/Azaezel/Torque3D/tree/player_hitboxes_rev2


Only problem that I have with this resource is that, although the hitbox is recognized on preload, the rayCast won't hit (during runtime) a shape exported to COLLADA that has a "-1" (or any) level of detail mesh attached to an animated bone.

My hitbox is named HBa-1 and weighed to an animated head bone. I chose the "-1" level of detail so that the hitbox remains invisible during the game.

I know about the stock hitbox feature that uses the shape's divided bounding box as hitboxes, but it is not useful for big enemies that have one or two small vulnerable spots.

I use Unwrap3D to export to DAE or DTS.

 

Because of this line:

mShapeInstance->castRayEA(start, end, info,0,mDataBlock->HBIndex)

in player::castRay,

the hitboxes must always be in the highest (first) detail level. Detail zero, as passed in the function above before the hitbox index.


If you wanted to do something like define a specific detail size as the hitbox detail you would have to loop through the model's details, mShape->details (for (U32 i = 0; i < mShape->details.size(); i++)) testing mShape->details.size until you found the one you wanted to use, then send that detail level's index instead of zero. If you didn't want to run that loop on every raycast, you could search for and store the hitbox detail level index during preload.


Alternatively, I used to just make the boxes invisible with a material.

Link to comment
Share on other sites

Thanks Atomic Walrus; but, if you read above, that was not the problem. The problem seems to come from how the model is exported. It is CRUCIAL that the DAE or DTS exporter of the modeling program you use is FULLY compatible with the version of T3D you're using. I'm using Unwrap3D to export most of my models, but it is not 100% compatible with T3D. Instead, I used Milkshape3D's DTS Exporter Plus to export the models with HitBoxes. It works quite well, but not perfectly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...