示例#1
0
void PathSpatialGizmo::redraw(){

	clear();

	Ref<Curve3D> c = path->get_curve();
	if (c.is_null())
		return;

	Vector3Array v3a=c->tesselate();
	//Vector3Array v3a=c->get_baked_points();

	int v3s = v3a.size();
	if (v3s==0)
		return;
	Vector<Vector3> v3p;
	Vector3Array::Read r = v3a.read();

	for(int i=0;i<v3s-1;i++) {

		v3p.push_back(r[i]);
		v3p.push_back(r[i+1]);
		//v3p.push_back(r[i]);
		//v3p.push_back(r[i]+Vector3(0,0.2,0));
	}

	add_lines(v3p,PathEditorPlugin::singleton->path_material);
	add_collision_segments(v3p);

	if (PathEditorPlugin::singleton->get_edited_path()==path) {
		v3p.clear();
		Vector<Vector3> handles;
		Vector<Vector3> sec_handles;

		for(int i=0;i<c->get_point_count();i++) {

			Vector3 p = c->get_point_pos(i);
			handles.push_back(p);
			if (i>0) {
				v3p.push_back(p);
				v3p.push_back(p+c->get_point_in(i));
				sec_handles.push_back(p+c->get_point_in(i));
			}

			if (i<c->get_point_count()-1) {
				v3p.push_back(p);
				v3p.push_back(p+c->get_point_out(i));
				sec_handles.push_back(p+c->get_point_out(i));
			}
		}

		add_lines(v3p,PathEditorPlugin::singleton->path_thin_material);
		add_handles(handles);
		add_handles(sec_handles,false,true);
	}

}
示例#2
0
void PathSpatialGizmo::redraw() {

	clear();

	Ref<SpatialMaterial> path_material = gizmo_plugin->get_material("path_material");
	Ref<SpatialMaterial> path_thin_material = gizmo_plugin->get_material("path_thin_material");
	Ref<SpatialMaterial> handles_material = gizmo_plugin->get_material("handles");

	Ref<Curve3D> c = path->get_curve();
	if (c.is_null())
		return;

	PoolVector<Vector3> v3a = c->tessellate();
	//PoolVector<Vector3> v3a=c->get_baked_points();

	int v3s = v3a.size();
	if (v3s == 0)
		return;
	Vector<Vector3> v3p;
	PoolVector<Vector3>::Read r = v3a.read();

	// BUG: the following won't work when v3s, avoid drawing as a temporary workaround.
	for (int i = 0; i < v3s - 1; i++) {

		v3p.push_back(r[i]);
		v3p.push_back(r[i + 1]);
		//v3p.push_back(r[i]);
		//v3p.push_back(r[i]+Vector3(0,0.2,0));
	}

	if (v3p.size() > 1) {
		add_lines(v3p, path_material);
		add_collision_segments(v3p);
	}

	if (PathEditorPlugin::singleton->get_edited_path() == path) {
		v3p.clear();
		Vector<Vector3> handles;
		Vector<Vector3> sec_handles;

		for (int i = 0; i < c->get_point_count(); i++) {

			Vector3 p = c->get_point_position(i);
			handles.push_back(p);
			if (i > 0) {
				v3p.push_back(p);
				v3p.push_back(p + c->get_point_in(i));
				sec_handles.push_back(p + c->get_point_in(i));
			}

			if (i < c->get_point_count() - 1) {
				v3p.push_back(p);
				v3p.push_back(p + c->get_point_out(i));
				sec_handles.push_back(p + c->get_point_out(i));
			}
		}

		if (v3p.size() > 1) {
			add_lines(v3p, path_thin_material);
		}
		if (handles.size()) {
			add_handles(handles, handles_material);
		}
		if (sec_handles.size()) {
			add_handles(sec_handles, handles_material, false, true);
		}
	}
}