AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INC] StudioHdr - Entity Model Information (https://forums.alliedmods.net/showthread.php?t=333857)

LuqS 08-10-2021 16:38

[INC] StudioHdr - Entity Model Information
 
StudioHdr - Entity Model Information

Description:
StudioHdr is a SourcePawn library (.inc) that lets developers get information about entity models. :bee:


Credits:
Феникс#1337 (Phoenix): For the base code:
Spoiler

KoNLiG: For letting me scream at him while the code didn't work and crashed the server.


List of features:
Quote:

StudioHdr methodmap

Bones
• `GetBone()` - Get a specific bone object by index.
• `FindBone()` - Find bone index by name.
• Get model 'NumBones'.

Hitbox Sets
• `GetHitboxSet()` - Get a specific hitbox set object by index.
• Get model 'NumHitboxSets'.

Skin Families
• Get model 'SkinFamiliesCount'.


Body Parts
• `GetBodyPart()` - Get a specific body part object by index.
• `FindBodyPart()` - Find body part index by name.
• Get model 'NumBodyParts'.


Attachments
• `GetAttachment()` - Get a specific attachment object by index.
• `FindAttachment()` - Find an attachment index by name.
• Get model 'AttachmentCount'.


Pose Parameters
• `GetPoseParameter()` - Get a specific pose parameter object by index.
• `FindPoseParameter()` - Find a pose parameter index by name.
• Get model 'NumPoseParameters'.



Bone methodmap
• `GetName()` - Get the name of the body part.
• `GetPos()` - Get the position of the bone (relative to model).

Hitbox methodmap
• `bone` - The related bone of the specific hitbox.
• `group` - The intersection group of the specific hitbox.
bounding box, or the ends of the capsule if flCapsuleRadius > 0
• `bbmin`
• `bbmax`
• `GetAngOffsetOrientation()` - Gets the angle offset orientation.
• `flCapsuleRadius` - The radius of the capsule (if not a capsule = 0.0)

HitboxSet methodmap
• `GetHitbox()` - Get a specific hitbox object by index.
• `NumHitboxs` - Number of hitboxes in the hitbox set.

BodyPart methodmap
• `GetName()` - Get the name of the body part.
• `base` - The base value of the body part.
• `nummodels` - Number of sub-models.


Attachment methodmap
• `GetName()` - Get the name of the attachment.

Pose Parameter methodmap
• `GetName()` - Get the name of the pose parameter.
• `start` - The minimum value of the pose parameter.
• `end` - The maximum value of the pose parameter.

Note:
This include was tested only in CS:GO (Linux).
This should work in any source engine based game (i am pretty sure).
If you want to support other games (and you can test), please write here below or add me on Discord!


Links:

GitHub Repository

LuqS 08-10-2021 16:39

Re: [INC] StudioHdr - Entity Model Information
 
Some code examples:

PHP Code:

bool SetBodyGroup(int entityint partint value)
{
    
// Get the current entity body.
    
int body GetEntProp(entityProp_Send"m_nBody");
    
    
// Get the StudioHDR
    
StudioHdr studiohdr GetEntityStudioHdr(entity);
    
    
// Get the new body value
    
if (!studiohdr.CalculateNewBodyGroup(bodypartvalue))
    {
        return 
false;
    }
    
    
// Set the new body value
    
SetEntProp(entityProp_Send"m_nBody"body);
    
    return 
true;
}

int GetEntitySkinCount(int entity)
{
    return 
GetEntityStudioHdr(entity).SkinFamiliesCount;
}

bool GetEntityPoseParameterBounds(int entityint pose_parameter_indexfloat bounds[2])
{
    
// Get the StudioHDR
    
StudioHdr studiohdr GetEntityStudioHdr(entity);
    
    
// Get entity pose parameter.
    
PoseParameter pose_parameter studiohdr.GetPoseParameter(pose_parameter_index);
    
    if (
pose_parameter == NULL_POSE_PARAMETER)
    {
        return 
false;
    }
    
    
bounds[0] = pose_parameter.start;
    
bounds[1] = pose_parameter.end;
    
    return 
true;
}

bool GetEntityAttachmentName(int entityint attachment_indexchar[] nameint name_length)
{
    
// Get the StudioHDR
    
StudioHdr studiohdr GetEntityStudioHdr(entity);
    
    
// Get attachment
    
Attachment attachment studiohdr.GetAttachment(attachment_index);
    
    
// if the `.GetName` function executed successfully.
    
return attachment.GetName(namename_length);
}

void ResetPoseParameters(int entity)
{
    
// Get the StudioHDR
    
StudioHdr studiohdr GetEntityStudioHdr(entity);
    
    
// Buffers
    
char name[64];
    
PoseParameter pose_parameter;
    
    for (
int current_posemax_pose studio_hdr.NumPoseParameterscurrent_pose max_posecurrent_pose++)
    {
        
// Get pose parameter by 
        
pose_parameter studio_hdr.GetPoseParameter(current_pose);
        
        
// Set pose parameter to the start value.
        
SetEntPropFloat(entityProp_Data"m_flPoseParameter"pose_parameter.startcurrent_pose);
    }
}

PoseParameter GetPoseParameterByName(int entity, const char[] pose_parameter_name)
{
    
// Get the StudioHDR
    
StudioHdr studiohdr GetEntityStudioHdr(entity);
    
    
// Find it by the name.
    
int index studio_hdr.FindPoseParameter(pose_parameter_name);
    if (
index == -1)
    {
        return 
NULL_POSE_PARAMETER;
    }
    
    return 
studio_hdr.GetPoseParameter(index);



Benito 08-10-2021 17:00

Re: [INC] StudioHdr - Entity Model Information
 
That's saves my life haha, nice release

Psyk0tik 08-10-2021 18:41

Re: [INC] StudioHdr - Entity Model Information
 
This looks cool. Nice one, LuqS!

LuqS 08-11-2021 03:21

Re: [INC] StudioHdr - Entity Model Information
 
Quote:

Originally Posted by Benito (Post 2754992)
That's saves my life haha, nice release

Quote:

Originally Posted by Psyk0tik (Post 2754998)
This looks cool. Nice one, LuqS!

Thanks!

LuqS 08-16-2021 07:38

Re: [INC] StudioHdr - Entity Model Information
 

Coming soon :wink:
VIDEO

https://i.imgur.com/c2hWLEh.png

LuqS 08-17-2021 17:07

Re: [INC] StudioHdr - Entity Model Information
 
18/8/2021 Update:

Quote:

StudioHdr methodmap
Bones
• `GetBone()` - Get a specific bone object by index.
• `FindBone()` - Find bone index by name.
• Get model 'NumBones'.

Hitbox Sets
• `GetHitboxSet()` - Get a specific hitbox set object by index.
• Get model 'NumHitboxSets'.

Bone methodmap
• `GetName()` - Get the name of the body part.
• `GetPos()` - Get the position of the bone (relative to model).

HitboxSet methodmap
• `GetHitbox()` - Get a specific hitbox object by index.
• `NumHitboxs` - Number of hitboxes in the hitbox set.

Hitbox methodmap
• `bone` - The related bone of the specific hitbox.
• `group` - The intersection group of the specific hitbox.
bounding box, or the ends of the capsule if flCapsuleRadius > 0
• `bbmin`
• `bbmax`
• `GetAngOffsetOrientation()` - Gets the angle offset orientation.
• `flCapsuleRadius` - The radius of the capsule (if not a capsule = 0.0)

Benito 08-18-2021 12:38

Re: [INC] StudioHdr - Entity Model Information
 
Quote:

Originally Posted by LuqS (Post 2755469)
18/8/2021 Update:

Nice one, good job !

LuqS 08-20-2021 06:14

Re: [INC] StudioHdr - Entity Model Information
 

Coming soon :wink:

https://i.imgur.com/ICCRdAA.png

Dragokas 08-20-2021 10:08

Re: [INC] StudioHdr - Entity Model Information
 
wow, that is really great!


All times are GMT -4. The time now is 06:15.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.