Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX
30 : : #define INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX
31 : :
32 : : #include <drawinglayer/drawinglayerdllapi.h>
33 : :
34 : : #include <drawinglayer/processor3d/baseprocessor3d.hxx>
35 : : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
36 : : #include <basegfx/matrix/b3dhommatrix.hxx>
37 : : #include <basegfx/color/bcolor.hxx>
38 : : #include <basegfx/polygon/b2dpolygon.hxx>
39 : : #include <basegfx/polygon/b3dpolygon.hxx>
40 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
41 : : #include <basegfx/polygon/b3dpolypolygon.hxx>
42 : : #include <basegfx/matrix/b2dhommatrix.hxx>
43 : :
44 : : //////////////////////////////////////////////////////////////////////////////
45 : :
46 : : namespace drawinglayer
47 : : {
48 : : namespace processor3d
49 : : {
50 : : /** Shadow3DExtractingProcessor class
51 : :
52 : : This processor extracts the 2D shadow geometry (projected geometry) of all feeded primitives.
53 : : It is used to create the shadow of 3D objects which consists of 2D geometry. It needs quite
54 : : some data to do so since we do not only offer flat projected 2D shadow, but also projections
55 : : dependent on the light source
56 : : */
57 : : class DRAWINGLAYER_DLLPUBLIC Shadow3DExtractingProcessor : public BaseProcessor3D
58 : : {
59 : : private:
60 : : /// typedef for data handling
61 : : typedef std::vector< primitive2d::BasePrimitive2D* > BasePrimitive2DVector;
62 : :
63 : : /// result holding vector (2D) and target vector for stacking (inited to &maPrimitive2DSequence)
64 : : BasePrimitive2DVector maPrimitive2DSequence;
65 : : BasePrimitive2DVector* mpPrimitive2DSequence;
66 : :
67 : : /// object transformation for scene for 2d definition
68 : : basegfx::B2DHomMatrix maObjectTransformation;
69 : :
70 : : /// prepared data (transformations) for 2D/3D shadow calculations
71 : : basegfx::B3DHomMatrix maWorldToEye;
72 : : basegfx::B3DHomMatrix maEyeToView;
73 : : basegfx::B3DVector maLightNormal;
74 : : basegfx::B3DVector maShadowPlaneNormal;
75 : : basegfx::B3DPoint maPlanePoint;
76 : : double mfLightPlaneScalar;
77 : :
78 : : /* the shadow color used for sub-primitives. Can stay at black since
79 : : the encapsulating 2d shadow primitive will contain the color
80 : : */
81 : : basegfx::BColor maPrimitiveColor;
82 : :
83 : : /// bitfield
84 : : /// flag if shadow plane projection preparation leaded to valid results
85 : : unsigned mbShadowProjectionIsValid : 1;
86 : :
87 : : /// flag if conversion is switched on
88 : : unsigned mbConvert : 1;
89 : :
90 : : /// flag if conversion shall use projection
91 : : unsigned mbUseProjection : 1;
92 : :
93 : : /// local helpers
94 : : basegfx::B2DPolygon impDoShadowProjection(const basegfx::B3DPolygon& rSource);
95 : : basegfx::B2DPolyPolygon impDoShadowProjection(const basegfx::B3DPolyPolygon& rSource);
96 : :
97 : : /* as tooling, the process() implementation takes over API handling and calls this
98 : : virtual render method when the primitive implementation is BasePrimitive3D-based.
99 : : */
100 : : virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate);
101 : :
102 : : /// helper to convert from BasePrimitive2DVector to primitive2d::Primitive2DSequence
103 : : const primitive2d::Primitive2DSequence getPrimitive2DSequenceFromBasePrimitive2DVector(
104 : : const BasePrimitive2DVector& rVector) const;
105 : :
106 : : public:
107 : : Shadow3DExtractingProcessor(
108 : : const geometry::ViewInformation3D& rViewInformation,
109 : : const basegfx::B2DHomMatrix& rObjectTransformation,
110 : : const basegfx::B3DVector& rLightNormal,
111 : : double fShadowSlant,
112 : : const basegfx::B3DRange& rContained3DRange);
113 : : virtual ~Shadow3DExtractingProcessor();
114 : :
115 : : /// data read access
116 : : const primitive2d::Primitive2DSequence getPrimitive2DSequence() const;
117 : 0 : const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
118 : 15 : const basegfx::B3DHomMatrix& getWorldToEye() const { return maWorldToEye; }
119 : 0 : const basegfx::B3DHomMatrix& getEyeToView() const { return maEyeToView; }
120 : : };
121 : : } // end of namespace processor3d
122 : : } // end of namespace drawinglayer
123 : :
124 : : #endif //_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX
125 : :
126 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|