/src/libreoffice/drawinglayer/inc/processor3d/shadow3dextractor.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <drawinglayer/processor3d/baseprocessor3d.hxx> |
23 | | #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> |
24 | | #include <basegfx/matrix/b3dhommatrix.hxx> |
25 | | #include <basegfx/polygon/b2dpolygon.hxx> |
26 | | #include <basegfx/polygon/b2dpolypolygon.hxx> |
27 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
28 | | |
29 | | namespace basegfx { class B3DPolyPolygon; } |
30 | | namespace basegfx { class B3DPolygon; } |
31 | | |
32 | | |
33 | | namespace drawinglayer::processor3d |
34 | | { |
35 | | /** Shadow3DExtractingProcessor class |
36 | | |
37 | | This processor extracts the 2D shadow geometry (projected geometry) of all fed primitives. |
38 | | It is used to create the shadow of 3D objects which consists of 2D geometry. It needs quite |
39 | | some data to do so since we do not only offer flat projected 2D shadow, but also projections |
40 | | dependent on the light source |
41 | | */ |
42 | | class Shadow3DExtractingProcessor final : public BaseProcessor3D |
43 | | { |
44 | | private: |
45 | | /// result holding vector (2D) and target vector for stacking (inited to &maPrimitive2DSequence) |
46 | | primitive2d::Primitive2DContainer maPrimitive2DSequence; |
47 | | primitive2d::Primitive2DContainer* mpPrimitive2DSequence; |
48 | | |
49 | | /// object transformation for scene for 2d definition |
50 | | basegfx::B2DHomMatrix maObjectTransformation; |
51 | | |
52 | | /// prepared data (transformations) for 2D/3D shadow calculations |
53 | | basegfx::B3DHomMatrix maWorldToEye; |
54 | | basegfx::B3DHomMatrix maEyeToView; |
55 | | basegfx::B3DVector maLightNormal; |
56 | | basegfx::B3DVector maShadowPlaneNormal; |
57 | | basegfx::B3DPoint maPlanePoint; |
58 | | double mfLightPlaneScalar; |
59 | | |
60 | | /// flag if shadow plane projection preparation led to valid results |
61 | | bool mbShadowProjectionIsValid : 1; |
62 | | |
63 | | /// flag if conversion is switched on |
64 | | bool mbConvert : 1; |
65 | | |
66 | | /// flag if conversion shall use projection |
67 | | bool mbUseProjection : 1; |
68 | | |
69 | | /// local helpers |
70 | | basegfx::B2DPolygon impDoShadowProjection(const basegfx::B3DPolygon& rSource); |
71 | | basegfx::B2DPolyPolygon impDoShadowProjection(const basegfx::B3DPolyPolygon& rSource); |
72 | | |
73 | | /* as tooling, the process() implementation takes over API handling and calls this |
74 | | virtual render method when the primitive implementation is BasePrimitive3D-based. |
75 | | */ |
76 | | virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate) override; |
77 | | |
78 | | public: |
79 | | Shadow3DExtractingProcessor( |
80 | | const geometry::ViewInformation3D& rViewInformation, |
81 | | basegfx::B2DHomMatrix aObjectTransformation, |
82 | | const basegfx::B3DVector& rLightNormal, |
83 | | double fShadowSlant, |
84 | | const basegfx::B3DRange& rContained3DRange); |
85 | | virtual ~Shadow3DExtractingProcessor() override; |
86 | | |
87 | | /// data read access |
88 | | const primitive2d::Primitive2DContainer& getPrimitive2DSequence() const; |
89 | 0 | const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } |
90 | 0 | const basegfx::B3DHomMatrix& getWorldToEye() const { return maWorldToEye; } |
91 | | }; |
92 | | |
93 | | } // end of namespace drawinglayer::processor3d |
94 | | |
95 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |