1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX 25 #define INCLUDED_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX 26 27 #include <drawinglayer/drawinglayerdllapi.h> 28 #include <drawinglayer/processor3d/baseprocessor3d.hxx> 29 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 30 #include <basegfx/matrix/b3dhommatrix.hxx> 31 #include <basegfx/color/bcolor.hxx> 32 #include <basegfx/polygon/b2dpolygon.hxx> 33 #include <basegfx/polygon/b3dpolygon.hxx> 34 #include <basegfx/polygon/b2dpolypolygon.hxx> 35 #include <basegfx/polygon/b3dpolypolygon.hxx> 36 #include <basegfx/matrix/b2dhommatrix.hxx> 37 38 ////////////////////////////////////////////////////////////////////////////// 39 40 namespace drawinglayer 41 { 42 namespace processor3d 43 { 44 /** Shadow3DExtractingProcessor class 45 46 This processor extracts the 2D shadow geometry (projected geometry) of all feeded primitives. 47 It is used to create the shadow of 3D objects which consists of 2D geometry. It needs quite 48 some data to do so since we do not only offer flat projected 2D shadow, but also projections 49 dependent on the light source 50 */ 51 class DRAWINGLAYER_DLLPUBLIC Shadow3DExtractingProcessor : public BaseProcessor3D 52 { 53 private: 54 /// result holding vector (2D) and target vector for stacking (inited to &maPrimitive2DSequence) 55 primitive2d::Primitive2DVector maPrimitive2DSequence; 56 primitive2d::Primitive2DVector* mpPrimitive2DSequence; 57 58 /// object transformation for scene for 2d definition 59 basegfx::B2DHomMatrix maObjectTransformation; 60 61 /// prepared data (transformations) for 2D/3D shadow calculations 62 basegfx::B3DHomMatrix maWorldToEye; 63 basegfx::B3DHomMatrix maEyeToView; 64 basegfx::B3DVector maLightNormal; 65 basegfx::B3DVector maShadowPlaneNormal; 66 basegfx::B3DPoint maPlanePoint; 67 double mfLightPlaneScalar; 68 69 /* the shadow color used for sub-primitives. Can stay at black since 70 the encapsulating 2d shadow primitive will contain the color 71 */ 72 basegfx::BColor maPrimitiveColor; 73 74 /// bitfield 75 /// flag if shadow plane projection preparation leaded to valid results 76 unsigned mbShadowProjectionIsValid : 1; 77 78 /// flag if conversion is switched on 79 unsigned mbConvert : 1; 80 81 /// flag if conversion shall use projection 82 unsigned mbUseProjection : 1; 83 84 /// local helpers 85 basegfx::B2DPolygon impDoShadowProjection(const basegfx::B3DPolygon& rSource); 86 basegfx::B2DPolyPolygon impDoShadowProjection(const basegfx::B3DPolyPolygon& rSource); 87 88 /* as tooling, the process() implementation takes over API handling and calls this 89 virtual render method when the primitive implementation is BasePrimitive3D-based. 90 */ 91 virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate); 92 93 public: 94 Shadow3DExtractingProcessor( 95 const geometry::ViewInformation3D& rViewInformation, 96 const basegfx::B2DHomMatrix& rObjectTransformation, 97 const basegfx::B3DVector& rLightNormal, 98 double fShadowSlant, 99 const basegfx::B3DRange& rContained3DRange); 100 virtual ~Shadow3DExtractingProcessor(); 101 102 /// data read access 103 const primitive2d::Primitive2DSequence getPrimitive2DSequence() const; getObjectTransformation() const104 const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } getWorldToEye() const105 const basegfx::B3DHomMatrix& getWorldToEye() const { return maWorldToEye; } getEyeToView() const106 const basegfx::B3DHomMatrix& getEyeToView() const { return maEyeToView; } 107 }; 108 } // end of namespace processor3d 109 } // end of namespace drawinglayer 110 111 #endif //_DRAWINGLAYER_PROCESSOR3D_SHADOW3DEXTRACTOR_HXX 112 113 // eof 114