NOTE: This Thread is just a copy from another forum! (No worries i posted it)
Hello together,
today i want to share something with you for christmas.
But before we start let me tell you, this system isn't in is final form! I will update this thread (if metin2dev will still exist in the new year) to
complete this system. Anyways let's get startet.
What kind of System is it?
You can use inbuilt animations on objects (map objects) and weapons (currently not working, just if the weapon is a ground item instance! I'm working on it).
Here is a preview: Bitte melden Sie sich an, um diesen Link zu sehen.
First you can see a placed object on the map with inbuilt animation (sorry it is really far away :O)
Later you can see a weapon (thanks to Bitte melden Sie sich an, um diesen Link zu sehen.) which has an inbuilt animation. But this is currently just working as ground instance and not in the player hands itself.
How to implement it
Open up your client source (c++)
eterGrbLib
1. struct FSetMotionPointer, struct FChangeMotionPointer and struct FEndStopMotionPointer in eterGrbLib/LODController.h
Bitte melden Sie sich an, um diesen Anhang zu sehen.
2. eterGrbLib/LODController.h
- //Search for this
- void SetMotionPointer(const CGrannyMotion * c_pMotion, float fBlendTime, int iLoopCount, float speedRatio);
- void ChangeMotionPointer(const CGrannyMotion * c_pMotion, int iLoopCount, float speedRatio);
- //Replace with
- void SetMotionPointer(const std::shared_ptr<CGrannyMotion> c_pMotion, float fBlendTime, int iLoopCount, float speedRatio);
- void ChangeMotionPointer(const std::shared_ptr<CGrannyMotion> c_pMotion, int iLoopCount, float speedRatio);
Bitte melden Sie sich an, um diesen Anhang zu sehen.
3. eterGrbLib/LODController.cpp
- //Search for
- void CGrannyLODController::SetMotionPointer(const CGrannyMotion * c_pMotion, float fBlendTime, int iLoopCount, float speedRatio)
- //Replace with
- void CGrannyLODController::SetMotionPointer(const std::shared_ptr<CGrannyMotion> c_pMotion, float fBlendTime, int iLoopCount, float speedRatio)
- //Search for
- void CGrannyLODController::ChangeMotionPointer(const CGrannyMotion * c_pMotion, int iLoopCount, float speedRatio)
- //Replace with
- void CGrannyLODController::ChangeMotionPointer(const std::shared_ptr<CGrannyMotion> c_pMotion, int iLoopCount, float speedRatio)
Bitte melden Sie sich an, um diesen Anhang zu sehen.
4. eterGrnLib/Mesh.cpp
Bitte melden Sie sich an, um diesen Anhang zu sehen.
5. eterGrnLib/ModelInstance.h
- //Search for
- void SetMotionPointer(const CGrannyMotion* pMotion, float blendTime=0.0f, int loopCount=0, float speedRatio=1.0f);
- void ChangeMotionPointer(const CGrannyMotion* pMotion, int loopCount=0, float speedRatio=1.0f);
- //Replace with
- void SetMotionPointer(const std::shared_ptr<CGrannyMotion> pMotion, float blendTime = 0.0f, int loopCount = 0, float speedRatio = 1.0f);
- void ChangeMotionPointer(const std::shared_ptr<CGrannyMotion> pMotion, int loopCount = 0, float speedRatio = 1.0f);
Bitte melden Sie sich an, um diesen Anhang zu sehen.
6. eterGrnLib/ModelInstanceMotion.cpp
- //Search for
- void CGrannyModelInstance::SetMotionPointer(const CGrannyMotion * pMotion, float blendTime, int loopCount, float speedRatio)
- //Replace with
- void CGrannyModelInstance::SetMotionPointer(const std::shared_ptr<CGrannyMotion> pMotion, float blendTime, int loopCount, float speedRatio)
- //Search for (it is in the SetMotionPointer function!)
- m_pgrnCtrl = GrannyPlayControlledAnimation(localTime, m_pgrnAni, pgrnModelInstance);
- //Replace with
- granny_model_instance* InstanceOfModel = pgrnModelInstance;
- granny_animation* Animation = m_pgrnAni;
- granny_real32 StartTime = localTime;
- granny_controlled_animation_builder* Builder =
- GrannyBeginControlledAnimation(StartTime, Animation);
- if (Builder)
- {
- granny_int32x TrackGroupIndex;
- if (GrannyFindTrackGroupForModel(Animation,
- GrannyGetSourceModel(InstanceOfModel)->Name,
- &TrackGroupIndex))
- {
- GrannySetTrackGroupLOD(Builder, TrackGroupIndex, true, 1.0f);
- GrannySetTrackGroupTarget(Builder, TrackGroupIndex, InstanceOfModel);
- }
- else {
- GrannySetTrackGroupLOD(Builder, 1.0f, true, 1.0f);
- GrannySetTrackGroupTarget(Builder, 0, InstanceOfModel);
- }
- m_pgrnCtrl = GrannyEndControlledAnimation(Builder);
- }
- //Search for
- void CGrannyModelInstance::ChangeMotionPointer(const CGrannyMotion* pMotion, int loopCount, float speedRatio)
- //Replace with
- void CGrannyModelInstance::ChangeMotionPointer(const std::shared_ptr<CGrannyMotion> pMotion, int loopCount, float speedRatio)
Bitte melden Sie sich an, um diesen Anhang zu sehen.
7. eterGrnLib/Thing.h
8. eterGrnLib/Thing.cpp
- //Search for
- void CGraphicThing::Initialize()
- {
- ...
- }
- //Replace with
- void CGraphicThing::Initialize()
- {
- m_pgrnFile = NULL;
- m_pgrnFileInfo = NULL;
- m_pgrnAni = NULL;
- m_models = NULL;
- }
- //Search for
- void CGraphicThing::OnClear()
- {
- ...
- }
- //Replace with
- void CGraphicThing::OnClear()
- {
- if (!m_motions.empty())
- m_motions.clear();
- if (m_models)
- delete [] m_models;
- if (m_pgrnFile)
- GrannyFreeFile(m_pgrnFile);
- Initialize();
- }
- //Search for
- CGrannyMotion * CGraphicThing::GetMotionPointer(int iMotion)
- {
- ...
- }
- //Replace with
- std::shared_ptr<CGrannyMotion> CGraphicThing::GetMotionPointer(int iMotion)
- {
- assert(CheckMotionIndex(iMotion));
- if (iMotion >= m_pgrnFileInfo->AnimationCount)
- return NULL;
- if (m_motions.empty())
- return NULL;
- return m_motions.at(iMotion);
- }
- //Search for
- bool CGraphicThing::LoadMotions()
- {
- ...
- }
- //Replace with
- bool CGraphicThing::LoadMotions()
- {
- assert(m_pgrnFile != NULL);
- assert(m_motions->empty());
- if (m_pgrnFileInfo->AnimationCount <= 0)
- return false;
- int motionCount = m_pgrnFileInfo->AnimationCount;
- for (int m = 0; m < motionCount; ++m)
- {
- auto motion = std::make_shared<CGrannyMotion>();
- if (!motion->BindGrannyAnimation(m_pgrnFileInfo->Animations[m]))
- return false;
- m_motions.push_back(motion);
- }
- return true;
- }
Bitte melden Sie sich an, um diesen Anhang zu sehen.
gameLib
1. gameLib/ActorInstanceMotion.cpp
Bitte melden Sie sich an, um diesen Anhang zu sehen.
2. gameLib/Area.cpp
userInterface
1. userInterface/PythonItem.cpp
- //Search for
- itor->second->Update();
- //Add BEFORE!!!
- itor->second->ThingInstance.Deform();
- itor->second->ThingInstance.Update();
- //Search for
- pGroundItemInstance->ThingInstance.Show();
- //Add below
- if (pGroundItemInstance->ThingInstance.GetBaseThingPtr()->GetMotionCount() > 0) {
- pGroundItemInstance->ThingInstance.RegisterMotionThing(0, pGroundItemInstance->ThingInstance.GetBaseThingPtr());
- pGroundItemInstance->ThingInstance.SetMotion(0);
- }
What is missing for now?
Currently the deforming for weapons holden by the player won't work. But as i said in the first few lines, i will add it later. But for now
i want to give this parts to you for christmas! (Sorry i'm currently out of time to finish it before 2019 ends... Maybe someone of you want to
complet it in his on way).
The attachments
Animated Object: Bitte melden Sie sich an, um diesen Link zu sehen. <- Thanks to KillMoves who did this sometime ago!!!
(Animated Weapon: Bitte melden Sie sich an, um diesen Link zu sehen. <- Thanks to Tatsumaru!!!
Have fun with it, your B4RC0D3