Blender V4.3
SilhouetteGeomEngine.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
13#include <vector>
14
15#include "../geometry/Geom.h"
16
18
19#ifdef WITH_CXX_GUARDEDALLOC
20# include "MEM_guardedalloc.h"
21#endif
22
23namespace Freestyle {
24
25using namespace Geometry;
26
27class SVertex;
28class FEdge;
29
31 private:
32 // The viewpoint under which the silhouette has to be computed
33 static Vec3r _Viewpoint;
34 static real _translation[3];
35 // the model view matrix (_modelViewMatrix[i][j] means element of line i and column j)
36 static real _modelViewMatrix[4][4];
37 // the projection matrix (_projectionMatrix[i][j] means element of line i and column j)
38 static real _projectionMatrix[4][4];
39 // the global transformation from world to screen (projection included)
40 // (_transform[i][j] means element of line i and column j)
41 static real _transform[4][4];
42 // the viewport
43 static int _viewport[4];
44 static real _Focal;
45
46 static real _znear;
47 static real _zfar;
48
49 // GL style (column major) projection matrix
50 static real _glProjectionMatrix[4][4];
51 // GL style (column major) model view matrix
52 static real _glModelViewMatrix[4][4];
53
54 static bool _isOrthographicProjection;
55
56 static SilhouetteGeomEngine *_pInstance;
57
58 public:
61 {
62 if (_pInstance == nullptr) {
63 _pInstance = new SilhouetteGeomEngine;
64 }
65 return _pInstance;
66 }
67
69 static inline void setViewpoint(const Vec3r &ivp)
70 {
71 _Viewpoint = ivp;
72 }
73
84 static void setTransform(const real iModelViewMatrix[4][4],
85 const real iProjectionMatrix[4][4],
86 const int iViewport[4],
87 real iFocal);
88
90 static void setFrustum(real iZNear, real iZFar);
91
92 /* accessors */
93 static void retrieveViewport(int viewport[4]);
94
100 static void ProjectSilhouette(std::vector<SVertex *> &ioVertices);
101 static void ProjectSilhouette(SVertex *ioVertex);
102
111 static real ImageToWorldParameter(FEdge *fe, real t);
112
114 static Vec3r WorldToImage(const Vec3r &M);
115
117 static Vec3r CameraToImage(const Vec3r &M);
118
119#ifdef WITH_CXX_GUARDEDALLOC
120 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:SilhouetteGeomEngine")
121#endif
122};
123
124} /* namespace Freestyle */
Configuration definitions.
Vectors and Matrices (useful type definitions)
Read Guarded memory(de)allocation.
static SilhouetteGeomEngine * getInstance()
static Vec3r CameraToImage(const Vec3r &M)
static void setViewpoint(const Vec3r &ivp)
static void setFrustum(real iZNear, real iZFar)
static void setTransform(const real iModelViewMatrix[4][4], const real iProjectionMatrix[4][4], const int iViewport[4], real iFocal)
static void ProjectSilhouette(std::vector< SVertex * > &ioVertices)
static real ImageToWorldParameter(FEdge *fe, real t)
static Vec3r WorldToImage(const Vec3r &M)
static void retrieveViewport(int viewport[4])
#define M
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14