1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 namespace basegfx
{ class B3DPolyPolygon
; }
30 namespace basegfx
{ class B3DPolygon
; }
33 namespace drawinglayer::processor3d
35 /** Shadow3DExtractingProcessor class
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
42 class Shadow3DExtractingProcessor final
: public BaseProcessor3D
45 /// result holding vector (2D) and target vector for stacking (inited to &maPrimitive2DSequence)
46 primitive2d::Primitive2DContainer maPrimitive2DSequence
;
47 primitive2d::Primitive2DContainer
* mpPrimitive2DSequence
;
49 /// object transformation for scene for 2d definition
50 basegfx::B2DHomMatrix maObjectTransformation
;
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
;
60 /// flag if shadow plane projection preparation led to valid results
61 bool mbShadowProjectionIsValid
: 1;
63 /// flag if conversion is switched on
66 /// flag if conversion shall use projection
67 bool mbUseProjection
: 1;
70 basegfx::B2DPolygon
impDoShadowProjection(const basegfx::B3DPolygon
& rSource
);
71 basegfx::B2DPolyPolygon
impDoShadowProjection(const basegfx::B3DPolyPolygon
& rSource
);
73 /* as tooling, the process() implementation takes over API handling and calls this
74 virtual render method when the primitive implementation is BasePrimitive3D-based.
76 virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D
& rCandidate
) override
;
79 Shadow3DExtractingProcessor(
80 const geometry::ViewInformation3D
& rViewInformation
,
81 basegfx::B2DHomMatrix aObjectTransformation
,
82 const basegfx::B3DVector
& rLightNormal
,
84 const basegfx::B3DRange
& rContained3DRange
);
85 virtual ~Shadow3DExtractingProcessor() override
;
88 const primitive2d::Primitive2DContainer
& getPrimitive2DSequence() const;
89 const basegfx::B2DHomMatrix
& getObjectTransformation() const { return maObjectTransformation
; }
90 const basegfx::B3DHomMatrix
& getWorldToEye() const { return maWorldToEye
; }
93 } // end of namespace drawinglayer::processor3d
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */