Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: C++ SFML how to add movie/scene?  (Read 8576 times)

0 Members and 1 Guest are viewing this topic.

reportados123

  • Newbie
  • *
  • Posts: 18
    • View Profile
C++ SFML how to add movie/scene?
« on: January 28, 2013, 06:03:43 pm »
Hi, I looked around on google but couldn't find an answer.

What I wanted to know is how you can add a movie/scene to the game? For example, I come from a Flash background and all you had to do was create your scene in a Movieclip, then you could just export it and basically add it to your game. Or do a more and unorganized way, do it directly on the timeline.

How could you achieve this in C++ and SFML? I was thinking about having multiple png files and drawing that to the screen but obviously, this is impractical and a big waste of memory (having to load every single png file, etc).

I'm completely stumped and I don't know how you could achieve this.

Thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: C++ SFML how to add movie/scene?
« Reply #1 on: January 28, 2013, 06:19:11 pm »
SFML doesn't support movies directly, but there are a few project on the forum, that make use of FFMPEG, the best known one is the sfMovie Project.
But FFMPEG is not the only way to do thing. You can for example also animate the scene directly with SFML or one could make use of gstreamer (there should also be something in the project section) or many many other ways. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

reportados123

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: C++ SFML how to add movie/scene?
« Reply #2 on: January 29, 2013, 12:11:42 am »
SFML doesn't support movies directly, but there are a few project on the forum, that make use of FFMPEG, the best known one is the sfMovie Project.
But FFMPEG is not the only way to do thing. You can for example also animate the scene directly with SFML or one could make use of gstreamer (there should also be something in the project section) or many many other ways. :)

How could you animate the scene directly using SFML? I was thinking of doing frame by frame (picture by picture), but again, not practical.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: C++ SFML how to add movie/scene?
« Reply #3 on: January 29, 2013, 12:22:31 am »
Completetly depends on what your doing.
Loading full images isn't really practical yes, but you can animate the parts of the image. Say you got a animated clock. Instead of have the full pictures for all possibilities, you simply take the clock as background image and animate the hands. Thus you need 4 images (background, hours hand, minutes hand, seconds hand). The background is static and you rotate the hands whenever they need to rotate.

Of course this only works with easy scenes and not with complex effects etc. thus if you export a movie from After Effects or so, you can't really apply that with SFML.
The cut scenes in games are also often pre-rendered clips that get loaded and played back. They often use some proprietary formats (e.g. Bink).

What exactly do you have in mind when talking about movie/scenes?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

reportados123

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: C++ SFML how to add movie/scene?
« Reply #4 on: January 29, 2013, 12:49:33 am »
Basically just playing a scene at the start before the main menu so they have a little bit of story. Nothing else really after that, just basic animation from sprite sheets. It'll contain a story animation and some music.

Which brings up another question actually, I'm interested if there's an alternative way to do animation apart from sprite sheets? This is 2D by the way, not 3D.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: C++ SFML how to add movie/scene?
« Reply #5 on: January 29, 2013, 01:17:38 am »
Which brings up another question actually, I'm interested if there's an alternative way to do animation apart from sprite sheets?
I'm not sure if you're grasping the potential of C++ and OpenGL. With C++ you can basically do, whatever a computer is capable of doing, that is everything. The catch is though, that you need to do it manually on your own. But since we don't want to reinvent the wheel every single time, there are libraries and tools that make our life easier. SFML for instance provides a nice API to handle images, audio, input, networking and most importantly OpenGL context and window creation.
So as you see, when you ask, if there are alternative ways to do animation, the question doesn't really help much, because you can do animations the way you want, as long as you can think of an idea on how to implement it in C++ (and OpenGL).
With modern GPUs the direction of creating animations and effects drifts towards using shaders, with which you can do quite amazing stuff. For example here you get a demo which uses one quad and does all the animation in a shader:


C++ can do anything, but since you have to do it manually, you might still want to use a software (often also written in C++), that provides a nice environment to easily create animations and then export it and somehow load it for your application.
It all depends on the complexity of the scene and how good you are at writing code.

And yes spritesheets is the most common way to do 2D animation. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

reportados123

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: C++ SFML how to add movie/scene?
« Reply #6 on: January 29, 2013, 01:46:18 am »
Wow that's cool. This is what I mean though, I wanted to know how you can make a scene to show the players. Would I make a video in some kind of video format and play it? I don't know :S

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: C++ SFML how to add movie/scene?
« Reply #7 on: January 29, 2013, 02:33:46 am »
I wanted to know how you can make a scene to show the players.
By programming? ;D
As I said it's all up to you. Do you have any idea how to program with C++ at all?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

reportados123

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: C++ SFML how to add movie/scene?
« Reply #8 on: January 29, 2013, 02:58:21 am »
lol? Yes I do know how to program with C++, I don't understand why you would assume me not knowing how lol. Maybe I haven't mastered it (as it's impossible to do so, since the language is so esoteric and is always growing) but I have the basics down, etc.

Edit: Yes.. by programming.  :P

Edit 2: I think I'll stick with loading and playing back the loaded file. Thanks for your help!
« Last Edit: January 29, 2013, 02:59:55 am by reportados123 »