Ejemplo n.º 1
0
Array StreamPeer::_get_partial_data(int p_bytes) {

	Array ret;

	DVector<uint8_t> data;
	data.resize(p_bytes);
	if (data.size() != p_bytes) {

		ret.push_back(ERR_OUT_OF_MEMORY);
		ret.push_back(DVector<uint8_t>());
		return ret;
	}

	DVector<uint8_t>::Write w = data.write();
	int received;
	Error err = get_partial_data(&w[0], p_bytes, received);
	w = DVector<uint8_t>::Write();

	if (err != OK) {
		data.resize(0);
	} else if (received != data.size()) {

		data.resize(received);
	}

	ret.push_back(err);
	ret.push_back(data);
	return ret;
}
Ejemplo n.º 2
0
void AudioServer::sample_set_signed_data(RID p_sample, const DVector<float>& p_buffer) {

	SampleFormat format = sample_get_format(p_sample);

	ERR_EXPLAIN("IMA ADPCM is not supported.");
	ERR_FAIL_COND(format==SAMPLE_FORMAT_IMA_ADPCM);

	int len = p_buffer.size();
	ERR_FAIL_COND( len == 0 );

	DVector<uint8_t> data;
	DVector<uint8_t>::Write w;
	DVector<float>::Read r = p_buffer.read();

	switch(format) {
		case SAMPLE_FORMAT_PCM8: {
			data.resize(len);
			w=data.write();

			int8_t *samples8 = (int8_t*)w.ptr();

			for(int i=0;i<len;i++) {

				float sample = Math::floor( r[i] * (1<<8) );
				if (sample<-128)
					sample=-128;
				else if (sample>127)
					sample=127;
				samples8[i]=sample;
			}
		} break;
		case SAMPLE_FORMAT_PCM16: {
			data.resize(len*2);
			w=data.write();

			int16_t *samples16 = (int16_t*)w.ptr();

			for(int i=0;i<len;i++) {

				float sample = Math::floor( r[i] * (1<<16) );
				if (sample<-32768)
					sample=-32768;
				else if (sample>32767)
					sample=32767;
				samples16[i]=sample;
			}
		} break;
	}

	w = DVector<uint8_t>::Write();

	sample_set_data(p_sample,data);


}
Ejemplo n.º 3
0
Dictionary PolygonPathFinder::_get_data() const{

	Dictionary d;
	DVector<Vector2> p;
	DVector<int> ind;
	Array connections;
	p.resize(points.size()-2);
	connections.resize(points.size()-2);
	ind.resize(edges.size()*2);
	DVector<float> penalties;
	penalties.resize(points.size()-2);
	{
		DVector<Vector2>::Write wp=p.write();
		DVector<float>::Write pw=penalties.write();

		for(int i=0;i<points.size()-2;i++) {
			wp[i]=points[i].pos;
			pw[i]=points[i].penalty;
			DVector<int> c;
			c.resize(points[i].connections.size());
			{
				DVector<int>::Write cw=c.write();
				int idx=0;
				for (Set<int>::Element *E=points[i].connections.front();E;E=E->next()) {
					cw[idx++]=E->get();
				}
			}
			connections[i]=c;
		}
	}
	{

		DVector<int>::Write iw=ind.write();
		int idx=0;
		for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
			iw[idx++]=E->get().points[0];
			iw[idx++]=E->get().points[1];
		}

	}

	d["bounds"]=bounds;
	d["points"]=p;
	d["penalties"]=penalties;
	d["connections"]=connections;
	d["segments"]=ind;

	return d;

}
Ejemplo n.º 4
0
static void _decompress_etc(Image *p_img) {

	ERR_FAIL_COND(p_img->get_format() != Image::FORMAT_ETC);

	int imgw = p_img->get_width();
	int imgh = p_img->get_height();
	DVector<uint8_t> src = p_img->get_data();
	DVector<uint8_t> dst;

	DVector<uint8_t>::Read r = src.read();

	int mmc = p_img->get_mipmaps();

	for (int i = 0; i <= mmc; i++) {

		dst.resize(dst.size() + imgw * imgh * 3);
		const uint8_t *srcbr = &r[p_img->get_mipmap_offset(i)];
		DVector<uint8_t>::Write w = dst.write();

		uint8_t *wptr = &w[dst.size() - imgw * imgh * 3];

		int bw = MAX(imgw / 4, 1);
		int bh = MAX(imgh / 4, 1);

		for (int y = 0; y < bh; y++) {

			for (int x = 0; x < bw; x++) {

				uint8_t block[4 * 4 * 4];

				rg_etc1::unpack_etc1_block(srcbr, (unsigned int *)block);
				srcbr += 8;

				int maxx = MIN(imgw, 4);
				int maxy = MIN(imgh, 4);

				for (int yy = 0; yy < maxy; yy++) {

					for (int xx = 0; xx < maxx; xx++) {

						uint32_t src_ofs = (yy * 4 + xx) * 4;
						uint32_t dst_ofs = ((y * 4 + yy) * imgw + x * 4 + xx) * 3;
						wptr[dst_ofs + 0] = block[src_ofs + 0];
						wptr[dst_ofs + 1] = block[src_ofs + 1];
						wptr[dst_ofs + 2] = block[src_ofs + 2];
					}
				}
			}
		}

		imgw = MAX(1, imgw / 2);
		imgh = MAX(1, imgh / 2);
	}

	r = DVector<uint8_t>::Read();
	//print_line("Re Creating ETC into regular image: w "+itos(p_img->get_width())+" h "+itos(p_img->get_height())+" mm "+itos(p_img->get_mipmaps()));
	*p_img = Image(p_img->get_width(), p_img->get_height(), p_img->get_mipmaps(), Image::FORMAT_RGB, dst);
	if (p_img->get_mipmaps())
		p_img->generate_mipmaps(-1, true);
}
Ejemplo n.º 5
0
int VideoStreamTheoraplayer::get_pending_frame_count() const {

	if (!clip)
		return 0;

	if (!frame.empty())
		return 1;

	TheoraVideoFrame* f = clip->getNextFrame();
	if (!f)
		return 0;

	float w=clip->getWidth(),h=clip->getHeight();
    int imgsize = w * h * f->mBpp;

	int size = f->getStride() * f->getHeight() * f->mBpp;
	DVector<uint8_t> data;
	data.resize(imgsize);
	DVector<uint8_t>::Write wr = data.write();
    uint8_t* ptr = wr.ptr();
    copymem(ptr, f->getBuffer(), imgsize);
    /*
    for (int i=0; i<h; i++) {
        int dstofs = i * w * f->mBpp;
        int srcofs = i * f->getStride() * f->mBpp;
        copymem(ptr + dstofs, f->getBuffer() + dstofs, w * f->mBpp);
    };
     */
	frame = Image();
	frame.create(w, h, 0, f->mBpp == 3 ? Image::FORMAT_RGB : Image::FORMAT_RGBA, data);

	clip->popFrame();

	return 1;
};
Ejemplo n.º 6
0
Variant::Variant(const DVector<Face3>& p_face_array) {


	DVector<Vector3> vertices;
	int face_count=p_face_array.size();
	vertices.resize(face_count*3);

	if (face_count) {
		DVector<Face3>::Read r = p_face_array.read();
		DVector<Vector3>::Write w = vertices.write();

		for(int i=0;i<face_count;i++) {

			for(int j=0;j<3;j++)
				w[i*3+j]=r[i].vertex[j];
		}

		r=DVector<Face3>::Read();
		w=DVector<Vector3>::Write();

	}

	type = NIL;

	*this = vertices;
}
Ejemplo n.º 7
0
DVector<int> TileMap::_get_tile_data() const {

	DVector<int> data;
	data.resize(tile_map.size()*2);
	DVector<int>::Write w = data.write();

	int idx=0;
	for(const Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {

		uint8_t *ptr = (uint8_t*)&w[idx];
		encode_uint16(E->key().x,&ptr[0]);
		encode_uint16(E->key().y,&ptr[2]);
		uint32_t val = E->get().id;
		if (E->get().flip_h)
			val|=(1<<29);
		if (E->get().flip_v)
			val|=(1<<30);

		encode_uint32(val,&ptr[4]);
		idx+=2;
	}


	w = DVector<int>::Write();

	return data;

}
Ejemplo n.º 8
0
Array ResourcePreloader::_get_resources() const {

	DVector<String> names;
	Array arr;
	arr.resize(resources.size());
	names.resize(resources.size());

	Set<String> sorted_names;

	for(Map<StringName,RES >::Element *E=resources.front();E;E=E->next()) {
		sorted_names.insert(E->key());
	}

	int i=0;
	for(Set<String>::Element *E=sorted_names.front();E;E=E->next()) {

		names.set(i,E->get());
		arr[i]=resources[E->get()];
		i++;
	}

	Array res;
	res.push_back(names);
	res.push_back(arr);
	return res;
}
Ejemplo n.º 9
0
String _Marshalls::variant_to_base64(const Variant& p_var) {

    int len;
    Error err = encode_variant(p_var,NULL,len);
    ERR_FAIL_COND_V( err != OK, "" );

    DVector<uint8_t> buff;
    buff.resize(len);
    DVector<uint8_t>::Write w = buff.write();

    err = encode_variant(p_var,&w[0],len);
    ERR_FAIL_COND_V( err != OK, "" );

    int b64len = len / 3 * 4 + 4 + 1;
    DVector<uint8_t> b64buff;
    b64buff.resize(b64len);
    DVector<uint8_t>::Write w64 = b64buff.write();

    int strlen = base64_encode((char*)(&w64[0]), (char*)(&w[0]), len);
    //OS::get_singleton()->print("len is %i, vector size is %i\n", b64len, strlen);
    w64[strlen] = 0;
    String ret = (char*)&w64[0];

    return ret;
};
Ejemplo n.º 10
0
RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String& p_original_path, Error *r_error) {

	if (r_error)
		*r_error=ERR_FILE_CANT_OPEN;


	FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
	ERR_FAIL_COND_V(!f,RES());

	DVector<uint8_t> data;

	data.resize(f->get_len());

	ERR_FAIL_COND_V(data.size()==0,RES());

	{
		DVector<uint8_t>::Write w = data.write();
		f->get_buffer(w.ptr(),data.size());
	}

	Ref<DynamicFontData> dfd;
	dfd.instance();
	dfd->set_font_data(data);

	if (r_error)
		*r_error=OK;

	return dfd;
}
Ejemplo n.º 11
0
void Particles2DEditorPlugin::_file_selected(const String& p_file) {

	print_line("file: "+p_file);

	int epc=epoints->get_val();

	Image img;
	Error err = ImageLoader::load_image(p_file,&img);
	ERR_EXPLAIN("Error loading image: "+p_file);
	ERR_FAIL_COND(err!=OK);

	img.convert(Image::FORMAT_GRAYSCALE_ALPHA);
	ERR_FAIL_COND(img.get_format()!=Image::FORMAT_GRAYSCALE_ALPHA);
	Size2i s = Size2(img.get_width(),img.get_height());
	ERR_FAIL_COND(s.width==0 || s.height==0);

	DVector<uint8_t> data = img.get_data();
	DVector<uint8_t>::Read r = data.read();

	Vector<Point2i> valid_positions;
	valid_positions.resize(s.width*s.height);
	int vpc=0;


	for(int i=0;i<s.width*s.height;i++) {

		uint8_t a = r[i*2+1];
		if (a>128) {
			valid_positions[vpc++]=Point2i(i%s.width,i/s.width);
		}
	}

	valid_positions.resize(vpc);

	ERR_EXPLAIN("No pixels with transparency > 128 in image..");
	ERR_FAIL_COND(valid_positions.size()==0);

	DVector<Point2> epoints;
	epoints.resize(epc);
	DVector<Point2>::Write w = epoints.write();

	Size2 extents = Size2(img.get_width()*0.5,img.get_height()*0.5);

	for(int i=0;i<epc;i++) {

		Point2 p = valid_positions[Math::rand()%vpc];
		p-=s/2;
		w[i]=p/extents;
	}

	w = DVector<Point2>::Write();

	undo_redo->create_action("Set Emission Mask");
	undo_redo->add_do_method(particles,"set_emission_points",epoints);
	undo_redo->add_do_method(particles,"set_emission_half_extents",extents);
	undo_redo->add_undo_method(particles,"set_emission_points",particles->get_emission_points());
	undo_redo->add_undo_method(particles,"set_emission_half_extents",particles->get_emission_half_extents());
	undo_redo->commit_action();

}
Ejemplo n.º 12
0
void AudioServer::sample_set_signed_data(RID p_sample, const DVector<float>& p_buffer) {

	int len = p_buffer.size();
	ERR_FAIL_COND( len == 0 );

	DVector<uint8_t> data;
	data.resize(len*2);
	DVector<uint8_t>::Write w=data.write();

	int16_t *samples = (int16_t*)w.ptr();

	DVector<float>::Read r = p_buffer.read();

	for(int i=0;i<len;i++) {

		float sample = r[i];
		sample = Math::floor( sample * (1<<16) );
		if (sample<-32768)
			sample=-32768;
		else if (sample>32767)
			sample=32767;
		samples[i]=sample;
	}

	w = DVector<uint8_t>::Write();

	sample_set_data(p_sample,data);


}
Ejemplo n.º 13
0
Error jpeg_load_image_from_buffer(Image *p_image,const uint8_t* p_buffer, int p_buffer_len) {

	jpgd::jpeg_decoder_mem_stream mem_stream(p_buffer,p_buffer_len);

	jpgd::jpeg_decoder decoder(&mem_stream);

	if (decoder.get_error_code() != jpgd::JPGD_SUCCESS) {
		return ERR_CANT_OPEN;
	}

	const int image_width = decoder.get_width();
	const int image_height = decoder.get_height();
	int comps = decoder.get_num_components();
	if (comps==3)
		comps=4; //weird

	if (decoder.begin_decoding() != jpgd::JPGD_SUCCESS)
		return ERR_FILE_CORRUPT;

	const int dst_bpl = image_width * comps;

	DVector<uint8_t> data;

	data.resize(dst_bpl * image_height);

	DVector<uint8_t>::Write dw = data.write();

	jpgd::uint8 *pImage_data = (jpgd::uint8*)dw.ptr();

	for (int y = 0; y < image_height; y++)
	{
		const jpgd::uint8* pScan_line;
		jpgd::uint scan_line_len;
		if (decoder.decode((const void**)&pScan_line, &scan_line_len) != jpgd::JPGD_SUCCESS)
		{
			return ERR_FILE_CORRUPT;
		}

		jpgd::uint8 *pDst = pImage_data + y * dst_bpl;
		memcpy(pDst, pScan_line, dst_bpl);


	}


	//all good

	Image::Format fmt;
	if (comps==1)
		fmt=Image::FORMAT_GRAYSCALE;
	else
		fmt=Image::FORMAT_RGBA;

	dw = DVector<uint8_t>::Write();
	p_image->create(image_width,image_height,0,fmt,data);

	return OK;

}
Ejemplo n.º 14
0
void EditorExportPlatformWindows::store_16(DVector<uint8_t>& vector, uint16_t value) {
	const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&value);
	int size = vector.size();
	vector.resize( size + 2 );
	DVector<uint8_t>::Write w = vector.write();
	w[size]=bytes[0];
	w[size+1]=bytes[1];
}
Ejemplo n.º 15
0
void image_compress_squish(Image *p_image) {

	int w=p_image->get_width();
	int h=p_image->get_height();

	if (p_image->get_mipmaps() == 0) {
		ERR_FAIL_COND( !w || w % 4 != 0);
		ERR_FAIL_COND( !h || h % 4 != 0);
	} else {
		ERR_FAIL_COND( !w || w !=nearest_power_of_2(w) );
		ERR_FAIL_COND( !h || h !=nearest_power_of_2(h) );
	};

	if (p_image->get_format()>=Image::FORMAT_BC1)
		return; //do not compress, already compressed


	Image::AlphaMode alpha = p_image->detect_alpha();
	Image::Format target_format;
	int shift=0;
	int squish_comp=squish::kColourRangeFit;
	switch(alpha) {

		case Image::ALPHA_NONE: target_format = Image::FORMAT_BC1; shift=1; squish_comp|=squish::kDxt1; break;
		case Image::ALPHA_BIT: target_format = Image::FORMAT_BC2; squish_comp|=squish::kDxt3; break;
		case Image::ALPHA_BLEND: target_format = Image::FORMAT_BC3; squish_comp|=squish::kDxt5; break;
	}


	p_image->convert(Image::FORMAT_RGBA); //always expects rgba

	int mm_count = p_image->get_mipmaps();

	DVector<uint8_t> data;
	int target_size = Image::get_image_data_size(w,h,target_format,mm_count);
	data.resize(target_size);

	DVector<uint8_t>::Read rb = p_image->get_data().read();
	DVector<uint8_t>::Write wb = data.write();

	int dst_ofs=0;

	for(int i=0;i<=mm_count;i++) {

		int src_ofs = p_image->get_mipmap_offset(i);
		squish::CompressImage( &rb[src_ofs],w,h,&wb[dst_ofs],squish_comp);
		dst_ofs+=(MAX(4,w)*MAX(4,h))>>shift;
		w>>=1;
		h>>=1;
	}

	rb = DVector<uint8_t>::Read();
	wb = DVector<uint8_t>::Write();

	p_image->create(p_image->get_width(),p_image->get_height(),p_image->get_mipmaps(),target_format,data);

}
Ejemplo n.º 16
0
DVector<Vector2> _Geometry::get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2) {

    Vector2 r1, r2;
    Geometry::get_closest_points_between_segments(p1,q1,p2,q2,r1,r2);
    DVector<Vector2> r;
    r.resize(2);
    r.set(0,r1);
    r.set(1,r2);
    return r;
}
Ejemplo n.º 17
0
Variant::Variant(const Vector<Color>& p_array) {

	type=NIL;
	DVector<Color> v;
	int len=p_array.size();
	v.resize(len);
	for (int i=0;i<len;i++)
		v.set(i,p_array[i]);
	*this=v;
}
Ejemplo n.º 18
0
DVector<String> ResourcePreloader::_get_resource_list() const {

	DVector<String> res;
	res.resize(resources.size());
	int i=0;
	for(Map<StringName,RES >::Element *E=resources.front();E;E=E->next(),i++) {
		res.set(i,E->key());
	}

	return res;
}
Ejemplo n.º 19
0
DVector<Vector3> _Geometry::segment_intersects_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius) {

    DVector<Vector3> r;
    Vector3 res,norm;
    if (!Geometry::segment_intersects_sphere(p_from,p_to,p_sphere_pos,p_sphere_radius,&res,&norm))
        return r;

    r.resize(2);
    r.set(0,res);
    r.set(1,norm);
    return r;
}
Ejemplo n.º 20
0
DVector<Vector3> _Geometry::segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector<Plane>& p_planes) {

    DVector<Vector3> r;
    Vector3 res,norm;
    if (!Geometry::segment_intersects_convex(p_from,p_to,p_planes.ptr(),p_planes.size(),&res,&norm))
        return r;

    r.resize(2);
    r.set(0,res);
    r.set(1,norm);
    return r;
}
Ejemplo n.º 21
0
Variant ConvexPolygonShape2DSW::get_data() const {

	DVector<Vector2> dvr;

	dvr.resize(point_count);

	for(int i=0;i<point_count;i++) {	
		dvr.set(i,points[i].pos);
	}

	return dvr;
}
Ejemplo n.º 22
0
void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) {

	if (unparenting)
		return;

	CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
	ERR_FAIL_COND(!co);

	if (polygon.size()==0)
		return;

	bool solids=build_mode==BUILD_SOLIDS;

	if (solids) {

		//here comes the sun, lalalala
		//decompose concave into multiple convex polygons and add them
		Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
		for(int i=0;i<decomp.size();i++) {
			Ref<ConvexPolygonShape2D> convex = memnew( ConvexPolygonShape2D );
			convex->set_points(decomp[i]);
			co->add_shape(convex,get_transform());
			if (trigger)
				co->set_shape_as_trigger(co->get_shape_count()-1,true);

		}

	} else {

		Ref<ConcavePolygonShape2D> concave = memnew( ConcavePolygonShape2D );

		DVector<Vector2> segments;
		segments.resize(polygon.size()*2);
		DVector<Vector2>::Write w=segments.write();

		for(int i=0;i<polygon.size();i++) {
			w[(i<<1)+0]=polygon[i];
			w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
		}

		w=DVector<Vector2>::Write();
		concave->set_segments(segments);

		co->add_shape(concave,get_transform());
		if (trigger)
			co->set_shape_as_trigger(co->get_shape_count()-1,true);

	}


	//co->add_shape(shape,get_transform());
}
Ejemplo n.º 23
0
DVector<String> AnimationTreePlayer::_get_node_list() {

	List<StringName> nl;
	get_node_list(&nl);
	DVector<String> ret;
	ret.resize(nl.size());
	int idx=0;
	for(List<StringName>::Element *E=nl.front();E;E=E->next()) {
		ret.set(idx++,E->get());
	}

	return ret;
}
Ejemplo n.º 24
0
DVector<uint8_t> _File::get_buffer(int p_length) const {

    DVector<uint8_t> data;
    ERR_FAIL_COND_V(!f,data);

    ERR_FAIL_COND_V(p_length<0,data);
    if (p_length==0)
        return data;
    Error err = data.resize(p_length);
    ERR_FAIL_COND_V(err!=OK,data);
    DVector<uint8_t>::Write w = data.write();
    int len = f->get_buffer(&w[0],p_length);
    ERR_FAIL_COND_V( len < 0 , DVector<uint8_t>());

    w = DVector<uint8_t>::Write();

    if (len < p_length)
        data.resize(p_length);

    return data;

}
Ejemplo n.º 25
0
DVector<Vector3> _Geometry::segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius) {

    DVector<Vector3> r;
    Vector3 res,norm;
    if (!Geometry::segment_intersects_cylinder(p_from,p_to,p_height,p_radius,&res,&norm))
        return r;

    r.resize(2);
    r.set(0,res);
    r.set(1,norm);
    return r;

}
Ejemplo n.º 26
0
DVector<String> Translation::_get_message_list() const {

	DVector<String> msgs;
	msgs.resize(translation_map.size());
	int idx=0;
	for (const Map<StringName, StringName>::Element *E=translation_map.front();E;E=E->next()) {

		msgs.set(idx,E->key());
		idx+=1;
	}

	return msgs;

}
Ejemplo n.º 27
0
void ThetaOperator::returnScaledNormalDistribution(
		  int level ,
		  double stdFactor ,
		  int scaleIndex ,
		  DVector& output){

/* --- Matlab code ---
	L = 6;
	N = -1:(1/2^L):1;
	Fakt = 5.3;
	V = tan(((pi/2) - 1/Fakt)*N);
	V1 = 3*atan( (N).^5+0.1*(N) );
	V = V ./ max(V);
    V1 = V1 ./ max(V1);
*/

	// first generate linear distribution
	int nrPoints = powerTwo[level] + 1;
	DVector tmpPoints(nrPoints);
	output.resize(nrPoints);

	for (int ii = 0 ; ii < nrPoints; ii++)
		tmpPoints[ii] = (double)(2*ii - powerTwo[level]) / (double)(powerTwo[level]);

	// ---- use different scaling formulas -----
	switch (scaleIndex){
		case 0:{
            double internFactor = 1.0/7.0;
            // calculate grading
            for (int ii = 0 ; ii < nrPoints; ii++)
            	output[ii] = tan( (FITOB_HALF_PI - internFactor)*tmpPoints[ii]);
            // do the scaling
            for (int ii = 0 ; ii < nrPoints; ii++)
            	output[ii] = stdFactor * output[ii] / output[nrPoints-1];
			break;
		}
		case 1:{
			// do some prework in the formula
			for (int ii = 0 ; ii < nrPoints; ii++)
				output[ii] = pow(tmpPoints[ii],5) + 0.1 * tmpPoints[ii];
            // calculate grading
            for (int ii = 0 ; ii < nrPoints; ii++)
            	output[ii] = 3.0 * atan( output[ii] );
            // do the scaling
            for (int ii = 0 ; ii < nrPoints; ii++)
            	output[ii] = stdFactor * output[ii] / output[nrPoints-1];
			break;
		}
	}
}
Ejemplo n.º 28
0
void Shape::add_vertices_to_array(DVector<Vector3> &array, const Transform& p_xform) {

	Vector<Vector3> toadd = _gen_debug_mesh_lines();

	if (toadd.size()) {

		int base=array.size();
		array.resize(base+toadd.size());
		DVector<Vector3>::Write w = array.write();
		for(int i=0;i<toadd.size();i++) {
			w[i+base]=p_xform.xform(toadd[i]);
		}

	}
}
Ejemplo n.º 29
0
Variant::Variant(const Vector<Vector3>& p_array) {

	type=NIL;
	DVector<Vector3> v;
	int len=p_array.size();
	if (len>0) {
		v.resize(len);
		DVector<Vector3>::Write w = v.write();
		const Vector3 *r = p_array.ptr();

		for (int i=0;i<len;i++)
			w[i]=r[i];
	}
	*this=v;
}
Ejemplo n.º 30
0
Variant::operator DVector<Plane>() const {

	Array va= operator Array();
	DVector<Plane> planes;
	int va_size=va.size();
	if (va_size==0)
		return planes;

	planes.resize(va_size);
	DVector<Plane>::Write w = planes.write();

	for(int i=0;i<va_size;i++)
		w[i]=va[i];

	return planes;
}