mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
clean-up + getScale/Angle script instructions
This commit is contained in:
parent
0a67f60a6e
commit
557e114992
@ -1,6 +1,3 @@
|
|||||||
|
|
||||||
#include "statsextensions.hpp"
|
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
@ -17,6 +14,7 @@
|
|||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
|
#include "OgreSceneNode.h"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
@ -31,13 +29,25 @@ namespace MWScript
|
|||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = R()(runtime);
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
Interpreter::Type_Float scale = runtime[0].mInteger;
|
Interpreter::Type_Float scale = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->scaleObject(ptr,scale);
|
MWBase::Environment::get().getWorld()->scaleObject(ptr,scale);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpGetScale : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
runtime.push(ptr.getCellRef().scale);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<class R>
|
template<class R>
|
||||||
class OpSetAngle : public Interpreter::Opcode0
|
class OpSetAngle : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
@ -49,7 +59,7 @@ namespace MWScript
|
|||||||
|
|
||||||
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
Interpreter::Type_Float angle = runtime[0].mInteger;
|
Interpreter::Type_Float angle = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
if(axis == "X")
|
if(axis == "X")
|
||||||
@ -67,15 +77,48 @@ namespace MWScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpGetAngle : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
if(axis == "X")
|
||||||
|
{
|
||||||
|
runtime.push(ptr.getRefData().getPosition().rot[0]);
|
||||||
|
}
|
||||||
|
if(axis == "Y")
|
||||||
|
{
|
||||||
|
runtime.push(ptr.getRefData().getPosition().rot[1]);
|
||||||
|
}
|
||||||
|
if(axis == "Z")
|
||||||
|
{
|
||||||
|
runtime.push(ptr.getRefData().getPosition().rot[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int opcodeSetScale = 0x2000164;
|
const int opcodeSetScale = 0x2000164;
|
||||||
const int opcodeSetScaleExplicit = 0x2000165;
|
const int opcodeSetScaleExplicit = 0x2000165;
|
||||||
const int opcodeSetAngle = 0x2000166;
|
const int opcodeSetAngle = 0x2000166;
|
||||||
const int opcodeSetAngleExplicit = 0x2000167;
|
const int opcodeSetAngleExplicit = 0x2000167;
|
||||||
|
const int opcodeGetScale = 0x2000168;
|
||||||
|
const int opcodeGetScaleExplicit = 0x2000169;
|
||||||
|
const int opcodeGetAngle = 0x200016a;
|
||||||
|
const int opcodeGetAngleExplicit = 0x200016b;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
extensions.registerInstruction("setscale","f",opcodeSetScale,opcodeSetScaleExplicit);
|
extensions.registerInstruction("setscale","f",opcodeSetScale,opcodeSetScaleExplicit);
|
||||||
extensions.registerInstruction("setangle","Sl",opcodeSetAngle,opcodeSetAngleExplicit);
|
extensions.registerFunction("getscale",'f',"",opcodeGetScale,opcodeGetScaleExplicit);
|
||||||
|
extensions.registerInstruction("setangle","Sf",opcodeSetAngle,opcodeSetAngleExplicit);
|
||||||
|
extensions.registerFunction("getangle",'f',"S",opcodeGetAngle,opcodeGetAngleExplicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
@ -84,6 +127,10 @@ namespace MWScript
|
|||||||
interpreter.installSegment5(opcodeSetScaleExplicit,new OpSetScale<ExplicitRef>);
|
interpreter.installSegment5(opcodeSetScaleExplicit,new OpSetScale<ExplicitRef>);
|
||||||
interpreter.installSegment5(opcodeSetAngle,new OpSetAngle<ImplicitRef>);
|
interpreter.installSegment5(opcodeSetAngle,new OpSetAngle<ImplicitRef>);
|
||||||
interpreter.installSegment5(opcodeSetAngleExplicit,new OpSetAngle<ExplicitRef>);
|
interpreter.installSegment5(opcodeSetAngleExplicit,new OpSetAngle<ExplicitRef>);
|
||||||
|
interpreter.installSegment5(opcodeGetScale,new OpGetScale<ImplicitRef>);
|
||||||
|
interpreter.installSegment5(opcodeGetScaleExplicit,new OpGetScale<ExplicitRef>);
|
||||||
|
interpreter.installSegment5(opcodeGetAngle,new OpGetAngle<ImplicitRef>);
|
||||||
|
interpreter.installSegment5(opcodeGetAngleExplicit,new OpGetAngle<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -612,8 +612,8 @@ namespace MWWorld
|
|||||||
MWWorld::Class::get(ptr).adjustRotation(ptr,x,y,z);
|
MWWorld::Class::get(ptr).adjustRotation(ptr,x,y,z);
|
||||||
|
|
||||||
ptr.getRefData().getPosition().rot[0] = Ogre::Degree(x).valueRadians();
|
ptr.getRefData().getPosition().rot[0] = Ogre::Degree(x).valueRadians();
|
||||||
ptr.getRefData().getPosition().rot[0] = Ogre::Degree(y).valueRadians();
|
ptr.getRefData().getPosition().rot[1] = Ogre::Degree(y).valueRadians();
|
||||||
ptr.getRefData().getPosition().rot[0] = Ogre::Degree(z).valueRadians();
|
ptr.getRefData().getPosition().rot[2] = Ogre::Degree(z).valueRadians();
|
||||||
|
|
||||||
Ogre::Quaternion rotx(Ogre::Degree(x),Ogre::Vector3::UNIT_X);
|
Ogre::Quaternion rotx(Ogre::Degree(x),Ogre::Vector3::UNIT_X);
|
||||||
Ogre::Quaternion roty(Ogre::Degree(y),Ogre::Vector3::UNIT_Y);
|
Ogre::Quaternion roty(Ogre::Degree(y),Ogre::Vector3::UNIT_Y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user