Sign in to follow this  
Followers 0
  • entries
    4
  • comment
    1
  • views
    2,490

[Example] Some kind of arrow

Sign in to follow this  
Followers 0
aiaf

198 views

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);
}


2
  Report Entry
Sign in to follow this  
Followers 0


0 Comments


There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Create Your Account

Sign in

Already have an account? Sign in here.


Sign In Now