/*
* CINELERRA
* Copyright (C) 2011 Adam Williams <broadcast at earthling dot net>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ *
*/
void SceneNode::render(VFrame *frame, int do_camera)
{
const int debug = 0;
- if(debug) printf("SceneNode::render %d this=%p title=%s image=%p x=%f y=%f frame=%p do_camera=%d\n",
- __LINE__,
+ if(debug) printf("SceneNode::render %d this=%p title=%s image=%p x=%f y=%f frame=%p do_camera=%d\n",
+ __LINE__,
this,
title,
image,
float sx = this->sx;
float sy = this->sy;
float ry = this->ry;
- if(parent)
+ if(parent)
parent->transform_coord(&x, &y, &sx, &sy, &ry);
- if(do_camera) scene->transform_camera(frame,
- &x,
- &y,
- &sx,
- &sy,
+ if(do_camera) scene->transform_camera(frame,
+ &x,
+ &y,
+ &sx,
+ &sy,
get_flip());
- if(debug) printf("SceneNode::render %d at_y=%f\n",
- __LINE__,
+ if(debug) printf("SceneNode::render %d at_y=%f\n",
+ __LINE__,
((SceneCamera*)scene->cameras.get(0))->at_y);
// Render everything into a temporary, then overlay the temporary
// if(!EQUIV(ry, 0) || get_flip())
// {
- temp = new VFrame(image->get_w(),
- image->get_h(),
- image->get_color_model());
+ temp = new VFrame(image->get_w(), image->get_h(), image->get_color_model(), 0);
// }
if(debug) printf("SceneNode::render %d\n", __LINE__);
VFrame *src = temp;
if(!EQUIV(ry, 0))
{
- src = temp2 = new VFrame(image->get_w(),
- image->get_h(),
- image->get_color_model());
- if(!scene->affine) scene->affine =
- new AffineEngine(scene->cpus, scene->cpus);
- scene->affine->rotate(temp2,
- temp,
- ry);
+ src = temp2 = new VFrame(image->get_w(), image->get_h(), image->get_color_model(), 0);
+ if(!scene->affine) scene->affine = new AffineEngine(scene->cpus, scene->cpus);
+ scene->affine->rotate(temp2, temp, ry);
if(debug) printf("SceneNode::render %d ry=%f\n", __LINE__, ry);
}
if(get_flip())
src->flip_horiz();
- if(debug) printf("SceneNode::render %d src=%p x=%f y=%f sx=%f sy=%f\n",
- __LINE__,
- src,
- x,
- y,
- sx,
- sy);
-
+ if(debug) printf("SceneNode::render %d src=%p x=%f y=%f sx=%f sy=%f\n",
+ __LINE__, src, x, y, sx, sy);
// Overlay on the output frame
if(!scene->overlayer) scene->overlayer = new OverlayFrame(scene->cpus);
if(get_flip())
{
- scene->overlayer->overlay(frame,
- src,
- 0,
- 0,
- image->get_w(),
- image->get_h(),
- frame->get_w() - x - image->get_w() * sx,
- y,
- frame->get_w() - x,
- y + image->get_h() * sy,
+ scene->overlayer->overlay(frame,
+ src,
+ 0,
+ 0,
+ image->get_w(),
+ image->get_h(),
+ frame->get_w() - x - image->get_w() * sx,
+ y,
+ frame->get_w() - x,
+ y + image->get_h() * sy,
1,
TRANSFER_NORMAL,
NEAREST_NEIGHBOR);
}
else
{
- if(debug) printf("SceneNode::render %d image=%p src=%p frame=%p\n",
- __LINE__,
+ if(debug) printf("SceneNode::render %d image=%p src=%p frame=%p\n",
+ __LINE__,
image,
src,
frame);
- scene->overlayer->overlay(frame,
- src,
- 0,
- 0,
- image->get_w(),
- image->get_h(),
- x,
- y,
- x + image->get_w() * sx,
- y + image->get_h() * sy,
+ scene->overlayer->overlay(frame,
+ src,
+ 0,
+ 0,
+ image->get_w(),
+ image->get_h(),
+ x,
+ y,
+ x + image->get_w() * sx,
+ y + image->get_h() * sy,
1,
TRANSFER_NORMAL,
NEAREST_NEIGHBOR);
void SceneNode::transform_coord(
- float *x,
- float *y,
- float *sx,
- float *sy,
+ float *x,
+ float *y,
+ float *sx,
+ float *sy,
float *ry)
{
// Rotate it
// pivot_x = image->get_w() / 2;
// pivot_y = image->get_h() / 2;
// }
-//
+//
// float rel_x = *x - pivot_x;
// float rel_y = *y - pivot_y;
// float angle = atan2(rel_y, rel_x);
const int debug = 0;
if(debug) printf("SceneGraph::render %d\n", __LINE__);
if(debug) dump();
-
+
this->cpus = cpus;
for(int i = 0; i < nodes.size(); i++)
}
}
-void SceneGraph::transform_camera(VFrame *frame,
- float *x,
- float *y,
- float *sx,
- float *sy,
+void SceneGraph::transform_camera(VFrame *frame,
+ float *x,
+ float *y,
+ float *sx,
+ float *sy,
int flip)
{
if(cameras.size())
PRINT_INDENT
printf("SceneCamera::dump %d this=%p\n", __LINE__, this);
PRINT_INDENT
- printf(" at_x=%f at_y=%f at_z=%f scale=%f\n",
+ printf(" at_x=%f at_y=%f at_z=%f scale=%f\n",
at_x,
at_y,
at_z,