示例#1
0
void
Sprite::update()
{
  float frame_inc = m_action->fps * (g_game_time - m_last_ticks);
  m_last_ticks = g_game_time;

  m_frame += frame_inc;

  while(m_frame >= 1.0f) {
    m_frame -= 1.0f;
    m_frameidx++;
  }

  while(m_frameidx >= get_frames()) {
    m_frameidx -= get_frames();
    m_animation_loops--;
    if(animation_done()) {
      break;
    }
  }

  if(animation_done()) {
    m_frame = 0;
    m_frameidx = get_frames() - 1;
  }

  assert(m_frameidx < get_frames());
}
示例#2
0
FrameIDs FileConstHandle::get_root_frames() const {
  FrameIDs ret;
  RMF_FOREACH(FrameID fr, get_frames()) {
    if (get_parents(fr).empty()) ret.push_back(fr);
  }
  return ret;
}
    frame_interface* synthetic_source::allocate_composite_frame(std::vector<frame_holder> holders)
    {
        frame_additional_data d {};

        auto req_size = 0;
        for (auto&& f : holders)
            req_size += get_embeded_frames_size(f.frame);

        auto res = _actual_source.alloc_frame(RS2_EXTENSION_COMPOSITE_FRAME, req_size * sizeof(rs2_frame*), d, true);
        if (!res) return nullptr;

        auto cf = static_cast<composite_frame*>(res);

        auto frames = cf->get_frames();
        for (auto&& f : holders)
            copy_frames(std::move(f), frames);
        frames -= req_size;

        auto releaser = [frames, req_size]()
        {
            for (auto i = 0; i < req_size; i++)
            {
                frames[i]->release();
                frames[i] = nullptr;
            }
        };
        frame_continuation release_frames(releaser, nullptr);
        cf->attach_continuation(std::move(release_frames));
        cf->set_stream(cf->first()->get_stream());

        return res;
    }
示例#4
0
void
frames (GtkWidget *box, GtkWidget *button)
{
    GtkWidget *label;
    GtkWidget *child_box1;
    GtkWidget *pbutton;
    gchar *string;
    config_t config;
    
    pbutton = gtk_button_new_with_label (get_frames (config));
    label = gtk_label_new ("Frames"); 
    child_box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
    
    gtk_widget_override_font (label, pango_font_description_from_string ("Cantarell Bold 11.5"));
    gtk_widget_set_size_request (pbutton, 80, 10);
    gtk_widget_set_tooltip_text (pbutton, "Set number of frames between JACK process calls");

    gtk_button_set_relief (GTK_BUTTON (pbutton), GTK_RELIEF_NONE);

    /* Pack box. */
    gtk_box_pack_start (GTK_BOX (child_box1), label, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (child_box1), pbutton, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), child_box1, FALSE, FALSE, 2);

    g_signal_connect (pbutton, "clicked", G_CALLBACK (popover_button_clicked_cb), NULL);
    g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), pbutton);
}
void Video_Player::update()
{
	elapsed += General::LOGIC_MILLIS / 1000.0;

	if (total_frames_loaded >= total_frames) {
		return;
	}

	int needed = MIN(total_frames-total_frames_loaded, buffer_size_in_frames - (int)frames.size());
	if (needed > 0) {
		get_frames(needed);
	}
}
static GstClockTime
get_time (GstRTSPRangeUnit unit, const GstRTSPTime * t1,
    const GstRTSPTime2 * t2)
{
  GstClockTime res;

  switch (t1->type) {
    case GST_RTSP_TIME_SECONDS:
    {
      res = get_seconds (t1);
      break;
    }
    case GST_RTSP_TIME_UTC:
    {
      GDateTime *dt, *bt;
      GTimeSpan span;

      /* make time base, we use 1900 */
      bt = g_date_time_new_utc (1900, 1, 1, 0, 0, 0.0);
      /* convert to GDateTime without the seconds */
      dt = g_date_time_new_utc (t2->year, t2->month, t2->day, 0, 0, 0.0);
      /* get amount of microseconds */
      span = g_date_time_difference (dt, bt);
      g_date_time_unref (bt);
      g_date_time_unref (dt);
      /* add seconds */
      res = get_seconds (t1) + (span * 1000);
      break;
    }
    case GST_RTSP_TIME_FRAMES:
      res = get_seconds (t1);
      res += get_frames (t2, unit);
      break;
    default:
    case GST_RTSP_TIME_NOW:
    case GST_RTSP_TIME_END:
      res = GST_CLOCK_TIME_NONE;
      break;
  }
  return res;
}
Video_Player::Video_Player(std::string dirname, int buffer_size_in_frames) :
	buffer_size_in_frames(buffer_size_in_frames),
	offset(0, 0)
{
	elapsed = 0.0;

	this->dirname = dirname;

	// Count frames
	total_frames = 0;
	for (; total_frames < 0xffff /* RANDOM */; total_frames++) {
		char filename[1000];
		snprintf(filename, 1000, "%s/%06d.png", this->dirname.c_str(), total_frames);
		if (!General::exists(filename)) {
			break;
		}
	}
	total_frames_loaded = 0;

	ALLEGRO_DEBUG("TOTAL FRAMES = %d\n", total_frames);

	// Request a full buffer of frames to start
	get_frames(MIN(buffer_size_in_frames, total_frames));
}
示例#8
0
 /** Set current frame */
 void set_frame(int frame)
 { 
   this->frame = (frame % get_frames()); 
 }
示例#9
0
 unsigned int SingleAvroFile::get_number_of_frames() const {
   return get_frames().size() - 1;
 }
示例#10
0
static void
popover_button_clicked_cb (GtkButton *button, gpointer user_data)
{
    GtkWidget *tb;
    GtkWidget *box;
    GtkWidget *radio1;
    GtkWidget *radio2;
    GtkWidget *radio3;
    GtkWidget *radio4;
    GtkWidget *radio5;
    GtkWidget *radio6;
    GtkWidget *radio7;
    GtkWidget *radio8;
    GtkWidget *radio9;
    GtkPassedFramesData *pdata;
    GSList *list; 
    config_t config;   

    box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);    
    radio1 = gtk_radio_button_new_with_label (NULL, "16");
    radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "32");
    radio3 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "64");
    radio4 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "128");
    radio5 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "256");
    radio6 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "512");
    radio7 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "1024");
    radio8 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "2048");
    radio9 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "4096");
      
    list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio1));

    pdata = g_slice_new (GtkPassedFramesData);
    pdata -> popover = gtk_popover_new (GTK_WIDGET (button));
    pdata -> button = (GTK_WIDGET (button));    
   
    while (list)
    {
        tb = list -> data;

        if (g_strcmp0 (gtk_button_get_label (GTK_BUTTON (tb)), get_frames (config)) == 0)
        {
            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE);
        }

        list = list -> next;
    }

    list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio1));

    gtk_box_pack_start (GTK_BOX (box), radio1, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio2, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio3, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio4, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio5, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio6, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio7, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio8, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (box), radio9, FALSE, FALSE, 2);
    gtk_container_add (GTK_CONTAINER (pdata -> popover), box);

    g_signal_connect (radio1, "toggled", G_CALLBACK (button_toggled_cb), pdata);
    g_signal_connect (radio2, "toggled", G_CALLBACK (button_toggled_cb), pdata);
    g_signal_connect (radio3, "toggled", G_CALLBACK (button_toggled_cb), pdata);
    g_signal_connect (radio4, "toggled", G_CALLBACK (button_toggled_cb), pdata);
    g_signal_connect (radio5, "toggled", G_CALLBACK (button_toggled_cb), pdata);
    g_signal_connect (radio6, "toggled", G_CALLBACK (button_toggled_cb), pdata);
    g_signal_connect (radio7, "toggled", G_CALLBACK (button_toggled_cb), pdata);
    g_signal_connect (radio8, "toggled", G_CALLBACK (button_toggled_cb), pdata);    
    g_signal_connect (radio9, "toggled", G_CALLBACK (button_toggled_cb), pdata);
   
    gtk_widget_show_all (pdata -> popover);   
}
示例#11
0
int
Sprite::get_height() const
{
  assert(m_frameidx < get_frames());
  return static_cast<int>(m_action->surfaces[m_frameidx]->get_height());
}
示例#12
0
//PRIVATE
void tower::set_delay() {
    atk_delay=get_frames(attributes->atk.delay,timer);
}
static bool load_keyframes(Lib3dsFile *file, const char *name, Lib3dsNodeTypes type, XFormNode *node) {
	if(!name || !*name) return false;
	
	Lib3dsNode *n = lib3ds_file_node_by_name(file, name, type);
	if(!n) return false;

	switch(type) {
	case LIB3DS_OBJECT_NODE:
		{
			Lib3dsObjectData *obj = &n->data.object;
			std::vector<int> *frames = get_frames(obj);
			if(!frames) return false;

			for(int i=0; i<(int)frames->size(); i++) {
				lib3ds_node_eval(n, (float)(*frames)[i]);
					
				Vector3 pos = CONV_VEC3(obj->pos) - CONV_VEC3(obj->pivot);
				Quaternion rot = CONV_QUAT(obj->rot);
				Vector3 scl = CONV_VEC3(obj->scl);

				Keyframe key(PRS(pos, rot, scl), FRAME_TO_TIME((*frames)[i]));
				node->add_keyframe(key);
			}
		}
		break;

	case LIB3DS_LIGHT_NODE:
		{
			Lib3dsLightData *light = &n->data.light;
			std::vector<int> *frames = get_frames(light);
			if(!frames) return false;

			for(int i=0; i<(int)frames->size(); i++) {
				lib3ds_node_eval(n, (float)(*frames)[i]);

				Vector3 pos = CONV_VEC3(light->pos);

				Keyframe key(PRS(pos, Quaternion()), FRAME_TO_TIME((*frames)[i]));
				node->add_keyframe(key);
			}
		}
		break;

	case LIB3DS_CAMERA_NODE:
		{
			Lib3dsCameraData *cam = &n->data.camera;
			std::vector<int> *frames = get_frames(cam);
			if(!frames) return false;

			for(int i=0; i<(int)frames->size(); i++) {
				lib3ds_node_eval(n, (float)(*frames)[i]);

				Vector3 pos = CONV_VEC3(cam->pos);

				Keyframe key(PRS(pos, Quaternion()), FRAME_TO_TIME((*frames)[i]));
				node->add_keyframe(key);
			}
		}
		break;

		/*
	case LIB3DS_TARGET_NODE:
		{
			Lib3dsCameraData *targ = &n->data.target;
			std::vector<int> *frames = get_frames(targ);
			if(!frames) return false;

			for(int i=0; i<(int)frames->size(); i++) {
				lib3ds_node_eval(n, (float)(*frames)[i]);

				Vector3 pos = CONV_VEC3(targ->pos);

				Keyframe key(PRS(pos, Quaternion()), FRAME_TO_TIME((*frames)[i]));
				node->add_keyframe(key);
			}

		}
		break;
		*/

	default:
		break;
	}

	return true;
}