AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved How to get model attachment origin on a specific frame? (https://forums.alliedmods.net/showthread.php?t=338571)

Natsheh 07-13-2022 05:34

How to get model attachment origin on a specific frame?
 
I don't know if its possible to achieve this, but as far as i know EngFunc_GetAttachment only gets the origin and angles for the attachment on the first frame.

klippy 07-13-2022 18:22

Re: How to get model attachment origin on a specific frame?
 
Looking at EngFunc_GetAttachment code, I believe it takes pev_frame into account. So if you want to get the attachment position on a frame other than what the entity's current frame is, just set pev_frame temporarily then revert it I guess.

Natsheh 07-14-2022 05:49

Re: How to get model attachment origin on a specific frame?
 
it Works, but i found something strange rgflAngles in GetAttachment as well as in GetBonePosition is not retrieved, why so ?

and also the origin of attachment is always retrieved with respect to the angles 0.0 0.0 0.0.

Natsheh 07-15-2022 05:34

Re: How to get model attachment origin on a specific frame?
 
Solution:

PHP Code:

pev(entpev_framefPrevFrame);
pev(entpev_animetimefAnimTime);
set_pev(entpev_frame, (get_gametime() - fAnimTime) * AnimationFPS)

engfunc(EngFunc_GetAttachmententattachmentIDfOriginfAngles);
set_pev(entpev_framefPrevFrame


Natsheh 07-15-2022 19:55

Re: How to get model attachment origin on a specific frame?
 
Quote:

Originally Posted by Natsheh (Post 2783739)
it Works, but i found something strange rgflAngles in GetAttachment as well as in GetBonePosition is not retrieved, why so ?

and also the origin of attachment is always retrieved with respect to the angles 0.0 0.0 0.0.

Work around solution....

PHP Code:

GetAttachmentData(const id, const iAttachmentIDFloat:fRetOrigin[3], Float:fRetAngles[3])
{
    static 
Float:fStart[3], Float:fVAngles[3], Float:fOrigin[3], Float:fVec[3], Float:fHeight;
    
engfunc(EngFunc_GetAttachmentidiAttachmentIDfStartfVAngles);

    
pev(idpev_originfOrigin);
    
pev(idpev_anglesfVAngles);
    
fHeight fOrigin[2] = fStart[2];
    
xs_vec_sub(fStartfOriginfStart);

    
xs_vec_copy(fStartfVec);
    
fStart[0] = ((fVec[0] * floatcos(fVAngles[1],degrees)) - fVec[1] * floatsin(fVAngles[1],degrees)) + fOrigin[0];
    
fStart[1] = ((fVec[0] * floatsin(fVAngles[1],degrees)) + fVec[1] * floatcos(fVAngles[1],degrees)) + fOrigin[1];
    
fStart[2] = fHeight;

    
xs_vec_copy(fStartfRetOrigin);
    
xs_vec_copy(fVAnglesfRetAngles);




All times are GMT -4. The time now is 05:09.

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