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 .
20 #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX
21 #define INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/processor3d/baseprocessor3d.hxx>
26 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
27 #include <basegfx/matrix/b3dhommatrix.hxx>
28 #include <basegfx/color/bcolor.hxx>
29 #include <basegfx/polygon/b2dpolygon.hxx>
30 #include <basegfx/polygon/b3dpolygon.hxx>
31 #include <basegfx/polygon/b2dpolypolygon.hxx>
32 #include <basegfx/polygon/b3dpolypolygon.hxx>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
35 //////////////////////////////////////////////////////////////////////////////
37 namespace drawinglayer
41 /** Shadow3DExtractingProcessor class
43 This processor extracts the 2D shadow geometry (projected geometry) of all feeded primitives.
44 It is used to create the shadow of 3D objects which consists of 2D geometry. It needs quite
45 some data to do so since we do not only offer flat projected 2D shadow, but also projections
46 dependent on the light source
48 class DRAWINGLAYER_DLLPUBLIC Shadow3DExtractingProcessor
: public BaseProcessor3D
51 /// result holding vector (2D) and target vector for stacking (inited to &maPrimitive2DSequence)
52 primitive2d::Primitive2DVector maPrimitive2DSequence
;
53 primitive2d::Primitive2DVector
* mpPrimitive2DSequence
;
55 /// object transformation for scene for 2d definition
56 basegfx::B2DHomMatrix maObjectTransformation
;
58 /// prepared data (transformations) for 2D/3D shadow calculations
59 basegfx::B3DHomMatrix maWorldToEye
;
60 basegfx::B3DHomMatrix maEyeToView
;
61 basegfx::B3DVector maLightNormal
;
62 basegfx::B3DVector maShadowPlaneNormal
;
63 basegfx::B3DPoint maPlanePoint
;
64 double mfLightPlaneScalar
;
66 /* the shadow color used for sub-primitives. Can stay at black since
67 the encapsulating 2d shadow primitive will contain the color
69 basegfx::BColor maPrimitiveColor
;
72 /// flag if shadow plane projection preparation leaded to valid results
73 unsigned mbShadowProjectionIsValid
: 1;
75 /// flag if conversion is switched on
76 unsigned mbConvert
: 1;
78 /// flag if conversion shall use projection
79 unsigned mbUseProjection
: 1;
82 basegfx::B2DPolygon
impDoShadowProjection(const basegfx::B3DPolygon
& rSource
);
83 basegfx::B2DPolyPolygon
impDoShadowProjection(const basegfx::B3DPolyPolygon
& rSource
);
85 /* as tooling, the process() implementation takes over API handling and calls this
86 virtual render method when the primitive implementation is BasePrimitive3D-based.
88 virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D
& rCandidate
);
91 Shadow3DExtractingProcessor(
92 const geometry::ViewInformation3D
& rViewInformation
,
93 const basegfx::B2DHomMatrix
& rObjectTransformation
,
94 const basegfx::B3DVector
& rLightNormal
,
96 const basegfx::B3DRange
& rContained3DRange
);
97 virtual ~Shadow3DExtractingProcessor();
100 const primitive2d::Primitive2DSequence
getPrimitive2DSequence() const;
101 const basegfx::B2DHomMatrix
& getObjectTransformation() const { return maObjectTransformation
; }
102 const basegfx::B3DHomMatrix
& getWorldToEye() const { return maWorldToEye
; }
103 const basegfx::B3DHomMatrix
& getEyeToView() const { return maEyeToView
; }
105 } // end of namespace processor3d
106 } // end of namespace drawinglayer
108 #endif //_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */