mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
added animation-related script instructions
This commit is contained in:
parent
51d5c7cd59
commit
0f4adc39b3
9 changed files with 210 additions and 5 deletions
|
@ -36,6 +36,7 @@ add_openmw_dir (mwscript
|
||||||
locals scriptmanager compilercontext interpretercontext cellextensions miscextensions
|
locals scriptmanager compilercontext interpretercontext cellextensions miscextensions
|
||||||
guiextensions soundextensions skyextensions statsextensions containerextensions
|
guiextensions soundextensions skyextensions statsextensions containerextensions
|
||||||
aiextensions controlextensions extensions globalscripts ref dialogueextensions
|
aiextensions controlextensions extensions globalscripts ref dialogueextensions
|
||||||
|
animationextensions
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwsound
|
add_openmw_dir (mwsound
|
||||||
|
|
|
@ -225,6 +225,15 @@ void RenderingManager::toggleLight()
|
||||||
setAmbientMode();
|
setAmbientMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderingManager::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
|
||||||
|
int mode, int number)
|
||||||
|
{
|
||||||
|
std::cout<<"play animation " << groupName << ", " << mode << ", " << number << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
std::cout<<"skip animation"<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,18 @@ class RenderingManager: private RenderingInterface {
|
||||||
/// configure fog according to cell
|
/// configure fog according to cell
|
||||||
void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
|
void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
|
||||||
|
|
||||||
|
void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
|
||||||
|
int number = 1);
|
||||||
|
///< Run animation for a MW-reference. Calls to this function for references that are currently not
|
||||||
|
/// in the rendered scene should be ignored.
|
||||||
|
///
|
||||||
|
/// \param mode: 0 normal, 1 immediate start, 2 immediate loop
|
||||||
|
/// \param number How offen the animation should be run
|
||||||
|
|
||||||
|
void skipAnimation (const MWWorld::Ptr& ptr);
|
||||||
|
///< Skip the animation for the given MW-reference for one frame. Calls to this function for
|
||||||
|
/// references that are currently not in the rendered scene should be ignored.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void setAmbientMode();
|
void setAmbientMode();
|
||||||
|
|
127
apps/openmw/mwscript/animationextensions.cpp
Normal file
127
apps/openmw/mwscript/animationextensions.cpp
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
|
||||||
|
#include "animationextensions.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <components/compiler/extensions.hpp>
|
||||||
|
|
||||||
|
#include <components/interpreter/interpreter.hpp>
|
||||||
|
#include <components/interpreter/runtime.hpp>
|
||||||
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
namespace Animation
|
||||||
|
{
|
||||||
|
template<class R>
|
||||||
|
class OpSkipAnim : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
InterpreterContext& context =
|
||||||
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
context.getWorld().skipAnimation (ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpPlayAnim : public Interpreter::Opcode1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
InterpreterContext& context =
|
||||||
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
std::string group = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
Interpreter::Type_Integer mode = 0;
|
||||||
|
|
||||||
|
if (arg0==1)
|
||||||
|
{
|
||||||
|
mode = runtime[0].mInteger;
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
if (mode<0 || mode>2)
|
||||||
|
throw std::runtime_error ("animation mode out of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
context.getWorld().playAnimationGroup (ptr, group, mode, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpLoopAnim : public Interpreter::Opcode1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
InterpreterContext& context =
|
||||||
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
std::string group = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
Interpreter::Type_Integer loops = runtime[0].mInteger;
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
if (loops<0)
|
||||||
|
throw std::runtime_error ("number of animation loops must be non-negative");
|
||||||
|
|
||||||
|
Interpreter::Type_Integer mode = 0;
|
||||||
|
|
||||||
|
if (arg0==1)
|
||||||
|
{
|
||||||
|
mode = runtime[0].mInteger;
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
if (mode<0 || mode>2)
|
||||||
|
throw std::runtime_error ("animation mode out of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
context.getWorld().playAnimationGroup (ptr, group, mode, loops);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const int opcodeSkipAnim = 0x2000138;
|
||||||
|
const int opcodeSkipAnimExplicit = 0x2000139;
|
||||||
|
const int opcodePlayAnim = 0x20006;
|
||||||
|
const int opcodePlayAnimExplicit = 0x20007;
|
||||||
|
const int opcodeLoopAnim = 0x20008;
|
||||||
|
const int opcodeLoopAnimExplicit = 0x20009;
|
||||||
|
|
||||||
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
|
{
|
||||||
|
extensions.registerInstruction ("skipanim", "", opcodeSkipAnim, opcodeSkipAnimExplicit);
|
||||||
|
extensions.registerInstruction ("playgroup", "c/l", opcodePlayAnim, opcodePlayAnimExplicit);
|
||||||
|
extensions.registerInstruction ("loopgroup", "cl/l", opcodeLoopAnim, opcodeLoopAnimExplicit);
|
||||||
|
}
|
||||||
|
|
||||||
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
{
|
||||||
|
interpreter.installSegment5 (opcodeSkipAnim, new OpSkipAnim<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeSkipAnimExplicit, new OpSkipAnim<ExplicitRef>);
|
||||||
|
interpreter.installSegment3 (opcodePlayAnim, new OpPlayAnim<ImplicitRef>);
|
||||||
|
interpreter.installSegment3 (opcodePlayAnimExplicit, new OpPlayAnim<ExplicitRef>);
|
||||||
|
interpreter.installSegment3 (opcodeLoopAnim, new OpLoopAnim<ImplicitRef>);
|
||||||
|
interpreter.installSegment3 (opcodeLoopAnimExplicit, new OpLoopAnim<ExplicitRef>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
apps/openmw/mwscript/animationextensions.hpp
Normal file
24
apps/openmw/mwscript/animationextensions.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef GAME_SCRIPT_ANIMATIONEXTENSIONS_H
|
||||||
|
#define GAME_SCRIPT_ANIMATIONEXTENSIONS_H
|
||||||
|
|
||||||
|
namespace Compiler
|
||||||
|
{
|
||||||
|
class Extensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Interpreter
|
||||||
|
{
|
||||||
|
class Interpreter;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
namespace Animation
|
||||||
|
{
|
||||||
|
void registerExtensions (Compiler::Extensions& extensions);
|
||||||
|
|
||||||
|
void installOpcodes (Interpreter::Interpreter& interpreter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,7 +19,11 @@ op 0x20002: AiEscort
|
||||||
op 0x20003: AiEscort, explicit reference
|
op 0x20003: AiEscort, explicit reference
|
||||||
op 0x20004: Lock
|
op 0x20004: Lock
|
||||||
op 0x20005: Lock, explicit reference
|
op 0x20005: Lock, explicit reference
|
||||||
opcodes 0x20006-0x3ffff unused
|
op 0x20006: PlayAnim
|
||||||
|
op 0x20007: PlayAnim, explicit reference
|
||||||
|
op 0x20008: LoopAnim
|
||||||
|
op 0x20009: LoopAnim, explicit reference
|
||||||
|
opcodes 0x2000a-0x3ffff unused
|
||||||
|
|
||||||
Segment 4:
|
Segment 4:
|
||||||
(not implemented yet)
|
(not implemented yet)
|
||||||
|
@ -109,4 +113,6 @@ op 0x2000134: SetJournalIndex
|
||||||
op 0x2000135: GetJournalIndex
|
op 0x2000135: GetJournalIndex
|
||||||
op 0x2000136: GetPCCell
|
op 0x2000136: GetPCCell
|
||||||
op 0x2000137: GetButtonPressed
|
op 0x2000137: GetButtonPressed
|
||||||
opcodes 0x2000138-0x3ffffff unused
|
op 0x2000138: SkipAnim
|
||||||
|
op 0x2000139: SkipAnim, expplicit reference
|
||||||
|
opcodes 0x200013a-0x3ffffff unused
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "aiextensions.hpp"
|
#include "aiextensions.hpp"
|
||||||
#include "controlextensions.hpp"
|
#include "controlextensions.hpp"
|
||||||
#include "dialogueextensions.hpp"
|
#include "dialogueextensions.hpp"
|
||||||
|
#include "animationextensions.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,7 @@ namespace MWScript
|
||||||
Ai::registerExtensions (extensions);
|
Ai::registerExtensions (extensions);
|
||||||
Control::registerExtensions (extensions);
|
Control::registerExtensions (extensions);
|
||||||
Dialogue::registerExtensions (extensions);
|
Dialogue::registerExtensions (extensions);
|
||||||
|
Animation::registerExtensions (extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -44,5 +46,6 @@ namespace MWScript
|
||||||
Ai::installOpcodes (interpreter);
|
Ai::installOpcodes (interpreter);
|
||||||
Control::installOpcodes (interpreter);
|
Control::installOpcodes (interpreter);
|
||||||
Dialogue::installOpcodes (interpreter);
|
Dialogue::installOpcodes (interpreter);
|
||||||
|
Animation::installOpcodes (interpreter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -673,4 +673,15 @@ namespace MWWorld
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
|
||||||
|
int number)
|
||||||
|
{
|
||||||
|
mRendering.playAnimationGroup (ptr, groupName, mode, number);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::skipAnimation (const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
mRendering.skipAnimation (ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,6 +206,18 @@ namespace MWWorld
|
||||||
const ESM::Cell *createRecord (const ESM::Cell& record);
|
const ESM::Cell *createRecord (const ESM::Cell& record);
|
||||||
///< Create a new recrod (of type cell) in the ESM store.
|
///< Create a new recrod (of type cell) in the ESM store.
|
||||||
/// \return ID, pointer to created record
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
|
void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
|
||||||
|
int number = 1);
|
||||||
|
///< Run animation for a MW-reference. Calls to this function for references that are
|
||||||
|
/// currently not in the rendered scene should be ignored.
|
||||||
|
///
|
||||||
|
/// \param mode: 0 normal, 1 immediate start, 2 immediate loop
|
||||||
|
/// \param number How offen the animation should be run
|
||||||
|
|
||||||
|
void skipAnimation (const MWWorld::Ptr& ptr);
|
||||||
|
///< Skip the animation for the given MW-reference for one frame. Calls to this function for
|
||||||
|
/// references that are currently not in the rendered scene should be ignored.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue