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