Hi Carsten,
thanks a lot for your answer!
I have a few more questions for you ;-) :
>>> // base template
>>> template <class FieldT>
>>> struct FieldValueInterpolator;
>>>
>>>
>>> // partial specialization for SF
>>> template <class ValueTypeT, Int32 NamespaceI>
>>> struct FieldValueInterpolator<SField<ValueTypeT, NamespaceI> >
>>> {
>>> typedef SField<ValueTypeT, NamespaceI> SFieldType;
>>> typedef typename SFieldType::ArgumentType ArgumentType;
>>>
>>> void updateField(Real32 fract, ArgumentType val0, ArgumentType val1,
>>> FieldContainerPtr pCont, UInt32 fieldId)
>>> {
>>> SFieldType *pCastSF = static_cast<SFieldType *>(
>>> pCont->getField(fieldId));
>>>
>>> // interpolate between val0 and val1 depending on fract,
>>> // which is in [0,1]
>>>
>>> // write value to pCastSF using pCastSF->setValue()
>>> }
>>> };
>>>
>>> // partial specialization for MF
>>> template <class ValueTypeT, Int32 NamespaceI>
>>> struct FieldValueInterpolator<MField<ValueTypeT, NamespaceI> >
>>> {
>>> typedef MField<ValueTypeT, NamespaceI> MFieldType;
>>> typedef typename MFieldType::ArgumentType ArgumentType;
>>>
>>> void updateField(Real32 fract, ArgumentType val0, ArgumentType val1,
>>> FieldContainerPtr pCont, UInt32 fieldId)
>>> {
>>> MFieldType *pCastMF = static_cast<MFieldType *>(
>>> pCont->getField(fieldId));
>>>
>>> // interpolate between val0 and val1 depending on fract,
>>> // which is in [0,1]
>>>
>>> // write value to pCastMF using pCastMF->push_back(),
>>> // (*pCastMF)[i] etc.
>>> }
>>> };
Such template is very handy... but, since the interpolation processes for
some different types are the same (i.e. two Real32 and two Real64 have the
same interpolation formula), is there any way to perform the interpolation
using the template above _without_ knowing the exact data type we are
working
with (i.e. all we need to know is we are dealing with a RealXX data type,
we don't want to distinguish between Real32 and Real64! The same holds for
UInt32 and Int32, Vec3f and Vec2f, and so on...)? Of course, Real32 and
Int32
would have to be treated differently...
And now some more questions:
- Does FieldDescription::getTypeId() always return the same value as
Field::getType().getId()? And is such return value calculated at runtime
or is it a default fixed value and if so, is it defined anywhere? I could
use such piece of information in order to correctly perform the
interpolation... In other words, how am I supposed to use the value
returned
by Field::getType().getId() or FieldDescription::getTypeId() inside a
switch
statement in order to know what field type I'm about to interpolate?
- To store the control point lists inside the AnimationController I'm using
a map<FieldContainerPtr, ControlPointList<CPType>> where CPType is the
data
type stored inside the control points in the list: for example, a control
point with a Quaternion inside has to be put inside a container defined as
follows: map<FieldContainerPtr, ControlPointList<SField<Quaternion>>>.
This involves defining a new container for _each_ data type: since I don't
want my code to bloat, I need a way to keep the number of used containers
as low as possible. Any suggestion here would be _greatly_ appreciated!
Thanks in advance!
Best Regards,
Carlo
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core