diff options
author | Armin Weiss <aw@openoffice.org> | 2006-05-12 10:54:47 +0000 |
---|---|---|
committer | Armin Weiss <aw@openoffice.org> | 2006-05-12 10:54:47 +0000 |
commit | c9ea78f03a45dac9b54a7afa33e069be8a290768 (patch) | |
tree | 633ef301cf53861c987cbcdcba61d499ef270bfc /drawinglayer | |
parent | cb7695b1bf4239f9c24e63e52e98b8c5677e6341 (diff) |
code changes for primitive support
Diffstat (limited to 'drawinglayer')
35 files changed, 6160 insertions, 10 deletions
diff --git a/drawinglayer/inc/drawinglayer/animation/animationtiming.hxx b/drawinglayer/inc/drawinglayer/animation/animationtiming.hxx new file mode 100644 index 000000000000..64d26b3779c5 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/animation/animationtiming.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: animationtiming.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:46:15 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_ANIMATION_ANIMATIONTIMING_HXX +#define _DRAWINGLAYER_ANIMATION_ANIMATIONTIMING_HXX + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#include <vector> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace animation + { + ////////////////////////////////////////////////////////////////////////////// + + class animationEntry + { + private: + animationEntry(const animationEntry&); + animationEntry& operator=(const animationEntry& rCandidate); + + public: + animationEntry(); + virtual ~animationEntry(); + virtual animationEntry* clone() const = 0; + + virtual bool operator==(const animationEntry& rCandidate) const = 0; + virtual double getDuration() const = 0; + virtual double getStateAtTime(double fTime) const = 0; + virtual double getNextEventTime(double fTime) const = 0; + }; + + ////////////////////////////////////////////////////////////////////////////// + + class animationEntryFixed : public animationEntry + { + protected: + double mfDuration; + double mfState; + + public: + animationEntryFixed(double fDuration, double fState = 0.0); + virtual ~animationEntryFixed(); + virtual animationEntry* clone() const; + + virtual bool operator==(const animationEntry& rCandidate) const; + virtual double getDuration() const; + virtual double getStateAtTime(double fTime) const; + virtual double getNextEventTime(double fTime) const; + }; + + ////////////////////////////////////////////////////////////////////////////// + + class animationEntryLinear : public animationEntry + { + protected: + double mfDuration; + double mfFrequency; + double mfStart; + double mfStop; + + public: + animationEntryLinear(double fDuration, double fFrequency = 250.0, double fStart = 0.0, double fStop = 1.0); + virtual ~animationEntryLinear(); + virtual animationEntry* clone() const; + + virtual bool operator==(const animationEntry& rCandidate) const; + virtual double getDuration() const; + virtual double getStateAtTime(double fTime) const; + virtual double getNextEventTime(double fTime) const; + }; + + ////////////////////////////////////////////////////////////////////////////// + + class animationEntryList : public animationEntry + { + protected: + double mfDuration; + ::std::vector< animationEntry* > maEntries; + + // helpers + sal_uInt32 impGetIndexAtTime(double fTime, double &rfAddedTime) const; + + public: + animationEntryList(); + animationEntryList(const animationEntryList& rCandidate); + virtual ~animationEntryList(); + virtual animationEntry* clone() const; + + virtual bool operator==(const animationEntry& rCandidate) const; + void append(const animationEntry& rCandidate); + virtual double getDuration() const; + virtual double getStateAtTime(double fTime) const; + virtual double getNextEventTime(double fTime) const; + }; + + ////////////////////////////////////////////////////////////////////////////// + + class animationEntryLoop : public animationEntryList + { + protected: + sal_uInt32 mnRepeat; + + public: + animationEntryLoop(sal_uInt32 nRepeat); + virtual ~animationEntryLoop(); + virtual animationEntry* clone() const; + + virtual bool operator==(const animationEntry& rCandidate) const; + virtual double getDuration() const; + virtual double getStateAtTime(double fTime) const; + virtual double getNextEventTime(double fTime) const; + }; + + ////////////////////////////////////////////////////////////////////////////// + } // end of namespace animation +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_ANIMATION_ANIMATIONTIMING_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx new file mode 100644 index 000000000000..28fb22545e44 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: hatchtextureprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:12 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/textureprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class hatchTexturePrimitive3D : public texturePrimitive3D + { + protected: + fillHatchAttribute maHatch; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + // helpers + void impCreateDecomposition(const primitiveList& rSource, primitiveList& rDest); + + public: + hatchTexturePrimitive3D( + const fillHatchAttribute& rHatch, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + virtual ~hatchTexturePrimitive3D(); + + // get data + const fillHatchAttribute& getHatch() const { return maHatch; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/polygonprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/polygonprimitive3d.hxx new file mode 100644 index 000000000000..b4d44e28c6df --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/polygonprimitive3d.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polygonprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:13 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVE_HXX +#include <drawinglayer/primitive/primitive.hxx> +#endif + +#ifndef _BGFX_COLOR_BCOLOR_HXX +#include <basegfx/color/bcolor.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_STROKEATTRIBUTE_HXX +#include <drawinglayer/primitive/strokeattribute.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class polygonHairlinePrimitive3D : public basePrimitive + { + protected: + ::basegfx::B3DPolygon maPolygon; + ::basegfx::BColor maBColor; + + public: + polygonHairlinePrimitive3D(const ::basegfx::B3DPolygon& rPolygon, const ::basegfx::BColor& rBColor); + virtual ~polygonHairlinePrimitive3D(); + + // get data + const ::basegfx::B3DPolygon& getB3DPolygon() const { return maPolygon; } + const ::basegfx::BColor& getBColor() const { return maBColor; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // get 3Drange of primitive. Default implementation uses decomposition + virtual ::basegfx::B3DRange get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const; + + // version for 3D geometries, analog to 2d version (see above) + virtual void transform(const ::basegfx::B3DHomMatrix& rMatrix); + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class polygonStrokePrimitive3D : public basePrimitive + { + protected: + ::basegfx::B3DPolygon maPolygon; + strokeAttribute maStrokeAttribute; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + polygonStrokePrimitive3D(const ::basegfx::B3DPolygon& rPolygon, const strokeAttribute& rStrokeAttribute); + virtual ~polygonStrokePrimitive3D(); + + // get data + ::basegfx::B3DPolygon getB3DPolygon() const { return maPolygon; } + const strokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // version for 3D geometries, analog to 2d version (see above) + virtual void transform(const ::basegfx::B3DHomMatrix& rMatrix); + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // _DRAWINGLAYER_PRIMITIVE_POLYGONPRIMITIVE_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/polygontubeprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/polygontubeprimitive3d.hxx new file mode 100644 index 000000000000..1116657a6c9d --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/polygontubeprimitive3d.hxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polygontubeprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:13 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +namespace basegfx { + class B3DPolyPolygon; + class B3DHomMatrix; +} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class polygonTubePrimitive3D : public polygonHairlinePrimitive3D + { + protected: + double mfRadius; + double mfDegreeStepWidth; + double mfMiterMinimumAngle; + ::basegfx::tools::B2DLineJoin maLineJoin; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + polygonTubePrimitive3D( + const ::basegfx::B3DPolygon& rPolygon, + const ::basegfx::BColor& rBColor, + double fRadius, ::basegfx::tools::B2DLineJoin aLineJoin, + double fDegreeStepWidth = 10.0 * F_PI180, + double fMiterMinimumAngle = 15.0 * F_PI180); + virtual ~polygonTubePrimitive3D(); + + // get data + double getRadius() const { return mfRadius; } + double getDegreeStepWidth() const { return mfDegreeStepWidth; } + double getMiterMinimumAngle() const { return mfMiterMinimumAngle; } + ::basegfx::tools::B2DLineJoin getLineJoin() const { return maLineJoin; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // _DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/polypolygonprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/polypolygonprimitive3d.hxx new file mode 100644 index 000000000000..6a0bdcf916ff --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/polypolygonprimitive3d.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polypolygonprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:13 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVE_HXX +#include <drawinglayer/primitive/primitive.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_MATERIALATTRIBUTE3D_HXX +#include <drawinglayer/primitive3d/materialattribute3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_TEXTURE_HXX +#include <drawinglayer/primitive/texture.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class polyPolygonMaterialPrimitive3D : public basePrimitive + { + protected: + ::basegfx::B3DPolyPolygon maPolyPolygon; + materialAttribute3D maMaterial; + + // bitfield + unsigned mbDoubleSided : 1; + + public: + polyPolygonMaterialPrimitive3D(const ::basegfx::B3DPolyPolygon& rPolyPolygon, const materialAttribute3D& rMaterial, bool bDoubleSided); + virtual ~polyPolygonMaterialPrimitive3D(); + + // get data + const ::basegfx::B3DPolyPolygon& getB3DPolyPolygon() const { return maPolyPolygon; } + const materialAttribute3D& getMaterial() const { return maMaterial; } + bool getDoubleSided() const { return mbDoubleSided; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // get 3Drange of primitive. Default implementation uses decomposition + virtual ::basegfx::B3DRange get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const; + + // version for 3D geometries, analog to 2d version (see above) + virtual void transform(const ::basegfx::B3DHomMatrix& rMatrix); + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx new file mode 100644 index 000000000000..96234e6ecb62 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrcubeprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:13 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +namespace drawinglayer +{ + namespace primitive + { + class sdrCubePrimitive3D : public sdrPrimitive3D + { + protected: + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + sdrCubePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute); + virtual ~sdrCubePrimitive3D(); + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // get 3D range of primitive. + virtual ::basegfx::B3DRange get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const; + }; + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx new file mode 100644 index 000000000000..ccc3486d7c4e --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrdecompositiontools3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX + +#include <vector> + +////////////////////////////////////////////////////////////////////////////// +// predefines +namespace basegfx { + class B3DPolygon; + class B3DPolyPolygon; + class B3DHomMatrix; + class B2DVector; +} + +namespace drawinglayer { namespace primitive { + class primitiveList; + class sdrLineAttribute; + class sdrFillAttribute; + class sdr3DObjectAttribute; + class fillGradientAttribute; + class sdrShadowAttribute; +}} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void add3DPolyPolygonLinePrimitive( + const ::basegfx::B3DPolyPolygon& rUnitPolyPolygon, + const ::basegfx::B3DHomMatrix& rObjectTransform, + primitiveList& rTarget, + const sdrLineAttribute& rLine); + + void add3DPolyPolygonFillPrimitive( + const ::std::vector< ::basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, + const ::basegfx::B3DHomMatrix& rObjectTransform, + const ::basegfx::B2DVector& rTextureSize, + primitiveList& rTarget, + const sdr3DObjectAttribute& aSdr3DObjectAttribute, + const sdrFillAttribute& rFill, + const fillGradientAttribute* pFillGradient = 0L); + + void addShadowPrimitive3D( + primitiveList& rTarget, + const sdrShadowAttribute& rShadow, + bool bShadow3D); + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx new file mode 100644 index 000000000000..8d5ddd02dd45 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrextrudelathetools3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX + +#include <vector> + +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + // slice types + enum sliceType + { + SLICETYPE_REGULAR, // normal geoemtry slice + SLICETYPE_FRONTCAP, // front cap + SLICETYPE_BACKCAP // back cap + }; + + // class to hold one 3D slice + class slice + { + protected: + ::basegfx::B3DPolyPolygon maPolyPolygon; + sliceType maSliceType; + + public: + slice(const ::basegfx::B2DPolyPolygon& rPolyPolygon, const ::basegfx::B3DHomMatrix& aTransform, sliceType aSliceType = SLICETYPE_REGULAR) + : maPolyPolygon(::basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPolygon)), + maSliceType(aSliceType) + { + maPolyPolygon.transform(aTransform); + } + + slice(const ::basegfx::B3DPolyPolygon& rPolyPolygon, sliceType aSliceType = SLICETYPE_REGULAR) + : maPolyPolygon(rPolyPolygon), + maSliceType(aSliceType) + { + } + + // data access + const ::basegfx::B3DPolyPolygon& getB3DPolyPolygon() const { return maPolyPolygon; } + sliceType getSliceType() const { return maSliceType; } + }; + + // typedef for a group of slices + typedef ::std::vector< slice > sliceVector; + + // helpers for creation + bool createLatheSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource, + double fBackScale, double fDiagonal, double fRotation, sal_uInt32 nSteps, + bool bCharacterMode, bool bCloseFront, bool bCloseBack); + void createExtrudeSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource, + double fBackScale, double fDiagonal, double fDepth, + bool bCharacterMode, bool bCloseFront, bool bCloseBack); + + // helpers for geometry extraction + void extractLinesFromSlice(::basegfx::B3DPolyPolygon& rLine, const sliceVector& rSliceVector, bool bClosed); + void extractPlanesFromSlice(::std::vector< ::basegfx::B3DPolyPolygon >& rFill, const sliceVector& rSliceVector, + bool bCreateNormals, bool bSmoothHorizontalNormals, bool bSmoothNormals, bool bSmoothLids, bool bClosed, + double fSmoothNormalsMix, double fSmoothLidsMix, bool bCreateTextureCoordinates, const ::basegfx::B2DHomMatrix& rTexTransform); + + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx new file mode 100644 index 000000000000..7c86df80ec5b --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrextrudeprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX +#include <basegfx/polygon/b2dpolypolygon.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class sdrExtrudePrimitive3D : public sdrPrimitive3D + { + protected: + ::basegfx::B2DPolyPolygon maPolyPolygon; + double mfDepth; + double mfDiagonal; + double mfBackScale; + + // bitfield + unsigned mbSmoothNormals : 1; // Plane self + unsigned mbSmoothHorizontalNormals : 1; // always + unsigned mbSmoothLids : 1; // Front/back + unsigned mbCharacterMode : 1; + unsigned mbCloseFront : 1; + unsigned mbCloseBack : 1; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + sdrExtrudePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute, + const ::basegfx::B2DPolyPolygon& rPolyPolygon, + double fDepth, + double fDiagonal, + double fBackScale, + bool bSmoothNormals, + bool bSmoothHorizontalNormals, + bool bSmoothLids, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack); + virtual ~sdrExtrudePrimitive3D(); + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // get 3D range of primitive. + virtual ::basegfx::B3DRange get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const; + + // data access + const ::basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; } + double getDepth() const { return mfDepth; } + double getDiagonal() const { return mfDiagonal; } + double getBackScale() const { return mfBackScale; } + bool getSmoothNormals() const { return mbSmoothNormals; } + bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; } + bool getSmoothLids() const { return mbSmoothLids; } + bool getCharacterMode() const { return mbCharacterMode; } + bool getCloseFront() const { return mbCloseFront; } + bool getCloseBack() const { return mbCloseBack; } + }; + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx new file mode 100644 index 000000000000..0847550c95bb --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx @@ -0,0 +1,130 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrlatheprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX +#include <basegfx/polygon/b2dpolypolygon.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class sdrLathePrimitive3D : public sdrPrimitive3D + { + protected: + ::basegfx::B2DPolyPolygon maPolyPolygon; + sal_uInt32 mnHorizontalSegments; + sal_uInt32 mnVerticalSegments; + double mfDiagonal; + double mfBackScale; + double mfRotation; + + // bitfield + unsigned mbSmoothNormals : 1; // Plane self + unsigned mbSmoothHorizontalNormals : 1; // always + unsigned mbSmoothLids : 1; // Front/back + unsigned mbCharacterMode : 1; + unsigned mbCloseFront : 1; + unsigned mbCloseBack : 1; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + sdrLathePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute, + const ::basegfx::B2DPolyPolygon& rPolyPolygon, + sal_uInt32 nHorizontalSegments, + sal_uInt32 nVerticalSegments, + double fDiagonal, + double fBackScale, + double fRotation, + bool bSmoothNormals, + bool bSmoothHorizontalNormals, + bool bSmoothLids, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack); + virtual ~sdrLathePrimitive3D(); + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // get 3D range of primitive. + virtual ::basegfx::B3DRange get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const; + + // data access + const ::basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; } + sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; } + sal_uInt32 getVerticalSegments() const { return mnVerticalSegments ; } + double getDiagonal() const { return mfDiagonal; } + double getBackScale() const { return mfBackScale; } + double getRotation() const { return mfRotation; } + bool getSmoothNormals() const { return mbSmoothNormals; } + bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; } + bool getSmoothLids() const { return mbSmoothLids; } + bool getCharacterMode() const { return mbCharacterMode; } + bool getCloseFront() const { return mbCloseFront; } + bool getCloseBack() const { return mbCloseBack; } + }; + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx new file mode 100644 index 000000000000..6ca56b460bcf --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVE_HXX +#include <drawinglayer/primitive/primitive.hxx> +#endif + +#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX +#include <basegfx/matrix/b3dhommatrix.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRALLATTRIBUTE3D_HXX +#include <drawinglayer/primitive3d/sdrallattribute3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRATTRIBUTE3D_HXX +#include <drawinglayer/primitive3d/sdrattribute3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class sdrPrimitive3D : public basePrimitive + { + protected: + ::basegfx::B3DHomMatrix maTransform; + ::basegfx::B2DVector maTextureSize; + sdrLineFillShadowAttribute maSdrLFSAttribute; + sdr3DObjectAttribute maSdr3DObjectAttribute; + + // Standard implementation for primitive3D which + // will use maTransform as range and expand by evtl. line width / 2 + ::basegfx::B3DRange getStandard3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const; + + public: + sdrPrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute); + virtual ~sdrPrimitive3D(); + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // data access + const ::basegfx::B3DHomMatrix& getTransform() const { return maTransform; } + const ::basegfx::B2DVector& getTextureSize() const { return maTextureSize; } + const sdrLineFillShadowAttribute& getSdrLFSAttribute() const { return maSdrLFSAttribute; } + const sdr3DObjectAttribute getSdr3DObjectAttribute() const { return maSdr3DObjectAttribute; } + + // version for 3D geometries, analog to 2d version (see above) + virtual void transform(const ::basegfx::B3DHomMatrix& rMatrix); + }; + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx new file mode 100644 index 000000000000..6917b49139b7 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrsphereprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// +// predefines + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class sdrSpherePrimitive3D : public sdrPrimitive3D + { + protected: + sal_uInt32 mnHorizontalSegments; + sal_uInt32 mnVerticalSegments; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + sdrSpherePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute, + sal_uInt32 nHorizontalSegments, sal_uInt32 nVerticalSegments); + virtual ~sdrSpherePrimitive3D(); + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // get 3D range of primitive. + virtual ::basegfx::B3DRange get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const; + + // data access + sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; } + sal_uInt32 getVerticalSegments() const { return mnVerticalSegments ; } + }; + } // end of namespace overlay +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/shadowprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/shadowprimitive3d.hxx new file mode 100644 index 000000000000..e663518c3b65 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/shadowprimitive3d.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: shadowprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:15 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE_LISTPRIMITIVE_HXX +#include <drawinglayer/primitive/listprimitive.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +#ifndef _BGFX_COLOR_BCOLOR_HXX +#include <basegfx/color/bcolor.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class shadowPrimitive3D : public listPrimitive + { + protected: + ::basegfx::B2DHomMatrix maShadowTransform; + ::basegfx::BColor maShadowColor; + double mfShadowTransparence; + + // bitfield + unsigned mbShadow3D : 1; + + public: + shadowPrimitive3D( + const ::basegfx::B2DHomMatrix& rShadowTransform, const ::basegfx::BColor& rShadowColor, + double fShadowTransparence, bool bShadow3D, const primitiveList& rPrimitiveList); + virtual ~shadowPrimitive3D(); + + // get data + const ::basegfx::B2DHomMatrix& getShadowTransform() const { return maShadowTransform; } + const ::basegfx::BColor& getShadowColor() const { return maShadowColor; } + double getShadowTransparence() const { return mfShadowTransparence; } + bool getShadow3D() const { return mbShadow3D; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + + // transformations for different aspects + virtual void transform(const ::basegfx::B2DHomMatrix& rMatrix); + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx new file mode 100644 index 000000000000..25cd863958ff --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx @@ -0,0 +1,238 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textureprimitive3d.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:45:15 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#define _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX + +#ifndef _DRAWINGLAYER_PRIMITIVE_LISTPRIMITIVE_HXX +#include <drawinglayer/primitive/listprimitive.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_FILLATTRIBUTE_HXX +#include <drawinglayer/primitive/fillattribute.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_FILLBITMAPATTRIBUTE_HXX +#include <drawinglayer/primitive/fillbitmapattribute.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVELIST_HXX +#include <drawinglayer/primitive/primitivelist.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class texturePrimitive3D : public listPrimitive + { + protected: + ::basegfx::B2DVector maTextureSize; + + // bitfield + // flag if texture shall be modulated with white interpolated color + unsigned mbModulate : 1; + + // flag if texture shall be filtered + unsigned mbFilter : 1; + + public: + texturePrimitive3D( + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + virtual ~texturePrimitive3D(); + + // get data + const ::basegfx::B2DVector& getTextureSize() const { return maTextureSize; } + bool getModulate() const { return mbModulate; } + bool getFilter() const { return mbFilter; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class simpleTransparenceTexturePrimitive3D : public texturePrimitive3D + { + protected: + double mfTransparence; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + simpleTransparenceTexturePrimitive3D( + double fTransparence, + const primitiveList& rPrimitiveList); + virtual ~simpleTransparenceTexturePrimitive3D(); + + // get data + double getTransparence() const { return mfTransparence; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class gradientTexturePrimitive3D : public texturePrimitive3D + { + protected: + fillGradientAttribute maGradient; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + gradientTexturePrimitive3D( + const fillGradientAttribute& rGradient, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + virtual ~gradientTexturePrimitive3D(); + + // get data + const fillGradientAttribute& getGradient() const { return maGradient; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class bitmapTexturePrimitive3D : public texturePrimitive3D + { + protected: + fillBitmapAttribute maBitmap; + + // create decomposition + virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation); + + public: + bitmapTexturePrimitive3D( + const fillBitmapAttribute& rBitmap, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + virtual ~bitmapTexturePrimitive3D(); + + // get data + const fillBitmapAttribute& getBitmap() const { return maBitmap; } + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + class transparenceTexturePrimitive3D : public gradientTexturePrimitive3D + { + public: + transparenceTexturePrimitive3D( + const fillGradientAttribute& rGradient, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize); + virtual ~transparenceTexturePrimitive3D(); + + // compare operator + virtual bool operator==(const basePrimitive& rPrimitive) const; + + // clone operator + virtual basePrimitive* createNewClone() const; + + // id generator + virtual PrimitiveID getID() const; + }; + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX + +// eof diff --git a/drawinglayer/prj/build.lst b/drawinglayer/prj/build.lst index 9fbb29512d83..9ed12fa6cd84 100644 --- a/drawinglayer/prj/build.lst +++ b/drawinglayer/prj/build.lst @@ -3,4 +3,7 @@ fx drawinglayer usr1 - all fx_mkout NULL fx drawinglayer\inc get - all fx_inc NULL fx drawinglayer\prj get - all fx_prj NULL fx drawinglayer\source\primitive nmake - all fx_primitive NULL -fx drawinglayer\util nmake - all fx_util fx_primitive NULL +fx drawinglayer\source\primitive3d nmake - all fx_primitive3d NULL +fx drawinglayer\source\animation nmake - all fx_animation NULL +fx drawinglayer\source\geometry nmake - all fx_geometry NULL +fx drawinglayer\util nmake - all fx_util fx_primitive fx_primitive3d fx_animation fx_geometry NULL diff --git a/drawinglayer/prj/d.lst b/drawinglayer/prj/d.lst index 3df12d2a493f..62fe4b7c8a23 100644 --- a/drawinglayer/prj/d.lst +++ b/drawinglayer/prj/d.lst @@ -7,15 +7,21 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive -..\inc\drawinglayer\primitive\sdrfillbitmapattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\sdrfillbitmapattribute.hxx -..\inc\drawinglayer\primitive\fillbitmapprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillbitmapprimitive.hxx -..\inc\drawinglayer\primitive\fillhatchprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillhatchprimitive.hxx -..\inc\drawinglayer\primitive\fillgradientprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillgradientprimitive.hxx +..\inc\drawinglayer\primitive\animatedprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\animatedprimitive.hxx +..\inc\drawinglayer\primitive\backgroundcolorprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\backgroundcolorprimitive.hxx ..\inc\drawinglayer\primitive\bitmapprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\bitmapprimitive.hxx ..\inc\drawinglayer\primitive\fillattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillattribute.hxx ..\inc\drawinglayer\primitive\fillbitmapattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillbitmapattribute.hxx +..\inc\drawinglayer\primitive\fillbitmapprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillbitmapprimitive.hxx +..\inc\drawinglayer\primitive\fillgradientprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillgradientprimitive.hxx +..\inc\drawinglayer\primitive\fillhatchprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\fillhatchprimitive.hxx +..\inc\drawinglayer\primitive\gridprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\gridprimitive.hxx +..\inc\drawinglayer\primitive\helplineprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\helplineprimitive.hxx +..\inc\drawinglayer\primitive\listprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\listprimitive.hxx +..\inc\drawinglayer\primitive\markerprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\markerprimitive.hxx ..\inc\drawinglayer\primitive\maskprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\maskprimitive.hxx ..\inc\drawinglayer\primitive\metafileprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\metafileprimitive.hxx +..\inc\drawinglayer\primitive\modifiedcolorprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\modifiedcolorprimitive.hxx ..\inc\drawinglayer\primitive\polygonprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\polygonprimitive.hxx ..\inc\drawinglayer\primitive\polypolygonprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\polypolygonprimitive.hxx ..\inc\drawinglayer\primitive\primitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\primitive.hxx @@ -23,8 +29,9 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive ..\inc\drawinglayer\primitive\primitivelist.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\primitivelist.hxx ..\inc\drawinglayer\primitive\primitiveprocessor.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\primitiveprocessor.hxx ..\inc\drawinglayer\primitive\referencedprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\referencedprimitive.hxx -..\inc\drawinglayer\primitive\rgbcolorattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\rgbcolorattribute.hxx +..\inc\drawinglayer\primitive\sceneprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\sceneprimitive.hxx ..\inc\drawinglayer\primitive\sdrattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\sdrattribute.hxx +..\inc\drawinglayer\primitive\sdrfillbitmapattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\sdrfillbitmapattribute.hxx ..\inc\drawinglayer\primitive\shadowprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\shadowprimitive.hxx ..\inc\drawinglayer\primitive\simpletransparenceprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\simpletransparenceprimitive.hxx ..\inc\drawinglayer\primitive\strokearrowattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\strokearrowattribute.hxx @@ -33,5 +40,31 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive ..\inc\drawinglayer\primitive\textprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\textprimitive.hxx ..\inc\drawinglayer\primitive\texture.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\texture.hxx ..\inc\drawinglayer\primitive\transparenceprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\transparenceprimitive.hxx -..\inc\drawinglayer\primitive\unifiedcolorprimitive.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\unifiedcolorprimitive.hxx ..\inc\drawinglayer\primitive\vclprimitiveprocessor.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive\vclprimitiveprocessor.hxx + +mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive3d +..\inc\drawinglayer\primitive3d\materialattribute3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\materialattribute3d.hxx +..\inc\drawinglayer\primitive3d\sdrallattribute3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrallattribute3d.hxx +..\inc\drawinglayer\primitive3d\sdrattribute3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrattribute3d.hxx +..\inc\drawinglayer\primitive3d\polygonprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\polygonprimitive3d.hxx +..\inc\drawinglayer\primitive3d\polygontubeprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\polygontubeprimitive3d.hxx +..\inc\drawinglayer\primitive3d\polypolygonprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\polypolygonprimitive3d.hxx +..\inc\drawinglayer\primitive3d\shadowprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\shadowprimitive3d.hxx +..\inc\drawinglayer\primitive3d\textureprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\textureprimitive3d.hxx +..\inc\drawinglayer\primitive3d\hatchtextureprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\hatchtextureprimitive3d.hxx +..\inc\drawinglayer\primitive3d\primitiveprocessor3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\primitiveprocessor3d.hxx +..\inc\drawinglayer\primitive3d\sdrdecompositiontools3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrdecompositiontools3d.hxx +..\inc\drawinglayer\primitive3d\sdrextrudelathetools3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrextrudelathetools3d.hxx +..\inc\drawinglayer\primitive3d\sdrprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrprimitive3d.hxx +..\inc\drawinglayer\primitive3d\sdrcubeprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrcubeprimitive3d.hxx +..\inc\drawinglayer\primitive3d\sdrextrudeprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrextrudeprimitive3d.hxx +..\inc\drawinglayer\primitive3d\sdrsphereprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrsphereprimitive3d.hxx +..\inc\drawinglayer\primitive3d\sdrlatheprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrlatheprimitive3d.hxx +..\inc\drawinglayer\primitive3d\sdrpolygonprimitive3d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive3d\sdrpolygonprimitive3d.hxx + +mkdir: %_DEST%\inc%_EXT%\drawinglayer\animation +..\inc\drawinglayer\animation\animationtiming.hxx %_DEST%\inc%_EXT%\drawinglayer\animation\animationtiming.hxx + +mkdir: %_DEST%\inc%_EXT%\drawinglayer\geometry +..\inc\drawinglayer\geometry\viewinformation.hxx %_DEST%\inc%_EXT%\drawinglayer\geometry\viewinformation.hxx +..\inc\drawinglayer\geometry\transformation3d.hxx %_DEST%\inc%_EXT%\drawinglayer\geometry\transformation3d.hxx diff --git a/drawinglayer/source/animation/animationtiming.cxx b/drawinglayer/source/animation/animationtiming.cxx new file mode 100644 index 000000000000..d3a4654a6e57 --- /dev/null +++ b/drawinglayer/source/animation/animationtiming.cxx @@ -0,0 +1,367 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: animationtiming.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:50:12 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_ANIMATION_ANIMATIONTIMING_HXX +#include <drawinglayer/animation/animationtiming.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace animation + { + ////////////////////////////////////////////////////////////////////////////// + + animationEntry::animationEntry() + { + } + + animationEntry::~animationEntry() + { + } + + ////////////////////////////////////////////////////////////////////////////// + + animationEntryFixed::animationEntryFixed(double fDuration, double fState) + : mfDuration(fDuration), + mfState(fState) + { + } + + animationEntryFixed::~animationEntryFixed() + { + } + + animationEntry* animationEntryFixed::clone() const + { + return new animationEntryFixed(mfDuration, mfState); + } + + bool animationEntryFixed::operator==(const animationEntry& rCandidate) const + { + const animationEntryFixed* pCompare = dynamic_cast< const animationEntryFixed* >(&rCandidate); + + return (pCompare + && mfDuration == pCompare->mfDuration + && mfState == pCompare->mfState); + } + + double animationEntryFixed::getDuration() const + { + return mfDuration; + } + + double animationEntryFixed::getStateAtTime(double fTime) const + { + return mfState; + } + + double animationEntryFixed::getNextEventTime(double fTime) const + { + if(fTime < mfDuration) + { + fTime = mfDuration; + } + + return fTime; + } + + ////////////////////////////////////////////////////////////////////////////// + + animationEntryLinear::animationEntryLinear(double fDuration, double fFrequency, double fStart, double fStop) + : mfDuration(fDuration), + mfFrequency(fFrequency), + mfStart(fStart), + mfStop(fStop) + { + } + + animationEntryLinear::~animationEntryLinear() + { + } + + animationEntry* animationEntryLinear::clone() const + { + return new animationEntryLinear(mfDuration, mfFrequency, mfStart, mfStop); + } + + bool animationEntryLinear::operator==(const animationEntry& rCandidate) const + { + const animationEntryLinear* pCompare = dynamic_cast< const animationEntryLinear* >(&rCandidate); + + return (pCompare + && mfDuration == pCompare->mfDuration + && mfStart == pCompare->mfStart + && mfStop == pCompare->mfStop); + } + + double animationEntryLinear::getDuration() const + { + return mfDuration; + } + + double animationEntryLinear::getStateAtTime(double fTime) const + { + if(0.0 != mfDuration) + { + const double fFactor(fTime / mfDuration); + return mfStart + ((mfStop - mfStart) * fFactor); + } + else + { + return mfStart; + } + } + + double animationEntryLinear::getNextEventTime(double fTime) const + { + if(fTime < mfDuration) + { + // use the simple solution: just add the frequency. More correct (but also more + // complicated) would be to calculate the slice of time we are in and when this + // slice will end. For the animations, this makes no quality difference. + fTime += mfFrequency; + + if(fTime > mfDuration) + { + fTime = mfDuration; + } + } + + return fTime; + } + + ////////////////////////////////////////////////////////////////////////////// + + sal_uInt32 animationEntryList::impGetIndexAtTime(double fTime, double &rfAddedTime) const + { + sal_uInt32 nIndex(0L); + + while(nIndex < maEntries.size() && rfAddedTime + maEntries[nIndex]->getDuration() <= fTime) + { + rfAddedTime += maEntries[nIndex++]->getDuration(); + } + + return nIndex; + } + + animationEntryList::animationEntryList() + : mfDuration(0.0) + { + } + + animationEntryList::animationEntryList(const animationEntryList& rCandidate) + : mfDuration(0.0) + { + for(sal_uInt32 a(0L); a < rCandidate.maEntries.size(); a++) + { + append(*rCandidate.maEntries[a]); + } + } + + animationEntryList::~animationEntryList() + { + for(sal_uInt32 a(0L); a < maEntries.size(); a++) + { + delete maEntries[a]; + } + } + + animationEntry* animationEntryList::clone() const + { + animationEntryList* pNew = new animationEntryList(); + + for(sal_uInt32 a(0L); a < maEntries.size(); a++) + { + pNew->append(*maEntries[a]); + } + + return pNew; + } + + bool animationEntryList::operator==(const animationEntry& rCandidate) const + { + const animationEntryList* pCompare = dynamic_cast< const animationEntryList* >(&rCandidate); + + if(pCompare && mfDuration == pCompare->mfDuration) + { + for(sal_uInt32 a(0L); a < maEntries.size(); a++) + { + if(!(*maEntries[a] == *pCompare->maEntries[a])) + { + return false; + } + } + + return true; + } + + return false; + } + + void animationEntryList::append(const animationEntry& rCandidate) + { + const double fDuration(rCandidate.getDuration()); + + if(0.0 != fDuration) + { + maEntries.push_back(rCandidate.clone()); + mfDuration += fDuration; + } + } + + double animationEntryList::getDuration() const + { + return mfDuration; + } + + double animationEntryList::getStateAtTime(double fTime) const + { + if(0.0 != mfDuration) + { + double fAddedTime(0.0); + const sal_uInt32 nIndex(impGetIndexAtTime(fTime, fAddedTime)); + + if(nIndex < maEntries.size()) + { + return maEntries[nIndex]->getStateAtTime(fTime - fAddedTime); + } + } + + return 0.0; + } + + double animationEntryList::getNextEventTime(double fTime) const + { + if(0.0 != mfDuration) + { + double fAddedTime(0.0); + const sal_uInt32 nIndex(impGetIndexAtTime(fTime, fAddedTime)); + + if(nIndex < maEntries.size()) + { + return maEntries[nIndex]->getNextEventTime(fTime - fAddedTime); + } + } + + return fTime; + } + + ////////////////////////////////////////////////////////////////////////////// + + animationEntryLoop::animationEntryLoop(sal_uInt32 nRepeat) + : animationEntryList(), + mnRepeat(nRepeat) + { + } + + animationEntryLoop::~animationEntryLoop() + { + } + + animationEntry* animationEntryLoop::clone() const + { + animationEntryLoop* pNew = new animationEntryLoop(mnRepeat); + + for(sal_uInt32 a(0L); a < maEntries.size(); a++) + { + pNew->append(*maEntries[a]); + } + + return pNew; + } + + bool animationEntryLoop::operator==(const animationEntry& rCandidate) const + { + const animationEntryLoop* pCompare = dynamic_cast< const animationEntryLoop* >(&rCandidate); + + return (pCompare + && animationEntryList::operator==(rCandidate) + && mnRepeat == pCompare->mnRepeat); + } + + double animationEntryLoop::getDuration() const + { + return (mfDuration * (double)mnRepeat); + } + + double animationEntryLoop::getStateAtTime(double fTime) const + { + if(mnRepeat && 0.0 != mfDuration) + { + const sal_uInt32 nCurrentLoop((sal_uInt32)(fTime / mfDuration)); + + if(nCurrentLoop > mnRepeat) + { + return 1.0; + } + else + { + const double fTimeAtLoopStart((double)nCurrentLoop * mfDuration); + const double fRelativeTime(fTime - fTimeAtLoopStart); + return animationEntryList::getStateAtTime(fRelativeTime); + } + } + + return 0.0; + } + + double animationEntryLoop::getNextEventTime(double fTime) const + { + if(mnRepeat && 0.0 != mfDuration) + { + const sal_uInt32 nCurrentLoop((sal_uInt32)(fTime / mfDuration)); + + if(nCurrentLoop <= mnRepeat) + { + const double fTimeAtLoopStart((double)nCurrentLoop * mfDuration); + const double fRelativeTime(fTime - fTimeAtLoopStart); + const double fNextEventAtLoop(animationEntryList::getNextEventTime(fRelativeTime)); + + if(fNextEventAtLoop != fRelativeTime) + { + return fNextEventAtLoop + fTimeAtLoopStart; + } + } + } + + return fTime; + } + } // end of namespace animation +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/animation/makefile.mk b/drawinglayer/source/animation/makefile.mk new file mode 100644 index 000000000000..2d1d39b4c387 --- /dev/null +++ b/drawinglayer/source/animation/makefile.mk @@ -0,0 +1,51 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: aw $ $Date: 2006-05-12 11:50:12 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=drawinglayer +TARGET=animation + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/animationtiming.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/drawinglayer/source/geometry/makefile.mk b/drawinglayer/source/geometry/makefile.mk new file mode 100644 index 000000000000..3e1f2074a5b6 --- /dev/null +++ b/drawinglayer/source/geometry/makefile.mk @@ -0,0 +1,52 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: aw $ $Date: 2006-05-12 11:49:41 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=drawinglayer +TARGET=geometry + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/viewinformation.obj \ + $(SLO)$/transformation3d.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx new file mode 100644 index 000000000000..e5f1733fc110 --- /dev/null +++ b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx @@ -0,0 +1,316 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: hatchtextureprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:06 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX +#include <basegfx/polygon/b2dpolypolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX +#include <basegfx/polygon/b2dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONCLIPPER_HXX +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#endif + +#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX +#include <basegfx/matrix/b3dhommatrix.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void hatchTexturePrimitive3D::impCreateDecomposition(const primitiveList& rSource, primitiveList& rDest) + { + for(sal_uInt32 a(0L); a < rSource.count(); a++) + { + // get reference + const referencedPrimitive& rCandidate = rSource.getReferencedPrimitive(a); + + // not all content is needed, remove transparencies and ModifiedColorPrimitives + switch(rCandidate.getID()) + { + case CreatePrimitiveID('P', 'O', 'M', '3'): + { + // polyPolygonMaterialPrimitive3D, check texturing and hatching + const polyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const polyPolygonMaterialPrimitive3D& >(rCandidate.getBasePrimitive()); + const ::basegfx::B3DPolyPolygon aFillPolyPolygon(rPrimitive.getB3DPolyPolygon()); + + if(aFillPolyPolygon.areTextureCoordinatesUsed()) + { + const sal_uInt32 nPolyCount(aFillPolyPolygon.count()); + ::basegfx::B2DPolyPolygon aTexPolyPolygon; + ::basegfx::B2DPoint a2N; + ::basegfx::B2DVector a2X, a2Y; + ::basegfx::B3DPoint a3N; + ::basegfx::B3DVector a3X, a3Y; + bool b2N(false), b2X(false), b2Y(false); + sal_uInt32 a, b; + + for(a = 0L; a < nPolyCount; a++) + { + const ::basegfx::B3DPolygon aPartPoly(aFillPolyPolygon.getB3DPolygon(a)); + const sal_uInt32 nPointCount(aPartPoly.count()); + ::basegfx::B2DPolygon aTexPolygon; + + for(b = 0L; b < nPointCount; b++) + { + const ::basegfx::B2DPoint a2Candidate(aPartPoly.getTextureCoordinate(b)); + + if(!b2N) + { + a2N = a2Candidate; + a3N = aPartPoly.getB3DPoint(b); + b2N = true; + } + else if(!b2X && !a2N.equal(a2Candidate)) + { + a2X = a2Candidate - a2N; + a3X = aPartPoly.getB3DPoint(b) - a3N; + b2X = true; + } + else if(!b2Y && !a2N.equal(a2Candidate) && !a2X.equal(a2Candidate)) + { + a2Y = a2Candidate - a2N; + + const double fCross(a2X.cross(a2Y)); + + if(!::basegfx::fTools::equalZero(fCross)) + { + a3Y = aPartPoly.getB3DPoint(b) - a3N; + b2Y = true; + } + } + + aTexPolygon.append(a2Candidate); + } + + aTexPolygon.setClosed(true); + aTexPolyPolygon.append(aTexPolygon); + } + + if(b2N && b2X && b2Y) + { + // found two linearly independent 2D vectors + // get 2d range of texture coordinates + const ::basegfx::B2DRange aOutlineRange(::basegfx::tools::getRange(aTexPolyPolygon)); + const ::basegfx::BColor aHatchColor(maHatch.getColor()); + const double fAngle(-maHatch.getAngle()); + ::std::vector< ::basegfx::B2DHomMatrix > aMatrices; + + // get hatch transformations + switch(maHatch.getStyle()) + { + case HATCHSTYLE_TRIPLE: + { + // rotated 45 degrees + geoTexSvxHatch aHatch(aOutlineRange, maHatch.getDistance(), fAngle + F_PI4); + aHatch.appendTransformations(aMatrices); + } + case HATCHSTYLE_DOUBLE: + { + // rotated 90 degrees + geoTexSvxHatch aHatch(aOutlineRange, maHatch.getDistance(), fAngle + F_PI2); + aHatch.appendTransformations(aMatrices); + } + case HATCHSTYLE_SINGLE: + { + // angle as given + geoTexSvxHatch aHatch(aOutlineRange, maHatch.getDistance(), fAngle); + aHatch.appendTransformations(aMatrices); + } + } + + // create geometry from unit line + ::basegfx::B2DPolyPolygon a2DHatchLines; + ::basegfx::B2DPolygon a2DUnitLine; + a2DUnitLine.append(::basegfx::B2DPoint(0.0, 0.0)); + a2DUnitLine.append(::basegfx::B2DPoint(1.0, 0.0)); + + for(a = 0L; a < aMatrices.size(); a++) + { + const ::basegfx::B2DHomMatrix& rMatrix = aMatrices[a]; + ::basegfx::B2DPolygon aNewLine(a2DUnitLine); + aNewLine.transform(rMatrix); + a2DHatchLines.append(aNewLine); + } + + if(a2DHatchLines.count()) + { + // clip against texture polygon + a2DHatchLines = ::basegfx::tools::clipPolyPolygonOnPolyPolygon(a2DHatchLines, aTexPolyPolygon, true, false); + } + + if(a2DHatchLines.count()) + { + // create 2d matrix with 2d vectors as column vectors and 2d point as offset, this represents + // a coordinate system transformation from unit coordinates to the new coordinate system + ::basegfx::B2DHomMatrix a2D; + a2D.set(0, 0, a2X.getX()); + a2D.set(1, 0, a2X.getY()); + a2D.set(0, 1, a2Y.getX()); + a2D.set(1, 1, a2Y.getY()); + a2D.set(0, 2, a2N.getX()); + a2D.set(1, 2, a2N.getY()); + + // invert that transformation, so we have a back-transformation from texture coordinates + // to unit coordinates + a2D.invert(); + a2DHatchLines.transform(a2D); + + // expand back-transformated geometry tpo 3D + ::basegfx::B3DPolyPolygon a3DHatchLines(::basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(a2DHatchLines, 0.0)); + + // create 3d matrix with 3d vectors as column vectors (0,0,1 as Z) and 3d point as offset, this represents + // a coordinate system transformation from unit coordinates to the object's 3d coordinate system + ::basegfx::B3DHomMatrix a3D; + a3D.set(0, 0, a3X.getX()); + a3D.set(1, 0, a3X.getY()); + a3D.set(2, 0, a3X.getZ()); + a3D.set(0, 1, a3Y.getX()); + a3D.set(1, 1, a3Y.getY()); + a3D.set(2, 1, a3Y.getZ()); + a3D.set(0, 3, a3N.getX()); + a3D.set(1, 3, a3N.getY()); + a3D.set(2, 3, a3N.getZ()); + + // transform hatch lines to 3D object coordinates + a3DHatchLines.transform(a3D); + + // build primitives from this geometry + const sal_uInt32 nHatchLines(a3DHatchLines.count()); + + for(a = 0L; a < nHatchLines; a++) + { + basePrimitive* pNew = new polygonHairlinePrimitive3D(a3DHatchLines.getB3DPolygon(a), aHatchColor); + rDest.append(referencedPrimitive(*pNew)); + } + } + } + } + + if(maHatch.isFillBackground()) + { + // add original primitive for background + rDest.append(rCandidate); + } + + break; + } + + default: + { + // add to destination + rDest.append(rCandidate); + break; + } + } + } + } + + void hatchTexturePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + if(maPrimitiveList.count()) + { + // create decomposition + primitiveList aNewPrimitiveList; + impCreateDecomposition(maPrimitiveList, aNewPrimitiveList); + rTarget.append(aNewPrimitiveList); + } + } + + hatchTexturePrimitive3D::hatchTexturePrimitive3D( + const fillHatchAttribute& rHatch, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter) + : texturePrimitive3D(rPrimitiveList, rTextureSize, bModulate, bFilter), + maHatch(rHatch) + { + } + + hatchTexturePrimitive3D::~hatchTexturePrimitive3D() + { + } + + bool hatchTexturePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(texturePrimitive3D::operator==(rPrimitive)) + { + const hatchTexturePrimitive3D& rCompare = (hatchTexturePrimitive3D&)rPrimitive; + return (maHatch == rCompare.maHatch); + } + + return false; + } + + basePrimitive* hatchTexturePrimitive3D::createNewClone() const + { + return new hatchTexturePrimitive3D(maHatch, maPrimitiveList, maTextureSize, mbModulate, mbFilter); + } + + PrimitiveID hatchTexturePrimitive3D::getID() const + { + return CreatePrimitiveID('H', 'A', 'X', '3'); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/makefile.mk b/drawinglayer/source/primitive3d/makefile.mk new file mode 100644 index 000000000000..49f2615555cb --- /dev/null +++ b/drawinglayer/source/primitive3d/makefile.mk @@ -0,0 +1,68 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: aw $ $Date: 2006-05-12 11:49:06 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=drawinglayer +TARGET=primitive3d + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/materialattribute3d.obj \ + $(SLO)$/sdrallattribute3d.obj \ + $(SLO)$/sdrattribute3d.obj \ + $(SLO)$/primitiveprocessor3d.obj \ + $(SLO)$/shadowprimitive3d.obj \ + $(SLO)$/textureprimitive3d.obj \ + $(SLO)$/hatchtextureprimitive3d.obj \ + $(SLO)$/polygontubeprimitive3d.obj \ + $(SLO)$/polygonprimitive3d.obj \ + $(SLO)$/polypolygonprimitive3d.obj \ + $(SLO)$/sdrdecompositiontools3d.obj \ + $(SLO)$/sdrextrudelathetools3d.obj \ + $(SLO)$/sdrprimitive3d.obj \ + $(SLO)$/sdrcubeprimitive3d.obj \ + $(SLO)$/sdrextrudeprimitive3d.obj \ + $(SLO)$/sdrsphereprimitive3d.obj \ + $(SLO)$/sdrlatheprimitive3d.obj \ + $(SLO)$/sdrpolygonprimitive3d.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/drawinglayer/source/primitive3d/polygonprimitive3d.cxx b/drawinglayer/source/primitive3d/polygonprimitive3d.cxx new file mode 100644 index 000000000000..5551c58ddba0 --- /dev/null +++ b/drawinglayer/source/primitive3d/polygonprimitive3d.cxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polygonprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:06 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolygontools.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVELIST_HXX +#include <drawinglayer/primitive/primitivelist.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + polygonHairlinePrimitive3D::polygonHairlinePrimitive3D(const ::basegfx::B3DPolygon& rPolygon, const ::basegfx::BColor& rBColor) + : maPolygon(rPolygon), + maBColor(rBColor) + { + } + + polygonHairlinePrimitive3D::~polygonHairlinePrimitive3D() + { + } + + bool polygonHairlinePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(getID() == rPrimitive.getID()) + { + const polygonHairlinePrimitive3D& rCompare = (polygonHairlinePrimitive3D&)rPrimitive; + + return (maPolygon == rCompare.maPolygon + && maBColor == rCompare.maBColor); + } + + return false; + } + + basePrimitive* polygonHairlinePrimitive3D::createNewClone() const + { + return new polygonHairlinePrimitive3D(maPolygon, maBColor); + } + + PrimitiveID polygonHairlinePrimitive3D::getID() const + { + return CreatePrimitiveID('P', 'O', 'H', '3'); + } + + ::basegfx::B3DRange polygonHairlinePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const + { + return ::basegfx::tools::getRange(maPolygon); + } + + void polygonHairlinePrimitive3D::transform(const ::basegfx::B3DHomMatrix& rMatrix) + { + basePrimitive::transform(rMatrix); + maPolygon.transform(rMatrix); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void polygonStrokePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + if(maPolygon.count()) + { + ::basegfx::B3DPolyPolygon aHairLinePolyPolygon(maPolygon); + + if(0.0 != maStrokeAttribute.getFullDotDashLen()) + { + // apply LineStyle + aHairLinePolyPolygon = ::basegfx::tools::applyLineDashing(aHairLinePolyPolygon, maStrokeAttribute.getDotDashArray(), maStrokeAttribute.getFullDotDashLen()); + + // merge LineStyle polygons to bigger parts + aHairLinePolyPolygon = ::basegfx::tools::mergeDashedLines(aHairLinePolyPolygon); + } + + if(maStrokeAttribute.getWidth()) + { + // create fat line data + const double fRadius(maStrokeAttribute.getWidth() / 2.0); + const ::basegfx::tools::B2DLineJoin aLineJoin(maStrokeAttribute.getLineJoin()); + + for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) + { + // create tube primitives + polygonTubePrimitive3D* pNew = new polygonTubePrimitive3D(aHairLinePolyPolygon.getB3DPolygon(a), + maStrokeAttribute.getColor(), + fRadius, aLineJoin); + rTarget.append(referencedPrimitive(*pNew)); + } + } + else + { + // create hair line data for all sub polygons + for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) + { + const ::basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a); + basePrimitive* pNew = new polygonHairlinePrimitive3D(aCandidate, maStrokeAttribute.getColor()); + rTarget.append(referencedPrimitive(*pNew)); + } + } + } + } + + polygonStrokePrimitive3D::polygonStrokePrimitive3D(const ::basegfx::B3DPolygon& rPolygon, const strokeAttribute& rStrokeAttribute) + : maPolygon(rPolygon), + maStrokeAttribute(rStrokeAttribute) + { + } + + polygonStrokePrimitive3D::~polygonStrokePrimitive3D() + { + } + + bool polygonStrokePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(getID() == rPrimitive.getID()) + { + const polygonStrokePrimitive3D& rCompare = (polygonStrokePrimitive3D&)rPrimitive; + + return (maPolygon == rCompare.maPolygon + && maStrokeAttribute == rCompare.maStrokeAttribute); + } + + return false; + } + + basePrimitive* polygonStrokePrimitive3D::createNewClone() const + { + return new polygonStrokePrimitive3D(maPolygon, maStrokeAttribute); + } + + PrimitiveID polygonStrokePrimitive3D::getID() const + { + return CreatePrimitiveID('P', 'L', 'S', '3'); + } + + void polygonStrokePrimitive3D::transform(const ::basegfx::B3DHomMatrix& rMatrix) + { + basePrimitive::transform(rMatrix); + maPolygon.transform(rMatrix); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx new file mode 100644 index 000000000000..144c59267778 --- /dev/null +++ b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx @@ -0,0 +1,571 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polygontubeprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:07 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONTUBEPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX +#include <basegfx/matrix/b3dhommatrix.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_MATERIALATTRIBUTE3D_HXX +#include <drawinglayer/primitive3d/materialattribute3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVELIST_HXX +#include <drawinglayer/primitive/primitivelist.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + namespace // anonymous namespace + { + const primitiveList& getLineTubeSegments(sal_uInt32 nSegments, const materialAttribute3D& rMaterial) + { + // static data for buffered tube primitives + static primitiveList aLineTubeList; + static sal_uInt32 nLineTubeSegments(0L); + static materialAttribute3D aLineMaterial; + + // may exclusively change static data, use mutex + ::osl::Mutex m_mutex; + + if(nSegments != nLineTubeSegments || rMaterial != aLineMaterial) + { + nLineTubeSegments = nSegments; + aLineMaterial = rMaterial; + aLineTubeList.clear(); + } + + if(0L == aLineTubeList.count() && 0L != nLineTubeSegments) + { + const ::basegfx::B3DPoint aLeft(0.0, 0.0, 0.0); + const ::basegfx::B3DPoint aRight(1.0, 0.0, 0.0); + ::basegfx::B3DPoint aLastLeft(0.0, 1.0, 0.0); + ::basegfx::B3DPoint aLastRight(1.0, 1.0, 0.0); + ::basegfx::B3DHomMatrix aRot; + aRot.rotate(F_2PI / (double)nLineTubeSegments, 0.0, 0.0); + + for(sal_uInt32 a(0L); a < nLineTubeSegments; a++) + { + const ::basegfx::B3DPoint aNextLeft(aRot * aLastLeft); + const ::basegfx::B3DPoint aNextRight(aRot * aLastRight); + ::basegfx::B3DPolygon aNew; + + aNew.append(aNextLeft); + aNew.setNormal(0L, ::basegfx::B3DVector(aNextLeft - aLeft)); + + aNew.append(aLastLeft); + aNew.setNormal(1L, ::basegfx::B3DVector(aLastLeft - aLeft)); + + aNew.append(aLastRight); + aNew.setNormal(2L, ::basegfx::B3DVector(aLastRight - aRight)); + + aNew.append(aNextRight); + aNew.setNormal(3L, ::basegfx::B3DVector(aNextRight - aRight)); + + aNew.setClosed(true); + + basePrimitive* pNew = new polyPolygonMaterialPrimitive3D(::basegfx::B3DPolyPolygon(aNew), aLineMaterial, false); + aLineTubeList.append(referencedPrimitive(*pNew)); + + aLastLeft = aNextLeft; + aLastRight = aNextRight; + } + } + + return aLineTubeList; + } + + const primitiveList& getLineCapSegments(sal_uInt32 nSegments, const materialAttribute3D& rMaterial) + { + // static data for buffered tube primitives + static primitiveList aLineCapList; + static sal_uInt32 nLineCapSegments(0L); + static materialAttribute3D aLineMaterial; + + // may exclusively change static data, use mutex + ::osl::Mutex m_mutex; + + if(nSegments != nLineCapSegments || rMaterial != aLineMaterial) + { + nLineCapSegments = nSegments; + aLineMaterial = rMaterial; + aLineCapList.clear(); + } + + if(0L == aLineCapList.count() && 0L != nLineCapSegments) + { + const ::basegfx::B3DPoint aNull(0.0, 0.0, 0.0); + ::basegfx::B3DPoint aLast(0.0, 1.0, 0.0); + ::basegfx::B3DHomMatrix aRot; + aRot.rotate(F_2PI / (double)nLineCapSegments, 0.0, 0.0); + + for(sal_uInt32 a(0L); a < nLineCapSegments; a++) + { + const ::basegfx::B3DPoint aNext(aRot * aLast); + ::basegfx::B3DPolygon aNew; + + aNew.append(aLast); + aNew.setNormal(0L, ::basegfx::B3DVector(aLast - aNull)); + + aNew.append(aNext); + aNew.setNormal(1L, ::basegfx::B3DVector(aNext - aNull)); + + aNew.append(aNull); + aNew.setNormal(2L, ::basegfx::B3DVector(-1.0, 0.0, 0.0)); + + aNew.setClosed(true); + + basePrimitive* pNew = new polyPolygonMaterialPrimitive3D(::basegfx::B3DPolyPolygon(aNew), aLineMaterial, false); + aLineCapList.append(referencedPrimitive(*pNew)); + + aLast = aNext; + } + } + + return aLineCapList; + } + + void getLineJoinSegments(primitiveList& rDest, sal_uInt32 nSegments, const materialAttribute3D& rMaterial, double fAngle, + double fDegreeStepWidth, double fMiterMinimumAngle, ::basegfx::tools::B2DLineJoin aLineJoin) + { + // nSegments is for whole circle, adapt to half circle + const sal_uInt32 nVerSeg(nSegments >> 1L); + + if(nVerSeg) + { + if(::basegfx::tools::B2DLINEJOIN_ROUND == aLineJoin) + { + // calculate new horizontal segments + const sal_uInt32 nHorSeg((sal_uInt32)((fAngle / F_2PI) * (double)nSegments)); + + if(nHorSeg) + { + // create half-sphere + const ::basegfx::B3DPolyPolygon aSphere(::basegfx::tools::createUnitSphereFillPolyPolygon(nHorSeg, nVerSeg, true, F_PI2, -F_PI2, 0.0, fAngle)); + + for(sal_uInt32 a(0L); a < aSphere.count(); a++) + { + basePrimitive* pNew = new polyPolygonMaterialPrimitive3D(::basegfx::B3DPolyPolygon(aSphere.getB3DPolygon(a)), rMaterial, false); + rDest.append(referencedPrimitive(*pNew)); + } + } + else + { + // fallback to bevel when there is not at least one segment hor and ver + aLineJoin = ::basegfx::tools::B2DLINEJOIN_BEVEL; + } + } + + if(::basegfx::tools::B2DLINEJOIN_MIDDLE == aLineJoin + || ::basegfx::tools::B2DLINEJOIN_BEVEL == aLineJoin + || ::basegfx::tools::B2DLINEJOIN_MITER == aLineJoin) + { + if(::basegfx::tools::B2DLINEJOIN_MITER == aLineJoin) + { + const double fMiterAngle(fAngle/2.0); + + if(fMiterAngle < fMiterMinimumAngle) + { + // fallback to bevel when miter's angle is too small + aLineJoin = ::basegfx::tools::B2DLINEJOIN_BEVEL; + } + } + + const double fInc(F_PI / (double)nVerSeg); + const double fSin(sin(-fAngle)); + const double fCos(cos(-fAngle)); + const bool bMiter(::basegfx::tools::B2DLINEJOIN_MITER == aLineJoin); + const double fMiterSin(bMiter ? sin(-(fAngle/2.0)) : 0.0); + const double fMiterCos(bMiter ? cos(-(fAngle/2.0)) : 0.0); + double fPos(-F_PI2); + ::basegfx::B3DPoint aPointOnXY, aPointRotY, aNextPointOnXY, aNextPointRotY; + ::basegfx::B3DPoint aCurrMiter, aNextMiter; + ::basegfx::B3DPolygon aNew, aMiter; + + // close polygon + aNew.setClosed(true); + aMiter.setClosed(true); + + for(sal_uInt32 a(0L); a < nVerSeg; a++) + { + const bool bFirst(0L == a); + const bool bLast(a + 1L == nVerSeg); + + if(bFirst || !bLast) + { + fPos += fInc; + + aNextPointOnXY = ::basegfx::B3DPoint( + cos(fPos), + sin(fPos), + 0.0); + + aNextPointRotY = ::basegfx::B3DPoint( + aNextPointOnXY.getX() * fCos, + aNextPointOnXY.getY(), + aNextPointOnXY.getX() * fSin); + + if(bMiter) + { + aNextMiter = ::basegfx::B3DPoint( + aNextPointOnXY.getX(), + aNextPointOnXY.getY(), + fMiterSin * (aNextPointOnXY.getX() / fMiterCos)); + } + } + + if(bFirst) + { + aNew.clear(); + + if(bMiter) + { + aNew.append(::basegfx::B3DPoint(0.0, -1.0, 0.0)); + aNew.append(aNextPointOnXY); + aNew.append(aNextMiter); + + aMiter.clear(); + aMiter.append(::basegfx::B3DPoint(0.0, -1.0, 0.0)); + aMiter.append(aNextMiter); + aMiter.append(aNextPointRotY); + } + else + { + aNew.append(::basegfx::B3DPoint(0.0, -1.0, 0.0)); + aNew.append(aNextPointOnXY); + aNew.append(aNextPointRotY); + } + } + else if(bLast) + { + aNew.clear(); + + if(bMiter) + { + aNew.append(::basegfx::B3DPoint(0.0, 1.0, 0.0)); + aNew.append(aCurrMiter); + aNew.append(aPointOnXY); + + aMiter.clear(); + aMiter.append(::basegfx::B3DPoint(0.0, 1.0, 0.0)); + aMiter.append(aPointRotY); + aMiter.append(aCurrMiter); + } + else + { + aNew.append(::basegfx::B3DPoint(0.0, 1.0, 0.0)); + aNew.append(aPointRotY); + aNew.append(aPointOnXY); + } + } + else + { + aNew.clear(); + + if(bMiter) + { + aNew.append(aPointOnXY); + aNew.append(aNextPointOnXY); + aNew.append(aNextMiter); + aNew.append(aCurrMiter); + + aMiter.clear(); + aMiter.append(aCurrMiter); + aMiter.append(aNextMiter); + aMiter.append(aNextPointRotY); + aMiter.append(aPointRotY); + } + else + { + aNew.append(aPointRotY); + aNew.append(aPointOnXY); + aNew.append(aNextPointOnXY); + aNew.append(aNextPointRotY); + } + } + + // set normals + for(sal_uInt32 b(0L); b < aNew.count(); b++) + { + aNew.setNormal(b, ::basegfx::B3DVector(aNew.getB3DPoint(b))); + } + + // create primitive + if(aNew.count()) + { + basePrimitive* pNew = new polyPolygonMaterialPrimitive3D(::basegfx::B3DPolyPolygon(aNew), rMaterial, false); + rDest.append(referencedPrimitive(*pNew)); + } + + if(bMiter && aMiter.count()) + { + // set normals + for(sal_uInt32 c(0L); c < aMiter.count(); c++) + { + aMiter.setNormal(c, ::basegfx::B3DVector(aMiter.getB3DPoint(c))); + } + + // create primitive + basePrimitive* pNew = new polyPolygonMaterialPrimitive3D(::basegfx::B3DPolyPolygon(aMiter), rMaterial, false); + rDest.append(referencedPrimitive(*pNew)); + } + + // prepare next step + if(bFirst || !bLast) + { + aPointOnXY = aNextPointOnXY; + aPointRotY = aNextPointRotY; + + if(bMiter) + { + aCurrMiter = aNextMiter; + } + } + } + } + } + } + + ::basegfx::B3DHomMatrix getRotationFromVector(const ::basegfx::B3DVector& rVector) + { + // build transformation from unit vector to vector + ::basegfx::B3DHomMatrix aRetval; + + // extract rot angles from vector, first in XY + const double fRotInXY(atan2(rVector.getY(), rVector.getX())); + + // now get rot in XZ. Use negative Z due to right-handed system. Use XYLength as + // X-Coordinate to get correct angle + const double fRotInXZ(atan2(-rVector.getZ(), rVector.getXYLength())); + + // fill rotation. This will first rotate around Y, then around + // Z, that's why the angles needed to be extracted in that order + if(!::basegfx::fTools::equalZero(fRotInXY) || !::basegfx::fTools::equalZero(fRotInXZ)) + { + aRetval.rotate(0.0, fRotInXZ, fRotInXY); + } + + return aRetval; + } + } // end of anonymous namespace + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void polygonTubePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + const sal_uInt32 nPointCount(maPolygon.count()); + + if(0L != nPointCount) + { + if(::basegfx::fTools::more(mfRadius, 0.0)) + { + const materialAttribute3D aMaterial(maBColor); + static sal_uInt32 nSegments(8L); // default for 3d line segments, for more quality just raise this value (in even steps) + const bool bClosed(maPolygon.isClosed()); + const bool bNoLineJoin(::basegfx::tools::B2DLINEJOIN_NONE == maLineJoin); + const sal_uInt32 nLoopCount(bClosed ? nPointCount : nPointCount - 1L); + ::basegfx::B3DPoint aLast(maPolygon.getB3DPoint(nPointCount - 1L)); + ::basegfx::B3DPoint aCurr(maPolygon.getB3DPoint(0L)); + + for(sal_uInt32 a(0L); a < nLoopCount; a++) + { + // get next data + const ::basegfx::B3DPoint aNext(maPolygon.getB3DPoint((a + 1L) % nPointCount)); + const ::basegfx::B3DVector aForw(aNext - aCurr); + const double fForwLen(aForw.getLength()); + primitiveList aNewList; + + if(::basegfx::fTools::more(fForwLen, 0.0)) + { + // get rotation from vector, this describes rotation from (1, 0, 0) to aForw + ::basegfx::B3DHomMatrix aRotVector(getRotationFromVector(aForw)); + + // create default transformation with scale and rotate + ::basegfx::B3DHomMatrix aVectorTrans; + aVectorTrans.scale(fForwLen, mfRadius, mfRadius); + aVectorTrans *= aRotVector; + aVectorTrans.translate(aCurr.getX(), aCurr.getY(), aCurr.getZ()); + + if(bNoLineJoin || (!bClosed && !a)) + { + // line start edge + aNewList = getLineCapSegments(nSegments, aMaterial); + aNewList.transform(aVectorTrans); + rTarget.append(aNewList); + } + else + { + const ::basegfx::B3DVector aBack(aCurr - aLast); + const double fCross(::basegfx::cross(aBack, aForw).getLength()); + + if(!::basegfx::fTools::equalZero(fCross)) + { + // line connect non-parallel, aBack, aForw, use maLineJoin + const double fAngle(acos(aBack.scalar(aForw) / (fForwLen * aBack.getLength()))); // 0.0 .. F_PI2 + aNewList.clear(); + getLineJoinSegments(aNewList, nSegments, aMaterial, fAngle, mfDegreeStepWidth, mfMiterMinimumAngle, maLineJoin); + + // calculate transformation. First, get angle in YZ between nForw projected on (1, 0, 0) and nBack + ::basegfx::B3DHomMatrix aInvRotVector(aRotVector); + aInvRotVector.invert(); + ::basegfx::B3DVector aTransBack(aInvRotVector * aBack); + const double fRotInYZ(atan2(aTransBack.getY(), aTransBack.getZ())); + + // create trans by rotating unit sphere with angle 90 degrees around Y, then 180-fRot in X. + // Also apply usual scaling and translation + ::basegfx::B3DHomMatrix aSphereTrans; + aSphereTrans.rotate(0.0, F_PI2, 0.0); + aSphereTrans.rotate(F_PI - fRotInYZ, 0.0, 0.0); + aSphereTrans *= aRotVector; + aSphereTrans.scale(mfRadius, mfRadius, mfRadius); + aSphereTrans.translate(aCurr.getX(), aCurr.getY(), aCurr.getZ()); + + // apply to list and append + aNewList.transform(aSphereTrans); + rTarget.append(aNewList); + } + } + + // create line segments + aNewList = getLineTubeSegments(nSegments, aMaterial); + aNewList.transform(aVectorTrans); + rTarget.append(aNewList); + + if(bNoLineJoin || (!bClosed && ((a + 1L) == nLoopCount))) + { + // line end edge, first rotate (mirror) and translate, then use use aRotVector + ::basegfx::B3DHomMatrix aBackTrans; + aBackTrans.rotate(0.0, F_PI, 0.0); + aBackTrans.translate(1.0, 0.0, 0.0); + aBackTrans.scale(fForwLen, mfRadius, mfRadius); + aBackTrans *= aRotVector; + aBackTrans.translate(aCurr.getX(), aCurr.getY(), aCurr.getZ()); + + aNewList = getLineCapSegments(nSegments, aMaterial); + aNewList.transform(aBackTrans); + rTarget.append(aNewList); + } + } + + // prepare next loop step + aLast = aCurr; + aCurr = aNext; + } + } + else + { + // create hairline + polygonHairlinePrimitive3D* pNew = new polygonHairlinePrimitive3D(maPolygon, maBColor); + rTarget.append(referencedPrimitive(*pNew)); + } + } + } + + polygonTubePrimitive3D::polygonTubePrimitive3D( + const ::basegfx::B3DPolygon& rPolygon, + const ::basegfx::BColor& rBColor, + double fRadius, ::basegfx::tools::B2DLineJoin aLineJoin, + double fDegreeStepWidth, + double fMiterMinimumAngle) + : polygonHairlinePrimitive3D(rPolygon, rBColor), + mfRadius(fRadius), + mfDegreeStepWidth(fDegreeStepWidth), + mfMiterMinimumAngle(fMiterMinimumAngle), + maLineJoin(aLineJoin) + { + } + + polygonTubePrimitive3D::~polygonTubePrimitive3D() + { + } + + bool polygonTubePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(polygonHairlinePrimitive3D::operator==(rPrimitive)) + { + const polygonTubePrimitive3D& rCompare = (polygonTubePrimitive3D&)rPrimitive; + + return (mfRadius == rCompare.mfRadius + && mfDegreeStepWidth == rCompare.mfDegreeStepWidth + && mfMiterMinimumAngle == rCompare.mfMiterMinimumAngle + && maLineJoin == rCompare.maLineJoin); + } + + return false; + } + + basePrimitive* polygonTubePrimitive3D::createNewClone() const + { + return new polygonTubePrimitive3D(maPolygon, maBColor, mfRadius, maLineJoin, mfDegreeStepWidth, mfMiterMinimumAngle); + } + + PrimitiveID polygonTubePrimitive3D::getID() const + { + return CreatePrimitiveID('T', 'U', 'B', '3'); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/polypolygonprimitive3d.cxx b/drawinglayer/source/primitive3d/polypolygonprimitive3d.cxx new file mode 100644 index 000000000000..14fa7cbc4cde --- /dev/null +++ b/drawinglayer/source/primitive3d/polypolygonprimitive3d.cxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: polypolygonprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:07 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + polyPolygonMaterialPrimitive3D::polyPolygonMaterialPrimitive3D(const ::basegfx::B3DPolyPolygon& rPolyPolygon, const materialAttribute3D& rMaterial, bool bDoubleSided) + : maPolyPolygon(rPolyPolygon), + maMaterial(rMaterial), + mbDoubleSided(bDoubleSided) + { + } + + polyPolygonMaterialPrimitive3D::~polyPolygonMaterialPrimitive3D() + { + } + + bool polyPolygonMaterialPrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(getID() == rPrimitive.getID()) + { + const polyPolygonMaterialPrimitive3D& rCompare = (polyPolygonMaterialPrimitive3D&)rPrimitive; + + return (maPolyPolygon == rCompare.maPolyPolygon + && maMaterial == rCompare.maMaterial + && mbDoubleSided == rCompare.mbDoubleSided); + } + + return false; + } + + basePrimitive* polyPolygonMaterialPrimitive3D::createNewClone() const + { + return new polyPolygonMaterialPrimitive3D(maPolyPolygon, maMaterial, mbDoubleSided); + } + + PrimitiveID polyPolygonMaterialPrimitive3D::getID() const + { + return CreatePrimitiveID('P', 'O', 'M', '3'); + } + + ::basegfx::B3DRange polyPolygonMaterialPrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const + { + return ::basegfx::tools::getRange(maPolyPolygon); + } + + void polyPolygonMaterialPrimitive3D::transform(const ::basegfx::B3DHomMatrix& rMatrix) + { + basePrimitive::transform(rMatrix); + maPolyPolygon.transform(rMatrix); + + if(maPolyPolygon.areNormalsUsed()) + { + maPolyPolygon.transformNormals(rMatrix); + } + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx new file mode 100644 index 000000000000..b5270cad199f --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx @@ -0,0 +1,234 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrcubeprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:07 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRCUBEPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrcubeprimitive3d.hxx> +#endif + +#ifndef _BGFX_RANGE_B3DRANGE_HXX +#include <basegfx/range/b3drange.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVELIST_HXX +#include <drawinglayer/primitive/primitivelist.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolygontools.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void sdrCubePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + const ::basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); + + // add fill + if(getSdrLFSAttribute().getFill()) + { + ::basegfx::B3DPolyPolygon aFill(::basegfx::tools::createCubeFillPolyPolygonFromB3DRange(aUnitRange)); + + // normal creation + { + if(::com::sun::star::drawing::NormalsKind_SPECIFIC == getSdr3DObjectAttribute().getNormalsKind() + || ::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()) + { + // create sphere normals + const ::basegfx::B3DPoint aCenter(::basegfx::tools::getRange(aFill).getCenter()); + aFill = ::basegfx::tools::applyDefaultNormalsSphere(aFill, aCenter); + } + + if(getSdr3DObjectAttribute().getNormalsInvert()) + { + // invert normals + aFill = ::basegfx::tools::invertNormals(aFill); + } + } + + // texture coordinates + { + // handle texture coordinates X + const bool bParallelX(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bObjectSpecificX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bSphereX(!bParallelX && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionX())); + + // handle texture coordinates Y + const bool bParallelY(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionY()); + const bool bObjectSpecificY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionY()); + const bool bSphereY(!bParallelY && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionY())); + + if(bParallelX || bParallelY) + { + // apply parallel texture coordinates in X and/or Y + const ::basegfx::B3DRange aRange(::basegfx::tools::getRange(aFill)); + aFill = ::basegfx::tools::applyDefaultTextureCoordinatesParallel(aFill, aRange, bParallelX, bParallelY); + } + + if(bSphereX || bSphereY) + { + // apply spherical texture coordinates in X and/or Y + const ::basegfx::B3DRange aRange(::basegfx::tools::getRange(aFill)); + const ::basegfx::B3DPoint aCenter(aRange.getCenter()); + aFill = ::basegfx::tools::applyDefaultTextureCoordinatesSphere(aFill, aCenter, bSphereX, bSphereY); + } + + if(bObjectSpecificX || bObjectSpecificY) + { + // object-specific + for(sal_uInt32 a(0L); a < aFill.count(); a++) + { + ::basegfx::B3DPolygon aTmpPoly(aFill.getB3DPolygon(a)); + + if(aTmpPoly.count() >= 4L) + { + for(sal_uInt32 b(0L); b < 4L; b++) + { + ::basegfx::B2DPoint aPoint(aTmpPoly.getTextureCoordinate(b)); + + if(bObjectSpecificX) + { + aPoint.setX((1L == b || 2L == b) ? 1.0 : 0.0); + } + + if(bObjectSpecificY) + { + aPoint.setY((2L == b || 3L == b) ? 1.0 : 0.0); + } + + aTmpPoly.setTextureCoordinate(b, aPoint); + } + + aFill.setB3DPolygon(a, aTmpPoly); + } + } + } + + // transform texture coordinates to texture size + ::basegfx::B2DHomMatrix aTexMatrix; + aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + aFill.transformTextureCoordiantes(aTexMatrix); + } + + // build vector of PolyPolygons + ::std::vector< ::basegfx::B3DPolyPolygon > a3DPolyPolygonVector; + + for(sal_uInt32 a(0L); a < aFill.count(); a++) + { + a3DPolyPolygonVector.push_back(::basegfx::B3DPolyPolygon(aFill.getB3DPolygon(a))); + } + + // create single PolyPolygonFill primitives + add3DPolyPolygonFillPrimitive( + a3DPolyPolygonVector, maTransform, maTextureSize, rTarget, + getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), + getSdrLFSAttribute().getFillFloatTransGradient()); + } + + // add line + if(getSdrLFSAttribute().getLine()) + { + ::basegfx::B3DPolyPolygon aLine(::basegfx::tools::createCubePolyPolygonFromB3DRange(aUnitRange)); + add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *getSdrLFSAttribute().getLine()); + } + + // add shadow + if(getSdrLFSAttribute().getShadow()) + { + addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + } + } + + sdrCubePrimitive3D::sdrCubePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute) + : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute) + { + } + + sdrCubePrimitive3D::~sdrCubePrimitive3D() + { + } + + bool sdrCubePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + return sdrPrimitive3D::operator==(rPrimitive); + } + + basePrimitive* sdrCubePrimitive3D::createNewClone() const + { + return new sdrCubePrimitive3D(maTransform, maTextureSize, maSdrLFSAttribute, maSdr3DObjectAttribute); + } + + PrimitiveID sdrCubePrimitive3D::getID() const + { + return CreatePrimitiveID('S', 'C', 'U', '3'); + } + + ::basegfx::B3DRange sdrCubePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const + { + // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2 + return getStandard3DRange(rViewInformation); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx new file mode 100644 index 000000000000..5b1a905a62cb --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx @@ -0,0 +1,277 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrdecompositiontools3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_STROKEATTRIBUTE_HXX +#include <drawinglayer/primitive/strokeattribute.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_SDRATTRIBUTE_HXX +#include <drawinglayer/primitive/sdrattribute.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVE_HXX +#include <drawinglayer/primitive/primitive.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYGONPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVELIST_HXX +#include <drawinglayer/primitive/primitivelist.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_SIMPLETRANSPARENCEPRIMITIVE_HXX +#include <drawinglayer/primitive/simpletransparenceprimitive.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_POLYPOLYGONPRIMITIVE_HXX +#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRATTRIBUTE3D_HXX +#include <drawinglayer/primitive3d/sdrattribute3d.hxx> +#endif + +#ifndef _VCL_VCLENUM_HXX +#include <vcl/vclenum.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_FILLATTRIBUTE_HXX +#include <drawinglayer/primitive/fillattribute.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_FILLBITMAPATTRIBUTE_HXX +#include <drawinglayer/primitive/fillbitmapattribute.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_SDRFILLBITMAPATTRIBUTE_HXX +#include <drawinglayer/primitive/sdrfillbitmapattribute.hxx> +#endif + +#ifndef _SV_BMPACC_HXX +#include <vcl/bmpacc.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/textureprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_MODIFIEDCOLORPRIMITIVE_HXX +#include <drawinglayer/primitive/modifiedcolorprimitive.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_HATCHTEXTUREPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/shadowprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void add3DPolyPolygonLinePrimitive( + const ::basegfx::B3DPolyPolygon& rUnitPolyPolygon, + const ::basegfx::B3DHomMatrix& rObjectTransform, + primitiveList& rTarget, + const sdrLineAttribute& rLine) + { + // prepare fully scaled polyPolygon + ::basegfx::B3DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon); + aScaledPolyPolygon.transform(rObjectTransform); + + // create stroke attribute + const strokeAttribute aStrokeAttribute(rLine.getColor(), rLine.getWidth(), rLine.getJoin(), rLine.getDotDashArray(), rLine.getFullDotDashLen()); + + // create primitives + primitiveList aNewPrimitiveList; + + for(sal_uInt32 a(0L); a < aScaledPolyPolygon.count(); a++) + { + basePrimitive* pNewLinePrimitive = new polygonStrokePrimitive3D(aScaledPolyPolygon.getB3DPolygon(a), aStrokeAttribute); + aNewPrimitiveList.append(referencedPrimitive(*pNewLinePrimitive)); + } + + if(0.0 != rLine.getTransparence()) + { + // create simpleTransparencePrimitive, add created fill primitives + basePrimitive* pNewSimpleTransparenceTexturePrimitive3D = new simpleTransparenceTexturePrimitive3D(rLine.getTransparence(), aNewPrimitiveList); + rTarget.append(referencedPrimitive(*pNewSimpleTransparenceTexturePrimitive3D)); + } + else + { + // add to decomposition + rTarget.append(aNewPrimitiveList); + } + } + + void add3DPolyPolygonFillPrimitive( + const ::std::vector< ::basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, + const ::basegfx::B3DHomMatrix& rObjectTransform, + const ::basegfx::B2DVector& rTextureSize, + primitiveList& rTarget, + const sdr3DObjectAttribute& aSdr3DObjectAttribute, + const sdrFillAttribute& rFill, + const fillGradientAttribute* pFillGradient) + { + if(r3DPolyPolygonVector.size()) + { + // create list of simple fill primitives + primitiveList aNewPrimitiveList; + + for(sal_uInt32 a(0L); a < r3DPolyPolygonVector.size(); a++) + { + // get scaled PolyPolygon + ::basegfx::B3DPolyPolygon aScaledPolyPolygon(r3DPolyPolygonVector[a]); + aScaledPolyPolygon.transform(rObjectTransform); + + if(aScaledPolyPolygon.areNormalsUsed()) + { + aScaledPolyPolygon.transformNormals(rObjectTransform); + } + + basePrimitive* pNewFillPrimitive = new polyPolygonMaterialPrimitive3D( + aScaledPolyPolygon, + aSdr3DObjectAttribute.getMaterial(), + aSdr3DObjectAttribute.getDoubleSided()); + aNewPrimitiveList.append(referencedPrimitive(*pNewFillPrimitive)); + } + + // look for and evtl. build texture sub-group primitive + if(rFill.isGradient() || rFill.isHatch() || rFill.isBitmap()) + { + bool bModulate(::com::sun::star::drawing::TextureMode_MODULATE == aSdr3DObjectAttribute.getTextureMode()); + bool bFilter(aSdr3DObjectAttribute.getTextureFilter()); + basePrimitive* pNewTexturePrimitive3D = 0L; + + if(rFill.isGradient()) + { + // create gradientTexture3D with sublist, add to local aNewPrimitiveList + pNewTexturePrimitive3D = new gradientTexturePrimitive3D(*rFill.getGradient(), aNewPrimitiveList, rTextureSize, bModulate, bFilter); + } + else if(rFill.isHatch()) + { + // create hatchTexture3D with sublist, add to local aNewPrimitiveList + pNewTexturePrimitive3D = new hatchTexturePrimitive3D(*rFill.getHatch(), aNewPrimitiveList, rTextureSize, bModulate, bFilter); + } + else // if(rFill.isBitmap()) + { + // create bitmapTexture3D with sublist, add to local aNewPrimitiveList + ::basegfx::B2DRange aTexRange(0.0, 0.0, rTextureSize.getX(), rTextureSize.getY()); + pNewTexturePrimitive3D = new bitmapTexturePrimitive3D(rFill.getBitmap()->getFillBitmapAttribute(aTexRange), aNewPrimitiveList, rTextureSize, bModulate, bFilter); + } + + // exchange aNewPrimitiveList content with texture group + aNewPrimitiveList.clear(); + aNewPrimitiveList.append(referencedPrimitive(*pNewTexturePrimitive3D)); + + if(::com::sun::star::drawing::TextureKind2_LUMINANCE == aSdr3DObjectAttribute.getTextureKind()) + { + // use modified color primitive to force textures to gray + basePrimitive* pModifiedColor = new modifiedColorPrimitive(::basegfx::BColor(), aNewPrimitiveList, 0.0, COLORMODIFY_GRAY); + aNewPrimitiveList.clear(); + aNewPrimitiveList.append(referencedPrimitive(*pModifiedColor)); + } + } + + if(0.0 != rFill.getTransparence()) + { + // create simpleTransparenceTexturePrimitive3D with sublist and append + basePrimitive* pNewSimpleTransparenceTexturePrimitive3D = new simpleTransparenceTexturePrimitive3D(rFill.getTransparence(), aNewPrimitiveList); + rTarget.append(referencedPrimitive(*pNewSimpleTransparenceTexturePrimitive3D)); + } + else if(pFillGradient) + { + // create transparenceTexture3D with sublist and append + basePrimitive* pNewTransparenceTexturePrimitive3D = new transparenceTexturePrimitive3D(*pFillGradient, aNewPrimitiveList, rTextureSize); + rTarget.append(referencedPrimitive(*pNewTransparenceTexturePrimitive3D)); + } + else + { + // append list + rTarget.append(aNewPrimitiveList); + } + } + } + + void addShadowPrimitive3D( + primitiveList& rTarget, + const sdrShadowAttribute& rShadow, + bool bShadow3D) + { + // create Shadow primitives. Need to be added in front, should use already created primitives + if(rTarget.count() && !::basegfx::fTools::moreOrEqual(rShadow.getTransparence(), 1.0)) + { + // prepare new list for shadow geometry + primitiveList aNewList; + + // prepare shadow offset + ::basegfx::B2DHomMatrix aShadowOffset; + aShadowOffset.set(0, 2, rShadow.getOffset().getX()); + aShadowOffset.set(1, 2, rShadow.getOffset().getY()); + + // create shadow primitive and add primitives + primitiveList aShadowPrimitiveList(rTarget); + shadowPrimitive3D* pNewShadow3D = new shadowPrimitive3D(aShadowOffset, rShadow.getColor(), rShadow.getTransparence(), bShadow3D, aShadowPrimitiveList); + rTarget.clear(); + rTarget.append(referencedPrimitive(*pNewShadow3D)); + } + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx new file mode 100644 index 000000000000..2a3f4c67d91c --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx @@ -0,0 +1,832 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrextrudelathetools3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX +#include <basegfx/polygon/b2dpolypolygon.hxx> +#endif + +#ifndef _BGFX_RANGE_B2DRANGE_HXX +#include <basegfx/range/b2drange.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +#ifndef _BGFX_POINT_B3DPOINT_HXX +#include <basegfx/point/b3dpoint.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolygontools.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_RANGE_B3DRANGE_HXX +#include <basegfx/range/b3drange.hxx> +#endif + +#ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX +#include <basegfx/matrix/b3dhommatrix.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#include <numeric> + +////////////////////////////////////////////////////////////////////////////// +// decompositon helpers for extrude/lathe (rotation) objects + +namespace +{ + ////////////////////////////////////////////////////////////////////////////// + // common helpers + + ::basegfx::B2DPolyPolygon impScalePolyPolygonOnCenter(const ::basegfx::B2DPolyPolygon& rSource, double fScale) + { + ::basegfx::B2DPolyPolygon aRetval(rSource); + + if(!::basegfx::fTools::equalZero(fScale)) + { + const ::basegfx::B2DRange aRange(::basegfx::tools::getRange(rSource)); + const ::basegfx::B2DPoint aCenter(aRange.getCenter()); + ::basegfx::B2DHomMatrix aTrans; + + aTrans.translate(-aCenter.getX(), -aCenter.getY()); + aTrans.scale(fScale, fScale); + aTrans.translate(aCenter.getX(), aCenter.getY()); + aRetval.transform(aTrans); + } + + return aRetval; + } + + void impGetOuterPolyPolygon(::basegfx::B2DPolyPolygon& rPolygon, ::basegfx::B2DPolyPolygon& rOuterPolyPolygon, double fOffset, bool bCharacterMode) + { + rOuterPolyPolygon = rPolygon; + + if(::basegfx::fTools::more(fOffset, 0.0)) + { + if(bCharacterMode) + { + // grow the outside polygon and scale all polygons to original size. This is done + // to avoid a shrink which potentially would lead to self-intersections, but changes + // the original polygon -> not a precision step, so e.g. not usable for charts + const ::basegfx::B2DRange aRange(::basegfx::tools::getRange(rPolygon)); + rPolygon = ::basegfx::tools::growInNormalDirection(rPolygon, fOffset); + const ::basegfx::B2DRange aGrownRange(::basegfx::tools::getRange(rPolygon)); + const double fScaleX(::basegfx::fTools::equalZero(aGrownRange.getWidth()) ? 1.0 : aRange.getWidth() / aGrownRange.getWidth()); + const double fScaleY(::basegfx::fTools::equalZero(aGrownRange.getHeight())? 1.0 : aRange.getHeight() / aGrownRange.getHeight()); + ::basegfx::B2DHomMatrix aScaleTrans; + + aScaleTrans.translate(-aGrownRange.getMinX(), -aGrownRange.getMinY()); + aScaleTrans.scale(fScaleX, fScaleY); + aScaleTrans.translate(aRange.getMinX(), aRange.getMinY()); + rPolygon.transform(aScaleTrans); + rOuterPolyPolygon.transform(aScaleTrans); + } + else + { + // use more precision, shrink the outer polygons. Since this may lead to self-intersections, + // some kind of correction should be applied here after that step + rOuterPolyPolygon = ::basegfx::tools::growInNormalDirection(rPolygon, -fOffset); + ::basegfx::tools::correctGrowShrinkPolygonPair(rPolygon, rOuterPolyPolygon); + } + } + } + + void impAddInBetweenFill(::basegfx::B3DPolyPolygon& rTarget, const ::basegfx::B3DPolyPolygon& rPolA, const ::basegfx::B3DPolyPolygon& rPolB, + double fTexVerStart, double fTexVerStop, bool bCreateNormals, bool bCreateTextureCoordinates) + { + OSL_ENSURE(rPolA.count() == rPolB.count(), "impAddInBetweenFill: unequally sized polygons (!)"); + const sal_uInt32 nPolygonCount(rPolA.count()); + + for(sal_uInt32 a(0L); a < nPolygonCount; a++) + { + const ::basegfx::B3DPolygon aSubA(rPolA.getB3DPolygon(a)); + const ::basegfx::B3DPolygon aSubB(rPolB.getB3DPolygon(a)); + OSL_ENSURE(aSubA.count() == aSubB.count(), "impAddInBetweenFill: unequally sized polygons (!)"); + const sal_uInt32 nPointCount(aSubA.count()); + + if(nPointCount) + { + const sal_uInt32 nEdgeCount(aSubA.isClosed() ? nPointCount : nPointCount - 1L); + double fTexHorMultiplicatorA, fTexHorMultiplicatorB; + double fPolygonPosA, fPolygonPosB; + + if(bCreateTextureCoordinates) + { + const double fPolygonLengthA(::basegfx::tools::getLength(aSubA)); + fTexHorMultiplicatorA = ::basegfx::fTools::equalZero(fPolygonLengthA) ? 1.0 : 1.0 / fPolygonLengthA; + + const double fPolygonLengthB(::basegfx::tools::getLength(aSubB)); + fTexHorMultiplicatorB = ::basegfx::fTools::equalZero(fPolygonLengthB) ? 1.0 : 1.0 / fPolygonLengthB; + + fPolygonPosA = fPolygonPosB = 0.0; + } + + for(sal_uInt32 b(0L); b < nEdgeCount; b++) + { + const sal_uInt32 nIndexA(b); + const sal_uInt32 nIndexB((b + 1L) % nPointCount); + + const ::basegfx::B3DPoint aStartA(aSubA.getB3DPoint(nIndexA)); + const ::basegfx::B3DPoint aEndA(aSubA.getB3DPoint(nIndexB)); + const ::basegfx::B3DPoint aStartB(aSubB.getB3DPoint(nIndexA)); + const ::basegfx::B3DPoint aEndB(aSubB.getB3DPoint(nIndexB)); + + ::basegfx::B3DPolygon aNew; + aNew.setClosed(true); + + aNew.append(aStartA); + aNew.append(aStartB); + aNew.append(aEndB); + aNew.append(aEndA); + + if(bCreateNormals) + { + aNew.setNormal(0L, aSubA.getNormal(nIndexA)); + aNew.setNormal(1L, aSubB.getNormal(nIndexA)); + aNew.setNormal(2L, aSubB.getNormal(nIndexB)); + aNew.setNormal(3L, aSubA.getNormal(nIndexB)); + } + + if(bCreateTextureCoordinates) + { + const double fRelTexAL(fPolygonPosA * fTexHorMultiplicatorA); + const double fEdgeLengthA(::basegfx::B3DVector(aEndA - aStartA).getLength()); + fPolygonPosA += fEdgeLengthA; + const double fRelTexAR(fPolygonPosA * fTexHorMultiplicatorA); + + const double fRelTexBL(fPolygonPosB * fTexHorMultiplicatorB); + const double fEdgeLengthB(::basegfx::B3DVector(aEndB - aStartB).getLength()); + fPolygonPosB += fEdgeLengthB; + const double fRelTexBR(fPolygonPosB * fTexHorMultiplicatorB); + + aNew.setTextureCoordinate(0L, ::basegfx::B2DPoint(fRelTexAL, fTexVerStart)); + aNew.setTextureCoordinate(1L, ::basegfx::B2DPoint(fRelTexBL, fTexVerStop)); + aNew.setTextureCoordinate(2L, ::basegfx::B2DPoint(fRelTexBR, fTexVerStop)); + aNew.setTextureCoordinate(3L, ::basegfx::B2DPoint(fRelTexAR, fTexVerStart)); + } + + rTarget.append(aNew); + } + } + } + } + + void impSetNormal(::basegfx::B3DPolyPolygon& rCandidate, const ::basegfx::B3DVector& rNormal) + { + for(sal_uInt32 a(0L); a < rCandidate.count(); a++) + { + ::basegfx::B3DPolygon aSub(rCandidate.getB3DPolygon(a)); + + for(sal_uInt32 b(0L); b < aSub.count(); b++) + { + aSub.setNormal(b, rNormal); + } + + rCandidate.setB3DPolygon(a, aSub); + } + } + + void impCreateInBetweenNormals(::basegfx::B3DPolyPolygon& rPolA, ::basegfx::B3DPolyPolygon& rPolB, bool bSmoothHorizontalNormals) + { + OSL_ENSURE(rPolA.count() == rPolB.count(), "sdrExtrudePrimitive3D: unequally sized polygons (!)"); + + for(sal_uInt32 a(0L); a < rPolA.count(); a++) + { + ::basegfx::B3DPolygon aSubA(rPolA.getB3DPolygon(a)); + ::basegfx::B3DPolygon aSubB(rPolB.getB3DPolygon(a)); + OSL_ENSURE(aSubA.count() == aSubB.count(), "sdrExtrudePrimitive3D: unequally sized polygons (!)"); + const sal_uInt32 nPointCount(aSubA.count()); + + if(nPointCount) + { + ::basegfx::B3DPoint aPrev(aSubA.getB3DPoint(nPointCount - 1L)); + ::basegfx::B3DPoint aCurrA(aSubA.getB3DPoint(0L)); + const bool bClosed(aSubA.isClosed()); + + for(sal_uInt32 b(0L); b < nPointCount; b++) + { + const sal_uInt32 nIndNext((b + 1L) % nPointCount); + const ::basegfx::B3DPoint aNext(aSubA.getB3DPoint(nIndNext)); + const ::basegfx::B3DPoint aCurrB(aSubB.getB3DPoint(b)); + + // vector to back + ::basegfx::B3DVector aDepth(aCurrB - aCurrA); + aDepth.normalize(); + + // vector to left + ::basegfx::B3DVector aLeft(aPrev - aCurrA); + + if(!bClosed && 0L == b) + { + // correct for non-closed lines + aLeft = aCurrA - aNext; + } + + aLeft.normalize(); + + // create left normal + const ::basegfx::B3DVector aNormalLeft(aDepth.getPerpendicular(aLeft)); + + if(bSmoothHorizontalNormals) + { + // vector to right + ::basegfx::B3DVector aRight(aNext - aCurrA); + + if(!bClosed && b + 1L == nPointCount) + { + // correct for non-closed lines + aRight = aCurrA - aPrev; + } + + aRight.normalize(); + + // create right normal + const ::basegfx::B3DVector aNormalRight(aRight.getPerpendicular(aDepth)); + + // create smoothed in-between normal + ::basegfx::B3DVector aNewNormal(aNormalLeft + aNormalRight); + aNewNormal.normalize(); + + // set as new normal at polygons + aSubA.setNormal(b, aNewNormal); + aSubB.setNormal(b, aNewNormal); + } + else + { + // set aNormalLeft as new normal at polygons + aSubA.setNormal(b, aNormalLeft); + aSubB.setNormal(b, aNormalLeft); + } + + // prepare next step + aPrev = aCurrA; + aCurrA = aNext; + } + + rPolA.setB3DPolygon(a, aSubA); + rPolB.setB3DPolygon(a, aSubB); + } + } + } + + void impMixNormals(::basegfx::B3DPolyPolygon& rPolA, const ::basegfx::B3DPolyPolygon& rPolB, double fWeightA) + { + const double fWeightB(1.0 - fWeightA); + OSL_ENSURE(rPolA.count() == rPolB.count(), "sdrExtrudePrimitive3D: unequally sized polygons (!)"); + + for(sal_uInt32 a(0L); a < rPolA.count(); a++) + { + ::basegfx::B3DPolygon aSubA(rPolA.getB3DPolygon(a)); + const ::basegfx::B3DPolygon aSubB(rPolB.getB3DPolygon(a)); + OSL_ENSURE(aSubA.count() == aSubB.count(), "sdrExtrudePrimitive3D: unequally sized polygons (!)"); + const sal_uInt32 nPointCount(aSubA.count()); + + for(sal_uInt32 b(0L); b < nPointCount; b++) + { + const ::basegfx::B3DVector aVA(aSubA.getNormal(b) * fWeightA); + const ::basegfx::B3DVector aVB(aSubB.getNormal(b) * fWeightB); + ::basegfx::B3DVector aVNew(aVA + aVB); + aVNew.normalize(); + aSubA.setNormal(b, aVNew); + } + + rPolA.setB3DPolygon(a, aSubA); + } + } + +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + bool createLatheSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource, + double fBackScale, double fDiagonal, double fRotation, sal_uInt32 nSteps, + bool bCharacterMode, bool bCloseFront, bool bCloseBack) + { + bool bClosedRotation(false); + + if(::basegfx::fTools::equalZero(fRotation) || 0L == nSteps) + { + // no rotation or no steps, just one plane + rSliceVector.push_back(slice(rSource, ::basegfx::B3DHomMatrix())); + } + else + { + const bool bBackScale(!::basegfx::fTools::equal(fBackScale, 1.0)); + bClosedRotation = (!bBackScale && ::basegfx::fTools::equal(fRotation, F_2PI)); + ::basegfx::B2DPolyPolygon aFront(rSource); + ::basegfx::B2DPolyPolygon aBack(rSource); + ::basegfx::B3DHomMatrix aTransformBack; + ::basegfx::B2DPolyPolygon aOuterBack; + + if(bClosedRotation) + { + bCloseFront = bCloseBack = false; + } + + if(bBackScale) + { + // avoid null zoom + if(::basegfx::fTools::equalZero(fBackScale)) + { + fBackScale = 0.000001; + } + + // back is scaled compared to front, create scaled version + aBack = impScalePolyPolygonOnCenter(aBack, fBackScale); + } + + if(bCloseFront || bCloseBack) + { + const ::basegfx::B2DRange aBaseRange(::basegfx::tools::getRange(aFront)); + const double fOuterLength(aBaseRange.getMaxX() * fRotation); + const double fInnerLength(aBaseRange.getMinX() * fRotation); + const double fAverageLength((fOuterLength + fInnerLength) * 0.5); + + if(bCloseFront) + { + const double fOffsetLen((fAverageLength / 12.0) * fDiagonal); + ::basegfx::B2DPolyPolygon aOuterFront; + impGetOuterPolyPolygon(aFront, aOuterFront, fOffsetLen, bCharacterMode); + ::basegfx::B3DHomMatrix aTransform; + aTransform.translate(0.0, 0.0, fOffsetLen); + rSliceVector.push_back(slice(aOuterFront, aTransform, SLICETYPE_FRONTCAP)); + } + + if(bCloseBack) + { + const double fOffsetLen((fAverageLength / 12.0) * fDiagonal); + impGetOuterPolyPolygon(aBack, aOuterBack, fOffsetLen, bCharacterMode); + aTransformBack.translate(0.0, 0.0, -fOffsetLen); + aTransformBack.rotate(0.0, fRotation, 0.0); + } + } + + // add start polygon (a = 0L) + if(!bClosedRotation) + { + rSliceVector.push_back(slice(aFront, ::basegfx::B3DHomMatrix())); + } + + // create segments (a + 1 .. nSteps) + const double fStepSize(1.0 / (double)nSteps); + + for(sal_uInt32 a(0L); a < nSteps; a++) + { + const double fStep((double)(a + 1L) * fStepSize); + ::basegfx::B2DPolyPolygon aNewPoly(bBackScale ? ::basegfx::tools::interpolate(aFront, aBack, fStep) : aFront); + ::basegfx::B3DHomMatrix aNewMat; + aNewMat.rotate(0.0, fRotation * fStep, 0.0); + rSliceVector.push_back(slice(aNewPoly, aNewMat)); + } + + if(bCloseBack) + { + rSliceVector.push_back(slice(aOuterBack, aTransformBack, SLICETYPE_BACKCAP)); + } + } + + return bClosedRotation; + } + + void createExtrudeSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource, + double fBackScale, double fDiagonal, double fDepth, + bool bCharacterMode, bool bCloseFront, bool bCloseBack) + { + if(::basegfx::fTools::equalZero(fDepth)) + { + // no depth, just one plane + rSliceVector.push_back(slice(rSource, ::basegfx::B3DHomMatrix())); + } + else + { + // there is depth, create Polygons for front,back and their default depth positions + ::basegfx::B2DPolyPolygon aFront(rSource); + ::basegfx::B2DPolyPolygon aBack(rSource); + const bool bBackScale(!::basegfx::fTools::equal(fBackScale, 1.0)); + double fZFront(fDepth); // default depth for aFront + double fZBack(0.0); // default depth for aBack + ::basegfx::B2DPolyPolygon aOuterBack; + + if(bBackScale) + { + // avoid null zoom + if(::basegfx::fTools::equalZero(fBackScale)) + { + fBackScale = 0.000001; + } + + // aFront is scaled compared to aBack, create scaled version + aFront = impScalePolyPolygonOnCenter(aFront, fBackScale); + } + + if(bCloseFront) + { + const double fOffset(fDepth * fDiagonal * 0.5); + fZFront = fDepth - fOffset; + ::basegfx::B2DPolyPolygon aOuterFront; + impGetOuterPolyPolygon(aFront, aOuterFront, fOffset, bCharacterMode); + ::basegfx::B3DHomMatrix aTransformFront; + aTransformFront.translate(0.0, 0.0, fDepth); + rSliceVector.push_back(slice(aOuterFront, aTransformFront, SLICETYPE_FRONTCAP)); + } + + if(bCloseBack) + { + const double fOffset(fDepth * fDiagonal * 0.5); + fZBack = fOffset; + impGetOuterPolyPolygon(aBack, aOuterBack, fOffset, bCharacterMode); + } + + // add front and back polygons at evtl. changed depths + { + ::basegfx::B3DHomMatrix aTransformA, aTransformB; + + aTransformA.translate(0.0, 0.0, fZFront); + rSliceVector.push_back(slice(aFront, aTransformA)); + + aTransformB.translate(0.0, 0.0, fZBack); + rSliceVector.push_back(slice(aBack, aTransformB)); + } + + if(bCloseBack) + { + rSliceVector.push_back(slice(aOuterBack, ::basegfx::B3DHomMatrix(), SLICETYPE_BACKCAP)); + } + } + } + + void extractLinesFromSlice(::basegfx::B3DPolyPolygon& rLine, const sliceVector& rSliceVector, bool bClosed) + { + const sal_uInt32 nNumSlices(rSliceVector.size()); + + if(nNumSlices) + { + // slices self + for(sal_uInt32 a(0L); a < nNumSlices; a++) + { + rLine.append(rSliceVector[a].getB3DPolyPolygon()); + } + + // horizontal + const ::basegfx::B3DPolyPolygon& aFirstPolyPolygon(rSliceVector[0L].getB3DPolyPolygon()); + const sal_uInt32 nPolygonCount(aFirstPolyPolygon.count()); + + for(sal_uInt32 b(0L); b < nPolygonCount; b++) + { + const ::basegfx::B3DPolygon& aFirstPolygon(aFirstPolyPolygon.getB3DPolygon(0L)); + const sal_uInt32 nPointCount(aFirstPolygon.count()); + + for(sal_uInt32 c(0L); c < nPointCount; c++) + { + ::basegfx::B3DPolygon aNew; + + for(sal_uInt32 d(0L); d < nNumSlices; d++) + { + aNew.append(rSliceVector[d].getB3DPolyPolygon().getB3DPolygon(b).getB3DPoint(c)); + } + + aNew.setClosed(bClosed); + rLine.append(aNew); + } + } + } + } + + void extractPlanesFromSlice(::std::vector< ::basegfx::B3DPolyPolygon >& rFill, const sliceVector& rSliceVector, + bool bCreateNormals, bool bSmoothHorizontalNormals, bool bSmoothNormals, bool bSmoothLids, bool bClosed, + double fSmoothNormalsMix, double fSmoothLidsMix, bool bCreateTextureCoordinates, const ::basegfx::B2DHomMatrix& rTexTransform) + { + const sal_uInt32 nNumSlices(rSliceVector.size()); + + if(nNumSlices) + { + // common parameters + const sal_uInt32 nLoopCount(bClosed ? nNumSlices : nNumSlices - 1L); + ::basegfx::B3DPolyPolygon aEdgeRounding; + sal_uInt32 a; + + // tetxture parameters + double fInvTexHeight(1.0); + double fTexHeightPos(0.0); + double fTexStart(0.0); + double fTexStop(1.0); + ::std::vector<double> aTexHeightArray; + ::basegfx::B3DRange aTexRangeFront; + ::basegfx::B3DRange aTexRangeBack; + + if(bCreateTextureCoordinates) + { + aTexRangeFront = ::basegfx::tools::getRange(rSliceVector[0L].getB3DPolyPolygon()); + aTexRangeBack = ::basegfx::tools::getRange(rSliceVector[nNumSlices - 1L].getB3DPolyPolygon()); + + if(aTexRangeBack.getDepth() > aTexRangeBack.getWidth()) + { + // last polygon is rotated so that depth is bigger than width, exchange X and Z + // for making applyDefaultTextureCoordinatesParallel use Z instead of X for + // horizontal texture coordinate + aTexRangeBack = ::basegfx::B3DRange( + aTexRangeBack.getMinZ(), aTexRangeBack.getMinY(), aTexRangeBack.getMinX(), + aTexRangeBack.getMaxZ(), aTexRangeBack.getMaxY(), aTexRangeBack.getMaxX()); + } + + ::basegfx::B3DPoint aCenter(::basegfx::tools::getRange(rSliceVector[0L].getB3DPolyPolygon()).getCenter()); + + for(sal_uInt32 a(0L); a < nLoopCount; a++) + { + const ::basegfx::B3DPoint aNextCenter(::basegfx::tools::getRange(rSliceVector[(a + 1L) % nNumSlices].getB3DPolyPolygon()).getCenter()); + const double fLength(::basegfx::B3DVector(aNextCenter - aCenter).getLength()); + aTexHeightArray.push_back(fLength); + aCenter = aNextCenter; + } + + const double fTexHeight(::std::accumulate(aTexHeightArray.begin(), aTexHeightArray.end(), 0.0)); + + if(!::basegfx::fTools::equalZero(fTexHeight)) + { + fInvTexHeight = 1.0 / fTexHeight; + } + } + + for(a = 0L; a < nLoopCount; a++) + { + const slice& rSliceA(rSliceVector[a]); + const slice& rSliceB(rSliceVector[(a + 1L) % nNumSlices]); + const bool bAcceptPair(SLICETYPE_REGULAR == rSliceA.getSliceType() && SLICETYPE_REGULAR == rSliceB.getSliceType()); + ::basegfx::B3DPolyPolygon aPolA(rSliceA.getB3DPolyPolygon()); + ::basegfx::B3DPolyPolygon aPolB(rSliceB.getB3DPolyPolygon()); + + if(bAcceptPair) + { + if(bCreateNormals) + { + impCreateInBetweenNormals(aPolB, aPolA, bSmoothHorizontalNormals); + } + + { + const sal_uInt32 nIndPrev((a + nNumSlices - 1L) % nNumSlices); + const slice& rSlicePrev(rSliceVector[nIndPrev]); + ::basegfx::B3DPolyPolygon aPrev(rSlicePrev.getB3DPolyPolygon()); + ::basegfx::B3DPolyPolygon aPolAA(rSliceA.getB3DPolyPolygon()); + + if(SLICETYPE_FRONTCAP == rSlicePrev.getSliceType()) + { + ::basegfx::B3DPolyPolygon aFront(rSlicePrev.getB3DPolyPolygon()); + const bool bHasSlant(aPolAA != aPrev); + + if(bCreateTextureCoordinates) + { + aFront = ::basegfx::tools::applyDefaultTextureCoordinatesParallel(aFront, aTexRangeFront); + } + + if(bCreateNormals) + { + const ::basegfx::B3DVector aNormal(aFront.count() ? -aFront.getB3DPolygon(0L).getNormal() : ::basegfx::B3DVector(0.0, 0.0, -1.0)); + impSetNormal(aFront, aNormal); + + if(bHasSlant) + { + impCreateInBetweenNormals(aPolAA, aPrev, bSmoothHorizontalNormals); + + if(bSmoothNormals) + { + // smooth and copy + impMixNormals(aPolA, aPolAA, fSmoothNormalsMix); + aPolAA = aPolA; + } + else + { + // take over from surface + aPolAA = aPolA; + } + + if(bSmoothLids) + { + // smooth and copy + impMixNormals(aFront, aPrev, fSmoothLidsMix); + aPrev = aFront; + } + else + { + // take over from front + aPrev = aFront; + } + } + else + { + if(bSmoothNormals) + { + // smooth + impMixNormals(aPolA, aFront, fSmoothNormalsMix); + } + + if(bSmoothLids) + { + // smooth and copy + impMixNormals(aFront, aPolA, fSmoothLidsMix); + aPolA = aFront; + } + } + } + + if(bHasSlant) + { + if(bCreateTextureCoordinates) + { + fTexStart = fTexHeightPos * fInvTexHeight; + fTexStop = (fTexHeightPos - aTexHeightArray[(a + nLoopCount - 1L) % nLoopCount]) * fInvTexHeight; + } + + impAddInBetweenFill(aEdgeRounding, aPolAA, aPrev, fTexStart, fTexStop, bCreateNormals, bCreateTextureCoordinates); + } + + aFront.flip(); + rFill.push_back(aFront); + } + else + { + if(bCreateNormals && bSmoothNormals && (nIndPrev != a + 1L)) + { + impCreateInBetweenNormals(aPolAA, aPrev, bSmoothHorizontalNormals); + impMixNormals(aPolA, aPolAA, 0.5); + } + } + } + + { + const sal_uInt32 nIndNext((a + 2L) % nNumSlices); + const slice& rSliceNext(rSliceVector[nIndNext]); + ::basegfx::B3DPolyPolygon aNext(rSliceNext.getB3DPolyPolygon()); + ::basegfx::B3DPolyPolygon aPolBB(rSliceB.getB3DPolyPolygon()); + + if(SLICETYPE_BACKCAP == rSliceNext.getSliceType()) + { + ::basegfx::B3DPolyPolygon aBack(rSliceNext.getB3DPolyPolygon()); + const bool bHasSlant(aPolBB != aNext); + + if(bCreateTextureCoordinates) + { + aBack = ::basegfx::tools::applyDefaultTextureCoordinatesParallel(aBack, aTexRangeBack); + } + + if(bCreateNormals) + { + const ::basegfx::B3DVector aNormal(aBack.count() ? aBack.getB3DPolygon(0L).getNormal() : ::basegfx::B3DVector(0.0, 0.0, 1.0)); + impSetNormal(aBack, aNormal); + + if(bHasSlant) + { + impCreateInBetweenNormals(aNext, aPolBB, bSmoothHorizontalNormals); + + if(bSmoothNormals) + { + // smooth and copy + impMixNormals(aPolB, aPolBB, fSmoothNormalsMix); + aPolBB = aPolB; + } + else + { + // take over from surface + aPolBB = aPolB; + } + + if(bSmoothLids) + { + // smooth and copy + impMixNormals(aBack, aNext, fSmoothLidsMix); + aNext = aBack; + } + else + { + // take over from back + aNext = aBack; + } + } + else + { + if(bSmoothNormals) + { + // smooth + impMixNormals(aPolB, aBack, fSmoothNormalsMix); + } + + if(bSmoothLids) + { + // smooth and copy + impMixNormals(aBack, aPolB, fSmoothLidsMix); + aPolB = aBack; + } + } + } + + if(bHasSlant) + { + if(bCreateTextureCoordinates) + { + fTexStart = (fTexHeightPos + aTexHeightArray[a] + aTexHeightArray[(a + 1L) % nLoopCount]) * fInvTexHeight; + fTexStop = (fTexHeightPos + aTexHeightArray[a]) * fInvTexHeight; + } + + impAddInBetweenFill(aEdgeRounding, aNext, aPolBB, fTexStart, fTexStop, bCreateNormals, bCreateTextureCoordinates); + } + + rFill.push_back(aBack); + } + else + { + if(bCreateNormals && bSmoothNormals && (nIndNext != a)) + { + impCreateInBetweenNormals(aNext, aPolBB, bSmoothHorizontalNormals); + impMixNormals(aPolB, aPolBB, 0.5); + } + } + } + + if(bCreateTextureCoordinates) + { + fTexStart = (fTexHeightPos + aTexHeightArray[a]) * fInvTexHeight; + fTexStop = fTexHeightPos * fInvTexHeight; + } + + impAddInBetweenFill(aEdgeRounding, aPolB, aPolA, fTexStart, fTexStop, bCreateNormals, bCreateTextureCoordinates); + } + + if(bCreateTextureCoordinates) + { + fTexHeightPos += aTexHeightArray[a]; + } + } + + if(bCreateTextureCoordinates) + { + aEdgeRounding.transformTextureCoordiantes(rTexTransform); + } + + for(a = 0L; a < aEdgeRounding.count(); a++) + { + rFill.push_back(::basegfx::B3DPolyPolygon(aEdgeRounding.getB3DPolygon(a))); + } + } + } + + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx new file mode 100644 index 000000000000..b49fd0df12e5 --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx @@ -0,0 +1,334 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrextrudeprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void sdrExtrudePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + if(maPolyPolygon.count()) + { + ::basegfx::B2DPolyPolygon aCandidate(maPolyPolygon); + sliceVector aSliceVector; + + if(getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine()) + { + // prepare the polygon + aCandidate.removeDoublePoints(); + aCandidate = ::basegfx::tools::correctOrientations(aCandidate); + aCandidate = ::basegfx::tools::correctOutmostPolygon(aCandidate); + + // prepare slices as geometry + createExtrudeSlices(aSliceVector, aCandidate, mfBackScale, mfDiagonal, mfDepth, mbCharacterMode, mbCloseFront, mbCloseBack); + } + + // add fill + if(getSdrLFSAttribute().getFill()) + { + sal_uInt32 a; + ::basegfx::B3DRange aRange; + + // decide what to create + const bool bCreateNormals(::com::sun::star::drawing::NormalsKind_SPECIFIC == getSdr3DObjectAttribute().getNormalsKind()); + const bool bCreateTextureCoordiantesX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bCreateTextureCoordiantesY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionY()); + double fRelativeTextureWidth(1.0); + ::basegfx::B2DHomMatrix aTexTransform; + + if(bCreateTextureCoordiantesX || bCreateTextureCoordiantesY) + { + const ::basegfx::B2DPolygon aFirstPolygon(aCandidate.getB2DPolygon(0L)); + const double fFrontLength(::basegfx::tools::getLength(aFirstPolygon)); + const double fFrontArea(::basegfx::tools::getArea(aFirstPolygon)); + const double fSqrtFrontArea(sqrt(fFrontArea)); + fRelativeTextureWidth = ::basegfx::fTools::equalZero(fSqrtFrontArea) ? 1.0 : fFrontLength / fSqrtFrontArea; + fRelativeTextureWidth = (double)((sal_uInt32)(fRelativeTextureWidth - 0.5)); + + if(fRelativeTextureWidth < 1.0) + { + fRelativeTextureWidth = 1.0; + } + + aTexTransform.translate(-0.5, -0.5); + aTexTransform.scale(-1.0, -1.0); + aTexTransform.translate(0.5, 0.5); + aTexTransform.scale(fRelativeTextureWidth, 1.0); + } + + // create geometry + ::std::vector< ::basegfx::B3DPolyPolygon > aFill; + extractPlanesFromSlice(aFill, aSliceVector, + bCreateNormals, mbSmoothHorizontalNormals, mbSmoothNormals, mbSmoothLids, false, + 0.5, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform); + + // get full range + for(a = 0L; a < aFill.size(); a++) + { + aRange.expand(::basegfx::tools::getRange(aFill[a])); + } + + // normal creation + { + if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()) + { + // create sphere normals + const ::basegfx::B3DPoint aCenter(aRange.getCenter()); + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::applyDefaultNormalsSphere(aFill[a], aCenter); + } + } + else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind()) + { + for(a = 0L; a < aFill.size(); a++) + { + aFill[a].clearNormals(); + } + } + + if(getSdr3DObjectAttribute().getNormalsInvert()) + { + // invert normals + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::invertNormals(aFill[a]); + } + } + } + + // texture coordinates + { + // handle texture coordinates X + const bool bParallelX(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bSphereX(!bParallelX && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionX())); + + // handle texture coordinates Y + const bool bParallelY(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionY()); + const bool bSphereY(!bParallelY && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionY())); + + if(bParallelX || bParallelY) + { + // apply parallel texture coordinates in X and/or Y + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::applyDefaultTextureCoordinatesParallel(aFill[a], aRange, bParallelX, bParallelY); + } + } + + if(bSphereX || bSphereY) + { + // apply spherical texture coordinates in X and/or Y + const ::basegfx::B3DPoint aCenter(aRange.getCenter()); + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::applyDefaultTextureCoordinatesSphere(aFill[a], aCenter, bSphereX, bSphereY); + } + } + + // transform texture coordinates to texture size + ::basegfx::B2DHomMatrix aTexMatrix; + aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a].transformTextureCoordiantes(aTexMatrix); + } + } + + // create single PolyPolygonFill primitives + add3DPolyPolygonFillPrimitive( + aFill, maTransform, maTextureSize, rTarget, + getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), + getSdrLFSAttribute().getFillFloatTransGradient()); + } + + // add line + if(getSdrLFSAttribute().getLine()) + { + ::basegfx::B3DPolyPolygon aLine; + extractLinesFromSlice(aLine, aSliceVector, false); + add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *maSdrLFSAttribute.getLine()); + } + + // add shadow + if(getSdrLFSAttribute().getShadow()) + { + addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + } + } + } + + sdrExtrudePrimitive3D::sdrExtrudePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute, + const ::basegfx::B2DPolyPolygon& rPolyPolygon, + double fDepth, + double fDiagonal, + double fBackScale, + bool bSmoothNormals, + bool bSmoothHorizontalNormals, + bool bSmoothLids, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack) + : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), + maPolyPolygon(rPolyPolygon), + mfDepth(fDepth), + mfDiagonal(fDiagonal), + mfBackScale(fBackScale), + mbSmoothNormals(bSmoothNormals), + mbSmoothHorizontalNormals(bSmoothHorizontalNormals), + mbSmoothLids(bSmoothLids), + mbCharacterMode(bCharacterMode), + mbCloseFront(bCloseFront), + mbCloseBack(bCloseBack) + { + // make sure depth is positive + if(::basegfx::fTools::lessOrEqual(mfDepth, 0.0)) + { + mfDepth = 0.0; + } + + // make sure the percentage value mfDiagonal is between 0.0 and 1.0 + if(::basegfx::fTools::lessOrEqual(mfDiagonal, 0.0)) + { + mfDiagonal = 0.0; + } + else if(::basegfx::fTools::moreOrEqual(mfDiagonal, 1.0)) + { + mfDiagonal = 1.0; + } + + // no close front/back when polygon is not closed + if(maPolyPolygon.count() && !maPolyPolygon.getB2DPolygon(0L).isClosed()) + { + mbCloseFront = mbCloseBack = false; + } + + // no edge rounding when not closing + if(!mbCloseFront && !mbCloseBack) + { + mfDiagonal = 0.0; + } + } + + sdrExtrudePrimitive3D::~sdrExtrudePrimitive3D() + { + } + + bool sdrExtrudePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(sdrPrimitive3D::operator==(rPrimitive)) + { + const sdrExtrudePrimitive3D& rCompare = static_cast< const sdrExtrudePrimitive3D& >(rPrimitive); + return (maPolyPolygon == rCompare.maPolyPolygon + && mfDepth == rCompare.mfDepth + && mfDiagonal == rCompare.mfDiagonal + && mfBackScale == rCompare.mfBackScale + && mbSmoothNormals == rCompare.mbSmoothNormals + && mbSmoothHorizontalNormals == rCompare.mbSmoothHorizontalNormals + && mbSmoothLids == rCompare.mbSmoothLids + && mbCharacterMode == rCompare.mbCharacterMode + && mbCloseFront == rCompare.mbCloseFront + && mbCloseBack == rCompare.mbCloseBack); + } + + return false; + } + + basePrimitive* sdrExtrudePrimitive3D::createNewClone() const + { + return new sdrExtrudePrimitive3D( + maTransform, maTextureSize, + maSdrLFSAttribute, maSdr3DObjectAttribute, + maPolyPolygon, mfDepth, mfDiagonal, mfBackScale, + mbSmoothNormals, mbSmoothHorizontalNormals, mbSmoothLids, mbCharacterMode, mbCloseFront, mbCloseBack); + } + + PrimitiveID sdrExtrudePrimitive3D::getID() const + { + return CreatePrimitiveID('S', 'X', 'T', '3'); + } + + ::basegfx::B3DRange sdrExtrudePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const + { + // call parent, use decomposition + return sdrPrimitive3D::get3DRange(rViewInformation); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx new file mode 100644 index 000000000000..d48e7676b24d --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx @@ -0,0 +1,338 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrlatheprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrlatheprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolygontools.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void sdrLathePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + if(maPolyPolygon.count()) + { + ::basegfx::B2DPolyPolygon aCandidate(maPolyPolygon); + sliceVector aSliceVector; + bool bClosedRotation(false); + + if(getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine()) + { + // prepare the polygon + aCandidate = ::basegfx::tools::adaptiveSubdivideByDistance(aCandidate); + aCandidate.removeDoublePoints(); + aCandidate = ::basegfx::tools::correctOrientations(aCandidate); + aCandidate = ::basegfx::tools::correctOutmostPolygon(aCandidate); + + // check edge count of first sub-polygon. If different, reSegment polyPolygon. This ensures + // that for polyPolygons, the subPolys 1..n only get reSegmented when polygon 0L is different + // at all (and not always) + const ::basegfx::B2DPolygon aSubCandidate(aCandidate.getB2DPolygon(0L)); + const sal_uInt32 nSubEdgeCount(aSubCandidate.isClosed() ? aSubCandidate.count() : (aSubCandidate.count() ? aSubCandidate.count() - 1L : 0L)); + + if(nSubEdgeCount != mnVerticalSegments) + { + aCandidate = ::basegfx::tools::reSegmentPolyPolygon(aCandidate, mnVerticalSegments); + } + + // prepare slices as geometry + bClosedRotation = createLatheSlices(aSliceVector, aCandidate, mfBackScale, mfDiagonal, mfRotation, mnHorizontalSegments, mbCharacterMode, mbCloseFront, mbCloseBack); + } + + // add fill + if(getSdrLFSAttribute().getFill()) + { + sal_uInt32 a; + ::basegfx::B3DRange aRange; + + // decide what to create + const bool bCreateNormals(::com::sun::star::drawing::NormalsKind_SPECIFIC == getSdr3DObjectAttribute().getNormalsKind()); + const bool bCreateTextureCoordiantesX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bCreateTextureCoordiantesY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionY()); + ::basegfx::B2DHomMatrix aTexTransform; + + if(bCreateTextureCoordiantesX || bCreateTextureCoordiantesY) + { + aTexTransform.set(0, 0, 0.0); + aTexTransform.set(0, 1, 1.0); + aTexTransform.set(1, 0, 1.0); + aTexTransform.set(1, 1, 0.0); + + aTexTransform.translate(0.0, -0.5); + aTexTransform.scale(1.0, -1.0); + aTexTransform.translate(0.0, 0.5); + } + + // create geometry + ::std::vector< ::basegfx::B3DPolyPolygon > aFill; + extractPlanesFromSlice(aFill, aSliceVector, + bCreateNormals, mbSmoothHorizontalNormals, mbSmoothNormals, mbSmoothLids, bClosedRotation, + 0.85, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform); + + // get full range + for(a = 0L; a < aFill.size(); a++) + { + aRange.expand(::basegfx::tools::getRange(aFill[a])); + } + + // normal creation + { + if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()) + { + // create sphere normals + const ::basegfx::B3DPoint aCenter(aRange.getCenter()); + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::applyDefaultNormalsSphere(aFill[a], aCenter); + } + } + else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind()) + { + for(a = 0L; a < aFill.size(); a++) + { + aFill[a].clearNormals(); + } + } + + if(getSdr3DObjectAttribute().getNormalsInvert()) + { + // invert normals + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::invertNormals(aFill[a]); + } + } + } + + // texture coordinates + { + // handle texture coordinates X + const bool bParallelX(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bSphereX(!bParallelX && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionX())); + + // handle texture coordinates Y + const bool bParallelY(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionY()); + const bool bSphereY(!bParallelY && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionY())); + + if(bParallelX || bParallelY) + { + // apply parallel texture coordinates in X and/or Y + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::applyDefaultTextureCoordinatesParallel(aFill[a], aRange, bParallelX, bParallelY); + } + } + + if(bSphereX || bSphereY) + { + // apply spherical texture coordinates in X and/or Y + const ::basegfx::B3DPoint aCenter(aRange.getCenter()); + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a] = ::basegfx::tools::applyDefaultTextureCoordinatesSphere(aFill[a], aCenter, bSphereX, bSphereY); + } + } + + // transform texture coordinates to texture size + ::basegfx::B2DHomMatrix aTexMatrix; + aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + + for(a = 0L; a < aFill.size(); a++) + { + aFill[a].transformTextureCoordiantes(aTexMatrix); + } + } + + // create single PolyPolygonFill primitives + add3DPolyPolygonFillPrimitive( + aFill, maTransform, maTextureSize, rTarget, + getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), + getSdrLFSAttribute().getFillFloatTransGradient()); + } + + // add line + if(getSdrLFSAttribute().getLine()) + { + ::basegfx::B3DPolyPolygon aLine; + extractLinesFromSlice(aLine, aSliceVector, bClosedRotation); + add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *maSdrLFSAttribute.getLine()); + } + + // add shadow + if(getSdrLFSAttribute().getShadow()) + { + addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + } + } + } + + sdrLathePrimitive3D::sdrLathePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute, + const ::basegfx::B2DPolyPolygon& rPolyPolygon, + sal_uInt32 nHorizontalSegments, + sal_uInt32 nVerticalSegments, + double fDiagonal, + double fBackScale, + double fRotation, + bool bSmoothNormals, + bool bSmoothHorizontalNormals, + bool bSmoothLids, + bool bCharacterMode, + bool bCloseFront, + bool bCloseBack) + : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), + maPolyPolygon(rPolyPolygon), + mnHorizontalSegments(nHorizontalSegments), + mnVerticalSegments(nVerticalSegments), + mfDiagonal(fDiagonal), + mfBackScale(fBackScale), + mfRotation(fRotation), + mbSmoothNormals(bSmoothNormals), + mbSmoothHorizontalNormals(bSmoothHorizontalNormals), + mbSmoothLids(bSmoothLids), + mbCharacterMode(bCharacterMode), + mbCloseFront(bCloseFront), + mbCloseBack(bCloseBack) + { + // make sure Rotation is positive + if(::basegfx::fTools::lessOrEqual(mfRotation, 0.0)) + { + mfRotation = 0.0; + } + + // make sure the percentage value mfDiagonal is between 0.0 and 1.0 + if(::basegfx::fTools::lessOrEqual(mfDiagonal, 0.0)) + { + mfDiagonal = 0.0; + } + else if(::basegfx::fTools::moreOrEqual(mfDiagonal, 1.0)) + { + mfDiagonal = 1.0; + } + + // no close front/back when polygon is not closed + if(maPolyPolygon.count() && !maPolyPolygon.getB2DPolygon(0L).isClosed()) + { + mbCloseFront = mbCloseBack = false; + } + + // no edge rounding when not closing + if(!mbCloseFront && !mbCloseBack) + { + mfDiagonal = 0.0; + } + } + + sdrLathePrimitive3D::~sdrLathePrimitive3D() + { + } + + bool sdrLathePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(sdrPrimitive3D::operator==(rPrimitive)) + { + const sdrLathePrimitive3D& rCompare = static_cast< const sdrLathePrimitive3D& >(rPrimitive); + return (maPolyPolygon == rCompare.maPolyPolygon + && mnHorizontalSegments == rCompare.mnHorizontalSegments + && mnVerticalSegments == rCompare.mnVerticalSegments + && mfDiagonal == rCompare.mfDiagonal + && mfBackScale == rCompare.mfBackScale + && mfRotation == rCompare.mfRotation + && mbSmoothNormals == rCompare.mbSmoothNormals + && mbSmoothHorizontalNormals == rCompare.mbSmoothHorizontalNormals + && mbSmoothLids == rCompare.mbSmoothLids + && mbCharacterMode == rCompare.mbCharacterMode + && mbCloseFront == rCompare.mbCloseFront + && mbCloseBack == rCompare.mbCloseBack); + } + + return false; + } + + basePrimitive* sdrLathePrimitive3D::createNewClone() const + { + return new sdrLathePrimitive3D(maTransform, maTextureSize, maSdrLFSAttribute, maSdr3DObjectAttribute, + maPolyPolygon, mnHorizontalSegments, mnVerticalSegments, mfDiagonal, mfBackScale, mfRotation, + mbSmoothNormals, mbSmoothHorizontalNormals, mbSmoothLids, mbCharacterMode, mbCloseFront, mbCloseBack); + } + + PrimitiveID sdrLathePrimitive3D::getID() const + { + return CreatePrimitiveID('S', 'L', 'A', '3'); + } + + ::basegfx::B3DRange sdrLathePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const + { + // call parent, use decomposition + return sdrPrimitive3D::get3DRange(rViewInformation); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx new file mode 100644 index 000000000000..f4326340b3a6 --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx @@ -0,0 +1,109 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrprimitive3d.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_SDRATTRIBUTE_HXX +#include <drawinglayer/primitive/sdrattribute.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + ::basegfx::B3DRange sdrPrimitive3D::getStandard3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const + { + ::basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); + aUnitRange.transform(getTransform()); + + if(maSdrLFSAttribute.getLine()) + { + const sdrLineAttribute& rLine = *maSdrLFSAttribute.getLine(); + + if(rLine.isVisible() && !::basegfx::fTools::equalZero(rLine.getWidth())) + { + // expand by hald LineWidth as tube radius + aUnitRange.grow(rLine.getWidth() / 2.0); + } + } + + return aUnitRange; + } + + sdrPrimitive3D::sdrPrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute) + : maTransform(rTransform), + maTextureSize(rTextureSize), + maSdrLFSAttribute(rSdrLFSAttribute), + maSdr3DObjectAttribute(rSdr3DObjectAttribute) + { + } + + sdrPrimitive3D::~sdrPrimitive3D() + { + } + + bool sdrPrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(getID() == rPrimitive.getID()) + { + const sdrPrimitive3D& rCompare = static_cast< const sdrPrimitive3D& >(rPrimitive); + + return (maTransform == rCompare.maTransform + && maTextureSize == rCompare.maTextureSize + && maSdrLFSAttribute == rCompare.maSdrLFSAttribute + && maSdr3DObjectAttribute == rCompare.maSdr3DObjectAttribute); + } + + return false; + } + + void sdrPrimitive3D::transform(const ::basegfx::B3DHomMatrix& rMatrix) + { + basePrimitive::transform(rMatrix); + maTransform *= rMatrix; + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx new file mode 100644 index 000000000000..66c0a7abf559 --- /dev/null +++ b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx @@ -0,0 +1,226 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: sdrsphereprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRSPHEREPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/sdrsphereprimitive3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYPOLYGON_HXX +#include <basegfx/polygon/b3dpolypolygon.hxx> +#endif + +#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX +#include <basegfx/polygon/b3dpolypolygontools.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE_PRIMITIVELIST_HXX +#include <drawinglayer/primitive/primitivelist.hxx> +#endif + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDRDECOMPOSITIONTOOLS3D_HXX +#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> +#endif + +#ifndef _BGFX_POLYGON_B3DPOLYGON_HXX +#include <basegfx/polygon/b3dpolygon.hxx> +#endif + +#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX +#include <basegfx/matrix/b2dhommatrix.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void sdrSpherePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + const ::basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); + + // add fill + if(getSdrLFSAttribute().getFill()) + { + const bool bCreateNormals(::com::sun::star::drawing::NormalsKind_SPECIFIC == getSdr3DObjectAttribute().getNormalsKind() + || ::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind()); + + // create unit geometry + ::basegfx::B3DPolyPolygon aFill(::basegfx::tools::createSphereFillPolyPolygonFromB3DRange(aUnitRange, + getHorizontalSegments(), getVerticalSegments(), bCreateNormals)); + + // normal inversion + if(bCreateNormals && getSdr3DObjectAttribute().getNormalsInvert() && aFill.areNormalsUsed()) + { + // invert normals + aFill = ::basegfx::tools::invertNormals(aFill); + } + + // texture coordinates + { + // handle texture coordinates X + const bool bParallelX(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bObjectSpecificX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionX()); + const bool bSphereX(::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionX()); + + // handle texture coordinates Y + const bool bParallelY(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == getSdr3DObjectAttribute().getTextureProjectionY()); + const bool bObjectSpecificY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC == getSdr3DObjectAttribute().getTextureProjectionY()); + const bool bSphereY(::com::sun::star::drawing::TextureProjectionMode_SPHERE == getSdr3DObjectAttribute().getTextureProjectionY()); + + if(bParallelX || bParallelY) + { + // apply parallel texture coordinates in X and/or Y + const ::basegfx::B3DRange aRange(::basegfx::tools::getRange(aFill)); + aFill = ::basegfx::tools::applyDefaultTextureCoordinatesParallel(aFill, aRange, bParallelX, bParallelY); + } + + if(bSphereX || bObjectSpecificX || bSphereY || bObjectSpecificY) + { + double fRelativeAngle; + + if(bObjectSpecificX) + { + // Since the texture coordinates are (for historical reasons) + // different from forced to sphere texture coordinates, + // create a old version from it by rotating to old state before applying + // the texture coordinates to emulate old behaviour + fRelativeAngle = F_2PI * ((double)((getHorizontalSegments() >> 1L) - 1L) / (double)getHorizontalSegments()); + ::basegfx::B3DHomMatrix aRot; + aRot.rotate(0.0, fRelativeAngle, 0.0); + aFill.transform(aRot); + } + + // apply spherical texture coordinates in X and/or Y + const ::basegfx::B3DRange aRange(::basegfx::tools::getRange(aFill)); + const ::basegfx::B3DPoint aCenter(aRange.getCenter()); + aFill = ::basegfx::tools::applyDefaultTextureCoordinatesSphere(aFill, aCenter, + bSphereX || bObjectSpecificX, bSphereY || bObjectSpecificY); + + if(bObjectSpecificX) + { + // rotate back again + ::basegfx::B3DHomMatrix aRot; + aRot.rotate(0.0, -fRelativeAngle, 0.0); + aFill.transform(aRot); + } + } + + // transform texture coordinates to texture size + ::basegfx::B2DHomMatrix aTexMatrix; + aTexMatrix.scale(maTextureSize.getX(), maTextureSize.getY()); + aFill.transformTextureCoordiantes(aTexMatrix); + } + + // build vector of PolyPolygons + ::std::vector< ::basegfx::B3DPolyPolygon > a3DPolyPolygonVector; + + for(sal_uInt32 a(0L); a < aFill.count(); a++) + { + a3DPolyPolygonVector.push_back(::basegfx::B3DPolyPolygon(aFill.getB3DPolygon(a))); + } + + // create single PolyPolygonFill primitives + add3DPolyPolygonFillPrimitive( + a3DPolyPolygonVector, maTransform, maTextureSize, rTarget, + getSdr3DObjectAttribute(), *getSdrLFSAttribute().getFill(), + getSdrLFSAttribute().getFillFloatTransGradient()); + } + + // add line + if(maSdrLFSAttribute.getLine()) + { + ::basegfx::B3DPolyPolygon aSphere(::basegfx::tools::createSpherePolyPolygonFromB3DRange(aUnitRange, getHorizontalSegments(), getVerticalSegments())); + add3DPolyPolygonLinePrimitive(aSphere, maTransform, rTarget, *maSdrLFSAttribute.getLine()); + } + + // add shadow + if(getSdrLFSAttribute().getShadow()) + { + addShadowPrimitive3D(rTarget, *getSdrLFSAttribute().getShadow(), getSdr3DObjectAttribute().getShadow3D()); + } + } + + sdrSpherePrimitive3D::sdrSpherePrimitive3D( + const ::basegfx::B3DHomMatrix& rTransform, + const ::basegfx::B2DVector& rTextureSize, + const sdrLineFillShadowAttribute& rSdrLFSAttribute, + const sdr3DObjectAttribute& rSdr3DObjectAttribute, + sal_uInt32 nHorizontalSegments, sal_uInt32 nVerticalSegments) + : sdrPrimitive3D(rTransform, rTextureSize, rSdrLFSAttribute, rSdr3DObjectAttribute), + mnHorizontalSegments(nHorizontalSegments), + mnVerticalSegments(nVerticalSegments) + { + } + + sdrSpherePrimitive3D::~sdrSpherePrimitive3D() + { + } + + bool sdrSpherePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(sdrPrimitive3D::operator==(rPrimitive)) + { + const sdrSpherePrimitive3D& rCompare = static_cast< const sdrSpherePrimitive3D& >(rPrimitive); + return (mnHorizontalSegments == rCompare.mnHorizontalSegments + && mnVerticalSegments == rCompare.mnVerticalSegments); + } + + return false; + } + + basePrimitive* sdrSpherePrimitive3D::createNewClone() const + { + return new sdrSpherePrimitive3D( + maTransform, maTextureSize, + maSdrLFSAttribute, maSdr3DObjectAttribute, + mnHorizontalSegments, mnVerticalSegments); + } + + PrimitiveID sdrSpherePrimitive3D::getID() const + { + return CreatePrimitiveID('S', 'S', 'P', '3'); + } + + ::basegfx::B3DRange sdrSpherePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const + { + // call parent, use decomposition + return sdrPrimitive3D::get3DRange(rViewInformation); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/shadowprimitive3d.cxx b/drawinglayer/source/primitive3d/shadowprimitive3d.cxx new file mode 100644 index 000000000000..821d300b4ec3 --- /dev/null +++ b/drawinglayer/source/primitive3d/shadowprimitive3d.cxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: shadowprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:09 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_SHADOWPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/shadowprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + shadowPrimitive3D::shadowPrimitive3D( + const ::basegfx::B2DHomMatrix& rShadowTransform, const ::basegfx::BColor& rShadowColor, + double fShadowTransparence, bool bShadow3D, const primitiveList& rPrimitiveList) + : listPrimitive(rPrimitiveList), + maShadowTransform(rShadowTransform), + maShadowColor(rShadowColor), + mfShadowTransparence(fShadowTransparence), + mbShadow3D(bShadow3D) + { + } + + shadowPrimitive3D::~shadowPrimitive3D() + { + } + + bool shadowPrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(listPrimitive::operator==(rPrimitive)) + { + const shadowPrimitive3D& rCompare = (shadowPrimitive3D&)rPrimitive; + return (maShadowTransform == rCompare.maShadowTransform + && maShadowColor == rCompare.maShadowColor + && mfShadowTransparence == rCompare.mfShadowTransparence + && mbShadow3D == rCompare.mbShadow3D); + } + + return false; + } + + basePrimitive* shadowPrimitive3D::createNewClone() const + { + return new shadowPrimitive3D(maShadowTransform, maShadowColor, mfShadowTransparence, mbShadow3D, maPrimitiveList); + } + + PrimitiveID shadowPrimitive3D::getID() const + { + return CreatePrimitiveID('S', 'H', 'D', '3'); + } + + void shadowPrimitive3D::transform(const ::basegfx::B2DHomMatrix& rMatrix) + { + // call basePrimitive, not listPrimitive parent to not change the SubList + basePrimitive::transform(rMatrix); + + // add tansform to local transform matrix. Applying to local sub-list is not necessary, + // this is done at decomposition or left to the renderer to allow evtl. less copying + maShadowTransform *= rMatrix; + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive3d/textureprimitive3d.cxx b/drawinglayer/source/primitive3d/textureprimitive3d.cxx new file mode 100644 index 000000000000..dff1a141e970 --- /dev/null +++ b/drawinglayer/source/primitive3d/textureprimitive3d.cxx @@ -0,0 +1,269 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textureprimitive3d.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: aw $ $Date: 2006-05-12 11:49:09 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PRIMITIVE3D_TEXTUREPRIMITIVE3D_HXX +#include <drawinglayer/primitive3d/textureprimitive3d.hxx> +#endif + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + texturePrimitive3D::texturePrimitive3D( + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, bool bFilter) + : listPrimitive(rPrimitiveList), + maTextureSize(rTextureSize), + mbModulate(bModulate), + mbFilter(bFilter) + { + } + + texturePrimitive3D::~texturePrimitive3D() + { + } + + bool texturePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(listPrimitive::operator==(rPrimitive)) + { + const texturePrimitive3D& rCompare = (texturePrimitive3D&)rPrimitive; + return (mbModulate == rCompare.mbModulate && mbFilter == rCompare.mbFilter); + } + + return false; + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void simpleTransparenceTexturePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + if(0.0 == mfTransparence) + { + // no transparence used, so just add the content + rTarget.append(maPrimitiveList); + } + else if(mfTransparence > 0.0 && mfTransparence < 1.0) + { + // create transparenceTexturePrimitive3D with fixed transparence as replacement + const ::basegfx::BColor aGray(mfTransparence, mfTransparence, mfTransparence); + const fillGradientAttribute aFillGradient(GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, 0.0, aGray, aGray, 1); + basePrimitive* pNewTransparenceTexturePrimitive3D = new transparenceTexturePrimitive3D(aFillGradient, maPrimitiveList, maTextureSize); + rTarget.append(referencedPrimitive(*pNewTransparenceTexturePrimitive3D)); + } + else + { + // completely transparent or invalid definition, add nothing + } + } + + simpleTransparenceTexturePrimitive3D::simpleTransparenceTexturePrimitive3D( + double fTransparence, + const primitiveList& rPrimitiveList) + : texturePrimitive3D(rPrimitiveList, ::basegfx::B2DVector(), false, false), + mfTransparence(fTransparence) + { + } + + simpleTransparenceTexturePrimitive3D::~simpleTransparenceTexturePrimitive3D() + { + } + + bool simpleTransparenceTexturePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(texturePrimitive3D::operator==(rPrimitive)) + { + const simpleTransparenceTexturePrimitive3D& rCompare = (simpleTransparenceTexturePrimitive3D&)rPrimitive; + return (mfTransparence == rCompare.mfTransparence); + } + + return false; + } + + basePrimitive* simpleTransparenceTexturePrimitive3D::createNewClone() const + { + return new simpleTransparenceTexturePrimitive3D(mfTransparence, maPrimitiveList); + } + + PrimitiveID simpleTransparenceTexturePrimitive3D::getID() const + { + return CreatePrimitiveID('S', 'T', 'X', '3'); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void gradientTexturePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + rTarget.append(maPrimitiveList); + } + + gradientTexturePrimitive3D::gradientTexturePrimitive3D( + const fillGradientAttribute& rGradient, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter) + : texturePrimitive3D(rPrimitiveList, rTextureSize, bModulate, bFilter), + maGradient(rGradient) + { + } + + gradientTexturePrimitive3D::~gradientTexturePrimitive3D() + { + } + + bool gradientTexturePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(texturePrimitive3D::operator==(rPrimitive)) + { + const gradientTexturePrimitive3D& rCompare = (gradientTexturePrimitive3D&)rPrimitive; + return (maGradient == rCompare.maGradient); + } + + return false; + } + + basePrimitive* gradientTexturePrimitive3D::createNewClone() const + { + return new gradientTexturePrimitive3D(maGradient, maPrimitiveList, maTextureSize, mbModulate, mbFilter); + } + + PrimitiveID gradientTexturePrimitive3D::getID() const + { + return CreatePrimitiveID('G', 'R', 'X', '3'); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + void bitmapTexturePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation) + { + rTarget.append(maPrimitiveList); + } + + bitmapTexturePrimitive3D::bitmapTexturePrimitive3D( + const fillBitmapAttribute& rBitmap, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize, + bool bModulate, bool bFilter) + : texturePrimitive3D(rPrimitiveList, rTextureSize, bModulate, bFilter), + maBitmap(rBitmap) + { + } + + bitmapTexturePrimitive3D::~bitmapTexturePrimitive3D() + { + } + + bool bitmapTexturePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + if(texturePrimitive3D::operator==(rPrimitive)) + { + const bitmapTexturePrimitive3D& rCompare = (bitmapTexturePrimitive3D&)rPrimitive; + return (maBitmap == rCompare.maBitmap); + } + + return false; + } + + basePrimitive* bitmapTexturePrimitive3D::createNewClone() const + { + return new bitmapTexturePrimitive3D(maBitmap, maPrimitiveList, maTextureSize, mbModulate, mbFilter); + } + + PrimitiveID bitmapTexturePrimitive3D::getID() const + { + return CreatePrimitiveID('B', 'M', 'X', '3'); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive + { + transparenceTexturePrimitive3D::transparenceTexturePrimitive3D( + const fillGradientAttribute& rGradient, + const primitiveList& rPrimitiveList, + const ::basegfx::B2DVector& rTextureSize) + : gradientTexturePrimitive3D(rGradient, rPrimitiveList, rTextureSize, false, false) + { + } + + transparenceTexturePrimitive3D::~transparenceTexturePrimitive3D() + { + } + + bool transparenceTexturePrimitive3D::operator==(const basePrimitive& rPrimitive) const + { + return (gradientTexturePrimitive3D::operator==(rPrimitive)); + } + + basePrimitive* transparenceTexturePrimitive3D::createNewClone() const + { + return new transparenceTexturePrimitive3D(maGradient, maPrimitiveList, maTextureSize); + } + + PrimitiveID transparenceTexturePrimitive3D::getID() const + { + return CreatePrimitiveID('T', 'R', 'X', '3'); + } + } // end of namespace primitive +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/util/drawinglayer.flt b/drawinglayer/util/drawinglayer.flt new file mode 100644 index 000000000000..28a1dd1b65c6 --- /dev/null +++ b/drawinglayer/util/drawinglayer.flt @@ -0,0 +1,4 @@ +__CT +Impl +IMP +internal
\ No newline at end of file diff --git a/drawinglayer/util/makefile.mk b/drawinglayer/util/makefile.mk index d38d18d6d9bd..84b1a12c20f2 100644 --- a/drawinglayer/util/makefile.mk +++ b/drawinglayer/util/makefile.mk @@ -4,9 +4,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: aw $ $Date: 2005-11-04 12:43:00 $ +# last change: $Author: aw $ $Date: 2006-05-12 11:42:54 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -46,7 +46,10 @@ TARGET=drawinglayer LIB1TARGET=$(SLB)$/drawinglayer.lib LIB1FILES=\ - $(SLB)$/primitive.lib + $(SLB)$/primitive.lib \ + $(SLB)$/primitive3d.lib \ + $(SLB)$/geometry.lib \ + $(SLB)$/animation.lib SHL1TARGET= drawinglayer$(UPD)$(DLLPOSTFIX) SHL1IMPLIB= idrawinglayer |