Blender V5.0
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
12
13#include <vector>
14
15#include "../geometry/Geom.h"
16
18
19#include "MEM_guardedalloc.h"
20
21namespace Freestyle {
22
23using namespace Geometry;
24
25class SVertex;
26class FEdge;
27
29 private:
30 // The viewpoint under which the silhouette has to be computed
31 static Vec3r _Viewpoint;
32 static real _translation[3];
33 // the model view matrix (_modelViewMatrix[i][j] means element of line i and column j)
34 static real _modelViewMatrix[4][4];
35 // the projection matrix (_projectionMatrix[i][j] means element of line i and column j)
36 static real _projectionMatrix[4][4];
37 // the global transformation from world to screen (projection included)
38 // (_transform[i][j] means element of line i and column j)
39 static real _transform[4][4];
40 // the viewport
41 static int _viewport[4];
42 static real _Focal;
43
44 static real _znear;
45 static real _zfar;
46
47 // GL style (column major) projection matrix
48 static real _glProjectionMatrix[4][4];
49 // GL style (column major) model view matrix
50 static real _glModelViewMatrix[4][4];
51
52 static bool _isOrthographicProjection;
53
54 static SilhouetteGeomEngine *_pInstance;
55
56 public:
59 {
60 if (_pInstance == nullptr) {
61 _pInstance = new SilhouetteGeomEngine;
62 }
63 return _pInstance;
64 }
65
67 static inline void setViewpoint(const Vec3r &ivp)
68 {
69 _Viewpoint = ivp;
70 }
71
82 static void setTransform(const real iModelViewMatrix[4][4],
83 const real iProjectionMatrix[4][4],
84 const int iViewport[4],
85 real iFocal);
86
88 static void setFrustum(real iZNear, real iZFar);
89
90 /* accessors */
91 static void retrieveViewport(int viewport[4]);
92
98 static void ProjectSilhouette(std::vector<SVertex *> &ioVertices);
99 static void ProjectSilhouette(SVertex *ioVertex);
100
109 static real ImageToWorldParameter(FEdge *fe, real t);
110
112 static Vec3r WorldToImage(const Vec3r &M);
113
115 static Vec3r CameraToImage(const Vec3r &M);
116
117 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:SilhouetteGeomEngine")
118};
119
120} /* 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
VecMat::Vec3< real > Vec3r
Definition Geom.h:30
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14