summaryrefslogtreecommitdiff
path: root/drawinglayer/source/primitive3d
diff options
context:
space:
mode:
Diffstat (limited to 'drawinglayer/source/primitive3d')
-rw-r--r--drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx87
-rw-r--r--drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx75
-rw-r--r--drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx75
-rw-r--r--drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx32
4 files changed, 147 insertions, 122 deletions
diff --git a/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx
index 241d02926cc1..df682ab04e6f 100644
--- a/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrdecompositiontools3d.cxx
@@ -64,6 +64,93 @@ namespace drawinglayer
{
namespace primitive3d
{
+ basegfx::B3DRange getRangeFrom3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill)
+ {
+ basegfx::B3DRange aRetval;
+
+ for(sal_uInt32 a(0); a < rFill.size(); a++)
+ {
+ aRetval.expand(basegfx::tools::getRange(rFill[a]));
+ }
+
+ return aRetval;
+ }
+
+ void applyNormalsKindSphereTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill, const basegfx::B3DRange& rRange)
+ {
+ // create sphere normals
+ const basegfx::B3DPoint aCenter(rRange.getCenter());
+
+ for(sal_uInt32 a(0); a < rFill.size(); a++)
+ {
+ rFill[a] = basegfx::tools::applyDefaultNormalsSphere(rFill[a], aCenter);
+ }
+ }
+
+ void applyNormalsKindFlatTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill)
+ {
+ for(sal_uInt32 a(0); a < rFill.size(); a++)
+ {
+ rFill[a].clearNormals();
+ }
+ }
+
+ void applyNormalsInvertTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill)
+ {
+ // invert normals
+ for(sal_uInt32 a(0); a < rFill.size(); a++)
+ {
+ rFill[a] = basegfx::tools::invertNormals(rFill[a]);
+ }
+ }
+
+ void applyTextureTo3DGeometry(
+ ::com::sun::star::drawing::TextureProjectionMode eModeX,
+ ::com::sun::star::drawing::TextureProjectionMode eModeY,
+ ::std::vector< basegfx::B3DPolyPolygon >& rFill,
+ const basegfx::B3DRange& rRange,
+ const basegfx::B2DVector& rTextureSize)
+ {
+ sal_uInt32 a;
+
+ // handle texture coordinates X
+ const bool bParallelX(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == eModeX);
+ const bool bSphereX(!bParallelX && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == eModeX));
+
+ // handle texture coordinates Y
+ const bool bParallelY(::com::sun::star::drawing::TextureProjectionMode_PARALLEL == eModeY);
+ const bool bSphereY(!bParallelY && (::com::sun::star::drawing::TextureProjectionMode_SPHERE == eModeY));
+
+ if(bParallelX || bParallelY)
+ {
+ // apply parallel texture coordinates in X and/or Y
+ for(a = 0; a < rFill.size(); a++)
+ {
+ rFill[a] = basegfx::tools::applyDefaultTextureCoordinatesParallel(rFill[a], rRange, bParallelX, bParallelY);
+ }
+ }
+
+ if(bSphereX || bSphereY)
+ {
+ // apply spherical texture coordinates in X and/or Y
+ const basegfx::B3DPoint aCenter(rRange.getCenter());
+
+ for(a = 0; a < rFill.size(); a++)
+ {
+ rFill[a] = basegfx::tools::applyDefaultTextureCoordinatesSphere(rFill[a], aCenter, bSphereX, bSphereY);
+ }
+ }
+
+ // transform texture coordinates to texture size
+ basegfx::B2DHomMatrix aTexMatrix;
+ aTexMatrix.scale(rTextureSize.getX(), rTextureSize.getY());
+
+ for(a = 0; a < rFill.size(); a++)
+ {
+ rFill[a].transformTextureCoordiantes(aTexMatrix);
+ }
+ }
+
Primitive3DSequence create3DPolyPolygonLinePrimitives(
const basegfx::B3DPolyPolygon& rUnitPolyPolygon,
const basegfx::B3DHomMatrix& rObjectTransform,
diff --git a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
index a83147da5022..e9ef154c95f3 100644
--- a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
@@ -67,10 +67,10 @@ namespace drawinglayer
if(rSliceVector.size())
{
sal_uInt32 a;
- basegfx::B3DRange aRange;
// decide what to create
- const bool bCreateNormals(::com::sun::star::drawing::NormalsKind_SPECIFIC == getSdr3DObjectAttribute().getNormalsKind());
+ const ::com::sun::star::drawing::NormalsKind eNormalsKind(getSdr3DObjectAttribute().getNormalsKind());
+ const bool bCreateNormals(::com::sun::star::drawing::NormalsKind_SPECIFIC == eNormalsKind);
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);
@@ -103,82 +103,35 @@ namespace drawinglayer
0.5, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform);
// get full range
- for(a = 0L; a < aFill.size(); a++)
- {
- aRange.expand(basegfx::tools::getRange(aFill[a]));
- }
+ const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
// normal creation
if(getSdrLFSAttribute().getFill())
{
- if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
+ if(::com::sun::star::drawing::NormalsKind_SPHERE == eNormalsKind)
{
- // create sphere normals
- const basegfx::B3DPoint aCenter(aRange.getCenter());
-
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a] = basegfx::tools::applyDefaultNormalsSphere(aFill[a], aCenter);
- }
+ applyNormalsKindSphereTo3DGeometry(aFill, aRange);
}
- else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
+ else if(::com::sun::star::drawing::NormalsKind_FLAT == eNormalsKind)
{
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a].clearNormals();
- }
+ applyNormalsKindFlatTo3DGeometry(aFill);
}
if(getSdr3DObjectAttribute().getNormalsInvert())
{
- // invert normals
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a] = basegfx::tools::invertNormals(aFill[a]);
- }
+ applyNormalsInvertTo3DGeometry(aFill);
}
}
// texture coordinates
if(getSdrLFSAttribute().getFill())
{
- // 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(getTextureSize().getX(), getTextureSize().getY());
-
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a].transformTextureCoordiantes(aTexMatrix);
- }
+ applyTextureTo3DGeometry(
+ getSdr3DObjectAttribute().getTextureProjectionX(),
+ getSdr3DObjectAttribute().getTextureProjectionY(),
+ aFill,
+ aRange,
+ getTextureSize());
}
if(getSdrLFSAttribute().getFill())
diff --git a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
index f51aa3a85e24..33008e762c0a 100644
--- a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
@@ -69,10 +69,10 @@ namespace drawinglayer
const bool bBackScale(!basegfx::fTools::equal(getBackScale(), 1.0));
const bool bClosedRotation(!bBackScale && getHorizontalSegments() && basegfx::fTools::equal(getRotation(), F_2PI));
sal_uInt32 a;
- basegfx::B3DRange aRange;
// decide what to create
- const bool bCreateNormals(::com::sun::star::drawing::NormalsKind_SPECIFIC == getSdr3DObjectAttribute().getNormalsKind());
+ const ::com::sun::star::drawing::NormalsKind eNormalsKind(getSdr3DObjectAttribute().getNormalsKind());
+ const bool bCreateNormals(::com::sun::star::drawing::NormalsKind_SPECIFIC == eNormalsKind);
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;
@@ -96,82 +96,35 @@ namespace drawinglayer
0.85, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform);
// get full range
- for(a = 0L; a < aFill.size(); a++)
- {
- aRange.expand(basegfx::tools::getRange(aFill[a]));
- }
+ const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
// normal creation
if(getSdrLFSAttribute().getFill())
{
- if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
+ if(::com::sun::star::drawing::NormalsKind_SPHERE == eNormalsKind)
{
- // create sphere normals
- const basegfx::B3DPoint aCenter(aRange.getCenter());
-
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a] = basegfx::tools::applyDefaultNormalsSphere(aFill[a], aCenter);
- }
+ applyNormalsKindSphereTo3DGeometry(aFill, aRange);
}
- else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
+ else if(::com::sun::star::drawing::NormalsKind_FLAT == eNormalsKind)
{
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a].clearNormals();
- }
+ applyNormalsKindFlatTo3DGeometry(aFill);
}
if(getSdr3DObjectAttribute().getNormalsInvert())
{
- // invert normals
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a] = basegfx::tools::invertNormals(aFill[a]);
- }
+ applyNormalsInvertTo3DGeometry(aFill);
}
}
// texture coordinates
if(getSdrLFSAttribute().getFill())
{
- // 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(getTextureSize().getX(), getTextureSize().getY());
-
- for(a = 0L; a < aFill.size(); a++)
- {
- aFill[a].transformTextureCoordiantes(aTexMatrix);
- }
+ applyTextureTo3DGeometry(
+ getSdr3DObjectAttribute().getTextureProjectionX(),
+ getSdr3DObjectAttribute().getTextureProjectionY(),
+ aFill,
+ aRange,
+ getTextureSize());
}
if(getSdrLFSAttribute().getFill())
diff --git a/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx
index e27b8b43fe93..a0813d3202a8 100644
--- a/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx
@@ -62,6 +62,38 @@ namespace drawinglayer
::std::vector< basegfx::B3DPolyPolygon > aFill;
aFill.push_back(getPolyPolygon3D());
+ // get full range
+ const basegfx::B3DRange aRange(getRangeFrom3DGeometry(aFill));
+
+ // #i98295# normal creation
+ if(getSdrLFSAttribute().getFill())
+ {
+ if(::com::sun::star::drawing::NormalsKind_SPHERE == getSdr3DObjectAttribute().getNormalsKind())
+ {
+ applyNormalsKindSphereTo3DGeometry(aFill, aRange);
+ }
+ else if(::com::sun::star::drawing::NormalsKind_FLAT == getSdr3DObjectAttribute().getNormalsKind())
+ {
+ applyNormalsKindFlatTo3DGeometry(aFill);
+ }
+
+ if(getSdr3DObjectAttribute().getNormalsInvert())
+ {
+ applyNormalsInvertTo3DGeometry(aFill);
+ }
+ }
+
+ // #i98314# texture coordinates
+ if(getSdrLFSAttribute().getFill())
+ {
+ applyTextureTo3DGeometry(
+ getSdr3DObjectAttribute().getTextureProjectionX(),
+ getSdr3DObjectAttribute().getTextureProjectionY(),
+ aFill,
+ aRange,
+ getTextureSize());
+ }
+
if(getSdrLFSAttribute().getFill())
{
// add fill