From b01233b07fbf06ba5139d4565c6148f65ab921e9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 16 Jan 2013 17:07:25 +0000 Subject: Movies support for Cycles This adds support of movie textures for Cycles rendering. Uses the same builtin images routines as packed/generated images, but with some extra non-rna hookups from blender_session side. Basically, it's not so clear how to give access to video frames via C++ RNA -- it'll require exposing ImBuf to API, doing some threading locks and so. Ended up adding two more functions which are actually bad level call, but don't consider it's so much bad -- we have few bad calls already, which are actually related. Changed a bit how builtin images names are passing to image manager. Now it's not just an ID datablock name, but also a frame number concatenated via '@' character, which makes itpossible to easily know frame number to be used for movie images, without adding extra descriptors to image manager. Decoding of builtin name is a bit slower now, but it should be still nothing in comparison with rendering complexity. Also exposed image user's frame_current to python API, which is needed to get absolute frame number of movie from node's image user. P.S. Generated/packed images are also using bad level call but only does it to make things more clear here. Either all images are using C++ RNA here or no images does. That's the most clear for now. --- intern/cycles/blender/blender_util.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'intern/cycles/blender/blender_util.h') diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 88c98860794..f134416f2d0 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -33,6 +33,8 @@ extern "C" { void BLI_timestr(double _time, char *str); void BKE_image_user_frame_calc(void *iuser, int cfra, int fieldnr); void BKE_image_user_file_path(void *iuser, void *ima, char *path); +unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame); +float *BKE_image_get_float_pixels_for_frame(void *image, int frame); } CCL_NAMESPACE_BEGIN @@ -100,6 +102,22 @@ static inline string image_user_file_path(BL::ImageUser iuser, BL::Image ima, in return string(filepath); } +static inline int image_user_frame_number(BL::ImageUser iuser, int cfra) +{ + BKE_image_user_frame_calc(iuser.ptr.data, cfra, 0); + return iuser.frame_current(); +} + +static inline unsigned char *image_get_pixels_for_frame(BL::Image image, int frame) +{ + return BKE_image_get_pixels_for_frame(image.ptr.data, frame); +} + +static inline float *image_get_float_pixels_for_frame(BL::Image image, int frame) +{ + return BKE_image_get_float_pixels_for_frame(image.ptr.data, frame); +} + /* Utilities */ static inline Transform get_transform(BL::Array array) -- cgit v1.2.3