Exemplo n.º 1
0
Dictionary Curve3D::_get_data() const {

	Dictionary dc;

	PoolVector3Array d;
	d.resize(points.size() * 3);
	PoolVector3Array::Write w = d.write();
	PoolRealArray t;
	t.resize(points.size());
	PoolRealArray::Write wt = t.write();

	for (int i = 0; i < points.size(); i++) {

		w[i * 3 + 0] = points[i].in;
		w[i * 3 + 1] = points[i].out;
		w[i * 3 + 2] = points[i].pos;
		wt[i] = points[i].tilt;
	}

	w = PoolVector3Array::Write();
	wt = PoolRealArray::Write();

	dc["points"] = d;
	dc["tilts"] = t;

	return dc;
}
Exemplo n.º 2
0
PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array) {
	PoolVector3Array ret;
	int length = mono_array_length(p_array);

	for (int i = 0; i < length; i++) {
		real_t *raw_elem = (real_t *)mono_array_addr_with_size(p_array, sizeof(real_t) * 3, i);
		MARSHALLED_IN(Vector3, raw_elem, elem);
		ret.push_back(elem);
	}

	return ret;
}
Exemplo n.º 3
0
PoolVector3Array Curve3D::tesselate(int p_max_stages, float p_tolerance) const {

	PoolVector3Array tess;

	if (points.size() == 0) {
		return tess;
	}
	Vector<Map<float, Vector3> > midpoints;

	midpoints.resize(points.size() - 1);

	int pc = 1;
	for (int i = 0; i < points.size() - 1; i++) {

		_bake_segment3d(midpoints[i], 0, 1, points[i].pos, points[i].out, points[i + 1].pos, points[i + 1].in, 0, p_max_stages, p_tolerance);
		pc++;
		pc += midpoints[i].size();
	}

	tess.resize(pc);
	PoolVector3Array::Write bpw = tess.write();
	bpw[0] = points[0].pos;
	int pidx = 0;

	for (int i = 0; i < points.size() - 1; i++) {

		for (Map<float, Vector3>::Element *E = midpoints[i].front(); E; E = E->next()) {

			pidx++;
			bpw[pidx] = E->get();
		}

		pidx++;
		bpw[pidx] = points[i + 1].pos;
	}

	bpw = PoolVector3Array::Write();

	return tess;
}
Exemplo n.º 4
0
void Curve3D::_set_data(const Dictionary &p_data) {

	ERR_FAIL_COND(!p_data.has("points"));
	ERR_FAIL_COND(!p_data.has("tilts"));

	PoolVector3Array rp = p_data["points"];
	int pc = rp.size();
	ERR_FAIL_COND(pc % 3 != 0);
	points.resize(pc / 3);
	PoolVector3Array::Read r = rp.read();
	PoolRealArray rtl = p_data["tilts"];
	PoolRealArray::Read rt = rtl.read();

	for (int i = 0; i < points.size(); i++) {

		points[i].in = r[i * 3 + 0];
		points[i].out = r[i * 3 + 1];
		points[i].pos = r[i * 3 + 2];
		points[i].tilt = rt[i];
	}

	baked_cache_dirty = true;
}