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>2014-05-03 13:51:53 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-05-03 13:54:59 +0400
commitb7f085d9c128f31d576c732c6439b5a71e8922ee (patch)
tree8a1fdc2e95470f61d9121b18b125dc272e87d536 /source/blender/freestyle/intern/stroke
parent6ec2d72eca618be05e9bf0723886b10e6d5efa46 (diff)
Patch D246: Texture Marks for freestyle strokes, written and contributed by Paolo Acampora.
Reviewers: brecht, kjym3, #freestyle Reviewed By: brecht, kjym3 Differential Revision: https://developer.blender.org/D246
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp11
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h58
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp13
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h36
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp242
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h51
6 files changed, 269 insertions, 142 deletions
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index dd9464f12c3..a9138704290 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -449,6 +449,17 @@ int ColorNoiseShader::shade(Stroke& stroke) const
//
///////////////////////////////////////////////////////////////////////////////
+int BlenderTextureShader::shade(Stroke& stroke) const
+{
+ return stroke.setMTex(_mtex);
+}
+
+int StrokeTextureStepShader::shade(Stroke& stroke) const
+{
+ stroke.setTextureStep(_step);
+ return 0;
+}
+
int TextureAssignerShader::shade(Stroke& stroke) const
{
#if 0
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index 5559613debb..9186d164e9b 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -36,6 +36,8 @@
#include "../geometry/Bezier.h"
#include "../geometry/Geom.h"
+struct MTex;
+
using namespace std;
namespace Freestyle {
@@ -894,6 +896,62 @@ public:
virtual int shade(Stroke& stroke) const;
};
+/*! [ Texture Shader ].
+ * Shader to assign texture to the Stroke material.
+ */
+
+class BlenderTextureShader : public StrokeShader
+{
+private:
+ MTex *_mtex;
+
+public:
+ /*! Builds the shader.
+ * \param mtex
+ * The blender texture to use.
+ */
+ BlenderTextureShader(MTex *mtex) : StrokeShader()
+ {
+ _mtex = mtex;
+ }
+
+ virtual string getName() const
+ {
+ return "BlenderTextureShader";
+ }
+
+ /*! The shading method */
+ virtual int shade(Stroke& stroke) const;
+};
+
+/*! [ Texture Shader ].
+ * Shader to assign texture to the Stroke material.
+ */
+
+class StrokeTextureStepShader : public StrokeShader
+{
+private:
+ float _step;
+
+public:
+ /*! Builds the shader.
+ * \param id
+ * The number of the preset to use.
+ */
+ StrokeTextureStepShader(float step) : StrokeShader()
+ {
+ _step = step;
+ }
+
+ virtual string getName() const
+ {
+ return "StrokeTextureStepShader";
+ }
+
+ /*! The shading method */
+ virtual int shade(Stroke& stroke) const;
+};
+
} // end of namespace StrokeShaders
} /* namespace Freestyle */
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index 86625e67405..9ed2cab8448 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -393,6 +393,10 @@ Stroke::Stroke()
//_mediumType = DEFAULT_STROKE;
_mediumType = OPAQUE_MEDIUM;
_textureId = 0;
+ _textureStep = 1.0;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ _mtex[a] = NULL;
+ }
_tips = false;
_rep = NULL;
}
@@ -411,6 +415,15 @@ Stroke::Stroke(const Stroke& iBrother)
_sampling = iBrother._sampling;
_mediumType = iBrother._mediumType;
_textureId = iBrother._textureId;
+ _textureStep = iBrother._textureStep;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (iBrother._mtex) {
+ _mtex[a] = iBrother._mtex[a];
+ }
+ else {
+ _mtex[a] = NULL;
+ }
+ }
_tips = iBrother._tips;
if (iBrother._rep)
_rep = new StrokeRep(*(iBrother._rep));
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 66dc5a1acf4..27a105bb1cc 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -43,6 +43,14 @@
#include "MEM_guardedalloc.h"
#endif
+extern "C" {
+#include "DNA_material_types.h"
+}
+
+#ifndef MAX_MTEX
+#define MAX_MTEX 18
+#endif
+
namespace Freestyle {
//
@@ -528,9 +536,11 @@ private:
float _Length; // The stroke length
viewedge_container _ViewEdges;
float _sampling;
+ float _textureStep;
// StrokeRenderer *_renderer; // mark implementation OpenGL renderer
MediumType _mediumType;
unsigned int _textureId;
+ MTex *_mtex[MAX_MTEX];
bool _tips;
Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity
StrokeRep *_rep;
@@ -635,6 +645,13 @@ public:
/*! Returns the id of the texture used to simulate th marks system for this Stroke */
inline unsigned int getTextureId() {return _textureId;}
+ /*! Returns the spacing of texture coordinates along the stroke lenght */
+ inline float getTextureStep() {return _textureStep;}
+
+ /*! Returns the texture used at given index to simulate the marks system for this Stroke */
+ inline MTex *getMTex(int idx) {
+ return _mtex[idx];}
+
/*! Returns true if this Stroke uses a texture with tips, false otherwise. */
inline bool hasTips() const
{
@@ -725,6 +742,25 @@ public:
_textureId = id;
}
+ /*! sets the spacing of texture coordinates along the stroke lenght. */
+ inline void setTextureStep(float step)
+ {
+ _textureStep = step;
+ }
+
+ /*! assigns a blender texture to the first available slot. */
+ inline int setMTex(MTex *mtex)
+ {
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (!_mtex[a]) {
+ _mtex[a] = mtex;
+
+ return 0;
+ }
+ }
+ return -1; /* no free slots */
+ }
+
/*! sets the flag telling whether this stroke is using a texture with tips or not. */
inline void setTips(bool iTips)
{
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index 1b9ab725ab9..4cfdd860d20 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -45,6 +45,7 @@ StrokeVertexRep::StrokeVertexRep(const StrokeVertexRep& iBrother)
{
_point2d = iBrother._point2d;
_texCoord = iBrother._texCoord;
+ _texCoord_w_tips = iBrother._texCoord_w_tips;
_color = iBrother._color;
_alpha = iBrother._alpha;
}
@@ -53,13 +54,13 @@ StrokeVertexRep::StrokeVertexRep(const StrokeVertexRep& iBrother)
// STRIP
/////////////////////////////////////
-Strip::Strip(const vector<StrokeVertex*>& iStrokeVertices, bool hasTips, bool beginTip, bool endTip)
+Strip::Strip(const vector<StrokeVertex*>& iStrokeVertices, bool hasTips, bool beginTip, bool endTip, float texStep)
{
createStrip(iStrokeVertices);
- if (!hasTips)
- computeTexCoord (iStrokeVertices);
- else
- computeTexCoordWithTips (iStrokeVertices, beginTip, endTip);
+
+ // We compute both kinds of coordinates to use different kinds of textures
+ computeTexCoord (iStrokeVertices, texStep);
+ computeTexCoordWithTips (iStrokeVertices, beginTip, endTip, texStep);
}
Strip::Strip(const Strip& iBrother)
@@ -485,21 +486,19 @@ void Strip::cleanUpSingularities (const vector<StrokeVertex*>& iStrokeVertices)
// Texture coordinates
////////////////////////////////
-void Strip::computeTexCoord (const vector<StrokeVertex *>& iStrokeVertices)
+void Strip::computeTexCoord (const vector<StrokeVertex *>& iStrokeVertices, float texStep)
{
vector<StrokeVertex *>::const_iterator v, vend;
StrokeVertex *sv;
int i = 0;
for (v = iStrokeVertices.begin(), vend = iStrokeVertices.end(); v != vend; v++) {
sv = (*v);
- _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / _averageThickness), 0));
- _vertices[i]->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
+ _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / (_averageThickness * texStep)), 0));
+ _vertices[i]->setColor(Vec3r(sv->attribute().getColorRGB()));
_vertices[i]->setAlpha(sv->attribute().getAlpha());
i++;
- _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / _averageThickness), 1));
- _vertices[i]->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
+ _vertices[i]->setTexCoord(Vec2r((real)(sv->curvilinearAbscissa() / (_averageThickness * texStep)), 1));
+ _vertices[i]->setColor(Vec3r(sv->attribute().getColorRGB()));
_vertices[i]->setAlpha(sv->attribute().getAlpha());
i++;
#if 0
@@ -509,23 +508,23 @@ void Strip::computeTexCoord (const vector<StrokeVertex *>& iStrokeVertices)
}
}
-void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd)
+void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd, float texStep)
{
- //soc unused - unsigned int sizeStrip = _vertices.size() + 8; //for the transition between the tip and the body
vector<StrokeVertex*>::const_iterator v, vend;
StrokeVertex *sv = NULL;
+ StrokeVertexRep *tvRep[2] = {NULL};
+
+ float l, fact, t;
+ float u = 0, uPrev = 0;
+ int tiles;
+ int i = 0;
+ float spacedThickness = _averageThickness * texStep;
v = iStrokeVertices.begin();
vend = iStrokeVertices.end();
- float l = (*v)->strokeLength() / _averageThickness;
- int tiles = int(l);
- float fact = (float(tiles) + 0.5) / l;
- //soc unused - float uTip2 = float(tiles) + 0.25;
- float u = 0;
- float uPrev = 0;
- int i = 0;
- float t;
- StrokeVertexRep *tvRep1, *tvRep2;
+ l = (*v)->strokeLength() / spacedThickness;
+ tiles = int(l + 0.5); // round to the nearest
+ fact = (float(tiles) + 0.5) / l;
#if 0
cerr << "l=" << l << " tiles=" << tiles << " _averageThicnkess="
@@ -538,166 +537,117 @@ void Strip::computeTexCoordWithTips (const vector<StrokeVertex*>& iStrokeVertice
for (; v != vend; v++) {
sv = (*v);
svRep = *currentSV;
- u = sv->curvilinearAbscissa() / _averageThickness * fact;
+ u = sv->curvilinearAbscissa() / spacedThickness * fact;
if (u > 0.25)
break;
- svRep->setTexCoord(Vec2r((real)u, 0.5));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0.5), true);
i++;
++currentSV;
svRep = *currentSV;
- svRep->setTexCoord(Vec2r((real)u, 1));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 1), true);
i++;
++currentSV;
uPrev = u;
}
- //first transition vertex
+ // first transition vertex
if (fabs(u - uPrev) > ZERO)
t = (0.25 - uPrev) / (u - uPrev);
else
t = 0;
-#if 0
- if (!tiles)
- t = 0.5;
-#endif
- tvRep1 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d()));
- tvRep1->setTexCoord(Vec2r(0.25, 0.5));
- tvRep1->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep1->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
-
- tvRep2 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t *_vertices[i]->point2d()));
- tvRep2->setTexCoord(Vec2r(0.25, 1));
- tvRep2->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep2->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
-
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
+ tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
+ // v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r(0.25, 0.5 * (k + 1)), true);
+ tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
+ tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
// copy the vertices with different texture coordinates
- tvRep1 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep1->setTexCoord(Vec2r(0.25, 0));
- tvRep1->setColor(_vertices[i - 2]->color());
- tvRep1->setAlpha(_vertices[i - 2]->alpha());
- i++;
-
- tvRep2 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep2->setTexCoord(Vec2r(0.25, 0.5));
- tvRep2->setColor(_vertices[i - 2]->color());
- tvRep2->setAlpha(_vertices[i - 2]->alpha());
- i++;
-
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
+ // v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r(0.0, 0.5 * k), true); // FIXED u coord
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
}
uPrev = 0;
- //body of the stroke
+ // body of the stroke
for (; v != vend; v++) {
sv = (*v);
svRep = *currentSV;
- u = sv->curvilinearAbscissa() / _averageThickness * fact - 0.25;
+ u = sv->curvilinearAbscissa() / spacedThickness * fact - 0.25;
if (u > tiles)
break;
- svRep->setTexCoord(Vec2r((real)u, 0));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0), true);
i++;
++currentSV;
svRep = *currentSV;
- svRep->setTexCoord(Vec2r((real)u, 0.5));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0.5), true);
i++;
++currentSV;
uPrev = u;
}
if (tipEnd) {
- //second transition vertex
- if ((fabs(u - uPrev) > ZERO))
+ // second transition vertex
+ if (fabs(u - uPrev) > ZERO)
t = (float(tiles) - uPrev) / (u - uPrev);
else
t = 0;
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d());
+ tvRep[k]->setTexCoord((1 - t) * _vertices[i - 2]->texCoord() + t * _vertices[i]->texCoord());
+ // v coord is 0.0 for tvRep[0], 0.5 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r((real)tiles, 0.5 * k), true); // FIXED u coord
+ tvRep[k]->setColor((1 - t) * _vertices[i - 2]->color() + t * Vec3r(sv->attribute().getColorRGB()));
+ tvRep[k]->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
- tvRep1 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d()));
- tvRep1->setTexCoord(Vec2r((real)tiles, 0));
- tvRep1->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep1->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
-
- tvRep2 = new StrokeVertexRep(Vec2r((1 - t) * _vertices[i - 2]->point2d() + t * _vertices[i]->point2d()));
- tvRep2->setTexCoord(Vec2r((real)tiles, 0.5));
- tvRep2->setColor(Vec3r((1 - t) * _vertices[i - 2]->color() +
- t * Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2])));
- tvRep2->setAlpha((1 - t) * _vertices[i - 2]->alpha() + t * sv->attribute().getAlpha());
- i++;
-
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
-
- //copy the vertices with different texture coordinates
- tvRep1 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep1->setTexCoord(Vec2r(0.75, 0.5));
- tvRep1->setColor(_vertices[i - 2]->color());
- tvRep1->setAlpha(_vertices[i - 2]->alpha());
- i++;
-
- tvRep2 = new StrokeVertexRep(_vertices[i - 2]->point2d());
- tvRep2->setTexCoord(Vec2r(0.75, 1));
- tvRep2->setColor(_vertices[i - 2]->color());
- tvRep2->setAlpha(_vertices[i - 2]->alpha());
- i++;
-
- currentSV = _vertices.insert(currentSV, tvRep1);
- ++currentSV;
- currentSV = _vertices.insert(currentSV, tvRep2);
- ++currentSV;
+ // copy the vertices with different texture coordinates
+ for (int k = 0; k < 2; k++) {
+ tvRep[k] = new StrokeVertexRep(*(_vertices[i - 2]));
+ // v coord is 0.5 for tvRep[0], 1.0 for tvRep[1]
+ tvRep[k]->setTexCoord(Vec2r(0.75, 0.5 * (k + 1)), true);
+ i++;
+ }
+ for (int k = 0; k < 2; k++) {
+ currentSV = _vertices.insert(currentSV, tvRep[k]);
+ ++currentSV;
+ }
- //end tip
+ // end tip
for (; v != vend; v++) {
- sv = (*v);
+ sv = (*v);
svRep = *currentSV;
- u = 0.75 + sv->curvilinearAbscissa() / _averageThickness * fact - float(tiles) - 0.25;
+ u = 0.75 + sv->curvilinearAbscissa() / spacedThickness * fact - float(tiles) - 0.25;
- svRep->setTexCoord(Vec2r((real)u, 0.5));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 0.5), true);
i++;
++currentSV;
svRep = *currentSV;
- svRep->setTexCoord(Vec2r((real)u, 1));
- svRep->setColor(Vec3r(sv->attribute().getColor()[0], sv->attribute().getColor()[1],
- sv->attribute().getColor()[2]));
- svRep->setAlpha(sv->attribute().getAlpha());
+ svRep->setTexCoord(Vec2r((real)u, 1), true);
i++;
++currentSV;
}
@@ -729,6 +679,10 @@ StrokeRep::StrokeRep()
{
_stroke = 0;
_strokeType = Stroke::OPAQUE_MEDIUM;
+ _textureStep = 1.0;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ _mtex[a] = NULL;
+ }
TextureManager *ptm = TextureManager::getInstance();
if (ptm)
_textureId = ptm->getDefaultTextureId();
@@ -746,6 +700,15 @@ StrokeRep::StrokeRep(Stroke *iStroke)
_stroke = iStroke;
_strokeType = iStroke->getMediumType();
_textureId = iStroke->getTextureId();
+ _textureStep = iStroke->getTextureStep();
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (iStroke->getMTex(a)) {
+ _mtex[a] = iStroke->getMTex(a);
+ }
+ else {
+ _mtex[a] = NULL;
+ }
+ }
if (_textureId == 0) {
TextureManager *ptm = TextureManager::getInstance();
if (ptm)
@@ -768,6 +731,15 @@ StrokeRep::StrokeRep(const StrokeRep& iBrother)
_stroke = iBrother._stroke;
_strokeType = iBrother._strokeType;
_textureId = iBrother._textureId;
+ _textureStep = iBrother._textureStep;
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (iBrother._mtex[a]) {
+ _mtex[a] = iBrother._mtex[a];
+ }
+ else {
+ _mtex[a] = NULL;
+ }
+ }
for (vector<Strip*>::const_iterator s = iBrother._strips.begin(), send = iBrother._strips.end();
s != send;
++s)
@@ -811,7 +783,7 @@ void StrokeRep::create()
end = true;
}
if ((!strip.empty()) && (strip.size() > 1)) {
- _strips.push_back(new Strip(strip, _stroke->hasTips(), first, end));
+ _strips.push_back(new Strip(strip, _stroke->hasTips(), first, end, _stroke->getTextureStep()));
strip.clear();
}
first = false;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index d01b27215fe..8bbbd9240cb 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -36,6 +36,10 @@
#include "MEM_guardedalloc.h"
#endif
+extern "C" {
+#include "DNA_material_types.h"
+}
+
namespace Freestyle {
using namespace Geometry;
@@ -78,9 +82,13 @@ public:
return _point2d;
}
- inline Vec2r& texCoord()
+ inline Vec2r& texCoord(bool tips=false)
{
- return _texCoord;
+ if (tips) {
+ return _texCoord_w_tips;
+ }
+ else
+ return _texCoord;
}
inline Vec3r& color()
@@ -98,9 +106,14 @@ public:
_point2d = p;
}
- inline void setTexCoord(const Vec2r& p)
+ inline void setTexCoord(const Vec2r& p, bool tips=false)
{
- _texCoord = p;
+ if (tips) {
+ _texCoord_w_tips = p;
+ }
+ else {
+ _texCoord = p;
+ }
}
inline void setColor(const Vec3r& p)
@@ -116,6 +129,7 @@ public:
protected:
Vec2r _point2d;
Vec2r _texCoord;
+ Vec2r _texCoord_w_tips;
Vec3r _color;
float _alpha;
@@ -135,15 +149,15 @@ protected:
public:
Strip(const std::vector<StrokeVertex*>& iStrokeVertices, bool hasTips = false,
- bool tipBegin = false, bool tipEnd = false);
+ bool tipBegin = false, bool tipEnd = false, float texStep = 1.0);
Strip(const Strip& iBrother);
virtual ~Strip();
protected:
void createStrip(const std::vector<StrokeVertex*>& iStrokeVertices);
void cleanUpSingularities(const std::vector<StrokeVertex*>& iStrokeVertices);
- void computeTexCoord (const std::vector<StrokeVertex*>& iStrokeVertices);
- void computeTexCoordWithTips (const std::vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd);
+ void computeTexCoord (const std::vector<StrokeVertex*>& iStrokeVertices, float texStep);
+ void computeTexCoordWithTips (const std::vector<StrokeVertex*>& iStrokeVertices, bool tipBegin, bool tipEnd, float texStep);
public:
inline int sizeStrip() const
@@ -168,6 +182,9 @@ protected:
vector<Strip*> _strips;
Stroke::MediumType _strokeType;
unsigned int _textureId;
+ float _textureStep;
+ MTex *_mtex[MAX_MTEX];
+ Material *_material;
// float _averageTextureAlpha;
@@ -194,6 +211,16 @@ public:
return _textureId;
}
+ inline MTex *getMTex(int idx) const
+ {
+ return _mtex[idx];
+ }
+
+ inline Material *getMaterial() const
+ {
+ return _material;
+ }
+
inline vector<Strip*>& getStrips()
{
return _strips;
@@ -220,6 +247,16 @@ public:
_textureId = textureId;
}
+ inline void setMaterial(Material *mat)
+ {
+ _material = mat;
+ }
+ /*
+ inline void setMTex(int idx, MTex *mtex_ptr)
+ {
+ _mtex[idx] = mtex_ptr;
+ }*/
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRep")
#endif