class interpolator
{
//stuff
virtual void setvalue(float value ,float time);
}
class vectorinterpolator :public interpolator
{
//stuff
void setvalue(vector value,float time);
}
//see, because the parameter type is different ,so could not do virtual right.
How to use abstract interface
From what I've seen, people just do something like this:
I decided this after looking at an example from Enginuity's memory manager, as well as a few journals. They all did the above ( Not EXACTLY as above ). I could be right but I could be wrong, I'm not sure.
class Interpolator{ virtual void setValue( float , float ) = 0;};class vectorInterpolator : public Interpolator{ void setValue( vector, float );};
I decided this after looking at an example from Enginuity's memory manager, as well as a few journals. They all did the above ( Not EXACTLY as above ). I could be right but I could be wrong, I'm not sure.
You can create an empty setvalue(vector, float) function in interpolator.
I believe the standard way to do it is
virtual void setvalue(vector value, float time)=0;
As long as you don't create any "interpolator," but only "vectorinterpolator"
I believe the standard way to do it is
virtual void setvalue(vector value, float time)=0;
As long as you don't create any "interpolator," but only "vectorinterpolator"
I will have a new derived class
so how to create a abstract interface?/
anybody have a good idea??
Is oo unavailable here?
class QuaternionInterpolator : public Interpolator{void setvalue(quaternion value,float time);}
so how to create a abstract interface?/
anybody have a good idea??
Is oo unavailable here?
first tell us what are u trying to make and "interface" what are you trying to keep ur main code seperate from other code. Don' worry about abstract yet, abstract is just an any object, tell me what you want to do and interface for what.
Quote:Original post by busyme
first tell us what are u trying to make and "interface" what are you trying to keep ur main code seperate from other code. Don' worry about abstract yet, abstract is just an any object, tell me what you want to do and interface for what.
I want to seperate concrete interpolator from main code with a interface .
look code:
class interpolator //intereface{//stuffvirtual void setvalue(float value ,float time);//virtual void getvalue(vector value,float time);}class vectorinterpolator :public interpolator{//stuffvoid setvalue(vector value,float time);void getvalue(vector value,float time);}class QuaternionInterpolator : public Interpolator{void setvalue(quaternion value,float time);void getvalue(vector value,float time);}//then I can doupdate(Interpolate* in, float timeDelta){ Interpolate *inter = new VectorInterpolate(...); vector value1; quaternion value2; inter->getvalue(&value1,timeDelta); Interpolate *inter = new QuaternionInterpolate(...); inter->getvalue(&value2,timeDelta); entity.getPosition(value1); entity.getRotate(value2); //the the entity will move according to animation key.}
think "template" sounds like this problem is better solved using generic programing instead of "pure" OO.
Hi,
why use that type of design?
do you want to be able to call
I think you should use something different.
Please say what you want to do (and why you want to do it that whay).
why use that type of design?
do you want to be able to call
interpolator inter = vectorinterpolator();inter(quaternion, time );
I think you should use something different.
Please say what you want to do (and why you want to do it that whay).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement