1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2010 Blender Foundation. 17 * All rights reserved. 18 */ 19 20 #pragma once 21 22 /** \file 23 * \ingroup DNA 24 */ 25 26 #include "DNA_ID.h" 27 #include "DNA_listBase.h" 28 29 #ifndef MAX_MTEX 30 # define MAX_MTEX 18 31 #endif 32 33 /* texco (also in DNA_material_types.h) */ 34 #define TEXCO_STROKE 16 /* actually its UV */ 35 36 struct AnimData; 37 struct ColorBand; 38 struct CurveMapping; 39 struct MTex; 40 struct Object; 41 struct bNodeTree; 42 43 typedef struct LineStyleModifier { 44 struct LineStyleModifier *next, *prev; 45 46 /** MAX_NAME. */ 47 char name[64]; 48 int type; 49 float influence; 50 int flags; 51 int blend; 52 } LineStyleModifier; 53 54 /* LineStyleModifier::type */ 55 #define LS_MODIFIER_ALONG_STROKE 1 56 #define LS_MODIFIER_DISTANCE_FROM_CAMERA 2 57 #define LS_MODIFIER_DISTANCE_FROM_OBJECT 3 58 #define LS_MODIFIER_MATERIAL 4 59 #define LS_MODIFIER_SAMPLING 5 60 #define LS_MODIFIER_BEZIER_CURVE 6 61 #define LS_MODIFIER_SINUS_DISPLACEMENT 7 62 #define LS_MODIFIER_SPATIAL_NOISE 8 63 #define LS_MODIFIER_PERLIN_NOISE_1D 9 64 #define LS_MODIFIER_PERLIN_NOISE_2D 10 65 #define LS_MODIFIER_BACKBONE_STRETCHER 11 66 #define LS_MODIFIER_TIP_REMOVER 12 67 #define LS_MODIFIER_CALLIGRAPHY 13 68 #define LS_MODIFIER_POLYGONIZATION 14 69 #define LS_MODIFIER_GUIDING_LINES 15 70 #define LS_MODIFIER_BLUEPRINT 16 71 #define LS_MODIFIER_2D_OFFSET 17 72 #define LS_MODIFIER_2D_TRANSFORM 18 73 #define LS_MODIFIER_TANGENT 19 74 #define LS_MODIFIER_NOISE 20 75 #define LS_MODIFIER_CREASE_ANGLE 21 76 #define LS_MODIFIER_SIMPLIFICATION 22 77 #define LS_MODIFIER_CURVATURE_3D 23 78 #define LS_MODIFIER_NUM 24 79 80 /* LineStyleModifier::flags */ 81 #define LS_MODIFIER_ENABLED 1 82 #define LS_MODIFIER_EXPANDED 2 83 84 /* flags (for color) */ 85 #define LS_MODIFIER_USE_RAMP 1 86 87 /* flags (for alpha & thickness) */ 88 #define LS_MODIFIER_USE_CURVE 1 89 #define LS_MODIFIER_INVERT 2 90 91 /* flags (for asymmetric thickness application) */ 92 #define LS_THICKNESS_ASYMMETRIC 1 93 94 /* blend (for alpha & thickness) */ 95 #define LS_VALUE_BLEND 0 96 #define LS_VALUE_ADD 1 97 #define LS_VALUE_MULT 2 98 #define LS_VALUE_SUB 3 99 #define LS_VALUE_DIV 4 100 #define LS_VALUE_DIFF 5 101 #define LS_VALUE_MIN 6 102 #define LS_VALUE_MAX 7 103 104 /* Along Stroke modifiers */ 105 106 typedef struct LineStyleColorModifier_AlongStroke { 107 struct LineStyleModifier modifier; 108 109 struct ColorBand *color_ramp; 110 } LineStyleColorModifier_AlongStroke; 111 112 typedef struct LineStyleAlphaModifier_AlongStroke { 113 struct LineStyleModifier modifier; 114 115 struct CurveMapping *curve; 116 int flags; 117 char _pad[4]; 118 } LineStyleAlphaModifier_AlongStroke; 119 120 typedef struct LineStyleThicknessModifier_AlongStroke { 121 struct LineStyleModifier modifier; 122 123 struct CurveMapping *curve; 124 int flags; 125 float value_min, value_max; 126 char _pad[4]; 127 } LineStyleThicknessModifier_AlongStroke; 128 129 /* Distance from Camera modifiers */ 130 131 typedef struct LineStyleColorModifier_DistanceFromCamera { 132 struct LineStyleModifier modifier; 133 134 struct ColorBand *color_ramp; 135 float range_min, range_max; 136 } LineStyleColorModifier_DistanceFromCamera; 137 138 typedef struct LineStyleAlphaModifier_DistanceFromCamera { 139 struct LineStyleModifier modifier; 140 141 struct CurveMapping *curve; 142 int flags; 143 float range_min, range_max; 144 char _pad[4]; 145 } LineStyleAlphaModifier_DistanceFromCamera; 146 147 typedef struct LineStyleThicknessModifier_DistanceFromCamera { 148 struct LineStyleModifier modifier; 149 150 struct CurveMapping *curve; 151 int flags; 152 float range_min, range_max; 153 float value_min, value_max; 154 char _pad[4]; 155 } LineStyleThicknessModifier_DistanceFromCamera; 156 157 /* Distance from Object modifiers */ 158 159 typedef struct LineStyleColorModifier_DistanceFromObject { 160 struct LineStyleModifier modifier; 161 162 struct Object *target; 163 struct ColorBand *color_ramp; 164 float range_min, range_max; 165 } LineStyleColorModifier_DistanceFromObject; 166 167 typedef struct LineStyleAlphaModifier_DistanceFromObject { 168 struct LineStyleModifier modifier; 169 170 struct Object *target; 171 struct CurveMapping *curve; 172 int flags; 173 float range_min, range_max; 174 char _pad[4]; 175 } LineStyleAlphaModifier_DistanceFromObject; 176 177 typedef struct LineStyleThicknessModifier_DistanceFromObject { 178 struct LineStyleModifier modifier; 179 180 struct Object *target; 181 struct CurveMapping *curve; 182 int flags; 183 float range_min, range_max; 184 float value_min, value_max; 185 char _pad[4]; 186 } LineStyleThicknessModifier_DistanceFromObject; 187 188 /* 3D curvature modifiers */ 189 190 typedef struct LineStyleColorModifier_Curvature_3D { 191 struct LineStyleModifier modifier; 192 193 float min_curvature, max_curvature; 194 struct ColorBand *color_ramp; 195 float range_min, range_max; 196 } LineStyleColorModifier_Curvature_3D; 197 198 typedef struct LineStyleAlphaModifier_Curvature_3D { 199 struct LineStyleModifier modifier; 200 201 struct CurveMapping *curve; 202 int flags; 203 float min_curvature, max_curvature; 204 char _pad[4]; 205 } LineStyleAlphaModifier_Curvature_3D; 206 207 typedef struct LineStyleThicknessModifier_Curvature_3D { 208 struct LineStyleModifier modifier; 209 210 struct CurveMapping *curve; 211 int flags; 212 char _pad[4]; 213 float min_curvature, max_curvature; 214 float min_thickness, max_thickness; 215 } LineStyleThicknessModifier_Curvature_3D; 216 217 /* Noise modifiers (for color, alpha and thickness) */ 218 219 typedef struct LineStyleColorModifier_Noise { 220 struct LineStyleModifier modifier; 221 222 struct ColorBand *color_ramp; 223 float period, amplitude; 224 int seed; 225 char _pad[4]; 226 } LineStyleColorModifier_Noise; 227 228 typedef struct LineStyleAlphaModifier_Noise { 229 struct LineStyleModifier modifier; 230 231 struct CurveMapping *curve; 232 int flags; 233 float period, amplitude; 234 int seed; 235 } LineStyleAlphaModifier_Noise; 236 237 typedef struct LineStyleThicknessModifier_Noise { 238 struct LineStyleModifier modifier; 239 240 float period, amplitude; 241 int flags; 242 int seed; 243 } LineStyleThicknessModifier_Noise; 244 245 /* Crease Angle modifiers */ 246 247 typedef struct LineStyleColorModifier_CreaseAngle { 248 struct LineStyleModifier modifier; 249 250 struct ColorBand *color_ramp; 251 float min_angle, max_angle; 252 } LineStyleColorModifier_CreaseAngle; 253 254 typedef struct LineStyleAlphaModifier_CreaseAngle { 255 struct LineStyleModifier modifier; 256 257 struct CurveMapping *curve; 258 int flags; 259 float min_angle, max_angle; 260 char _pad[4]; 261 } LineStyleAlphaModifier_CreaseAngle; 262 263 typedef struct LineStyleThicknessModifier_CreaseAngle { 264 struct LineStyleModifier modifier; 265 266 struct CurveMapping *curve; 267 int flags; 268 char _pad[4]; 269 float min_angle, max_angle; 270 float min_thickness, max_thickness; 271 } LineStyleThicknessModifier_CreaseAngle; 272 273 /* Tangent modifiers */ 274 275 typedef struct LineStyleColorModifier_Tangent { 276 struct LineStyleModifier modifier; 277 278 struct ColorBand *color_ramp; 279 } LineStyleColorModifier_Tangent; 280 281 typedef struct LineStyleAlphaModifier_Tangent { 282 struct LineStyleModifier modifier; 283 284 struct CurveMapping *curve; 285 int flags; 286 char _pad[4]; 287 } LineStyleAlphaModifier_Tangent; 288 289 typedef struct LineStyleThicknessModifier_Tangent { 290 struct LineStyleModifier modifier; 291 292 struct CurveMapping *curve; 293 int flags; 294 float min_thickness, max_thickness; 295 char _pad[4]; 296 } LineStyleThicknessModifier_Tangent; 297 298 /* Material modifiers */ 299 300 /* mat_attr */ 301 #define LS_MODIFIER_MATERIAL_DIFF 1 302 #define LS_MODIFIER_MATERIAL_DIFF_R 2 303 #define LS_MODIFIER_MATERIAL_DIFF_G 3 304 #define LS_MODIFIER_MATERIAL_DIFF_B 4 305 #define LS_MODIFIER_MATERIAL_SPEC 5 306 #define LS_MODIFIER_MATERIAL_SPEC_R 6 307 #define LS_MODIFIER_MATERIAL_SPEC_G 7 308 #define LS_MODIFIER_MATERIAL_SPEC_B 8 309 #define LS_MODIFIER_MATERIAL_SPEC_HARD 9 310 #define LS_MODIFIER_MATERIAL_ALPHA 10 311 #define LS_MODIFIER_MATERIAL_LINE 11 312 #define LS_MODIFIER_MATERIAL_LINE_R 12 313 #define LS_MODIFIER_MATERIAL_LINE_G 13 314 #define LS_MODIFIER_MATERIAL_LINE_B 14 315 #define LS_MODIFIER_MATERIAL_LINE_A 15 316 317 typedef struct LineStyleColorModifier_Material { 318 struct LineStyleModifier modifier; 319 320 struct ColorBand *color_ramp; 321 int flags; 322 int mat_attr; 323 } LineStyleColorModifier_Material; 324 325 typedef struct LineStyleAlphaModifier_Material { 326 struct LineStyleModifier modifier; 327 328 struct CurveMapping *curve; 329 int flags; 330 int mat_attr; 331 } LineStyleAlphaModifier_Material; 332 333 typedef struct LineStyleThicknessModifier_Material { 334 struct LineStyleModifier modifier; 335 336 struct CurveMapping *curve; 337 int flags; 338 float value_min, value_max; 339 int mat_attr; 340 } LineStyleThicknessModifier_Material; 341 342 /* Geometry modifiers */ 343 344 typedef struct LineStyleGeometryModifier_Sampling { 345 struct LineStyleModifier modifier; 346 347 float sampling; 348 char _pad[4]; 349 } LineStyleGeometryModifier_Sampling; 350 351 typedef struct LineStyleGeometryModifier_BezierCurve { 352 struct LineStyleModifier modifier; 353 354 float error; 355 char _pad[4]; 356 } LineStyleGeometryModifier_BezierCurve; 357 358 typedef struct LineStyleGeometryModifier_SinusDisplacement { 359 struct LineStyleModifier modifier; 360 361 float wavelength, amplitude, phase; 362 char _pad[4]; 363 } LineStyleGeometryModifier_SinusDisplacement; 364 365 /* LineStyleGeometryModifier_SpatialNoise::flags */ 366 #define LS_MODIFIER_SPATIAL_NOISE_SMOOTH 1 367 #define LS_MODIFIER_SPATIAL_NOISE_PURERANDOM 2 368 369 typedef struct LineStyleGeometryModifier_SpatialNoise { 370 struct LineStyleModifier modifier; 371 372 float amplitude, scale; 373 unsigned int octaves; 374 int flags; 375 } LineStyleGeometryModifier_SpatialNoise; 376 377 typedef struct LineStyleGeometryModifier_PerlinNoise1D { 378 struct LineStyleModifier modifier; 379 380 float frequency, amplitude; 381 /** In radians!. */ 382 float angle; 383 unsigned int octaves; 384 int seed; 385 char _pad1[4]; 386 } LineStyleGeometryModifier_PerlinNoise1D; 387 388 typedef struct LineStyleGeometryModifier_PerlinNoise2D { 389 struct LineStyleModifier modifier; 390 391 float frequency, amplitude; 392 /** In radians!. */ 393 float angle; 394 unsigned int octaves; 395 int seed; 396 char _pad1[4]; 397 } LineStyleGeometryModifier_PerlinNoise2D; 398 399 typedef struct LineStyleGeometryModifier_BackboneStretcher { 400 struct LineStyleModifier modifier; 401 402 float backbone_length; 403 char _pad[4]; 404 } LineStyleGeometryModifier_BackboneStretcher; 405 406 typedef struct LineStyleGeometryModifier_TipRemover { 407 struct LineStyleModifier modifier; 408 409 float tip_length; 410 char _pad[4]; 411 } LineStyleGeometryModifier_TipRemover; 412 413 typedef struct LineStyleGeometryModifier_Polygonalization { 414 struct LineStyleModifier modifier; 415 416 float error; 417 char _pad[4]; 418 } LineStyleGeometryModifier_Polygonalization; 419 420 typedef struct LineStyleGeometryModifier_GuidingLines { 421 struct LineStyleModifier modifier; 422 423 float offset; 424 char _pad[4]; 425 } LineStyleGeometryModifier_GuidingLines; 426 427 /* LineStyleGeometryModifier_BluePrintLines::shape */ 428 #define LS_MODIFIER_BLUEPRINT_CIRCLES 1 429 #define LS_MODIFIER_BLUEPRINT_ELLIPSES 2 430 #define LS_MODIFIER_BLUEPRINT_SQUARES 4 431 432 typedef struct LineStyleGeometryModifier_Blueprint { 433 struct LineStyleModifier modifier; 434 435 int flags; 436 unsigned int rounds; 437 float backbone_length; 438 unsigned int random_radius; 439 unsigned int random_center; 440 unsigned int random_backbone; 441 } LineStyleGeometryModifier_Blueprint; 442 443 typedef struct LineStyleGeometryModifier_2DOffset { 444 struct LineStyleModifier modifier; 445 446 float start, end; 447 float x, y; 448 } LineStyleGeometryModifier_2DOffset; 449 450 /* LineStyleGeometryModifier_2DTransform::pivot */ 451 #define LS_MODIFIER_2D_TRANSFORM_PIVOT_CENTER 1 452 #define LS_MODIFIER_2D_TRANSFORM_PIVOT_START 2 453 #define LS_MODIFIER_2D_TRANSFORM_PIVOT_END 3 454 #define LS_MODIFIER_2D_TRANSFORM_PIVOT_PARAM 4 455 #define LS_MODIFIER_2D_TRANSFORM_PIVOT_ABSOLUTE 5 456 457 typedef struct LineStyleGeometryModifier_2DTransform { 458 struct LineStyleModifier modifier; 459 460 int pivot; 461 float scale_x, scale_y; 462 /** In radians!. */ 463 float angle; 464 float pivot_u; 465 float pivot_x, pivot_y; 466 char _pad[4]; 467 } LineStyleGeometryModifier_2DTransform; 468 469 typedef struct LineStyleGeometryModifier_Simplification { 470 struct LineStyleModifier modifier; 471 472 float tolerance; 473 char _pad[4]; 474 } LineStyleGeometryModifier_Simplification; 475 476 /* Calligraphic thickness modifier */ 477 478 typedef struct LineStyleThicknessModifier_Calligraphy { 479 struct LineStyleModifier modifier; 480 481 float min_thickness, max_thickness; 482 /** In radians!. */ 483 float orientation; 484 char _pad[4]; 485 } LineStyleThicknessModifier_Calligraphy; 486 487 /* FreestyleLineStyle::panel */ 488 #define LS_PANEL_STROKES 1 489 #define LS_PANEL_COLOR 2 490 #define LS_PANEL_ALPHA 3 491 #define LS_PANEL_THICKNESS 4 492 #define LS_PANEL_GEOMETRY 5 493 #define LS_PANEL_TEXTURE 6 494 #define LS_PANEL_MISC 7 495 496 /* FreestyleLineStyle::flag */ 497 #define LS_DS_EXPAND (1 << 0) /* for animation editors */ 498 #define LS_SAME_OBJECT (1 << 1) 499 #define LS_DASHED_LINE (1 << 2) 500 #define LS_MATERIAL_BOUNDARY (1 << 3) 501 #define LS_MIN_2D_LENGTH (1 << 4) 502 #define LS_MAX_2D_LENGTH (1 << 5) 503 #define LS_NO_CHAINING (1 << 6) 504 #define LS_MIN_2D_ANGLE (1 << 7) 505 #define LS_MAX_2D_ANGLE (1 << 8) 506 #define LS_SPLIT_LENGTH (1 << 9) 507 #define LS_SPLIT_PATTERN (1 << 10) 508 #define LS_NO_SORTING (1 << 11) 509 #define LS_REVERSE_ORDER (1 << 12) /* for sorting */ 510 #define LS_TEXTURE (1 << 13) 511 #define LS_CHAIN_COUNT (1 << 14) 512 513 /* FreestyleLineStyle::chaining */ 514 #define LS_CHAINING_PLAIN 1 515 #define LS_CHAINING_SKETCHY 2 516 517 /* FreestyleLineStyle::caps */ 518 #define LS_CAPS_BUTT 1 519 #define LS_CAPS_ROUND 2 520 #define LS_CAPS_SQUARE 3 521 522 /* FreestyleLineStyle::thickness_position */ 523 #define LS_THICKNESS_CENTER 1 524 #define LS_THICKNESS_INSIDE 2 525 #define LS_THICKNESS_OUTSIDE 3 526 #define LS_THICKNESS_RELATIVE 4 /* thickness_ratio is used */ 527 528 /* FreestyleLineStyle::sort_key */ 529 #define LS_SORT_KEY_DISTANCE_FROM_CAMERA 1 530 #define LS_SORT_KEY_2D_LENGTH 2 531 #define LS_SORT_KEY_PROJECTED_X 3 532 #define LS_SORT_KEY_PROJECTED_Y 4 533 534 /* FreestyleLineStyle::integration_type */ 535 #define LS_INTEGRATION_MEAN 1 536 #define LS_INTEGRATION_MIN 2 537 #define LS_INTEGRATION_MAX 3 538 #define LS_INTEGRATION_FIRST 4 539 #define LS_INTEGRATION_LAST 5 540 541 typedef struct FreestyleLineStyle { 542 ID id; 543 struct AnimData *adt; 544 545 float r, g, b, alpha; 546 float thickness; 547 int thickness_position; 548 float thickness_ratio; 549 int flag, caps; 550 int chaining; 551 unsigned int rounds; 552 float split_length; 553 /** In radians, for splitting. */ 554 float min_angle, max_angle; 555 float min_length, max_length; 556 unsigned int chain_count; 557 unsigned short split_dash1, split_gap1; 558 unsigned short split_dash2, split_gap2; 559 unsigned short split_dash3, split_gap3; 560 int sort_key, integration_type; 561 float texstep; 562 short texact, pr_texture; 563 short use_nodes; 564 char _pad[6]; 565 unsigned short dash1, gap1, dash2, gap2, dash3, gap3; 566 /** For UI. */ 567 int panel; 568 /** MAX_MTEX. */ 569 struct MTex *mtex[18]; 570 /* nodes */ 571 struct bNodeTree *nodetree; 572 573 ListBase color_modifiers; 574 ListBase alpha_modifiers; 575 ListBase thickness_modifiers; 576 ListBase geometry_modifiers; 577 } FreestyleLineStyle; 578