Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

How to use abstract interface

This topic is 4773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
From what I've seen, people just do something like this:


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.

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
I will have a new derived class

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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
{
//stuff
virtual void setvalue(float value ,float time);//
virtual void getvalue(vector value,float time);
}

class vectorinterpolator :public interpolator
{
//stuff
void 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 do
update(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.
}



Share this post


Link to post
Share on other sites
Hi,

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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!