Menu

draw line

Dany
2010-02-11
2013-04-30
  • Dany

    Dany - 2010-02-11

    Hi.
    Suppose we have a Boid with a circle of radius 2, how do I draw a line from the center of Boid up to the radius?
    Number 2 translated in terms of carrier as it becomes?

     
  • Craig Reynolds

    Craig Reynolds - 2010-02-11

    Hi. Look in Annotation.h, it defines annotationLine which takes the two endpoints as Vec3 and a color.  There are other kinds of annotations defined in that file.  Annotations differ from basic drawing in that they are "optional" and can be turned on and off by the user.  You can also use the "draw API" defined in Draw.h if that seems more appropriate for your application.

    To draw the line you describe, if for example you want it along the boid's direction of travel, you would write something like this in the Boid's update (or draw) method:

    annotationLine (position(), forward()*2, gGreen);

     
  • Dany

    Dany - 2010-02-11

    Thank you.
    If I wanted to see a line from the center of the agent  to his radius drawn around the agent, how can I do?
    The radius is a float and the method requires a note Vec3.

            annotationLine void (const Vec3 & startPoint,
                                 const Vec3 & endpoint,
                                 const Vec3 & color);

    annotationLine (position (), Radius2??, color)

     
  • Craig Reynolds

    Craig Reynolds - 2010-02-11

    OK, first of all my previous code snippet was wrong, it should have been:

    annotationLine (position(), [b]position() +[/b] (forward()*radius), gGreen);
    

    the previous version would have drawn from each boid to near the origin of 3d space.  If this is not what you need, I am having a hard time understanding exactly what you are trying to draw.  You want a line "from the center of the agent to his radius drawn around the agent".  I think "around" is the word I don't understand.  If you want to draw a circle, see annotationXZCircle.  Perhaps you mean you want the line to animate like the hands on a clock?  Or draw from the center, toward some distant point but clipping at a certain radius?

    Any of these can be done, but I need a better description of your goal.

     
  • Craig Reynolds

    Craig Reynolds - 2010-02-11

    Jeez, the bold markup in this forum utility didn't work that should be:

    annotationLine (position(), position() + (forward()*radius), gGreen);

     
  • Dany

    Dany - 2010-02-12

    Hello, I will try to explain.
    I should draw a line from the center of my agent up to a radius for example
    equal to 2  that need not represent anything, neither direction nor speed.

    drawXZCircleOrDisk (Radius2, position (), color, 100, false);
    annotationLine (position (),??? Radius2 ?????, gGreen);

     

Log in to post a comment.

MongoDB Logo MongoDB