Jump to content

aiaf's Blog

  • entries
    11
  • comments
    4
  • views
    7,355

[Example] Some kind of arrow


aiaf

1,763 views

 Share

Draws a box from one vector to another.

To be used as some kind of arrow.

 

Need feedback if its a better way to do this, but so far seem to be ok for my purposes.

 

Example usage:

ArrowUi *t = new ArrowUi(Vec3(0.0, 0.0, 0.0), testshadow->GetModel()->GetPosition());

 

class ArrowUi {
   private:
    Model *model;
    Entity *pivot;
    Vec3 from;
    Vec3 to;
    float distance;
   public:
    ArrowUi();
    ArrowUi(Vec3 from, Vec3 to);
    void From(Vec3 from);
    void To(Vec3 to);
    void Draw();
};


ArrowUi::ArrowUi() {
   model = NULL;
   surface = NULL;
   pivot = NULL;
   from = NULL;
   to = NULL;
}

ArrowUi::ArrowUi(Vec3 from, Vec3 to) {
   this->from = from;
   this->to = to;
   Draw();
}

void ArrowUi::From(Vec3 from) {
   this->from = from;
}

void ArrowUi::To(Vec3 to) {
   this->to = to;
}

void ArrowUi::Draw() {
   pivot = Pivot::Create();
   pivot->SetPosition(from, true);

   distance = from.DistanceToPoint(to);
   model = Model::Box(0.05, 0.05, distance, pivot);
   model->Move(0, 0, distance/2);

   pivot->AlignToVector(to - from, 0);
   pivot->AlignToVector(to - from, 1);
   pivot->AlignToVector(to - from, 2);
}

  • Upvote 1
 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...