1
0
forked from 0ad/0ad

Support scripted modulation of actor colours

This was SVN commit r7357.
This commit is contained in:
Ykkrosh 2010-03-17 22:56:49 +00:00
parent bcd5e78b7a
commit 99a261328a
3 changed files with 23 additions and 0 deletions

View File

@ -114,6 +114,8 @@ public:
// a list of strings if it really needs to be a specific variation.
// TODO: store animation state
// TODO: store shading colour
}
virtual void Deserialize(const CSimContext& context, const CParamNode& paramNode, IDeserializer& UNUSED(deserialize))
@ -176,6 +178,14 @@ public:
m_Unit->SetAnimationState(name, once, speed);
}
virtual void SetShadingColour(CFixed_23_8 r, CFixed_23_8 g, CFixed_23_8 b, CFixed_23_8 a)
{
if (!m_Unit)
return;
m_Unit->GetModel()->SetShadingColor(CColor(r.ToFloat(), g.ToFloat(), b.ToFloat(), a.ToFloat()));
}
private:
void Interpolate(const CSimContext& context, float frameTime, float frameOffset);
void RenderSubmit(const CSimContext& context, SceneCollector& collector, const CFrustum& frustum, bool culling);

View File

@ -23,4 +23,5 @@
BEGIN_INTERFACE_WRAPPER(Visual)
DEFINE_INTERFACE_METHOD_3("SelectAnimation", void, ICmpVisual, SelectAnimation, std::string, bool, float)
DEFINE_INTERFACE_METHOD_4("SetShadingColour", void, ICmpVisual, SetShadingColour, CFixed_23_8, CFixed_23_8, CFixed_23_8, CFixed_23_8)
END_INTERFACE_WRAPPER(Visual)

View File

@ -21,6 +21,7 @@
#include "simulation2/system/Interface.h"
#include "maths/Bound.h"
#include "maths/Fixed.h"
/**
* The visual representation of an entity (typically an actor).
@ -49,6 +50,17 @@ public:
*/
virtual void SelectAnimation(std::string name, bool once, float speed) = 0;
/**
* Set the shading colour that will be modulated with the model's textures.
* Default shading is (1, 1, 1, 1).
* Alpha should probably be 1 else it's unlikely to work properly.
* @param r red component, expected range [0, 1]
* @param g green component, expected range [0, 1]
* @param b blue component, expected range [0, 1]
* @param a alpha component, expected range [0, 1]
*/
virtual void SetShadingColour(CFixed_23_8 r, CFixed_23_8 g, CFixed_23_8 b, CFixed_23_8 a) = 0;
DECLARE_INTERFACE_TYPE(Visual)
};