HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_OnionSkin.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GU library (C++)
7  *
8  * COMMENTS: Onion Skin Utility
9  */
10 
11 #pragma once
12 
13 #include "GU_API.h"
14 
15 #include <CH/CH_Manager.h>
16 
17 #include <UT/UT_Array.h>
18 #include <UT/UT_Assert.h>
19 #include <UT/UT_Color.h>
20 #include <UT/UT_Debug.h>
21 #include <UT/UT_Optional.h>
22 #include <UT/UT_Vector4.h>
23 
24 /// Info about when a primitive representing a single onion skin should be
25 /// evaluated. This structure is stored on a GT primitive to query its
26 /// evaluation time.
28 {
29  fpreal myEvalTime = 0.0f;
30  bool myIsEvalTimeRelative = true;
31 
33  {
34  if (myIsEvalTimeRelative)
35  return time + myEvalTime;
36  else
37  return myEvalTime;
38  }
39 };
40 
41 /// Info about how a primitive representing a single onion skin should look/be
42 /// rendered. This structure is stored on a GR primitive to make it render
43 /// like an onion skin. It is also stored on a GT primitive to pass along to the
44 /// GR primitive.
46 {
47  enum class RenderMode
48  {
49  /// Use the viewport's render mode.
50  DEFAULT,
51  /// Force wireframe render.
52  WIREFRAME,
53  /// Force outline render.
54  OUTLINE
55  };
56 
57  /// RGBA tint color.
58  UT_Vector4F myColor = UT_Vector4F(1.0f, 1.0f, 1.0f, 1.0f);
59  RenderMode myRenderMode = RenderMode::DEFAULT;
60  /// Used for outline thickness if `myRenderMode` is `OUTLINE`.
61  fpreal32 myThickness = 0.0f;
62  /// Used to determine multisample index. Ideally neighbouring onion skins
63  /// have indices `myIdx - 1` and `myIdx + 1` to minimize artifacts from
64  /// rendering, though this is not always easy to achieve.
65  exint myIdx = 0;
66 };
67 
68 /// One of these exists for each onion skin primitive. These are created
69 /// based on onion skin options and control how a specific skin is evaluated and
70 /// how it looks.
71 /// @see GU_OnionSkinOptions::makePrimInfo
73 {
76 };
77 
78 /// Onion skin options that are in the viewport common display options.
79 /// Not specific to any onion skinned primitive in particular.
81 {
82  exint myFrameIncrement = 0;
83  exint myPreFrameCount = 0;
84  exint myPostFrameCount = 0;
85  UT_Color myPreFrameColor = UT_Color(UT_RGB, 1, 1, 1);
86  UT_Color myPostFrameColor = UT_Color(UT_RGB, 1, 1, 1);
87  fpreal myAlpha = 0.5;
88 
90  { return myPreFrameCount + myPostFrameCount; }
91 };
92 
93 /// Options for how a single primitive should be onion skinned.
94 /// For example, how many onion skins a character shape primitive has.
96 {
98  {
100 
102  bool myIsFrameRelative = true;
103  UT_Color myColor = UT_Color(UT_RGB, 1, 1, 1);
104  fpreal myAlpha = 0.5;
105  RenderMode myRenderMode = RenderMode::DEFAULT;
106  fpreal32 myThickness = 1.0;
107  };
108 
109  bool myUseCommonSkins = true;
111 
113  const GU_CommonOnionSkinOptions &opts) const
114  {
115  exint num = myExtraSkins.size();
116  if (myUseCommonSkins)
117  num += opts.getNumOnionSkins();
118  return num;
119  }
120 
121  GU_OnionSkinPrimInfo makePrimInfo(
122  const GU_CommonOnionSkinOptions &opts,
123  exint idx) const;
124 };
GT_API const UT_StringHolder time
exint getNumOnionSkins() const
Definition: GU_OnionSkin.h:89
int64 exint
Definition: SYS_Types.h:125
float fpreal32
Definition: SYS_Types.h:200
exint getNumOnionSkins(const GU_CommonOnionSkinOptions &opts) const
Definition: GU_OnionSkin.h:112
GU_OnionSkinPrimEvalInfo myEvalInfo
Definition: GU_OnionSkin.h:74
GLfloat f
Definition: glcorearb.h:1926
#define GU_API
Definition: GU_API.h:14
UT_Array< PerSkinOptions > myExtraSkins
Definition: GU_OnionSkin.h:110
UT_Vector4T< fpreal32 > UT_Vector4F
GU_OnionSkinPrimRenderInfo myRenderInfo
Definition: GU_OnionSkin.h:75
fpreal64 fpreal
Definition: SYS_Types.h:283
fpreal getEvalTime(fpreal time)
Definition: GU_OnionSkin.h:32