The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.
The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.
The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.
IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.
To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.
This commit is contained in:
@@ -13,9 +13,14 @@ extern "C" {
|
|||||||
extern float freestyle_sphere_radius;
|
extern float freestyle_sphere_radius;
|
||||||
extern float freestyle_dkr_epsilon;
|
extern float freestyle_dkr_epsilon;
|
||||||
|
|
||||||
|
extern float freestyle_viewpoint[3];
|
||||||
|
extern float freestyle_mv[4][4];
|
||||||
|
extern float freestyle_proj[4][4];
|
||||||
|
extern int freestyle_viewport[4];
|
||||||
|
|
||||||
void FRS_initialize();
|
void FRS_initialize();
|
||||||
void FRS_prepare(Render* re);
|
void FRS_prepare(Render* re);
|
||||||
void FRS_render_GL(Render* re);
|
void FRS_render_Blender(Render* re);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,283 +80,59 @@ BBox<Vec3r> AppCanvas::scene3DBBox() const
|
|||||||
void AppCanvas::preDraw()
|
void AppCanvas::preDraw()
|
||||||
{
|
{
|
||||||
Canvas::preDraw();
|
Canvas::preDraw();
|
||||||
|
|
||||||
_pViewer->prepareCanvas();
|
|
||||||
glClearColor(0,0,0,0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glPolygonMode(GL_FRONT, GL_FILL);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppCanvas::init()
|
void AppCanvas::init()
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool firsttime = true;
|
// static bool firsttime = true;
|
||||||
if (firsttime) {
|
// if (firsttime) {
|
||||||
|
//
|
||||||
GLenum err = glewInit();
|
// _Renderer = new BlenderStrokeRenderer;
|
||||||
if (GLEW_OK != err)
|
// if(!StrokeRenderer::loadTextures())
|
||||||
{
|
// {
|
||||||
cerr << "Error: problem occurred while initializing GLEW" << endl;
|
// cerr << "unable to load stroke textures" << endl;
|
||||||
}
|
// return;
|
||||||
cout << "GLEW initialized: ";
|
// }
|
||||||
|
// }
|
||||||
if(glBlendEquation) {
|
|
||||||
cout << "using glBlendEquation" << endl;
|
|
||||||
} else if(glBlendEquationEXT) {
|
|
||||||
cout << "using glBlendEquationEXT" << endl;
|
|
||||||
} else {
|
|
||||||
_basic = true;
|
|
||||||
cout << "glBlendEquation or glBlendEquationEXT unavailable on this hardware -> switching to strokes basic rendering mode" << endl;
|
|
||||||
}
|
|
||||||
firsttime=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_Renderer = new GLStrokeRenderer;
|
|
||||||
if(!StrokeRenderer::loadTextures())
|
|
||||||
{
|
|
||||||
cerr << "unable to load stroke textures" << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppCanvas::postDraw()
|
void AppCanvas::postDraw()
|
||||||
{
|
{
|
||||||
//inverse frame buffer
|
Canvas::postDraw();
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
_pViewer->releaseCanvas();
|
|
||||||
|
|
||||||
Canvas::postDraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppCanvas::Erase()
|
void AppCanvas::Erase()
|
||||||
{
|
{
|
||||||
Canvas::Erase();
|
Canvas::Erase();
|
||||||
//_pViewer->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Abstract
|
||||||
|
|
||||||
#include "../image/GaussianFilter.h"
|
#include "../image/GaussianFilter.h"
|
||||||
void AppCanvas::readColorPixels(int x,int y,int w, int h, RGBImage& oImage) const
|
void AppCanvas::readColorPixels(int x,int y,int w, int h, RGBImage& oImage) const
|
||||||
{
|
{
|
||||||
//static unsigned number = 0;
|
//static unsigned number = 0;
|
||||||
float *rgb = new float[3*w*h];
|
float *rgb = new float[3*w*h];
|
||||||
_pViewer->readPixels(x,y,w,h,AppGLWidget::RGB,rgb);
|
//_pViewer->readPixels(x,y,w,h,AppGLWidget::RGB,rgb);
|
||||||
oImage.setArray(rgb, width(), height(), w,h, x, y, false);
|
oImage.setArray(rgb, width(), height(), w,h, x, y, false);
|
||||||
// FIXME
|
|
||||||
// QImage qtmp(w, h, 32);
|
|
||||||
// for(unsigned py=0;py<h;++py){
|
|
||||||
// for(unsigned px=0;px<w;++px){
|
|
||||||
// int r = (int)255*(oImage.getR(x+px,y+py));
|
|
||||||
// int g = (int)255*(oImage.getG(x+px,y+py));
|
|
||||||
// int b = (int)255*(oImage.getB(x+px,y+py));
|
|
||||||
// qtmp.setPixel(px,py,qRgb(r,g,b));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// qtmp.save("densityQuery"+QString::number(number)+".png", "PNG");
|
|
||||||
// if(number == 1090){
|
|
||||||
// RGBImage img;
|
|
||||||
// float *rgbtmp = new float[3*width()*height()];
|
|
||||||
// _pViewer->readPixels(0,0,width(),height(),AppGLWidget::RGB,rgbtmp);
|
|
||||||
// img.setArray(rgbtmp, width(), height(), width(), height(), 0, 0, false);
|
|
||||||
// QImage qtmp(width(), height(), 32);
|
|
||||||
// for(unsigned py=0;py<height();++py){
|
|
||||||
// for(unsigned px=0;px<width();++px){
|
|
||||||
// int r = (int)255*(img.getR(px,py));
|
|
||||||
// int g = (int)255*(img.getG(px,py));
|
|
||||||
// int b = (int)255*(img.getB(px,py));
|
|
||||||
// qtmp.setPixel(px,height()-1-py,qRgb(r,g,b));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// qtmp.save("densityQuery"+QString::number(number)+".png", "PNG");
|
|
||||||
//
|
|
||||||
// GaussianFilter filter;
|
|
||||||
// filter.setSigma(4.0);
|
|
||||||
// int bound = filter.getBound();
|
|
||||||
// QImage qtmp2(width(), height(), 32);
|
|
||||||
// for(int py2=0;py2<height();++py2){
|
|
||||||
// for(int px2=0;px2<width();++px2){
|
|
||||||
// if( (px2-bound < 0) || (px2+bound>width())
|
|
||||||
// || (py2-bound < 0) || (py2+bound>height()))
|
|
||||||
// continue;
|
|
||||||
// int g = 255*filter.getSmoothedPixel<RGBImage>(&img, px2,py2);
|
|
||||||
// qtmp2.setPixel(px2,height()-1-py2,qRgb(g,g,g));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// qtmp2.save("blurredCausalDensity"+QString::number(number)+".png", "PNG");
|
|
||||||
// }
|
|
||||||
// cout << number << endl;
|
|
||||||
// ++number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppCanvas::readDepthPixels(int x,int y,int w, int h, GrayImage& oImage) const
|
void AppCanvas::readDepthPixels(int x,int y,int w, int h, GrayImage& oImage) const
|
||||||
{
|
{
|
||||||
float *rgb = new float[w*h];
|
float *rgb = new float[w*h];
|
||||||
_pViewer->readPixels(x,y,w,h,AppGLWidget::DEPTH,rgb);
|
//_pViewer->readPixels(x,y,w,h,AppGLWidget::DEPTH,rgb);
|
||||||
oImage.setArray(rgb, width(), height(), w,h, x, y, false);
|
oImage.setArray(rgb, width(), height(), w,h, x, y, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppCanvas::update()
|
|
||||||
{
|
|
||||||
// static int counter = 0;
|
|
||||||
// char fileName[100] = "framebuffer";
|
|
||||||
// char number[10];
|
|
||||||
//
|
|
||||||
_pViewer->updateGL();
|
|
||||||
//_pViewer->swapBuffers();
|
|
||||||
//QImage fb = _pViewer->grabFrameBuffer();
|
|
||||||
// sprintf(number, "%3d", counter);
|
|
||||||
// strcat(fileName, number);
|
|
||||||
// strcat(fileName, ".bmp");
|
|
||||||
// fb.save(fileName, "BMP");
|
|
||||||
//counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppCanvas::Render(const StrokeRenderer *iRenderer)
|
|
||||||
{
|
|
||||||
if(_basic){
|
|
||||||
RenderBasic(iRenderer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
glClearColor(1,1,1,1);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glPolygonMode(GL_FRONT, GL_FILL);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
|
|
||||||
if(_pViewer->draw3DsceneEnabled())
|
|
||||||
{
|
|
||||||
glClearColor(1,1,1,0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
_pViewer->set3DContext();
|
|
||||||
_pViewer->DrawScene(_pViewer->glRenderer());
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
FRS_glBlendEquation(GL_ADD);
|
|
||||||
|
|
||||||
glBlendFunc(GL_DST_COLOR, GL_ZERO);
|
|
||||||
|
|
||||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
|
||||||
FRS_glBlendEquation(GL_FUNC_SUBTRACT);
|
|
||||||
glBlendFunc(GL_ONE, GL_ONE);
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glColor4f(1,1,1,1);
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
|
||||||
{
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glVertex2f(2048, 0);
|
|
||||||
glVertex2f(0, 2048);
|
|
||||||
glVertex2f(2048, 2048);
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
glPopAttrib();
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
FRS_glBlendEquation(GL_ADD);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
Canvas::Render(iRenderer);
|
|
||||||
//
|
|
||||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
|
||||||
FRS_glBlendEquation(GL_FUNC_SUBTRACT);
|
|
||||||
glBlendFunc(GL_ONE, GL_ONE);
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glColor3f(1,1,1);
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
|
||||||
{
|
|
||||||
glVertex2f(0, 0);
|
|
||||||
glVertex2f(2048, 0);
|
|
||||||
glVertex2f(0, 2048);
|
|
||||||
glVertex2f(2048, 2048);
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
glPopAttrib();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppCanvas::RenderBasic(const StrokeRenderer *iRenderer)
|
|
||||||
{
|
|
||||||
glClearColor(1,1,1,1);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glPolygonMode(GL_FRONT, GL_FILL);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
|
|
||||||
if(_pViewer->draw3DsceneEnabled())
|
|
||||||
{
|
|
||||||
glClearColor(1,1,1,0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
_pViewer->set3DContext();
|
|
||||||
_pViewer->DrawScene(_pViewer->glRenderer());
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
glBlendFunc(GL_DST_COLOR, GL_ZERO);
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glPopAttrib();
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
Canvas::RenderBasic(iRenderer);
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AppCanvas::RenderStroke(Stroke *iStroke) {
|
void AppCanvas::RenderStroke(Stroke *iStroke) {
|
||||||
|
|
||||||
if(_basic)
|
if(_basic)
|
||||||
iStroke->RenderBasic(_Renderer);
|
iStroke->RenderBasic(_Renderer);
|
||||||
else
|
else
|
||||||
iStroke->Render(_Renderer);
|
iStroke->Render(_Renderer);
|
||||||
|
|
||||||
if(_pViewer->getRecordFlag()){
|
|
||||||
_pViewer->saveSnapshot(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AppCanvas::update() {}
|
||||||
|
|
||||||
|
|||||||
@@ -33,13 +33,10 @@ public:
|
|||||||
|
|
||||||
virtual BBox<Vec3r> scene3DBBox() const ;
|
virtual BBox<Vec3r> scene3DBBox() const ;
|
||||||
|
|
||||||
/*! update the canvas (display) */
|
// abstract
|
||||||
virtual void update() ;
|
virtual void RenderStroke(Stroke*);
|
||||||
|
virtual void update();
|
||||||
|
|
||||||
/*! Renders the created strokes */
|
|
||||||
virtual void Render(const StrokeRenderer *iRenderer);
|
|
||||||
virtual void RenderBasic(const StrokeRenderer *iRenderer);
|
|
||||||
virtual void RenderStroke(Stroke *iStroke) ;
|
|
||||||
|
|
||||||
/*! accessors */
|
/*! accessors */
|
||||||
virtual int width() const ;
|
virtual int width() const ;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "../scene_graph/NodeShape.h"
|
#include "../scene_graph/NodeShape.h"
|
||||||
#include "../scene_graph/VertexRep.h"
|
#include "../scene_graph/VertexRep.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
|
#include "AppCanvas.h"
|
||||||
|
|
||||||
#include "../system/StringUtils.h"
|
#include "../system/StringUtils.h"
|
||||||
|
|
||||||
@@ -203,7 +204,6 @@ AppGLWidget::~AppGLWidget()
|
|||||||
_pDebugRenderer = NULL;
|
_pDebugRenderer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeCurrent();
|
|
||||||
//saveToFile(filename);
|
//saveToFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,11 +285,6 @@ void AppGLWidget::init()
|
|||||||
//glEnable(GL_BLEND);
|
//glEnable(GL_BLEND);
|
||||||
NodeLight *light = new NodeLight;
|
NodeLight *light = new NodeLight;
|
||||||
_Light.AddChild(light);
|
_Light.AddChild(light);
|
||||||
|
|
||||||
// Change QGLViewer's default shortcut for snapshots
|
|
||||||
//setShortcut(QGLViewer::SAVE_SCREENSHOT, Qt::CTRL + Qt::Key_W);
|
|
||||||
// setShortcutKey (QGLViewer::SAVE_SCREENSHOT, Key_W);
|
|
||||||
// setShortcutStateKey(QGLViewer::SAVE_SCREENSHOT, ControlButton);
|
|
||||||
|
|
||||||
cout << "Renderer (GL) : " << glGetString(GL_RENDERER) << endl
|
cout << "Renderer (GL) : " << glGetString(GL_RENDERER) << endl
|
||||||
<< "Vendor (GL) : " << glGetString(GL_VENDOR) << endl << endl;
|
<< "Vendor (GL) : " << glGetString(GL_VENDOR) << endl << endl;
|
||||||
@@ -326,9 +321,6 @@ void AppGLWidget::draw()
|
|||||||
Draw2DScene(_pGLRenderer);
|
Draw2DScene(_pGLRenderer);
|
||||||
set3DContext();
|
set3DContext();
|
||||||
}
|
}
|
||||||
if(_record){
|
|
||||||
saveSnapshot(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppGLWidget::DrawScene(SceneVisitor *iRenderer)
|
void AppGLWidget::DrawScene(SceneVisitor *iRenderer)
|
||||||
@@ -409,41 +401,6 @@ void AppGLWidget::DrawScene(SceneVisitor *iRenderer)
|
|||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppGLWidget::prepareCanvas()
|
|
||||||
{
|
|
||||||
makeCurrent();
|
|
||||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
|
||||||
|
|
||||||
// if(_frontBufferFlag){
|
|
||||||
// if(_backBufferFlag)
|
|
||||||
// glDrawBuffer(GL_FRONT_AND_BACK);
|
|
||||||
// else
|
|
||||||
// glDrawBuffer(GL_FRONT);
|
|
||||||
// }
|
|
||||||
// else if(_backBufferFlag)
|
|
||||||
// glDrawBuffer(GL_BACK);
|
|
||||||
//glDrawBuffer( workingBuffer ); //soc
|
|
||||||
|
|
||||||
// Projection Matrix
|
|
||||||
//==================
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
glOrtho(0,width(), 0, height(), -1.0, 1.0);
|
|
||||||
|
|
||||||
//Modelview Matrix
|
|
||||||
//================
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppGLWidget::releaseCanvas()
|
|
||||||
{
|
|
||||||
makeCurrent();
|
|
||||||
//glDrawBuffer( workingBuffer ); //soc
|
|
||||||
glPopAttrib();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 1 // FRS_antialiasing
|
#if 1 // FRS_antialiasing
|
||||||
|
|
||||||
void AppGLWidget::init_jit(int osa)
|
void AppGLWidget::init_jit(int osa)
|
||||||
@@ -518,6 +475,7 @@ void AppGLWidget::Draw2DScene(SceneVisitor *iRenderer)
|
|||||||
glAccum(GL_RETURN, 1.0);
|
glAccum(GL_RETURN, 1.0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@@ -670,13 +628,7 @@ bool AppGLWidget::getBackBufferFlag() {
|
|||||||
// COPIED FROM LIBQGLVIEWER
|
// COPIED FROM LIBQGLVIEWER
|
||||||
//*******************************
|
//*******************************
|
||||||
|
|
||||||
// inherited
|
// inherited
|
||||||
//Updates the display. Do not call draw() directly, use this method instead.
|
|
||||||
void AppGLWidget::updateGL() {}
|
|
||||||
|
|
||||||
//Makes this widget's rendering context the current OpenGL rendering context. Useful with several viewers
|
|
||||||
void AppGLWidget::makeCurrent() { }
|
|
||||||
|
|
||||||
// not-inherited
|
// not-inherited
|
||||||
void AppGLWidget::setStateFileName(const string& name) { stateFileName_ = name; };
|
void AppGLWidget::setStateFileName(const string& name) { stateFileName_ = name; };
|
||||||
void AppGLWidget::saveSnapshot(bool b) {}
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ using namespace std;
|
|||||||
# include "../rendering/GLDebugRenderer.h"
|
# include "../rendering/GLDebugRenderer.h"
|
||||||
//# include <QGLViewer/qglviewer.h>
|
//# include <QGLViewer/qglviewer.h>
|
||||||
|
|
||||||
|
# include "../stroke/BlenderStrokeRenderer.h"
|
||||||
|
|
||||||
|
|
||||||
//soc
|
//soc
|
||||||
#include "AppGLWidget_camera.h"
|
#include "AppGLWidget_camera.h"
|
||||||
@@ -81,12 +83,8 @@ public:
|
|||||||
inline unsigned int height() { return _height; }
|
inline unsigned int height() { return _height; }
|
||||||
inline void setWidth( unsigned int width ) { _width = width; }
|
inline void setWidth( unsigned int width ) { _width = width; }
|
||||||
inline void setHeight( unsigned int height ) { _height = height; }
|
inline void setHeight( unsigned int height ) { _height = height; }
|
||||||
|
|
||||||
void updateGL();
|
|
||||||
void makeCurrent();
|
|
||||||
|
|
||||||
// not-inherited
|
// not-inherited
|
||||||
void saveSnapshot(bool b);
|
|
||||||
void setStateFileName(const string& name);
|
void setStateFileName(const string& name);
|
||||||
|
|
||||||
|
|
||||||
@@ -157,20 +155,20 @@ public:
|
|||||||
{
|
{
|
||||||
_SilhouetteRootNode->AddChild(iSilhouette);
|
_SilhouetteRootNode->AddChild(iSilhouette);
|
||||||
//ToggleSilhouette(true);
|
//ToggleSilhouette(true);
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Add2DSilhouette(NodeGroup *iSilhouette)
|
inline void Add2DSilhouette(NodeGroup *iSilhouette)
|
||||||
{
|
{
|
||||||
//_pFENode->AddChild(iSilhouette);
|
//_pFENode->AddChild(iSilhouette);
|
||||||
//ToggleSilhouette(true);
|
//ToggleSilhouette(true);
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Add2DVisibleSilhouette(NodeGroup *iVSilhouette)
|
inline void Add2DVisibleSilhouette(NodeGroup *iVSilhouette)
|
||||||
{
|
{
|
||||||
//_pVisibleSilhouetteNode->AddChild(iVSilhouette);
|
//_pVisibleSilhouetteNode->AddChild(iVSilhouette);
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setDebug(NodeGroup* iDebug)
|
inline void setDebug(NodeGroup* iDebug)
|
||||||
@@ -187,7 +185,7 @@ public:
|
|||||||
inline void AddDebug(NodeGroup* iDebug)
|
inline void AddDebug(NodeGroup* iDebug)
|
||||||
{
|
{
|
||||||
_DebugRootNode->AddChild(iDebug);
|
_DebugRootNode->AddChild(iDebug);
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DetachModel(Node *iModel)
|
inline void DetachModel(Node *iModel)
|
||||||
@@ -215,7 +213,7 @@ public:
|
|||||||
//_p2DNode.DetachChildren();
|
//_p2DNode.DetachChildren();
|
||||||
//_pFENode->DetachChildren();
|
//_pFENode->DetachChildren();
|
||||||
//_pVisibleSilhouetteNode->DetachChildren();
|
//_pVisibleSilhouetteNode->DetachChildren();
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DetachSilhouette()
|
inline void DetachSilhouette()
|
||||||
@@ -224,20 +222,20 @@ public:
|
|||||||
//_pFENode->DetachChildren();
|
//_pFENode->DetachChildren();
|
||||||
//_pVisibleSilhouetteNode->DetachChildren();
|
//_pVisibleSilhouetteNode->DetachChildren();
|
||||||
_p2DSelectionNode->destroy();
|
_p2DSelectionNode->destroy();
|
||||||
//updateGL(); //FIXME
|
// //FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DetachVisibleSilhouette()
|
inline void DetachVisibleSilhouette()
|
||||||
{
|
{
|
||||||
//_pVisibleSilhouetteNode->DetachChildren();
|
//_pVisibleSilhouetteNode->DetachChildren();
|
||||||
_p2DSelectionNode->destroy();
|
_p2DSelectionNode->destroy();
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DetachDebug()
|
inline void DetachDebug()
|
||||||
{
|
{
|
||||||
_DebugRootNode->DetachChildren();
|
_DebugRootNode->DetachChildren();
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMainWindow(QMainWindow *iMainWindow) ;
|
void setMainWindow(QMainWindow *iMainWindow) ;
|
||||||
@@ -252,31 +250,26 @@ public:
|
|||||||
|
|
||||||
inline void RetriveModelViewMatrix(float *p)
|
inline void RetriveModelViewMatrix(float *p)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
|
||||||
glGetFloatv(GL_MODELVIEW_MATRIX, p);
|
glGetFloatv(GL_MODELVIEW_MATRIX, p);
|
||||||
}
|
}
|
||||||
inline void RetriveModelViewMatrix(real *p)
|
inline void RetriveModelViewMatrix(real *p)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
|
||||||
glGetDoublev(GL_MODELVIEW_MATRIX, p);
|
glGetDoublev(GL_MODELVIEW_MATRIX, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RetrieveProjectionMatrix(float *p)
|
inline void RetrieveProjectionMatrix(float *p)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
|
||||||
glGetFloatv(GL_PROJECTION_MATRIX, p);
|
glGetFloatv(GL_PROJECTION_MATRIX, p);
|
||||||
|
|
||||||
}
|
}
|
||||||
inline void RetrieveProjectionMatrix(real *p)
|
inline void RetrieveProjectionMatrix(real *p)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
|
||||||
glGetDoublev(GL_PROJECTION_MATRIX, p);
|
glGetDoublev(GL_PROJECTION_MATRIX, p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RetrieveViewport(int *p)
|
inline void RetrieveViewport(int *p)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
|
||||||
glGetIntegerv(GL_VIEWPORT,(GLint *)p);
|
glGetIntegerv(GL_VIEWPORT,(GLint *)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +309,7 @@ public:
|
|||||||
inline void ToggleSilhouette(bool enabled)
|
inline void ToggleSilhouette(bool enabled)
|
||||||
{
|
{
|
||||||
_fedges = enabled;
|
_fedges = enabled;
|
||||||
updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reinit the renderers which need to be informed
|
// Reinit the renderers which need to be informed
|
||||||
@@ -326,7 +319,7 @@ public:
|
|||||||
inline void setSelectedFEdge(FEdge* iFEdge) { _pDebugRenderer->setSelectedFEdge(iFEdge); }
|
inline void setSelectedFEdge(FEdge* iFEdge) { _pDebugRenderer->setSelectedFEdge(iFEdge); }
|
||||||
|
|
||||||
inline GLDebugRenderer* debugRenderer() { return _pDebugRenderer; }
|
inline GLDebugRenderer* debugRenderer() { return _pDebugRenderer; }
|
||||||
inline void toggle3D() { _Draw3DScene == true ? _Draw3DScene = false : _Draw3DScene = true; updateGL();}
|
inline void toggle3D() { _Draw3DScene == true ? _Draw3DScene = false : _Draw3DScene = true; }
|
||||||
|
|
||||||
/*! glReadPixels */
|
/*! glReadPixels */
|
||||||
typedef enum{
|
typedef enum{
|
||||||
@@ -341,7 +334,7 @@ public:
|
|||||||
PixelFormat format,
|
PixelFormat format,
|
||||||
float *pixels)
|
float *pixels)
|
||||||
{
|
{
|
||||||
makeCurrent();
|
|
||||||
//glReadBuffer(GL_FRONT); //in reality: glReadBuffer and glDrawBuffer are both set to GL_BACK
|
//glReadBuffer(GL_FRONT); //in reality: glReadBuffer and glDrawBuffer are both set to GL_BACK
|
||||||
//glReadBuffer(GL_BACK);
|
//glReadBuffer(GL_BACK);
|
||||||
GLenum glformat;
|
GLenum glformat;
|
||||||
@@ -362,31 +355,13 @@ public:
|
|||||||
glReadPixels(x,y,width, height, glformat, GL_FLOAT, (GLfloat*)pixels);
|
glReadPixels(x,y,width, height, glformat, GL_FLOAT, (GLfloat*)pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() { makeCurrent(); glClear(GL_COLOR_BUFFER_BIT ); }
|
void clear() { glClear(GL_COLOR_BUFFER_BIT ); }
|
||||||
|
|
||||||
void prepareCanvas();
|
|
||||||
void releaseCanvas();
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FRONT,
|
FRONT,
|
||||||
BACK
|
BACK
|
||||||
} GLBuffer;
|
} GLBuffer;
|
||||||
|
|
||||||
// void setReadPixelsBuffer(int iBuffer)
|
|
||||||
// {
|
|
||||||
// makeCurrent();
|
|
||||||
// switch(iBuffer)
|
|
||||||
// {
|
|
||||||
// case FRONT:
|
|
||||||
// glReadBuffer(GL_FRONT);
|
|
||||||
// break;
|
|
||||||
// case BACK:
|
|
||||||
// glReadBuffer(GL_BACK);
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
BBox<Vec3r> scene3DBBox() const { return _ModelRootNode->bbox(); }
|
BBox<Vec3r> scene3DBBox() const { return _ModelRootNode->bbox(); }
|
||||||
|
|
||||||
@@ -508,7 +483,7 @@ protected:
|
|||||||
GLBBoxRenderer *_pBBoxRenderer;
|
GLBBoxRenderer *_pBBoxRenderer;
|
||||||
GLMonoColorRenderer *_pMonoColorRenderer;
|
GLMonoColorRenderer *_pMonoColorRenderer;
|
||||||
GLDebugRenderer *_pDebugRenderer;
|
GLDebugRenderer *_pDebugRenderer;
|
||||||
|
|
||||||
QMainWindow *_pMainWindow;
|
QMainWindow *_pMainWindow;
|
||||||
|
|
||||||
Chronometer _Chrono;
|
Chronometer _Chrono;
|
||||||
|
|||||||
@@ -48,23 +48,18 @@
|
|||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "../view_map/ViewMap.h"
|
#include "../view_map/ViewMap.h"
|
||||||
#include "../winged_edge/Curvature.h"
|
#include "../winged_edge/Curvature.h"
|
||||||
//#include "QGLBasicWidget.h"
|
|
||||||
//#include <qimage.h>
|
|
||||||
#include "../image/Image.h"
|
#include "../image/Image.h"
|
||||||
#include "../view_map/SteerableViewMap.h"
|
#include "../view_map/SteerableViewMap.h"
|
||||||
#include "../stroke/PSStrokeRenderer.h"
|
#include "../stroke/PSStrokeRenderer.h"
|
||||||
#include "../stroke/TextStrokeRenderer.h"
|
#include "../stroke/TextStrokeRenderer.h"
|
||||||
#include "../stroke/StyleModule.h"
|
#include "../stroke/StyleModule.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
//# include "GLXOffscreenBuffer.h"
|
|
||||||
//# include "GLXOffscreenBuffer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../system/StringUtils.h"
|
#include "../system/StringUtils.h"
|
||||||
|
|
||||||
#include "../scene_graph/BlenderFileLoader.h"
|
#include "../scene_graph/BlenderFileLoader.h"
|
||||||
|
|
||||||
|
#include "../../FRS_freestyle.h"
|
||||||
|
|
||||||
Controller::Controller()
|
Controller::Controller()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -252,8 +247,6 @@ int Controller::LoadMesh(Render *re)
|
|||||||
// delete ws_builder;
|
// delete ws_builder;
|
||||||
// ws_builder = 0;
|
// ws_builder = 0;
|
||||||
// }
|
// }
|
||||||
_pView->updateGL();
|
|
||||||
|
|
||||||
|
|
||||||
//soc QFileInfo qfi(iFileName);
|
//soc QFileInfo qfi(iFileName);
|
||||||
//soc string basename((const char*)qfi.fileName().toAscii().data());
|
//soc string basename((const char*)qfi.fileName().toAscii().data());
|
||||||
@@ -341,17 +334,7 @@ void Controller::CloseFile()
|
|||||||
_Grid.clear();
|
_Grid.clear();
|
||||||
_SceneNumFaces = 0;
|
_SceneNumFaces = 0;
|
||||||
_minEdgeSize = DBL_MAX;
|
_minEdgeSize = DBL_MAX;
|
||||||
// _pView2D->DetachScene();
|
|
||||||
// if(NULL != _SRoot)
|
|
||||||
// {
|
|
||||||
// int ref = _SRoot->destroy();
|
|
||||||
// if(0 == ref)
|
|
||||||
// {
|
|
||||||
// //_SRoot->addRef();
|
|
||||||
// delete _SRoot;
|
|
||||||
// _SRoot = NULL;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static const streamsize buffer_size = 512 * 1024;
|
// static const streamsize buffer_size = 512 * 1024;
|
||||||
@@ -597,18 +580,25 @@ void Controller::ComputeViewMap()
|
|||||||
// we need to perform all these operations while the
|
// we need to perform all these operations while the
|
||||||
// 3D context is on.
|
// 3D context is on.
|
||||||
_pView->set3DContext();
|
_pView->set3DContext();
|
||||||
float src[3] = { 0, 0, 0 };
|
Vec3r vp( freestyle_viewpoint[0], freestyle_viewpoint[1], freestyle_viewpoint[2]);
|
||||||
float vp_tmp[3] = { 0, 0, 0 };
|
|
||||||
_pView->_camera->getWorldCoordinatesOf(src, vp_tmp);
|
real mv[4][4];
|
||||||
Vec3r vp(vp_tmp[0], vp_tmp[1], vp_tmp[2]);
|
for( int i= 0; i < 4; i++)
|
||||||
|
for( int j= 0; j < 4; j++)
|
||||||
|
mv[i][j] = freestyle_mv[i][j];
|
||||||
|
|
||||||
|
|
||||||
|
real proj[4][4];
|
||||||
|
for( int i= 0; i < 4; i++)
|
||||||
|
for( int j= 0; j < 4; j++)
|
||||||
|
proj[i][j] = freestyle_proj[i][j];
|
||||||
|
|
||||||
|
|
||||||
|
int viewport[4];
|
||||||
|
for( int i= 0; i < 4; i++)
|
||||||
|
viewport[i] = freestyle_viewport[i];
|
||||||
|
|
||||||
|
|
||||||
real mv[4][4];
|
|
||||||
_pView->RetriveModelViewMatrix((real *)mv);
|
|
||||||
// retrieve the projection matrix:
|
|
||||||
real proj[4][4];
|
|
||||||
_pView->RetrieveProjectionMatrix((real *)proj);
|
|
||||||
int viewport[4];
|
|
||||||
_pView->RetrieveViewport(viewport);
|
|
||||||
real focalLength = _pView->GetFocalLength();
|
real focalLength = _pView->GetFocalLength();
|
||||||
|
|
||||||
// Flag the WXEdge structure for silhouette edge detection:
|
// Flag the WXEdge structure for silhouette edge detection:
|
||||||
@@ -632,7 +622,14 @@ void Controller::ComputeViewMap()
|
|||||||
vmBuilder.setEnableQI(_EnableQI);
|
vmBuilder.setEnableQI(_EnableQI);
|
||||||
vmBuilder.setViewpoint(Vec3r(vp));
|
vmBuilder.setViewpoint(Vec3r(vp));
|
||||||
|
|
||||||
vmBuilder.setTransform(mv, proj, viewport, focalLength, _pView->GetAspect(), _pView->GetFovyRadian());
|
cout << "focalLength: " << focalLength << endl;
|
||||||
|
cout << "aspect: " << _pView->GetAspect() << endl;
|
||||||
|
cout << "fovyradian: " << _pView->GetFovyRadian() << endl;
|
||||||
|
|
||||||
|
cout << "znear: " << _pView->znear() << endl;
|
||||||
|
cout << "zfar: " << _pView->zfar() << endl;
|
||||||
|
|
||||||
|
vmBuilder.setTransform( mv, proj,viewport, focalLength, _pView->GetAspect(), _pView->GetFovyRadian());
|
||||||
vmBuilder.setFrustum(_pView->znear(), _pView->zfar());
|
vmBuilder.setFrustum(_pView->znear(), _pView->zfar());
|
||||||
|
|
||||||
vmBuilder.setGrid(&_Grid);
|
vmBuilder.setGrid(&_Grid);
|
||||||
@@ -843,10 +840,17 @@ void Controller::DrawStrokes()
|
|||||||
_Chrono.start();
|
_Chrono.start();
|
||||||
_Canvas->Draw();
|
_Canvas->Draw();
|
||||||
real d = _Chrono.stop();
|
real d = _Chrono.stop();
|
||||||
cout << "Strokes drawing : " << d << endl;
|
cout << "Strokes generation : " << d << endl;
|
||||||
resetModified();
|
resetModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::RenderBlender(Render *re) {
|
||||||
|
BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer;
|
||||||
|
_Canvas->Render( blenderRenderer );
|
||||||
|
blenderRenderer->RenderScene(re);
|
||||||
|
blenderRenderer->Close();
|
||||||
|
}
|
||||||
|
|
||||||
void Controller::InsertStyleModule(unsigned index, const char *iFileName)
|
void Controller::InsertStyleModule(unsigned index, const char *iFileName)
|
||||||
{
|
{
|
||||||
// QFileInfo fi(iFileName);
|
// QFileInfo fi(iFileName);
|
||||||
@@ -898,7 +902,6 @@ void Controller::SwapStyleModules(unsigned i1, unsigned i2)
|
|||||||
void Controller::toggleLayer(unsigned index, bool iDisplay)
|
void Controller::toggleLayer(unsigned index, bool iDisplay)
|
||||||
{
|
{
|
||||||
_Canvas->setVisible(index, iDisplay);
|
_Canvas->setVisible(index, iDisplay);
|
||||||
_pView->updateGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setModified(unsigned index, bool iMod)
|
void Controller::setModified(unsigned index, bool iMod)
|
||||||
@@ -917,10 +920,6 @@ void Controller::updateCausalStyleModules(unsigned index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::saveSnapshot(bool b) {
|
|
||||||
_pView->saveSnapshot(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Controller::resetModified(bool iMod)
|
void Controller::resetModified(bool iMod)
|
||||||
{
|
{
|
||||||
//_pStyleWindow->resetModified(iMod);
|
//_pStyleWindow->resetModified(iMod);
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class ViewEdge;
|
|||||||
class AppCanvas;
|
class AppCanvas;
|
||||||
class InteractiveShader;
|
class InteractiveShader;
|
||||||
class Shader;
|
class Shader;
|
||||||
|
class StrokeRenderer;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -81,7 +82,8 @@ public:
|
|||||||
void ComputeSteerableViewMap();
|
void ComputeSteerableViewMap();
|
||||||
void saveSteerableViewMapImages();
|
void saveSteerableViewMapImages();
|
||||||
void toggleEdgeTesselationNature(Nature::EdgeNature iNature);
|
void toggleEdgeTesselationNature(Nature::EdgeNature iNature);
|
||||||
void DrawStrokes();
|
void RenderBlender(Render *re);
|
||||||
|
void DrawStrokes();
|
||||||
void SwapStyleModules(unsigned i1, unsigned i2);
|
void SwapStyleModules(unsigned i1, unsigned i2);
|
||||||
void InsertStyleModule(unsigned index, const char *iFileName);
|
void InsertStyleModule(unsigned index, const char *iFileName);
|
||||||
void AddStyleModule(const char *iFileName);
|
void AddStyleModule(const char *iFileName);
|
||||||
@@ -92,7 +94,6 @@ public:
|
|||||||
void setModified(unsigned index, bool iMod);
|
void setModified(unsigned index, bool iMod);
|
||||||
void resetModified(bool iMod=false);
|
void resetModified(bool iMod=false);
|
||||||
void updateCausalStyleModules(unsigned index);
|
void updateCausalStyleModules(unsigned index);
|
||||||
void saveSnapshot(bool b = false);
|
|
||||||
void displayDensityCurves(int x, int y);
|
void displayDensityCurves(int x, int y);
|
||||||
|
|
||||||
|
|
||||||
@@ -150,6 +151,9 @@ private:
|
|||||||
// Current directories
|
// Current directories
|
||||||
//ConfigIO* _current_dirs;
|
//ConfigIO* _current_dirs;
|
||||||
|
|
||||||
|
// Canvas
|
||||||
|
AppCanvas *_Canvas;
|
||||||
|
|
||||||
//View
|
//View
|
||||||
// 3D
|
// 3D
|
||||||
AppGLWidget *_pView;
|
AppGLWidget *_pView;
|
||||||
@@ -199,7 +203,6 @@ private:
|
|||||||
real _EPSILON;
|
real _EPSILON;
|
||||||
real _bboxDiag;
|
real _bboxDiag;
|
||||||
|
|
||||||
AppCanvas *_Canvas;
|
|
||||||
|
|
||||||
//AppStyleWindow *_pStyleWindow;
|
//AppStyleWindow *_pStyleWindow;
|
||||||
//AppOptionsWindow *_pOptionsWindow;
|
//AppOptionsWindow *_pOptionsWindow;
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../FRS_freestyle.h"
|
#include "../../FRS_freestyle.h"
|
||||||
|
#include "AppCanvas.h"
|
||||||
|
|
||||||
#include "DNA_camera_types.h"
|
#include "DNA_camera_types.h"
|
||||||
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
#include "render_types.h"
|
#include "render_types.h"
|
||||||
#include "renderpipeline.h"
|
#include "renderpipeline.h"
|
||||||
@@ -37,6 +39,11 @@ extern "C" {
|
|||||||
int freestyle_flags;
|
int freestyle_flags;
|
||||||
float freestyle_sphere_radius = 1.0;
|
float freestyle_sphere_radius = 1.0;
|
||||||
float freestyle_dkr_epsilon = 0.001;
|
float freestyle_dkr_epsilon = 0.001;
|
||||||
|
|
||||||
|
float freestyle_viewpoint[3];
|
||||||
|
float freestyle_mv[4][4];
|
||||||
|
float freestyle_proj[4][4];
|
||||||
|
int freestyle_viewport[4];
|
||||||
|
|
||||||
void FRS_initialize(){
|
void FRS_initialize(){
|
||||||
|
|
||||||
@@ -60,9 +67,16 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
void FRS_init_view(Render* re){
|
void FRS_init_view(Render* re){
|
||||||
view->setWidth( re->winx );
|
int width = re->scene->r.xsch;
|
||||||
view->setHeight( re->winy );
|
int height = re->scene->r.ysch;
|
||||||
view->_camera->setScreenWidthAndHeight( re->winx, re->winy);
|
|
||||||
|
freestyle_viewport[0] = freestyle_viewport[1] = 0;
|
||||||
|
freestyle_viewport[2] = width;
|
||||||
|
freestyle_viewport[3] = height;
|
||||||
|
|
||||||
|
view->setWidth( width );
|
||||||
|
view->setHeight( height );
|
||||||
|
view->_camera->setScreenWidthAndHeight( width , height );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FRS_init_camera(Render* re){
|
void FRS_init_camera(Render* re){
|
||||||
@@ -73,18 +87,47 @@ extern "C" {
|
|||||||
view->_camera->setType(AppGLWidget_Camera::PERSPECTIVE);
|
view->_camera->setType(AppGLWidget_Camera::PERSPECTIVE);
|
||||||
view->_camera->setHorizontalFieldOfView( M_PI / 180.0f * cam->angle );
|
view->_camera->setHorizontalFieldOfView( M_PI / 180.0f * cam->angle );
|
||||||
}
|
}
|
||||||
// else if (cam->type == CAM_ORTHO){
|
else if (cam->type == CAM_ORTHO){
|
||||||
// view->_camera->setType(AppGLWidget_Camera::ORTHOGRAPHIC);
|
view->_camera->setType(AppGLWidget_Camera::ORTHOGRAPHIC);
|
||||||
// // view->_camera->setFocusDistance does not seem to work
|
// view->_camera->setFocusDistance does not seem to work
|
||||||
// // integrate cam->ortho_scale parameter
|
// integrate cam->ortho_scale parameter
|
||||||
// }
|
}
|
||||||
|
|
||||||
Vec camPosition(maincam_obj->obmat[3][0], maincam_obj->obmat[3][1], maincam_obj->obmat[3][2]);
|
Vec camPosition(maincam_obj->obmat[3][0], maincam_obj->obmat[3][1], maincam_obj->obmat[3][2]);
|
||||||
Vec camUp( re->viewmat[0][1], re->viewmat[1][1], re->viewmat[2][1]);
|
Vec camUp( re->viewmat[0][1], re->viewmat[1][1], re->viewmat[2][1]);
|
||||||
Vec camDirection( -re->viewmat[0][2], -re->viewmat[1][2], -re->viewmat[2][2]);
|
Vec camDirection( -re->viewmat[0][2], -re->viewmat[1][2], -re->viewmat[2][2]);
|
||||||
|
|
||||||
view->_camera->setPosition(camPosition);
|
view->_camera->setPosition(camPosition);
|
||||||
view->_camera->setUpVector(camUp);
|
view->_camera->setUpVector(camUp);
|
||||||
view->_camera->setViewDirection(camDirection);
|
view->_camera->setViewDirection(camDirection);
|
||||||
|
|
||||||
|
freestyle_viewpoint[0] = maincam_obj->obmat[3][0];
|
||||||
|
freestyle_viewpoint[1] = maincam_obj->obmat[3][1];
|
||||||
|
freestyle_viewpoint[2] = maincam_obj->obmat[3][2];
|
||||||
|
|
||||||
|
freestyle_mv[0][0] = maincam_obj->obmat[0][0];
|
||||||
|
freestyle_mv[0][1] = maincam_obj->obmat[1][0];
|
||||||
|
freestyle_mv[0][2] = maincam_obj->obmat[2][0];
|
||||||
|
freestyle_mv[0][3] = 0.0;
|
||||||
|
|
||||||
|
freestyle_mv[1][0] = maincam_obj->obmat[0][1];
|
||||||
|
freestyle_mv[1][1] = maincam_obj->obmat[1][1];
|
||||||
|
freestyle_mv[1][2] = maincam_obj->obmat[2][1];
|
||||||
|
freestyle_mv[1][3] = 0.0;
|
||||||
|
|
||||||
|
freestyle_mv[2][0] = re->viewmat[2][0];
|
||||||
|
freestyle_mv[2][1] = re->viewmat[2][1];
|
||||||
|
freestyle_mv[2][2] = re->viewmat[2][2];
|
||||||
|
freestyle_mv[2][3] = 0.0;
|
||||||
|
|
||||||
|
freestyle_mv[3][0] = re->viewmat[3][0];
|
||||||
|
freestyle_mv[3][1] = re->viewmat[3][1];
|
||||||
|
freestyle_mv[3][2] = re->viewmat[3][2];
|
||||||
|
freestyle_mv[3][3] = 1.0;
|
||||||
|
|
||||||
|
for( int i = 0; i < 4; i++ )
|
||||||
|
for( int j = 0; j < 4; j++ )
|
||||||
|
freestyle_proj[i][j] = re->winmat[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,28 +160,39 @@ extern "C" {
|
|||||||
|
|
||||||
// compute view map
|
// compute view map
|
||||||
controller->ComputeViewMap();
|
controller->ComputeViewMap();
|
||||||
|
|
||||||
// build strokes
|
|
||||||
controller->DrawStrokes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FRS_render_GL(Render* re) {
|
// void FRS_render_GL(Render* re) {
|
||||||
|
//
|
||||||
cout << "Rendering Freestyle with OpenGL" << endl;
|
//
|
||||||
|
// // build strokes
|
||||||
// render strokes
|
// controller->DrawStrokes();
|
||||||
view->workingBuffer = GL_BACK;
|
//
|
||||||
view->draw();
|
// cout << "Rendering Freestyle with OpenGL" << endl;
|
||||||
|
//
|
||||||
// display result
|
// // render strokes
|
||||||
RenderResult rres;
|
// view->workingBuffer = GL_BACK;
|
||||||
RE_GetResultImage(re, &rres);
|
// view->draw();
|
||||||
view->readPixels(0, 0, re->winx, re->winy, AppGLWidget::RGBA, rres.rectf );
|
//
|
||||||
re->result->renlay = render_get_active_layer(re, re->result);
|
// // display result
|
||||||
re->display_draw(re->result, NULL);
|
// RenderResult rres;
|
||||||
|
// RE_GetResultImage(re, &rres);
|
||||||
|
// view->readPixels(0, 0, re->winx, re->winy, AppGLWidget::RGBA, rres.rectf );
|
||||||
|
// re->result->renlay = render_get_active_layer(re, re->result);
|
||||||
|
// re->display_draw(re->result, NULL);
|
||||||
|
//
|
||||||
|
// controller->CloseFile();
|
||||||
|
// }
|
||||||
|
|
||||||
|
void FRS_render_Blender(Render* re) {
|
||||||
|
|
||||||
|
// build strokes
|
||||||
|
controller->DrawStrokes();
|
||||||
|
|
||||||
|
cout << "Rendering Freestyle with Blender's internal renderer" << endl;
|
||||||
|
controller->RenderBlender(re);
|
||||||
controller->CloseFile();
|
controller->CloseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ void GLStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
|
|||||||
for(Strip::vertex_container::iterator v=vertices.begin(), vend=vertices.end();
|
for(Strip::vertex_container::iterator v=vertices.begin(), vend=vertices.end();
|
||||||
v!=vend;
|
v!=vend;
|
||||||
++v){
|
++v){
|
||||||
|
|
||||||
StrokeVertexRep * svRep = (*v);
|
StrokeVertexRep * svRep = (*v);
|
||||||
Vec3r color = svRep->color();
|
Vec3r color = svRep->color();
|
||||||
real alpha = svRep->alpha();
|
real alpha = svRep->alpha();
|
||||||
|
|||||||
270
source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp
Normal file
270
source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
# include "BlenderStrokeRenderer.h"
|
||||||
|
# include "Canvas.h"
|
||||||
|
# include "../app_blender/AppConfig.h"
|
||||||
|
|
||||||
|
# include "../rendering/GLStrokeRenderer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "DNA_camera_types.h"
|
||||||
|
#include "DNA_customdata_types.h"
|
||||||
|
#include "DNA_listBase.h"
|
||||||
|
#include "DNA_mesh_types.h"
|
||||||
|
#include "DNA_meshdata_types.h"
|
||||||
|
#include "DNA_screen_types.h"
|
||||||
|
|
||||||
|
#include "BIF_drawscene.h"
|
||||||
|
#include "BIF_renderwin.h"
|
||||||
|
#include "BIF_writeimage.h"
|
||||||
|
|
||||||
|
#include "BKE_customdata.h"
|
||||||
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_library.h" /* free_libblock */
|
||||||
|
#include "BKE_material.h"
|
||||||
|
#include "BKE_main.h" /* struct Main */
|
||||||
|
#include "BKE_object.h"
|
||||||
|
#include "BKE_scene.h"
|
||||||
|
#include "BSE_sequence.h" /* to clear_scene_in_allseqs */
|
||||||
|
#include "BSE_node.h" /* to clear_scene_in_nodes */
|
||||||
|
#include "BSE_edit.h" /* countall */
|
||||||
|
|
||||||
|
#include "RE_pipeline.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BlenderStrokeRenderer::BlenderStrokeRenderer()
|
||||||
|
:StrokeRenderer(){
|
||||||
|
|
||||||
|
// TEMPORARY - need a texture manager
|
||||||
|
_textureManager = new GLTextureManager;
|
||||||
|
_textureManager->load();
|
||||||
|
|
||||||
|
// Scene.New("FreestyleStrokes")
|
||||||
|
old_scene = G.scene;
|
||||||
|
|
||||||
|
ListBase lb;
|
||||||
|
scene = add_scene("freestyle_strokes_scene ");
|
||||||
|
lb = scene->r.layers;
|
||||||
|
scene->r= old_scene->r;
|
||||||
|
scene->r.layers= lb;
|
||||||
|
set_scene( scene ); // scene.makeCurrent()
|
||||||
|
|
||||||
|
// image dimensions
|
||||||
|
float width = scene->r.xsch;
|
||||||
|
float height = scene->r.ysch;
|
||||||
|
|
||||||
|
// Camera
|
||||||
|
object_camera = add_object(OB_CAMERA);
|
||||||
|
|
||||||
|
Camera* camera = (Camera *) object_camera->data;
|
||||||
|
camera->type = CAM_ORTHO;
|
||||||
|
camera->ortho_scale = max(width,height);
|
||||||
|
|
||||||
|
object_camera->loc[0] = 0.5 * width;
|
||||||
|
object_camera->loc[1] = 0.5 * height;
|
||||||
|
object_camera->loc[2] = 1.0;
|
||||||
|
|
||||||
|
scene->camera = object_camera;
|
||||||
|
|
||||||
|
// Material
|
||||||
|
material = add_material("stroke_material");
|
||||||
|
material->mode |= MA_VERTEXCOLP;
|
||||||
|
material->mode |= MA_SHLESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlenderStrokeRenderer::~BlenderStrokeRenderer(){
|
||||||
|
|
||||||
|
if(0 != _textureManager)
|
||||||
|
{
|
||||||
|
delete _textureManager;
|
||||||
|
_textureManager = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEALLOCATE STRUCTURE
|
||||||
|
|
||||||
|
// Scene* scene;
|
||||||
|
// Object* object_camera;
|
||||||
|
// Material* material;
|
||||||
|
|
||||||
|
// Scene* old_scene;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const{
|
||||||
|
RenderStrokeRepBasic(iStrokeRep);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const{
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
// Build up scene
|
||||||
|
////////////////////
|
||||||
|
|
||||||
|
vector<Strip*>& strips = iStrokeRep->getStrips();
|
||||||
|
Strip::vertex_container::iterator v[3];
|
||||||
|
StrokeVertexRep *svRep[3];
|
||||||
|
Vec3r color[3];
|
||||||
|
unsigned int face_index;
|
||||||
|
|
||||||
|
for(vector<Strip*>::iterator s=strips.begin(), send=strips.end();
|
||||||
|
s!=send;
|
||||||
|
++s){
|
||||||
|
|
||||||
|
// me = Mesh.New()
|
||||||
|
Object* object_mesh = add_object(OB_MESH);
|
||||||
|
Mesh* mesh = (Mesh *) object_mesh->data;
|
||||||
|
MEM_freeN(mesh->bb);
|
||||||
|
mesh->bb= NULL;
|
||||||
|
mesh->id.us = 0;
|
||||||
|
|
||||||
|
// me.materials = [mat]
|
||||||
|
mesh->mat = ( Material ** ) MEM_mallocN( 1 * sizeof( Material * ), "MaterialList" );
|
||||||
|
mesh->mat[0] = material;
|
||||||
|
mesh->totcol = 1;
|
||||||
|
test_object_materials( (ID*) mesh );
|
||||||
|
|
||||||
|
int strip_vertex_count = (*s)->sizeStrip();
|
||||||
|
|
||||||
|
// vertices allocation
|
||||||
|
mesh->totvert = strip_vertex_count;
|
||||||
|
mesh->mvert = (MVert*) CustomData_add_layer( &mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
|
||||||
|
|
||||||
|
// faces allocation
|
||||||
|
mesh->totface = strip_vertex_count - 2;
|
||||||
|
mesh->mface = (MFace*) CustomData_add_layer( &mesh->fdata, CD_MFACE, CD_CALLOC, NULL, mesh->totface);
|
||||||
|
|
||||||
|
// colors allocation - me.vertexColors = True
|
||||||
|
mesh->mcol = (MCol *) CustomData_add_layer( &mesh->fdata, CD_MCOL, CD_CALLOC, NULL, mesh->totface );
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
// Data copy
|
||||||
|
////////////////////
|
||||||
|
|
||||||
|
MVert* vertices = mesh->mvert;
|
||||||
|
MFace* faces = mesh->mface;
|
||||||
|
MCol* colors = mesh->mcol;
|
||||||
|
|
||||||
|
Strip::vertex_container& strip_vertices = (*s)->vertices();
|
||||||
|
v[0] = strip_vertices.begin();
|
||||||
|
v[1] = v[0]; ++(v[1]);
|
||||||
|
v[2] = v[1]; ++(v[2]);
|
||||||
|
|
||||||
|
// first vertex
|
||||||
|
svRep[0] = *(v[0]);
|
||||||
|
vertices->co[0] = svRep[0]->point2d()[0];
|
||||||
|
vertices->co[1] = svRep[0]->point2d()[1];
|
||||||
|
vertices->co[2] = 0.0;
|
||||||
|
++vertices;
|
||||||
|
|
||||||
|
// second vertex
|
||||||
|
svRep[1] = *(v[1]);
|
||||||
|
vertices->co[0] = svRep[1]->point2d()[0];
|
||||||
|
vertices->co[1] = svRep[1]->point2d()[1];
|
||||||
|
vertices->co[2] = 0.0;
|
||||||
|
++vertices;
|
||||||
|
|
||||||
|
// iterating over subsequent vertices: each vertex adds a new face
|
||||||
|
face_index = 0;
|
||||||
|
|
||||||
|
while( v[2] != strip_vertices.end() )
|
||||||
|
{
|
||||||
|
// INPUT
|
||||||
|
svRep[0] = *(v[0]);
|
||||||
|
svRep[1] = *(v[1]);
|
||||||
|
svRep[2] = *(v[2]);
|
||||||
|
|
||||||
|
color[0] = svRep[0]->color();
|
||||||
|
color[1] = svRep[1]->color();
|
||||||
|
color[2] = svRep[2]->color();
|
||||||
|
|
||||||
|
// vertex
|
||||||
|
vertices->co[0] = svRep[2]->point2d()[0];
|
||||||
|
vertices->co[1] = svRep[2]->point2d()[1];
|
||||||
|
vertices->co[2] = 0.0;
|
||||||
|
|
||||||
|
// faces
|
||||||
|
faces->v1 = face_index;
|
||||||
|
faces->v2 = face_index + 1;
|
||||||
|
faces->v3 = face_index + 2;
|
||||||
|
faces->v4 = 0;
|
||||||
|
|
||||||
|
// colors
|
||||||
|
// red and blue are swapped - cf DNA_meshdata_types.h : MCol
|
||||||
|
colors->r = (short)(255.0f*(color[0])[2]);
|
||||||
|
colors->g = (short)(255.0f*(color[0])[1]);
|
||||||
|
colors->b = (short)(255.0f*(color[0])[0]);
|
||||||
|
colors->a = (short)(255.0f*svRep[0]->alpha());
|
||||||
|
++colors;
|
||||||
|
|
||||||
|
colors->r = (short)(255.0f*(color[1])[2]);
|
||||||
|
colors->g = (short)(255.0f*(color[1])[1]);
|
||||||
|
colors->b = (short)(255.0f*(color[1])[0]);
|
||||||
|
colors->a = (short)(255.0f*svRep[1]->alpha());
|
||||||
|
++colors;
|
||||||
|
|
||||||
|
colors->r = (short)(255.0f*(color[2])[2]);
|
||||||
|
colors->g = (short)(255.0f*(color[2])[1]);
|
||||||
|
colors->b = (short)(255.0f*(color[2])[0]);
|
||||||
|
colors->a = (short)(255.0f*svRep[2]->alpha());
|
||||||
|
++colors;
|
||||||
|
|
||||||
|
// ITERATION
|
||||||
|
++v[0]; ++v[1]; ++v[2];
|
||||||
|
++faces; ++vertices; ++colors;
|
||||||
|
++face_index;
|
||||||
|
|
||||||
|
} // loop over strip vertices
|
||||||
|
|
||||||
|
} // loop over strips
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlenderStrokeRenderer::RenderScene( Render *re ) {
|
||||||
|
scene->r.mode &= ~( R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR );
|
||||||
|
scene->r.planes = R_PLANES32;
|
||||||
|
scene->r.imtype = R_PNG;
|
||||||
|
|
||||||
|
re->freestyle_render = RE_NewRender(scene->id.name);
|
||||||
|
RE_BlenderFrame( re->freestyle_render, scene, 1);
|
||||||
|
|
||||||
|
// char filepath[255];
|
||||||
|
// BLI_strncpy( filepath, "/Users/mx/Desktop/", sizeof(filepath) );
|
||||||
|
// strcat(filepath, "frs_result");
|
||||||
|
// BIF_save_rendered_image(filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlenderStrokeRenderer::Close() {
|
||||||
|
|
||||||
|
Scene *sce;
|
||||||
|
bScreen *sc;
|
||||||
|
|
||||||
|
// from header_info.c
|
||||||
|
/* check all sets */
|
||||||
|
for( sce= (Scene*) G.main->scene.first; sce; sce= (Scene*)sce->id.next) {
|
||||||
|
if(sce->set == scene) sce->set= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check all sequences */
|
||||||
|
clear_scene_in_allseqs(scene);
|
||||||
|
|
||||||
|
/* check render layer nodes in other scenes */
|
||||||
|
clear_scene_in_nodes(scene);
|
||||||
|
|
||||||
|
for (sc= (bScreen*)G.main->screen.first; sc; sc= (bScreen*)sc->id.next ) {
|
||||||
|
if(sc->scene == scene) sc->scene= G.scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
free_libblock( &G.main->scene, scene );
|
||||||
|
set_scene( old_scene );
|
||||||
|
countall();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#ifndef BLENDERSTROKERENDERER_H
|
||||||
|
# define BLENDERSTROKERENDERER_H
|
||||||
|
|
||||||
|
# include "../system/FreestyleConfig.h"
|
||||||
|
# include "StrokeRenderer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "DNA_material_types.h"
|
||||||
|
#include "DNA_object_types.h"
|
||||||
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
|
#include "render_types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class LIB_STROKE_EXPORT BlenderStrokeRenderer : public StrokeRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BlenderStrokeRenderer();
|
||||||
|
virtual ~BlenderStrokeRenderer();
|
||||||
|
|
||||||
|
/*! Renders a stroke rep */
|
||||||
|
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const;
|
||||||
|
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const;
|
||||||
|
|
||||||
|
void RenderScene(Render *re);
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Scene* scene;
|
||||||
|
Scene* old_scene;
|
||||||
|
|
||||||
|
Object* object_camera;
|
||||||
|
Material* material;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BLENDERSTROKERENDERER_H
|
||||||
|
|
||||||
@@ -108,31 +108,12 @@ void Canvas::Draw()
|
|||||||
|
|
||||||
for(unsigned i = 0; i < _StyleModules.size(); i++) {
|
for(unsigned i = 0; i < _StyleModules.size(); i++) {
|
||||||
_current_sm = _StyleModules[i];
|
_current_sm = _StyleModules[i];
|
||||||
if (!_StyleModules[i]->getModified())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (_StyleModules[i]->getDrawable() && _Layers[i]) {
|
|
||||||
if (_basic)
|
|
||||||
_Layers[i]->RenderBasic(_Renderer);
|
|
||||||
else
|
|
||||||
_Layers[i]->Render(_Renderer);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
if (i < _Layers.size() && _Layers[i])
|
if (i < _Layers.size() && _Layers[i])
|
||||||
delete _Layers[i];
|
delete _Layers[i];
|
||||||
|
|
||||||
_Layers[i] = _StyleModules[i]->execute();
|
_Layers[i] = _StyleModules[i]->execute();
|
||||||
|
|
||||||
if (_StyleModules[i]->getDrawable() && _Layers[i]) {
|
|
||||||
if (_basic)
|
|
||||||
_Layers[i]->RenderBasic(_Renderer);
|
|
||||||
else
|
|
||||||
_Layers[i]->Render(_Renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
timestamp->increment();
|
timestamp->increment();
|
||||||
}
|
}
|
||||||
postDraw();
|
postDraw();
|
||||||
|
|||||||
@@ -834,7 +834,7 @@ void Operators::create(UnaryPredicate1D& pred, vector<StrokeShader*> shaders) {
|
|||||||
Stroke* stroke = createStroke(**it);
|
Stroke* stroke = createStroke(**it);
|
||||||
if (stroke) {
|
if (stroke) {
|
||||||
applyShading(*stroke, shaders);
|
applyShading(*stroke, shaders);
|
||||||
canvas->RenderStroke(stroke);
|
//canvas->RenderStroke(stroke);
|
||||||
_current_strokes_set.push_back(stroke);
|
_current_strokes_set.push_back(stroke);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ private:
|
|||||||
vector<string> pathnames;
|
vector<string> pathnames;
|
||||||
StringUtils::getPathName(_path, "", pathnames);
|
StringUtils::getPathName(_path, "", pathnames);
|
||||||
|
|
||||||
struct Text *text = add_empty_text("tmp_initpath.txt");
|
struct Text *text = add_empty_text("tmp_freestyle_initpath.txt");
|
||||||
string cmd = "import sys\n";
|
string cmd = "import sys\n";
|
||||||
txt_insert_buf(text, const_cast<char*>(cmd.c_str()));
|
txt_insert_buf(text, const_cast<char*>(cmd.c_str()));
|
||||||
|
|
||||||
|
|||||||
@@ -625,7 +625,6 @@ typedef struct Scene {
|
|||||||
/* yafray: renderer flag (not only exclusive to yafray) */
|
/* yafray: renderer flag (not only exclusive to yafray) */
|
||||||
#define R_INTERN 0
|
#define R_INTERN 0
|
||||||
#define R_YAFRAY 1
|
#define R_YAFRAY 1
|
||||||
#define R_FREESTYLE 2
|
|
||||||
|
|
||||||
/* scemode (int now) */
|
/* scemode (int now) */
|
||||||
#define R_DOSEQ 0x0001
|
#define R_DOSEQ 0x0001
|
||||||
|
|||||||
@@ -994,8 +994,6 @@ static int RenderData_setRenderer( BPy_RenderData * self, PyObject * value )
|
|||||||
self->renderContext->renderer = R_INTERN;
|
self->renderContext->renderer = R_INTERN;
|
||||||
else if( type == R_YAFRAY )
|
else if( type == R_YAFRAY )
|
||||||
self->renderContext->renderer = R_YAFRAY;
|
self->renderContext->renderer = R_YAFRAY;
|
||||||
else if( type == R_FREESTYLE )
|
|
||||||
self->renderContext->renderer = R_FREESTYLE;
|
|
||||||
else
|
else
|
||||||
return EXPP_ReturnIntError( PyExc_ValueError,
|
return EXPP_ReturnIntError( PyExc_ValueError,
|
||||||
"expected constant INTERNAL or YAFRAY" );
|
"expected constant INTERNAL or YAFRAY" );
|
||||||
@@ -3873,7 +3871,6 @@ PyObject *Render_Init( void )
|
|||||||
|
|
||||||
PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN );
|
PyModule_AddIntConstant( submodule, "INTERNAL", R_INTERN );
|
||||||
PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY );
|
PyModule_AddIntConstant( submodule, "YAFRAY", R_YAFRAY );
|
||||||
PyModule_AddIntConstant( submodule, "FREESTYLE", R_FREESTYLE );
|
|
||||||
PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW );
|
PyModule_AddIntConstant( submodule, "AVIRAW", R_AVIRAW );
|
||||||
PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG );
|
PyModule_AddIntConstant( submodule, "AVIJPEG", R_AVIJPEG );
|
||||||
PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC );
|
PyModule_AddIntConstant( submodule, "AVICODEC", R_AVICODEC );
|
||||||
|
|||||||
@@ -198,6 +198,9 @@ struct Render
|
|||||||
ListBase *sss_points;
|
ListBase *sss_points;
|
||||||
struct Material *sss_mat;
|
struct Material *sss_mat;
|
||||||
|
|
||||||
|
/* Freestyle */
|
||||||
|
struct Render* freestyle_render;
|
||||||
|
|
||||||
ListBase customdata_names;
|
ListBase customdata_names;
|
||||||
|
|
||||||
struct Object *excludeob;
|
struct Object *excludeob;
|
||||||
|
|||||||
@@ -4427,6 +4427,8 @@ void RE_Database_Free(Render *re)
|
|||||||
free_occ(re);
|
free_occ(re);
|
||||||
free_strand_surface(re);
|
free_strand_surface(re);
|
||||||
|
|
||||||
|
if( re->freestyle_render ) RE_FreeRender(re->freestyle_render);
|
||||||
|
|
||||||
re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
|
re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0;
|
||||||
re->i.convertdone= 0;
|
re->i.convertdone= 0;
|
||||||
|
|
||||||
@@ -4874,6 +4876,13 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view)
|
|||||||
if((re->r.mode & R_SSS) && !re->test_break())
|
if((re->r.mode & R_SSS) && !re->test_break())
|
||||||
if(re->r.renderer==R_INTERN)
|
if(re->r.renderer==R_INTERN)
|
||||||
make_sss_tree(re);
|
make_sss_tree(re);
|
||||||
|
|
||||||
|
/* Freestyle */
|
||||||
|
if((re->r.mode & R_EDGE_FRS ) && !re->test_break())
|
||||||
|
if(re->r.renderer==R_INTERN) {
|
||||||
|
FRS_prepare(re);
|
||||||
|
FRS_render_Blender(re);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(re->test_break())
|
if(re->test_break())
|
||||||
|
|||||||
@@ -1630,18 +1630,12 @@ static void do_render_3d(Render *re)
|
|||||||
else
|
else
|
||||||
RE_Database_FromScene(re, re->scene, 1);
|
RE_Database_FromScene(re, re->scene, 1);
|
||||||
|
|
||||||
/* Freestyle */
|
|
||||||
if( re->r.mode & R_EDGE_FRS ) {
|
|
||||||
FRS_prepare(re);
|
|
||||||
}
|
|
||||||
|
|
||||||
threaded_tile_processor(re);
|
threaded_tile_processor(re);
|
||||||
|
|
||||||
/* do left-over 3d post effects (flares) */
|
/* do left-over 3d post effects (flares) */
|
||||||
if(re->flag & R_HALO)
|
if(re->flag & R_HALO)
|
||||||
if(!re->test_break())
|
if(!re->test_break())
|
||||||
add_halo_flare(re);
|
add_halo_flare(re);
|
||||||
|
|
||||||
|
|
||||||
/* free all render verts etc */
|
/* free all render verts etc */
|
||||||
RE_Database_Free(re);
|
RE_Database_Free(re);
|
||||||
@@ -2198,36 +2192,6 @@ static void do_render_composite_fields_blur_3d(Render *re)
|
|||||||
re->display_draw(re->result, NULL);
|
re->display_draw(re->result, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freestyleRender(Render *re)
|
|
||||||
{
|
|
||||||
// init render result
|
|
||||||
RE_FreeRenderResult(re->result);
|
|
||||||
re->result = new_render_result(re, &re->disprect, 0, RR_USEMEM);
|
|
||||||
|
|
||||||
// set camera
|
|
||||||
RE_SetCamera(re, re->scene->camera);
|
|
||||||
|
|
||||||
// set up render database
|
|
||||||
if(render_scene_needs_vector(re))
|
|
||||||
RE_Database_FromScene_Vectors(re, re->scene);
|
|
||||||
else
|
|
||||||
RE_Database_FromScene(re, re->scene, 1);
|
|
||||||
|
|
||||||
// used to reobtain ogl context after RE_Database_FromScene call
|
|
||||||
re->display_clear(re->result);
|
|
||||||
|
|
||||||
// Freestyle initialization
|
|
||||||
FRS_prepare(re);
|
|
||||||
|
|
||||||
// run Freestyle
|
|
||||||
re->i.starttime = PIL_check_seconds_timer();
|
|
||||||
FRS_render_GL(re);
|
|
||||||
re->i.lastframetime = PIL_check_seconds_timer()- re->i.starttime;
|
|
||||||
re->stats_draw(&re->i);
|
|
||||||
|
|
||||||
RE_Database_Free(re);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef DISABLE_YAFRAY
|
#ifndef DISABLE_YAFRAY
|
||||||
/* yafray: main yafray render/export call */
|
/* yafray: main yafray render/export call */
|
||||||
static void yafrayRender(Render *re)
|
static void yafrayRender(Render *re)
|
||||||
@@ -2269,7 +2233,7 @@ static void yafrayRender(Render *re)
|
|||||||
re->rectx= re->winx;
|
re->rectx= re->winx;
|
||||||
re->recty= re->winy;
|
re->recty= re->winy;
|
||||||
|
|
||||||
rres= new_render_result(re, &re->disprect, 0, RR_USEMEM);
|
rres = new_render_result(re, &re->disprect, 0, RR_USEMEM);
|
||||||
|
|
||||||
merge_render_result(rres, re->result);
|
merge_render_result(rres, re->result);
|
||||||
RE_FreeRenderResult(re->result);
|
RE_FreeRenderResult(re->result);
|
||||||
@@ -2322,15 +2286,10 @@ static void do_render_all_options(Render *re)
|
|||||||
#ifndef DISABLE_YAFRAY
|
#ifndef DISABLE_YAFRAY
|
||||||
if(re->r.renderer==R_YAFRAY)
|
if(re->r.renderer==R_YAFRAY)
|
||||||
yafrayRender(re);
|
yafrayRender(re);
|
||||||
else if(re->r.renderer==R_FREESTYLE)
|
|
||||||
freestyleRender(re);
|
|
||||||
else
|
else
|
||||||
do_render_composite_fields_blur_3d(re);
|
do_render_composite_fields_blur_3d(re);
|
||||||
#else
|
#else
|
||||||
if(re->r.renderer==R_FREESTYLE)
|
do_render_composite_fields_blur_3d(re);
|
||||||
freestyleRender(re);
|
|
||||||
else
|
|
||||||
do_render_composite_fields_blur_3d(re);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2449,7 +2408,7 @@ static int is_rendering_allowed(Render *re)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* renderer */
|
/* renderer */
|
||||||
if(!ELEM3(re->r.renderer, R_INTERN, R_YAFRAY, R_FREESTYLE)) {
|
if(!ELEM(re->r.renderer, R_INTERN, R_YAFRAY)) {
|
||||||
re->error("Unknown render engine set");
|
re->error("Unknown render engine set");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -901,6 +901,30 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma
|
|||||||
ps->shadfac= 0;
|
ps->shadfac= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void freestyle_enhance_add(RenderPart *pa, float *rectf)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
float* freestyle;
|
||||||
|
|
||||||
|
RenderLayer* rl= render_get_active_layer( R.freestyle_render, R.freestyle_render->result );
|
||||||
|
if( rl->rectf == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
for( x = pa->disprect.xmin + pa->crop; x < pa->disprect.xmax - pa->crop; x++) {
|
||||||
|
for( y = pa->disprect.ymin + pa->crop; y < pa->disprect.ymax - pa->crop; y++) {
|
||||||
|
|
||||||
|
freestyle = rl->rectf + 4 * (R.recty * x + y);
|
||||||
|
if( freestyle[3] > 0.0)
|
||||||
|
addAlphaOverFloat(rectf, freestyle);
|
||||||
|
rectf += 4;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void edge_enhance_add(RenderPart *pa, float *rectf, float *arect)
|
static void edge_enhance_add(RenderPart *pa, float *rectf, float *arect)
|
||||||
{
|
{
|
||||||
float addcol[4];
|
float addcol[4];
|
||||||
@@ -1219,6 +1243,10 @@ void zbufshadeDA_tile(RenderPart *pa)
|
|||||||
if(R.r.mode & R_EDGE)
|
if(R.r.mode & R_EDGE)
|
||||||
edge_enhance_add(pa, rl->rectf, edgerect);
|
edge_enhance_add(pa, rl->rectf, edgerect);
|
||||||
|
|
||||||
|
if(rl->layflag & SCE_LAY_FRS)
|
||||||
|
if(R.r.mode & R_EDGE_FRS)
|
||||||
|
freestyle_enhance_add(pa, rl->rectf);
|
||||||
|
|
||||||
if(rl->passflag & SCE_PASS_VECTOR)
|
if(rl->passflag & SCE_PASS_VECTOR)
|
||||||
reset_sky_speed(pa, rl);
|
reset_sky_speed(pa, rl);
|
||||||
|
|
||||||
@@ -1383,6 +1411,10 @@ void zbufshade_tile(RenderPart *pa)
|
|||||||
edge_enhance_add(pa, rl->rectf, edgerect);
|
edge_enhance_add(pa, rl->rectf, edgerect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(rl->layflag & SCE_LAY_FRS)
|
||||||
|
if(R.r.mode & R_EDGE_FRS)
|
||||||
|
freestyle_enhance_add(pa, rl->rectf);
|
||||||
|
|
||||||
if(rl->passflag & SCE_PASS_VECTOR)
|
if(rl->passflag & SCE_PASS_VECTOR)
|
||||||
reset_sky_speed(pa, rl);
|
reset_sky_speed(pa, rl);
|
||||||
|
|
||||||
|
|||||||
@@ -2175,7 +2175,7 @@ static void render_panel_output(void)
|
|||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
uiDefButBitI(block, TOG, R_EDGE, B_NOP,"Edge", 115, 89, 60, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon Edge-enhance");
|
uiDefButBitI(block, TOG, R_EDGE, B_NOP,"Edge", 115, 89, 60, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon Edge-enhance");
|
||||||
uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 175, 89, 75, 20, "Display Edge settings");
|
uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 175, 89, 75, 20, "Display Edge settings");
|
||||||
uiDefButBitI(block, TOG, R_EDGE_FRS, B_NOP,"Freestyle", 250, 89, 60, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Freestyle");
|
uiDefButBitI(block, TOG, R_EDGE_FRS, B_SWITCHRENDER,"Freestyle", 250, 89, 60, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Freestyle");
|
||||||
uiBlockEndAlign(block);
|
uiBlockEndAlign(block);
|
||||||
|
|
||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
@@ -2276,10 +2276,10 @@ static void render_panel_render(void)
|
|||||||
uiDefBut(block, BUT,B_DORENDER,"RENDER", 369, 164, 191,37, 0, 0, 0, 0, 0, "Render the current frame (F12)");
|
uiDefBut(block, BUT,B_DORENDER,"RENDER", 369, 164, 191,37, 0, 0, 0, 0, 0, "Render the current frame (F12)");
|
||||||
#ifndef DISABLE_YAFRAY
|
#ifndef DISABLE_YAFRAY
|
||||||
/* yafray: on request, render engine menu is back again, and moved to Render panel */
|
/* yafray: on request, render engine menu is back again, and moved to Render panel */
|
||||||
uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|YafRay %x1|Freestyle %x2",
|
uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|YafRay %x1",
|
||||||
369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");
|
369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");
|
||||||
#else
|
#else
|
||||||
uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|Freestyle %x1",
|
uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0",
|
||||||
369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");
|
369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");
|
||||||
#endif /* disable yafray */
|
#endif /* disable yafray */
|
||||||
|
|
||||||
@@ -3316,8 +3316,6 @@ static void render_panel_freestyle()
|
|||||||
uiDefButBitI(block, TOG, FREESTYLE_SUGGESTIVE_CONTOURS_FLAG, B_NOP, "Suggestive Contours", 10, 130, 150, 20, &freestyle_flags, 0, 0, 0, 0, "Compute suggestive contours");
|
uiDefButBitI(block, TOG, FREESTYLE_SUGGESTIVE_CONTOURS_FLAG, B_NOP, "Suggestive Contours", 10, 130, 150, 20, &freestyle_flags, 0, 0, 0, 0, "Compute suggestive contours");
|
||||||
uiDefButF(block, NUM, B_NOP, "kr Derivative Epsilon", 10,110,300,20, &freestyle_dkr_epsilon, 0.0f, 10.0f, 0.1, 3, "Suggestive contour kr derivative epsilon");
|
uiDefButF(block, NUM, B_NOP, "kr Derivative Epsilon", 10,110,300,20, &freestyle_dkr_epsilon, 0.0f, 10.0f, 0.1, 3, "Suggestive contour kr derivative epsilon");
|
||||||
uiBlockEndAlign(block);
|
uiBlockEndAlign(block);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layer_copy_func(void *lay_v, void *lay_p)
|
static void layer_copy_func(void *lay_v, void *lay_p)
|
||||||
@@ -3538,10 +3536,8 @@ void render_panels()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (G.scene->r.renderer==R_FREESTYLE) {
|
if( G.scene->r.mode & R_EDGE_FRS )
|
||||||
render_panel_freestyle();
|
render_panel_freestyle();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user