Freestyle: an improved workflow of line style shading nodes.
Removed the previous changes for passing a line style through the Controller, and revised the BlenderTextureShader to assign the shader node tree of a line style (if specified) to strokes. This way the assignment of shading nodes can be done through both the Freestyle GUI and Python scripting.
This commit is contained in:
@@ -1078,8 +1078,7 @@ def process(layer_name, lineset_name):
|
|||||||
has_tex = False
|
has_tex = False
|
||||||
if scene.render.use_shading_nodes:
|
if scene.render.use_shading_nodes:
|
||||||
if linestyle.use_nodes and linestyle.node_tree:
|
if linestyle.use_nodes and linestyle.node_tree:
|
||||||
### TODO ###
|
shaders_list.append(BlenderTextureShader(linestyle.node_tree))
|
||||||
#shaders_list.append(BlenderTextureShader(linestyle.nodetree))
|
|
||||||
has_tex = True
|
has_tex = True
|
||||||
else:
|
else:
|
||||||
if linestyle.use_texture:
|
if linestyle.use_texture:
|
||||||
|
|||||||
@@ -892,10 +892,9 @@ void Controller::InsertStyleModule(unsigned index, const char *iFileName)
|
|||||||
_Canvas->InsertStyleModule(index, sm);
|
_Canvas->InsertStyleModule(index, sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::InsertStyleModule(unsigned index, const char *iName, struct Text *iText,
|
void Controller::InsertStyleModule(unsigned index, const char *iName, struct Text *iText)
|
||||||
struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
|
|
||||||
{
|
{
|
||||||
StyleModule *sm = new BlenderStyleModule(iName, _inter, iText, iLineStyle, iUseShadingNodes);
|
StyleModule *sm = new BlenderStyleModule(iText, iName, _inter);
|
||||||
_Canvas->InsertStyleModule(index, sm);
|
_Canvas->InsertStyleModule(index, sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,7 @@ public:
|
|||||||
Render *RenderStrokes(Render *re, bool render);
|
Render *RenderStrokes(Render *re, bool render);
|
||||||
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 InsertStyleModule(unsigned index, const char *iName, struct Text *iText,
|
void InsertStyleModule(unsigned index, const char *iName, struct Text *iText);
|
||||||
struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes);
|
|
||||||
void AddStyleModule(const char *iFileName);
|
void AddStyleModule(const char *iFileName);
|
||||||
void RemoveStyleModule(unsigned index);
|
void RemoveStyleModule(unsigned index);
|
||||||
void ReloadStyleModule(unsigned index, const char * iFileName);
|
void ReloadStyleModule(unsigned index, const char * iFileName);
|
||||||
|
|||||||
@@ -146,7 +146,9 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(bContext *C, Render *re, int render
|
|||||||
|
|
||||||
BlenderStrokeRenderer::~BlenderStrokeRenderer()
|
BlenderStrokeRenderer::~BlenderStrokeRenderer()
|
||||||
{
|
{
|
||||||
return; //XXX
|
#if 0
|
||||||
|
return; // XXX
|
||||||
|
#endif
|
||||||
|
|
||||||
// The freestyle_scene object is not released here. Instead,
|
// The freestyle_scene object is not released here. Instead,
|
||||||
// the scene is released in free_all_freestyle_renders() in
|
// the scene is released in free_all_freestyle_renders() in
|
||||||
@@ -217,7 +219,7 @@ unsigned int BlenderStrokeRenderer::get_stroke_mesh_id(void) const
|
|||||||
return mesh_id;
|
return mesh_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, FreestyleLineStyle *linestyle)
|
Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree)
|
||||||
{
|
{
|
||||||
Material *ma = BKE_material_add(bmain, "stroke_shader");
|
Material *ma = BKE_material_add(bmain, "stroke_shader");
|
||||||
bNodeTree *ntree;
|
bNodeTree *ntree;
|
||||||
@@ -226,9 +228,9 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, Frees
|
|||||||
PointerRNA fromptr, toptr;
|
PointerRNA fromptr, toptr;
|
||||||
|
|
||||||
cout << "linestyle " << linestyle << " nodetree " << linestyle->nodetree << " use_nodes " << linestyle->use_nodes << endl;
|
cout << "linestyle " << linestyle << " nodetree " << linestyle->nodetree << " use_nodes " << linestyle->use_nodes << endl;
|
||||||
if (linestyle && linestyle->use_nodes && linestyle->nodetree) {
|
if (iNodeTree) {
|
||||||
// make a copy of linestyle->nodetree
|
// make a copy of linestyle->nodetree
|
||||||
ntree = ntreeCopyTree_ex(linestyle->nodetree, bmain, true);
|
ntree = ntreeCopyTree_ex(iNodeTree, bmain, true);
|
||||||
|
|
||||||
// find the active Output Line Style node
|
// find the active Output Line Style node
|
||||||
for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
|
for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
|
||||||
@@ -357,8 +359,8 @@ Material* BlenderStrokeRenderer::GetStrokeShader(bContext *C, Main *bmain, Frees
|
|||||||
|
|
||||||
void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
|
void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
|
||||||
{
|
{
|
||||||
if (iStrokeRep->useShadingNodes()) {
|
if (BKE_scene_use_new_shading_nodes(freestyle_scene)) {
|
||||||
Material *ma = BlenderStrokeRenderer::GetStrokeShader(_context, freestyle_bmain, iStrokeRep->getLineStyle());
|
Material *ma = BlenderStrokeRenderer::GetStrokeShader(_context, freestyle_bmain, iStrokeRep->getNodeTree());
|
||||||
|
|
||||||
if (strcmp(freestyle_scene->r.engine, "CYCLES") == 0) {
|
if (strcmp(freestyle_scene->r.engine, "CYCLES") == 0) {
|
||||||
PointerRNA scene_ptr;
|
PointerRNA scene_ptr;
|
||||||
|
|||||||
@@ -30,11 +30,12 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
struct Main;
|
struct Main;
|
||||||
|
struct Material;
|
||||||
struct Object;
|
struct Object;
|
||||||
struct Render;
|
struct Render;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
struct bContext;
|
struct bContext;
|
||||||
struct FreestyleLineStyle;
|
struct bNodeTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Freestyle {
|
namespace Freestyle {
|
||||||
@@ -53,7 +54,7 @@ public:
|
|||||||
|
|
||||||
Render *RenderScene(Render *re, bool render);
|
Render *RenderScene(Render *re, bool render);
|
||||||
|
|
||||||
static Material* GetStrokeShader(bContext *C, Main *bmain, FreestyleLineStyle *linestyle);
|
static Material* GetStrokeShader(bContext *C, Main *bmain, bNodeTree *iNodeTree);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Main *freestyle_bmain;
|
Main *freestyle_bmain;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "BLI_utildefines.h" // BLI_assert()
|
#include "BLI_utildefines.h" // BLI_assert()
|
||||||
|
|
||||||
struct FreestyleLineStyle;
|
|
||||||
struct Scene;
|
struct Scene;
|
||||||
struct Text;
|
struct Text;
|
||||||
}
|
}
|
||||||
@@ -41,26 +40,15 @@ namespace Freestyle {
|
|||||||
class BlenderStyleModule : public StyleModule
|
class BlenderStyleModule : public StyleModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BlenderStyleModule(const string &name, Interpreter *inter, struct Text *text,
|
BlenderStyleModule(struct Text *text, const string &name, Interpreter *inter) : StyleModule(name, inter)
|
||||||
struct FreestyleLineStyle *lineStyle, bool useShadingNodes)
|
|
||||||
: StyleModule(name, inter)
|
|
||||||
{
|
{
|
||||||
_text = text;
|
_text = text;
|
||||||
_lineStyle = lineStyle;
|
|
||||||
_useShadingNodes = useShadingNodes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~BlenderStyleModule()
|
virtual ~BlenderStyleModule()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual StrokeLayer *execute()
|
|
||||||
{
|
|
||||||
StrokeLayer *sl = StyleModule::execute();
|
|
||||||
sl->setLineStyle(_lineStyle, _useShadingNodes);
|
|
||||||
return sl;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int interpret()
|
virtual int interpret()
|
||||||
{
|
{
|
||||||
@@ -71,8 +59,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct Text *_text;
|
struct Text *_text;
|
||||||
struct FreestyleLineStyle *_lineStyle;
|
|
||||||
bool _useShadingNodes;
|
|
||||||
|
|
||||||
#ifdef WITH_CXX_GUARDEDALLOC
|
#ifdef WITH_CXX_GUARDEDALLOC
|
||||||
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderStyleModule")
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderStyleModule")
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ extern "C" {
|
|||||||
#include "BKE_library.h"
|
#include "BKE_library.h"
|
||||||
#include "BKE_linestyle.h"
|
#include "BKE_linestyle.h"
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_scene.h"
|
|
||||||
#include "BKE_text.h"
|
#include "BKE_text.h"
|
||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
|
|
||||||
@@ -295,8 +294,6 @@ static bool test_edge_type_conditions(struct edge_type_condition *conditions,
|
|||||||
|
|
||||||
static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
|
static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
|
||||||
{
|
{
|
||||||
const bool use_shading_nodes = BKE_scene_use_new_shading_nodes(re->scene);
|
|
||||||
|
|
||||||
// load mesh
|
// load mesh
|
||||||
re->i.infostr = "Freestyle: Mesh loading";
|
re->i.infostr = "Freestyle: Mesh loading";
|
||||||
re->stats_draw(re->sdh, &re->i);
|
re->stats_draw(re->sdh, &re->i);
|
||||||
@@ -331,7 +328,7 @@ static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
|
|||||||
cout << " (" << module_conf->script->name << ")";
|
cout << " (" << module_conf->script->name << ")";
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
controller->InsertStyleModule(layer_count, id_name, module_conf->script, NULL, use_shading_nodes);
|
controller->InsertStyleModule(layer_count, id_name, module_conf->script);
|
||||||
controller->toggleLayer(layer_count, true);
|
controller->toggleLayer(layer_count, true);
|
||||||
layer_count++;
|
layer_count++;
|
||||||
}
|
}
|
||||||
@@ -372,7 +369,7 @@ static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
|
|||||||
(lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl;
|
(lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl;
|
||||||
}
|
}
|
||||||
Text *text = create_lineset_handler(bmain, srl->name, lineset->name);
|
Text *text = create_lineset_handler(bmain, srl->name, lineset->name);
|
||||||
controller->InsertStyleModule(layer_count, lineset->name, text, lineset->linestyle, use_shading_nodes);
|
controller->InsertStyleModule(layer_count, lineset->name, text);
|
||||||
controller->toggleLayer(layer_count, true);
|
controller->toggleLayer(layer_count, true);
|
||||||
if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) {
|
if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) {
|
||||||
++use_ridges_and_valleys;
|
++use_ridges_and_valleys;
|
||||||
@@ -743,8 +740,9 @@ Material *FRS_create_stroke_material(bContext *C, Main *bmain, Scene *scene)
|
|||||||
|
|
||||||
if (!linestyle) {
|
if (!linestyle) {
|
||||||
cout << "FRS_create_stroke_material: No active line style in the current scene" << endl;
|
cout << "FRS_create_stroke_material: No active line style in the current scene" << endl;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle);
|
return BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle->nodetree);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|||||||
@@ -41,38 +41,46 @@ static char BlenderTextureShader___doc__[] =
|
|||||||
"\n"
|
"\n"
|
||||||
"[Texture shader]\n"
|
"[Texture shader]\n"
|
||||||
"\n"
|
"\n"
|
||||||
".. method:: __init__(LineStyleTextureSlot)\n"
|
".. method:: __init__(texture)\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Builds a BlenderTextureShader object.\n"
|
" Builds a BlenderTextureShader object.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" :arg mtex: texture slot to add to stroke shading.\n"
|
" :arg texture: A line style texture slot or a shader node tree to define\n"
|
||||||
" :type mtex: LineStyleTextureSlot\n"
|
" a set of textures.\n"
|
||||||
|
" :type texture: :class:`LineStyleTextureSlot` or :class:`ShaderNodeTree`\n"
|
||||||
"\n"
|
"\n"
|
||||||
".. method:: shade(stroke)\n"
|
".. method:: shade(stroke)\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Assigns a blender texture slot to the stroke shading\n"
|
" Assigns a blender texture slot to the stroke shading in order to\n"
|
||||||
" in order to simulate marks.\n"
|
" simulate marks.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" :arg stroke: A Stroke object.\n"
|
" :arg stroke: A Stroke object.\n"
|
||||||
" :type stroke: :class:`Stroke`\n";
|
" :type stroke: :class:`Stroke`\n";
|
||||||
|
|
||||||
static int BlenderTextureShader___init__(BPy_BlenderTextureShader *self, PyObject *args, PyObject *kwds)
|
static int BlenderTextureShader___init__(BPy_BlenderTextureShader *self, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
static const char *kwlist[] = {"LineStyleTextureSlot", NULL};
|
static const char *kwlist[] = {"texture", NULL};
|
||||||
PyObject *py_mtex;
|
PyObject *obj;
|
||||||
MTex *_mtex;
|
MTex *_mtex;
|
||||||
|
bNodeTree *_nodetree;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_mtex))
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj))
|
||||||
return -1;
|
return -1;
|
||||||
|
_mtex = (MTex *)PyC_RNA_AsPointer(obj, "LineStyleTextureSlot");
|
||||||
_mtex = (MTex*)PyC_RNA_AsPointer(py_mtex, "LineStyleTextureSlot");
|
|
||||||
|
|
||||||
if (_mtex) {
|
if (_mtex) {
|
||||||
self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_mtex);
|
self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_mtex);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
PyErr_Clear();
|
||||||
|
_nodetree = (bNodeTree *)PyC_RNA_AsPointer(obj, "ShaderNodeTree");
|
||||||
|
if (_nodetree) {
|
||||||
|
self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_nodetree);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"expected either 'LineStyleTextureSlot' or 'ShaderNodeTree', "
|
||||||
|
"found '%.200s' instead", Py_TYPE(obj)->tp_name);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------BPy_BlenderTextureShader type definition ------------------------------*/
|
/*-----------------------BPy_BlenderTextureShader type definition ------------------------------*/
|
||||||
|
|||||||
@@ -451,7 +451,13 @@ int ColorNoiseShader::shade(Stroke& stroke) const
|
|||||||
|
|
||||||
int BlenderTextureShader::shade(Stroke& stroke) const
|
int BlenderTextureShader::shade(Stroke& stroke) const
|
||||||
{
|
{
|
||||||
|
if (_mtex)
|
||||||
return stroke.setMTex(_mtex);
|
return stroke.setMTex(_mtex);
|
||||||
|
if (_nodeTree) {
|
||||||
|
stroke.setNodeTree(_nodeTree);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StrokeTextureStepShader::shade(Stroke& stroke) const
|
int StrokeTextureStepShader::shade(Stroke& stroke) const
|
||||||
|
|||||||
@@ -36,7 +36,10 @@
|
|||||||
#include "../geometry/Bezier.h"
|
#include "../geometry/Bezier.h"
|
||||||
#include "../geometry/Geom.h"
|
#include "../geometry/Geom.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
struct MTex;
|
struct MTex;
|
||||||
|
struct bNodeTree;
|
||||||
|
}
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -904,6 +907,7 @@ class BlenderTextureShader : public StrokeShader
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
MTex *_mtex;
|
MTex *_mtex;
|
||||||
|
bNodeTree *_nodeTree;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*! Builds the shader.
|
/*! Builds the shader.
|
||||||
@@ -913,6 +917,17 @@ public:
|
|||||||
BlenderTextureShader(MTex *mtex) : StrokeShader()
|
BlenderTextureShader(MTex *mtex) : StrokeShader()
|
||||||
{
|
{
|
||||||
_mtex = mtex;
|
_mtex = mtex;
|
||||||
|
_nodeTree = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Builds the shader.
|
||||||
|
* \param nodetree
|
||||||
|
* A node tree (of new shading nodes) to define textures.
|
||||||
|
*/
|
||||||
|
BlenderTextureShader(bNodeTree *nodetree) : StrokeShader()
|
||||||
|
{
|
||||||
|
_nodeTree = nodetree;
|
||||||
|
_mtex = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual string getName() const
|
virtual string getName() const
|
||||||
|
|||||||
@@ -30,10 +30,7 @@
|
|||||||
#include "StrokeAdvancedIterators.h"
|
#include "StrokeAdvancedIterators.h"
|
||||||
#include "StrokeRenderer.h"
|
#include "StrokeRenderer.h"
|
||||||
|
|
||||||
#include "DNA_linestyle_types.h"
|
|
||||||
|
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
#include "BKE_linestyle.h"
|
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
|
|
||||||
namespace Freestyle {
|
namespace Freestyle {
|
||||||
@@ -398,11 +395,10 @@ Stroke::Stroke()
|
|||||||
_mediumType = OPAQUE_MEDIUM;
|
_mediumType = OPAQUE_MEDIUM;
|
||||||
_textureId = 0;
|
_textureId = 0;
|
||||||
_textureStep = 1.0;
|
_textureStep = 1.0;
|
||||||
_lineStyle = NULL;
|
|
||||||
_useShadingNodes = false;
|
|
||||||
for (int a = 0; a < MAX_MTEX; a++) {
|
for (int a = 0; a < MAX_MTEX; a++) {
|
||||||
_mtex[a] = NULL;
|
_mtex[a] = NULL;
|
||||||
}
|
}
|
||||||
|
_nodeTree = NULL;
|
||||||
_tips = false;
|
_tips = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,8 +417,6 @@ Stroke::Stroke(const Stroke& iBrother)
|
|||||||
_mediumType = iBrother._mediumType;
|
_mediumType = iBrother._mediumType;
|
||||||
_textureId = iBrother._textureId;
|
_textureId = iBrother._textureId;
|
||||||
_textureStep = iBrother._textureStep;
|
_textureStep = iBrother._textureStep;
|
||||||
_lineStyle = iBrother._lineStyle;
|
|
||||||
_useShadingNodes = iBrother._useShadingNodes;
|
|
||||||
for (int a = 0; a < MAX_MTEX; a++) {
|
for (int a = 0; a < MAX_MTEX; a++) {
|
||||||
if (iBrother._mtex) {
|
if (iBrother._mtex) {
|
||||||
_mtex[a] = iBrother._mtex[a];
|
_mtex[a] = iBrother._mtex[a];
|
||||||
@@ -431,6 +425,7 @@ Stroke::Stroke(const Stroke& iBrother)
|
|||||||
_mtex[a] = NULL;
|
_mtex[a] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_nodeTree = iBrother._nodeTree;
|
||||||
_tips = iBrother._tips;
|
_tips = iBrother._tips;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,11 +755,6 @@ void Stroke::ScaleThickness(float iFactor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stroke::hasTex() const
|
|
||||||
{
|
|
||||||
return BKE_linestyle_use_textures(_lineStyle, _useShadingNodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stroke::Render(const StrokeRenderer *iRenderer)
|
void Stroke::Render(const StrokeRenderer *iRenderer)
|
||||||
{
|
{
|
||||||
StrokeRep rep(this);
|
StrokeRep rep(this);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "DNA_material_types.h"
|
#include "DNA_material_types.h"
|
||||||
|
|
||||||
struct FreestyleLineStyle;
|
struct bNodeTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MAX_MTEX
|
#ifndef MAX_MTEX
|
||||||
@@ -543,10 +543,9 @@ private:
|
|||||||
MediumType _mediumType;
|
MediumType _mediumType;
|
||||||
unsigned int _textureId;
|
unsigned int _textureId;
|
||||||
MTex *_mtex[MAX_MTEX];
|
MTex *_mtex[MAX_MTEX];
|
||||||
|
bNodeTree *_nodeTree;
|
||||||
bool _tips;
|
bool _tips;
|
||||||
Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity
|
Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity
|
||||||
FreestyleLineStyle *_lineStyle;
|
|
||||||
bool _useShadingNodes;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*! default constructor */
|
/*! default constructor */
|
||||||
@@ -645,18 +644,6 @@ public:
|
|||||||
return _mediumType;
|
return _mediumType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Return the line style associated to this Stroke. */
|
|
||||||
inline FreestyleLineStyle *getLineStyle()
|
|
||||||
{
|
|
||||||
return _lineStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Return true if the new shading nodes are used. */
|
|
||||||
inline bool useShadingNodes()
|
|
||||||
{
|
|
||||||
return _useShadingNodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Returns the id of the texture used to simulate th marks system for this Stroke */
|
/*! Returns the id of the texture used to simulate th marks system for this Stroke */
|
||||||
inline unsigned int getTextureId() {return _textureId;}
|
inline unsigned int getTextureId() {return _textureId;}
|
||||||
|
|
||||||
@@ -668,8 +655,17 @@ public:
|
|||||||
return _mtex[idx];
|
return _mtex[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Return the shader node tree to define textures. */
|
||||||
|
inline bNodeTree *getNodeTree()
|
||||||
|
{
|
||||||
|
return _nodeTree;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns true if this Stroke has textures assigned, false otherwise. */
|
/*! Returns true if this Stroke has textures assigned, false otherwise. */
|
||||||
bool hasTex() const;
|
inline bool hasTex() const
|
||||||
|
{
|
||||||
|
return (_mtex && _mtex[0] != NULL) || _nodeTree;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns true if this Stroke uses a texture with tips, false otherwise. */
|
/*! Returns true if this Stroke uses a texture with tips, false otherwise. */
|
||||||
inline bool hasTips() const
|
inline bool hasTips() const
|
||||||
@@ -749,13 +745,6 @@ public:
|
|||||||
/*! sets the 2D length of the Stroke. */
|
/*! sets the 2D length of the Stroke. */
|
||||||
void setLength(float iLength);
|
void setLength(float iLength);
|
||||||
|
|
||||||
/*! sets the line style of the Stroke. */
|
|
||||||
void setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
|
|
||||||
{
|
|
||||||
_lineStyle = iLineStyle;
|
|
||||||
_useShadingNodes = iUseShadingNodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! sets the medium type that must be used for this Stroke. */
|
/*! sets the medium type that must be used for this Stroke. */
|
||||||
inline void setMediumType(MediumType iType)
|
inline void setMediumType(MediumType iType)
|
||||||
{
|
{
|
||||||
@@ -786,6 +775,12 @@ public:
|
|||||||
return -1; /* no free slots */
|
return -1; /* no free slots */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! assigns a node tree (of new shading nodes) to define textures. */
|
||||||
|
inline void setNodeTree(bNodeTree *iNodeTree)
|
||||||
|
{
|
||||||
|
_nodeTree = iNodeTree;
|
||||||
|
}
|
||||||
|
|
||||||
/*! sets the flag telling whether this stroke is using a texture with tips or not. */
|
/*! sets the flag telling whether this stroke is using a texture with tips or not. */
|
||||||
inline void setTips(bool iTips)
|
inline void setTips(bool iTips)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,13 +36,6 @@ StrokeLayer::~StrokeLayer()
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrokeLayer::setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
|
|
||||||
{
|
|
||||||
for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) {
|
|
||||||
(*s)->setLineStyle(iLineStyle, iUseShadingNodes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StrokeLayer::ScaleThickness(float iFactor)
|
void StrokeLayer::ScaleThickness(float iFactor)
|
||||||
{
|
{
|
||||||
for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) {
|
for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) {
|
||||||
|
|||||||
@@ -34,10 +34,6 @@
|
|||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
struct FreestyleLineStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Freestyle {
|
namespace Freestyle {
|
||||||
|
|
||||||
class Stroke;
|
class Stroke;
|
||||||
@@ -105,8 +101,6 @@ public:
|
|||||||
_strokes.push_back(iStroke);
|
_strokes.push_back(iStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes);
|
|
||||||
|
|
||||||
#ifdef WITH_CXX_GUARDEDALLOC
|
#ifdef WITH_CXX_GUARDEDALLOC
|
||||||
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeLayer")
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeLayer")
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -705,8 +705,7 @@ StrokeRep::StrokeRep()
|
|||||||
{
|
{
|
||||||
_stroke = 0;
|
_stroke = 0;
|
||||||
_strokeType = Stroke::OPAQUE_MEDIUM;
|
_strokeType = Stroke::OPAQUE_MEDIUM;
|
||||||
_lineStyle = NULL;
|
_nodeTree = NULL;
|
||||||
_useShadingNodes = false;
|
|
||||||
_hasTex = false;
|
_hasTex = false;
|
||||||
_textureStep = 1.0;
|
_textureStep = 1.0;
|
||||||
for (int a = 0; a < MAX_MTEX; a++) {
|
for (int a = 0; a < MAX_MTEX; a++) {
|
||||||
@@ -728,8 +727,7 @@ StrokeRep::StrokeRep(Stroke *iStroke)
|
|||||||
{
|
{
|
||||||
_stroke = iStroke;
|
_stroke = iStroke;
|
||||||
_strokeType = iStroke->getMediumType();
|
_strokeType = iStroke->getMediumType();
|
||||||
_lineStyle = iStroke->getLineStyle();
|
_nodeTree = iStroke->getNodeTree();
|
||||||
_useShadingNodes = iStroke->useShadingNodes();
|
|
||||||
_hasTex = iStroke->hasTex();
|
_hasTex = iStroke->hasTex();
|
||||||
_textureId = iStroke->getTextureId();
|
_textureId = iStroke->getTextureId();
|
||||||
_textureStep = iStroke->getTextureStep();
|
_textureStep = iStroke->getTextureStep();
|
||||||
@@ -764,8 +762,7 @@ StrokeRep::StrokeRep(const StrokeRep& iBrother)
|
|||||||
_strokeType = iBrother._strokeType;
|
_strokeType = iBrother._strokeType;
|
||||||
_textureId = iBrother._textureId;
|
_textureId = iBrother._textureId;
|
||||||
_textureStep = iBrother._textureStep;
|
_textureStep = iBrother._textureStep;
|
||||||
_lineStyle = iBrother._lineStyle;
|
_nodeTree = iBrother._nodeTree;
|
||||||
_useShadingNodes = iBrother._useShadingNodes;
|
|
||||||
_hasTex = iBrother._hasTex;
|
_hasTex = iBrother._hasTex;
|
||||||
for (int a = 0; a < MAX_MTEX; a++) {
|
for (int a = 0; a < MAX_MTEX; a++) {
|
||||||
if (iBrother._mtex[a]) {
|
if (iBrother._mtex[a]) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "DNA_material_types.h" // for MAX_MTEX
|
#include "DNA_material_types.h" // for MAX_MTEX
|
||||||
struct FreestyleLineStyle;
|
struct bNodeTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Freestyle {
|
namespace Freestyle {
|
||||||
@@ -186,9 +186,8 @@ protected:
|
|||||||
unsigned int _textureId;
|
unsigned int _textureId;
|
||||||
float _textureStep;
|
float _textureStep;
|
||||||
MTex *_mtex[MAX_MTEX];
|
MTex *_mtex[MAX_MTEX];
|
||||||
|
bNodeTree *_nodeTree;
|
||||||
Material *_material;
|
Material *_material;
|
||||||
FreestyleLineStyle *_lineStyle;
|
|
||||||
bool _useShadingNodes;
|
|
||||||
bool _hasTex;
|
bool _hasTex;
|
||||||
|
|
||||||
// float _averageTextureAlpha;
|
// float _averageTextureAlpha;
|
||||||
@@ -226,14 +225,9 @@ public:
|
|||||||
return _material;
|
return _material;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FreestyleLineStyle *getLineStyle() const
|
inline bNodeTree *getNodeTree() const
|
||||||
{
|
{
|
||||||
return _lineStyle;
|
return _nodeTree;
|
||||||
}
|
|
||||||
|
|
||||||
inline bool useShadingNodes() const
|
|
||||||
{
|
|
||||||
return _useShadingNodes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool hasTex() const
|
inline bool hasTex() const
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
virtual ~StyleModule() {}
|
virtual ~StyleModule() {}
|
||||||
|
|
||||||
virtual StrokeLayer *execute()
|
StrokeLayer *execute()
|
||||||
{
|
{
|
||||||
if (!_inter) {
|
if (!_inter) {
|
||||||
cerr << "Error: no interpreter was found to execute the script" << endl;
|
cerr << "Error: no interpreter was found to execute the script" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user