BVB Source Codes

CRYENGINE Show AttachmentSkin.h Source code

Return Download CRYENGINE: download AttachmentSkin.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #pragma once
  4.  
  5. #include "AttachmentBase.h"
  6. #include "Vertex/VertexData.h"
  7. #include "Vertex/VertexAnimation.h"
  8. #include "ModelSkin.h"
  9.  
  10. class CModelMesh;
  11. struct SVertexAnimationJob;
  12.  
  13. //////////////////////////////////////////////////////////////////////
  14. // Special value to indicate a Skinning Transformation job is still running
  15. #define SKINNING_TRANSFORMATION_RUNNING_INDICATOR (reinterpret_cast<SSkinningData*>(static_cast<intptr_t>(-1)))
  16.  
  17. class CAttachmentSKIN : public IAttachmentSkin, public SAttachmentBase
  18. {
  19. public:
  20.  
  21.         CAttachmentSKIN()
  22.         {
  23.                 for (uint32 j = 0; j < 2; ++j) m_pRenderMeshsSW[j] = NULL;
  24.                 memset(m_arrSkinningRendererData, 0, sizeof(m_arrSkinningRendererData));
  25.                 m_pModelSkin = 0;
  26.         };
  27.  
  28.         ~CAttachmentSKIN();
  29.  
  30.         virtual void AddRef() override
  31.         {
  32.                 ++m_nRefCounter;
  33.         }
  34.  
  35.         virtual void Release() override
  36.         {
  37.                 if (--m_nRefCounter == 0)
  38.                         delete this;
  39.         }
  40.  
  41.         virtual uint32             GetType() const override                               { return CA_SKIN; }
  42.         virtual uint32             SetJointName(const char* szJointName) override         { return 0; }
  43.  
  44.         virtual const char*        GetName() const override                               { return m_strSocketName; };
  45.         virtual uint32             GetNameCRC() const override                            { return m_nSocketCRC32; }
  46.         virtual uint32             ReName(const char* strSocketName, uint32 crc) override { m_strSocketName.clear();  m_strSocketName = strSocketName; m_nSocketCRC32 = crc;  return 1; };
  47.  
  48.         virtual uint32             GetFlags() const override                              { return m_AttFlags; }
  49.         virtual void               SetFlags(uint32 flags) override                        { m_AttFlags = flags; }
  50.  
  51.         void                       ReleaseRemapTablePair();
  52.         void                       ReleaseSoftwareRenderMeshes();
  53.  
  54.         virtual uint32             Immediate_AddBinding(IAttachmentObject* pModel, ISkin* pISkin = 0, uint32 nLoadingFlags = 0) override;
  55.         virtual void               Immediate_ClearBinding(uint32 nLoadingFlags = 0) override;
  56.         virtual uint32             Immediate_SwapBinding(IAttachment* pNewAttachment) override;
  57.  
  58.         virtual IAttachmentObject* GetIAttachmentObject() const override { return m_pIAttachmentObject; }
  59.         virtual IAttachmentSkin*   GetIAttachmentSkin() override         { return this; }
  60.  
  61.         virtual void               HideAttachment(uint32 x) override;
  62.         virtual uint32             IsAttachmentHidden() const override             { return m_AttFlags & FLAGS_ATTACH_HIDE_MAIN_PASS; }
  63.         virtual void               HideInRecursion(uint32 x) override;
  64.         virtual uint32             IsAttachmentHiddenInRecursion() const override  { return m_AttFlags & FLAGS_ATTACH_HIDE_RECURSION; }
  65.         virtual void               HideInShadow(uint32 x) override;
  66.         virtual uint32             IsAttachmentHiddenInShadow() const override     { return m_AttFlags & FLAGS_ATTACH_HIDE_SHADOW_PASS; }
  67.  
  68.         virtual void               SetAttAbsoluteDefault(const QuatT& qt) override {};
  69.         virtual void               SetAttRelativeDefault(const QuatT& qt) override {};
  70.         virtual const QuatT& GetAttAbsoluteDefault() const override          { return g_IdentityQuatT; };
  71.         virtual const QuatT& GetAttRelativeDefault() const override          { return g_IdentityQuatT; };
  72.  
  73.         virtual const QuatT& GetAttModelRelative() const override            { return g_IdentityQuatT;  };//this is relative to the animated bone
  74.         virtual const QuatTS GetAttWorldAbsolute() const override;
  75.         virtual const QuatT& GetAdditionalTransformation() const override    { return g_IdentityQuatT; }
  76.         virtual void         UpdateAttModelRelative() override;
  77.  
  78.         virtual uint32       GetJointID() const override     { return -1; };
  79.         virtual void         AlignJointAttachment() override {};
  80.  
  81.         virtual void         Serialize(TSerialize ser) override;
  82.         virtual size_t       SizeOfThis() const override;
  83.         virtual void         GetMemoryUsage(ICrySizer* pSizer) const override;
  84.         virtual void         TriggerMeshStreaming(uint32 nDesiredRenderLOD, const SRenderingPassInfo& passInfo);
  85.  
  86.         void                 DrawAttachment(SRendParams& rParams, const SRenderingPassInfo& passInfo, const Matrix34& rWorldMat34, f32 fZoomFactor = 1);
  87.         void                 RecreateDefaultSkeleton(CCharInstance* pInstanceSkel, uint32 nLoadingFlags);
  88.         void                 UpdateRemapTable();
  89.  
  90.         // Vertex Transformation
  91. public:
  92.         SSkinningData*          GetVertexTransformationData(const bool bVertexAnimation, uint8 nRenderLOD);
  93.         bool                    ShouldSwSkin() const     { return (m_AttFlags & FLAGS_ATTACH_SW_SKINNING) != 0; }
  94.         bool                    ShouldSkinLinear() const { return (m_AttFlags & FLAGS_ATTACH_LINEAR_SKINNING) != 0; }
  95.         _smart_ptr<IRenderMesh> CreateVertexAnimationRenderMesh(uint lod, uint id);
  96.         void                    CullVertexFrames(const SRenderingPassInfo& passInfo, float fDistance);
  97.  
  98. #ifdef EDITOR_PCDEBUGCODE
  99.         void DrawVertexDebug(IRenderMesh* pRenderMesh, const QuatT& location, const SVertexAnimationJob* pVertexAnimation, const SVertexSkinData& vertexSkinData);
  100.         void DrawWireframeStatic(const Matrix34& m34, int nLOD, uint32 color);
  101.         void SoftwareSkinningDQ_VS_Emulator(CModelMesh* pModelMesh, Matrix34 rRenderMat34, uint8 tang, uint8 binorm, uint8 norm, uint8 wire, const DualQuat* const pSkinningTransformations);
  102. #endif
  103.  
  104.         //////////////////////////////////////////////////////////////////////////
  105.         //IAttachmentSkin implementation
  106.         //////////////////////////////////////////////////////////////////////////
  107.         virtual IVertexAnimation* GetIVertexAnimation() override { return &m_vertexAnimation; }
  108.         virtual ISkin*            GetISkin() override            { return m_pModelSkin; };
  109.         virtual float             GetExtent(EGeomForm eForm) override;
  110.         virtual void              GetRandomPos(PosNorm& ran, CRndGen& seed, EGeomForm eForm) const override;
  111.         virtual SMeshLodInfo      ComputeGeometricMean() const override;
  112.  
  113.         int                       GetGuid() const;
  114.  
  115.         //---------------------------------------------------------
  116.  
  117.         //just for skin-attachments
  118.         DynArray<JointIdType>   m_arrRemapTable; // maps skin's bone indices to skeleton's bone indices
  119.         _smart_ptr<CSkin>       m_pModelSkin;
  120.         _smart_ptr<IRenderMesh> m_pRenderMeshsSW[2];
  121.         string                  m_sSoftwareMeshName;
  122.         CVertexData             m_vertexData;
  123.         CVertexAnimation        m_vertexAnimation;
  124.         // history for skinning data, needed for motion blur
  125.         struct { SSkinningData* pSkinningData; int nFrameID; } m_arrSkinningRendererData[3]; // triple buffered for motion blur
  126.  
  127. private:
  128.         // function to keep in sync ref counts on skins and cleanup of remap tables
  129.         void ReleaseModelSkin();
  130.  
  131. };
  132.  
downloadAttachmentSkin.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top