Jump to content
  • Advertisement
Sign in to follow this  
giugio

decorator

This topic is 2998 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

Hy.
I use a scengraph with opengl and wild magic 4 .
Now i have created a drawable node that can draw items with an instance of rendering class (a class that do the render)with geometry and effect.
Now i would use the decorator for draw items in relation to the state of the object.
for ex if i select a node i would draw the node geometry and the bounding box with the red color.
if i select a node and press the quote i would draw the node geometry ,the bounding box with the red color and the quotes geometry.
is correct to use a decorator pattern?
i'm think after read the book of gof that is a good solution for this case.
or you advice somethings other?

thanks

Share this post


Link to post
Share on other sites
Advertisement
Hy.
I have anoter problem ,i have created a decorator for the class DrawableNode , a class BoundingBoxDecorator , that draw a box(From the bounding volume) over the mesh(that is in drawablenode) is possible to add dinamically the BoundingBoxDecorator from inside the class DrawableNode?

code:
DrawableNode:
Quote:

class DrawableNode : public Node
{
public:
DrawableNode(){;}
virtual ~DrawableNode();

virtual void DrawNode(Renderer* pRenderer);
void Selected(bool flag);// add boundingboxdecorator
TriMeshPtr m_pMesh;
};


Decorator
Quote:

class Decorator : public DrawableNode
{
public:
Decorator(){};
Decorator(DrawableNodePtr pComponent);
virtual ~Decorator();
void DrawNode(Renderer* pRenderer);

protected:
DrawableNodePtr m_pComponent;

};

DecoratorBoundingBox
Quote:

class DecoratorBoundingBox : public Decorator
{
public:
DecoratorBoundingBox();
DecoratorBoundingBox(DrawableNodePtr pComponent);
virtual ~DecoratorBoundingBox();
virtual void DrawNode(Renderer* pRenderer);
void DrawBoundingBox();
};





For Ex : The DrawableNode for any reason look that is selected , how i add the DecoratorBoundingBox that draw the boundingbox from inside the DrawableNode?
like
void DrawableNode::Selected(bool sel)
{
if(sel)
this = new DecoratorBoundingBox(this);
}
but don't work

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!