Jump to content




Photo
Posted by aiaf, 05 November 2016 · 185 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);
}





February 2017

S M T W T F S
   1234
567891011
12131415161718
1920212223 24 25
262728    

Recent Comments

Search My Blog

Tags