Пример #1
0
void paths_create() {
    for (int i = 0; i < NUM_WEDGES; i++) {
        if (s_paths[i]) {
            gpath_destroy(s_paths[i]);
        }

        GPathInfo path_info = (GPathInfo) {
            .num_points = 3,
             .points = s_points[i]
        };
        s_paths[i] = gpath_create(&path_info);
        gpath_move_to(s_paths[i], s_center);
    }
}

void paths_destroy() {
    for (int i = 0; i < NUM_WEDGES; i++) {
        gpath_destroy(s_paths[i]);
    }
}

Layer* forecast_create(GRect window_bounds) {
    s_center = grect_center_point(&window_bounds);
    init_points();
    paths_create();
    s_canvas_layer = layer_create(window_bounds);
    //layer_add_child(s_canvas_layer, textlayer_create());
    layer_set_update_proc(s_canvas_layer, draw_forecast);

    static Layer* icons_layer;
    icons_layer = forecast_icons_create(window_bounds);
    layer_add_child(s_canvas_layer, icons_layer);

    return s_canvas_layer;
}
Пример #2
0
Plane::Plane(elem* e){

	stringstream *ss = new stringstream(e->attr["step"]);
	*ss >> this->step;
	delete ss;

	init_points();
}
Пример #3
0
//process the morphing object for one frame
void do_morph_frame(object *obj)
{
	int i;
	polymodel *pm;
	morph_data *md;

	md = find_morph_data(obj);

	if (md == NULL) {					//maybe loaded half-morphed from disk
		obj->flags |= OF_SHOULD_BE_DEAD;		//..so kill it
		return;
	}

	pm = &Polygon_models[md->obj->rtype.pobj_info.model_num];

	//printf("morph_frame active = ");
	//for (i=0;i<pm->n_models;i++)
	//	printf("%d ",submodel_active[i]);
	//printf("\n");


	for (i=0;i<pm->n_models;i++)
		if (md->submodel_active[i]==1) {

			update_points(pm,i,md);

			if (md->n_morphing_points[i] == 0) {		//maybe start submodel
				int t;

				md->submodel_active[i] = 2;		//not animating, just visible

				md->n_submodels_active--;		//this one done animating

				for (t=0;t<pm->n_models;t++)
					if (pm->submodel_parents[t] == i) {		//start this one

						init_points(pm,NULL,t,md);
						md->n_submodels_active++;
						md->submodel_active[t] = 1;

					}
			}

		}

	if (!md->n_submodels_active) {			//done morphing!

		md->obj->control_type = md->morph_save_control_type;
		md->obj->movement_type = md->morph_save_movement_type;

		md->obj->render_type = RT_POLYOBJ;

		md->obj->mtype.phys_info = md->morph_save_phys_info;

		md->obj = NULL;
	}

}
Пример #4
0
//make the object morph
void morph_start(object *obj)
{
	polymodel *pm;
	vms_vector pmmin,pmmax;
	vms_vector box_size;
	int i;
	morph_data *md;

	for (i=0;i<MAX_MORPH_OBJECTS;i++)
		if (morph_objects[i].obj == NULL || morph_objects[i].obj->type==OBJ_NONE  || morph_objects[i].obj->signature!=morph_objects[i].Morph_sig)
			break;

	if (i==MAX_MORPH_OBJECTS)		//no free slots
		return;

	md = &morph_objects[i];

	Assert(obj->render_type == RT_POLYOBJ);

	md->obj = obj;
	md->Morph_sig = obj->signature;

	md->morph_save_control_type = obj->control_type;
	md->morph_save_movement_type = obj->movement_type;
	md->morph_save_phys_info = obj->mtype.phys_info;

	Assert(obj->control_type == CT_AI);		//morph objects are also AI objects

	obj->control_type = CT_MORPH;
	obj->render_type = RT_MORPH;
	obj->movement_type = MT_PHYSICS;		//RT_NONE;

	obj->mtype.phys_info.rotvel = morph_rotvel;

	pm = &Polygon_models[obj->rtype.pobj_info.model_num];

	find_min_max(pm,0,&pmmin,&pmmax);

	box_size.x = max(-pmmin.x,pmmax.x) / 2;
	box_size.y = max(-pmmin.y,pmmax.y) / 2;
	box_size.z = max(-pmmin.z,pmmax.z) / 2;

	for (i=0;i<MAX_VECS;i++)		//clear all points
		md->morph_times[i] = 0;

	for (i=1;i<MAX_SUBMODELS;i++)		//clear all parts
		md->submodel_active[i] = 0;

	md->submodel_active[0] = 1;		//1 means visible & animating

	md->n_submodels_active = 1;

	//now, project points onto surface of box

	init_points(pm,&box_size,0,md);

}
Пример #5
0
void Mesh::mesh_init(const char* file_name , float percent)
{
	origin = new CSimpleObject;
	origin->LoadFromObj(file_name);
	init_points();                   //初始化节点
	init_faces();                    //初始化面
	finalsize = int(fsize * percent);
	cout<<finalsize<<endl;
}
Пример #6
0
 PointsSpace(PointId num_points, Dimensions num_dimensions) 
   : num_points_(num_points), num_dimensions_(num_dimensions)
 {init_points();};
Пример #7
0
Plane::Plane(int i):step(i){
	init_points();
}
Пример #8
0
Plane::Plane(){
	step = 10;
	init_points();
}
Пример #9
0
    Int run() {
      std::fill(begin(sum_p), end(sum_p), 0LL);
      N = 0;
      init_points();
      init_sum_p();

      for ( auto i = 0; i < N; ++ i ) {
        if ( std::get<POINT_TYPE>(P[i]) == TYPE_S ) {
          auto l_id = std::get<POINT_ID>(P[i]);
          auto l = std::lower_bound(P_v, P_v + N, in->S[l_id]) - P_v;
          auto r = std::lower_bound(P_v, P_v + N, in->T[l_id]) - P_v;
          if ( in->S[l_id] > in->T[l_id] ) {
            std::get<POINT_TYPE>(P[l]) = TYPE_T;
            std::get<POINT_TYPE>(P[r]) = TYPE_S;
            std::get<POINT_REV>(P[l]) = true;
            std::get<POINT_REV>(P[r]) = true;
          }
        }
      }

      Int res = 0;
      Int a = 0;
      Int b = 0;
      for ( auto i = 0; i + 1 < N; ++ i ) {
        if ( std::get<POINT_TYPE>(P[i]) == TYPE_P ) {
          std::swap(a, b);
        } else if ( std::get<POINT_TYPE>(P[i]) == TYPE_S ) {
          auto l_id = std::get<POINT_ID>(P[i]);
          auto l = std::lower_bound(P_v, P_v + N, in->S[l_id]) - P_v;
          auto r = std::lower_bound(P_v, P_v + N, in->T[l_id]) - P_v;
          auto s = get_sum(l, r);
          if ( std::get<POINT_REV>(P[i]) ) {
            if ( s % 2 == 0 ) {
              a ++;
            } else {
              b ++;
            }
          } else {
            a ++;
          }
        } else if ( std::get<POINT_TYPE>(P[i]) == TYPE_T ) {
          auto l_id = std::get<POINT_ID>(P[i]);
          auto l = std::lower_bound(P_v, P_v + N, in->S[l_id]) - P_v;
          auto r = std::lower_bound(P_v, P_v + N, in->T[l_id]) - P_v;
          auto s = get_sum(l, r);
          if ( std::get<POINT_REV>(P[i]) ) {
            if ( s % 2 == 0 ) {
              b --;
            } else {
              a --;
            }
          } else {
            if ( s % 2 == 0 ) {
              a --;
            } else {
              b --;
            }
          }
        }
        if ( i + 1 < N ) {
          res += a * ( P_v[i + 1] - P_v[i]);
        } else {
          res += a;
        }
        // cout << P_v[i] << ": inc = " << a << ", no inc = " << b << ", res = " << res << endl;
      }
      return res;
    }