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); | float *background_color = m_scene->GetWorldInfo()->getBackColor(); | ||||
| setBackground(background_color[0] * 255, background_color[1] * 255, background_color[2] * 255, 255); | |||||
panzergame: It's only for python getter at initialization ? | |||||
lordlokiAuthorUnsubmitted 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… | |||||
| // retrieve rendering objects | // retrieve rendering objects | ||||
| 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) | ||||
| ▲ Show 20 Lines • Show All 493 Lines • ▼ Show 20 Lines | ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObject *mirror, RAS_IPolyMaterial *mat) : | ||||
| // this constructor is used for automatic planar mirror | // this constructor is used for automatic planar mirror | ||||
| // create a camera, take all data by default, in any case we will recompute the frustrum on each frame | // create a camera, take all data by default, in any case we will recompute the frustrum on each frame | ||||
| RAS_CameraData camdata; | RAS_CameraData camdata; | ||||
| vector<RAS_TexVert*> mirrorVerts; | vector<RAS_TexVert*> mirrorVerts; | ||||
| vector<RAS_TexVert*>::iterator it; | vector<RAS_TexVert*>::iterator it; | ||||
| float mirrorArea = 0.f; | float mirrorArea = 0.f; | ||||
| float mirrorNormal[3] = {0.f, 0.f, 0.f}; | float mirrorNormal[3] = {0.f, 0.f, 0.f}; | ||||
| float mirrorUp[3]; | float mirrorUp[3]; | ||||
| float background_color; | |||||
| float dist, vec[3], axis[3]; | float dist, vec[3], axis[3]; | ||||
| float zaxis[3] = {0.f, 0.f, 1.f}; | float zaxis[3] = {0.f, 0.f, 1.f}; | ||||
| float yaxis[3] = {0.f, 1.f, 0.f}; | float yaxis[3] = {0.f, 1.f, 0.f}; | ||||
| float mirrorMat[3][3]; | float mirrorMat[3][3]; | ||||
| float left, right, top, bottom, back; | float left, right, top, bottom, back; | ||||
| // make sure this camera will delete its node | // make sure this camera will delete its node | ||||
| m_camera= new KX_Camera(scene, KX_Scene::m_callbacks, camdata, true, true); | m_camera= new KX_Camera(scene, KX_Scene::m_callbacks, camdata, true, true); | ||||
| m_camera->SetName("__mirror__cam__"); | m_camera->SetName("__mirror__cam__"); | ||||
| ▲ Show 20 Lines • Show All 131 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 | ||||
| background_color = m_scene->GetWorldInfo()->getBackColor(); | |||||
| setBackground(background_color[0] * 255, background_color[1] * 255, background_color[2] * 255, 255); | |||||
| } | } | ||||
| // 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 ?