Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-07-26 05:23:27 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-07-26 05:23:27 +0400
commit25ce805a58fa833cf9c4e818f34d9664de1f3636 (patch)
treeddbb6464d836dd7437dd5b161cf3f8c6d8070eb9 /source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
parent2ef33845046b978b9a86c1ec90184af96d5bb943 (diff)
* Implemented the basic stroke rendering functionality for the new
Parameter Editor mode. This is a WIP commit. Only the base line color, base alpha transparency, and base line thickness are respected. More additions are anticipated to account for other parameters. * Added FRS_finish_stroke_rendering() to clean Freestyle-related temporary resources after stroke rendering. * Some functions in FRS_freestyle.cpp are now declared as static functions, so as not to mess up the program-wide name space. * Made the StyleModule class inheritable, and defined new subclass BlenderStyleModule that takes a Text object instead of a file name.
Diffstat (limited to 'source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp')
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp83
1 files changed, 61 insertions, 22 deletions
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index c3c5058ddfd..18ec12bb862 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -15,12 +15,14 @@ extern "C" {
#include "MEM_guardedalloc.h"
#include "DNA_camera_types.h"
+#include "DNA_text_types.h"
#include "DNA_freestyle_types.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_linestyle.h"
#include "BKE_main.h"
+#include "BKE_text.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BPY_extern.h"
@@ -61,6 +63,7 @@ extern "C" {
controller = new Controller();
view = new AppView;
controller->setView(view);
+ controller->Clear();
freestyle_scene = NULL;
default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
@@ -83,7 +86,7 @@ extern "C" {
// Rendering
//=======================================================
- void init_view(Render* re){
+ static void init_view(Render* re){
float ycor = ((float)re->r.yasp) / ((float)re->r.xasp);
int width = re->r.xsch;
int height = (int)(((float)re->r.ysch) * ycor);
@@ -107,7 +110,7 @@ extern "C" {
cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl;
}
- void init_camera(Render* re){
+ static void init_camera(Render* re){
// It is assumed that imported meshes are in the camera coordinate system.
// Therefore, the view point (i.e., camera position) is at the origin, and
// the the model-view matrix is simply the identity matrix.
@@ -128,12 +131,19 @@ extern "C" {
//print_m4("proj", freestyle_proj);
}
-
- void prepare(Render* re, SceneRenderLayer* srl ) {
-
- // clear canvas
- controller->Clear();
+ static Text *create_lineset_handler(char *layer_name, char *lineset_name)
+ {
+ Text *text = add_empty_text(lineset_name);
+ write_text(text, "import parameter_editor; parameter_editor.process('");
+ write_text(text, layer_name);
+ write_text(text, "', '");
+ write_text(text, lineset_name);
+ write_text(text, "')\n");
+ return text;
+ }
+ static void prepare(Render* re, SceneRenderLayer* srl ) {
+
// load mesh
re->i.infostr= "Freestyle: Mesh loading";
re->stats_draw(re->sdh, &re->i);
@@ -147,19 +157,34 @@ extern "C" {
FreestyleConfig* config = &srl->freestyleConfig;
cout << "\n=== Rendering options ===" << endl;
- cout << "Modules :"<< endl;
int layer_count = 0;
-
- for( FreestyleModuleConfig* module_conf = (FreestyleModuleConfig *)config->modules.first; module_conf; module_conf = module_conf->next ) {
- if( module_conf->is_displayed ) {
- cout << " " << layer_count+1 << ": " << module_conf->module_path << endl;
- controller->InsertStyleModule( layer_count, module_conf->module_path );
- controller->toggleLayer(layer_count, true);
- layer_count++;
+ switch (config->mode) {
+ case FREESTYLE_CONTROL_SCRIPT_MODE:
+ cout << "Modules :"<< endl;
+ for (FreestyleModuleConfig* module_conf = (FreestyleModuleConfig *)config->modules.first; module_conf; module_conf = module_conf->next) {
+ if( module_conf->is_displayed ) {
+ cout << " " << layer_count+1 << ": " << module_conf->module_path << endl;
+ controller->InsertStyleModule( layer_count, module_conf->module_path );
+ controller->toggleLayer(layer_count, true);
+ layer_count++;
+ }
}
- }
- cout << endl;
+ cout << endl;
+ break;
+ case FREESTYLE_CONTROL_EDITOR_MODE:
+ cout << "Linesets:"<< endl;
+ for (FreestyleLineSet *lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {
+ if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
+ cout << " " << layer_count+1 << ": " << lineset->name << " - " << lineset->linestyle->id.name+2 << endl;
+ Text *text = create_lineset_handler(srl->name, lineset->name);
+ controller->InsertStyleModule( layer_count, lineset->name, text );
+ controller->toggleLayer(layer_count, true);
+ layer_count++;
+ }
+ }
+ break;
+ }
// set parameters
controller->setCreaseAngle( config->crease_angle );
@@ -234,12 +259,22 @@ extern "C" {
}
}
- int displayed_layer_count( SceneRenderLayer* srl ) {
+ static int displayed_layer_count( SceneRenderLayer* srl ) {
int count = 0;
- for( FreestyleModuleConfig* module_conf = (FreestyleModuleConfig *)srl->freestyleConfig.modules.first; module_conf; module_conf = module_conf->next ) {
- if( module_conf->is_displayed )
- count++;
+ switch (srl->freestyleConfig.mode) {
+ case FREESTYLE_CONTROL_SCRIPT_MODE:
+ for (FreestyleModuleConfig* module = (FreestyleModuleConfig *)srl->freestyleConfig.modules.first; module; module = module->next) {
+ if( module->is_displayed )
+ count++;
+ }
+ break;
+ case FREESTYLE_CONTROL_EDITOR_MODE:
+ for (FreestyleLineSet *lineset = (FreestyleLineSet *)srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
+ if (lineset->flags & FREESTYLE_LINESET_ENABLED)
+ count++;
+ }
+ break;
}
return count;
}
@@ -271,7 +306,6 @@ extern "C" {
cout << "----------------------------------------------------------" << endl;
// prepare Freestyle:
- // - clear canvas
// - load mesh
// - add style modules
// - set parameters
@@ -305,6 +339,11 @@ extern "C" {
return freestyle_render;
}
+ void FRS_finish_stroke_rendering(Render* re) {
+ // clear canvas
+ controller->Clear();
+ }
+
//=======================================================
// Freestyle Panel Configuration
//=======================================================