Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/VideoTexture/ImageRender.cpp
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | ImageRender::ImageRender (KX_Scene *scene, KX_Camera * camera) : | ||||
| m_camera(camera), | m_camera(camera), | ||||
| m_owncamera(false), | m_owncamera(false), | ||||
| m_observer(NULL), | m_observer(NULL), | ||||
| m_mirror(NULL), | m_mirror(NULL), | ||||
| m_clip(100.f), | m_clip(100.f), | ||||
| m_mirrorHalfWidth(0.f), | m_mirrorHalfWidth(0.f), | ||||
| m_mirrorHalfHeight(0.f) | m_mirrorHalfHeight(0.f) | ||||
| { | { | ||||
| // initialize background color | // initialize background color to scene background color as default | ||||
| setBackground(0, 0, 255, 255); | setBackground(m_scene); | ||||
| // retrieve rendering objects | // retrieve rendering objects | ||||
panzergame: It's only for python getter at initialization ? | |||||
Not Done Inline Actionsyes, it is. lordloki: yes, it is. | |||||
Not Done Inline ActionsThis is a dupli code, can you write a function like "SetBackroundFromWorldColor" ? which take as argument the scene or the world info. panzergame: This is a dupli code, can you write a function like "SetBackroundFromWorldColor" ? which take… | |||||
| m_engine = KX_GetActiveEngine(); | m_engine = KX_GetActiveEngine(); | ||||
| m_rasterizer = m_engine->GetRasterizer(); | m_rasterizer = m_engine->GetRasterizer(); | ||||
| m_canvas = m_engine->GetCanvas(); | m_canvas = m_engine->GetCanvas(); | ||||
| } | } | ||||
| // destructor | // destructor | ||||
| ImageRender::~ImageRender (void) | ImageRender::~ImageRender (void) | ||||
| { | { | ||||
| if (m_owncamera) | if (m_owncamera) | ||||
| m_camera->Release(); | m_camera->Release(); | ||||
| } | } | ||||
| // set background color | // set background color | ||||
| void ImageRender::setBackground (int red, int green, int blue, int alpha) | void ImageRender::setBackground (int red, int green, int blue, int alpha) | ||||
| { | { | ||||
| m_background[0] = (red < 0) ? 0.f : (red > 255) ? 1.f : float(red)/255.f; | m_background[0] = (red < 0) ? 0.f : (red > 255) ? 1.f : float(red)/255.f; | ||||
| m_background[1] = (green < 0) ? 0.f : (green > 255) ? 1.f : float(green)/255.f; | m_background[1] = (green < 0) ? 0.f : (green > 255) ? 1.f : float(green)/255.f; | ||||
| m_background[2] = (blue < 0) ? 0.f : (blue > 255) ? 1.f : float(blue)/255.f; | m_background[2] = (blue < 0) ? 0.f : (blue > 255) ? 1.f : float(blue)/255.f; | ||||
| m_background[3] = (alpha < 0) ? 0.f : (alpha > 255) ? 1.f : float(alpha)/255.f; | m_background[3] = (alpha < 0) ? 0.f : (alpha > 255) ? 1.f : float(alpha)/255.f; | ||||
| } | } | ||||
| void ImageRender::setBackground (KX_Scene *scene) | |||||
| { | |||||
| if (!scene) | |||||
| return; | |||||
| const float *background_color = scene->GetWorldInfo()->getBackColor(); | |||||
| m_background[0] = background_color[0]; | |||||
| m_background[1] = background_color[1]; | |||||
| m_background[2] = background_color[2]; | |||||
| m_background[3] = 255.0f; | |||||
| } | |||||
| // capture image from viewport | // capture image from viewport | ||||
| void ImageRender::calcImage (unsigned int texId, double ts) | void ImageRender::calcImage (unsigned int texId, double ts) | ||||
| { | { | ||||
| if (m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture | if (m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture | ||||
| m_camera->GetViewport() || // camera must be inactive | m_camera->GetViewport() || // camera must be inactive | ||||
| m_camera == m_scene->GetActiveCamera()) | m_camera == m_scene->GetActiveCamera()) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 617 Lines • ▼ Show 20 Lines | ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObject *mirror, RAS_IPolyMaterial *mat) : | ||||
| // mirror position in local space | // mirror position in local space | ||||
| m_mirrorPos.setValue(vec[0], vec[1], vec[2]); | m_mirrorPos.setValue(vec[0], vec[1], vec[2]); | ||||
| // mirror normal vector (pointed towards the back of the mirror) in local space | // mirror normal vector (pointed towards the back of the mirror) in local space | ||||
| m_mirrorZ.setValue(-mirrorNormal[0], -mirrorNormal[1], -mirrorNormal[2]); | m_mirrorZ.setValue(-mirrorNormal[0], -mirrorNormal[1], -mirrorNormal[2]); | ||||
| m_mirrorY.setValue(mirrorUp[0], mirrorUp[1], mirrorUp[2]); | m_mirrorY.setValue(mirrorUp[0], mirrorUp[1], mirrorUp[2]); | ||||
| m_mirrorX = m_mirrorY.cross(m_mirrorZ); | m_mirrorX = m_mirrorY.cross(m_mirrorZ); | ||||
| m_render = true; | m_render = true; | ||||
| setBackground(0, 0, 255, 255); | // set mirror background color to scene background color as default | ||||
| setBackground(m_scene); | |||||
| } | } | ||||
| // define python type | // define python type | ||||
| PyTypeObject ImageMirrorType = { | PyTypeObject ImageMirrorType = { | ||||
| PyVarObject_HEAD_INIT(NULL, 0) | PyVarObject_HEAD_INIT(NULL, 0) | ||||
| Show All 40 Lines | |||||
It's only for python getter at initialization ?