2006-08-09 16:00:16 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* $RCSfile: defaultprocessor3d.cxx,v $
|
|
|
|
*
|
2008-05-27 13:11:34 +00:00
|
|
|
* $Revision: 1.11 $
|
2006-08-09 16:00:16 +00:00
|
|
|
*
|
2008-05-27 13:11:34 +00:00
|
|
|
* last change: $Author: aw $ $Date: 2008-05-27 14:11:22 $
|
2006-08-09 16:00:16 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2008-03-05 08:18:45 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_drawinglayer.hxx"
|
|
|
|
|
2006-08-09 16:00:16 +00:00
|
|
|
#include <drawinglayer/processor3d/defaultprocessor3d.hxx>
|
2008-05-14 08:22:09 +00:00
|
|
|
#include <drawinglayer/primitive3d/textureprimitive3d.hxx>
|
2006-10-19 09:40:02 +00:00
|
|
|
#include <drawinglayer/texture/texture.hxx>
|
2008-04-16 03:59:59 +00:00
|
|
|
#include <drawinglayer/texture/texture3d.hxx>
|
2006-10-19 09:40:02 +00:00
|
|
|
#include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx>
|
|
|
|
#include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx>
|
2008-05-14 08:22:09 +00:00
|
|
|
#include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
|
2006-08-09 16:00:16 +00:00
|
|
|
#include <basegfx/polygon/b3dpolygontools.hxx>
|
2008-05-14 08:22:09 +00:00
|
|
|
#include <drawinglayer/attribute/materialattribute3d.hxx>
|
2006-10-19 09:40:02 +00:00
|
|
|
#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
|
2006-08-09 16:00:16 +00:00
|
|
|
#include <basegfx/polygon/b3dpolypolygontools.hxx>
|
2008-05-14 08:22:09 +00:00
|
|
|
#include <com/sun/star/drawing/ShadeMode.hpp>
|
|
|
|
#include <drawinglayer/attribute/sdrattribute3d.hxx>
|
2006-10-19 09:40:02 +00:00
|
|
|
#include <drawinglayer/primitive3d/transformprimitive3d.hxx>
|
2008-04-16 03:59:59 +00:00
|
|
|
#include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
|
2006-10-19 09:40:02 +00:00
|
|
|
|
2006-08-09 16:00:16 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-02-07 12:42:32 +00:00
|
|
|
using namespace com::sun::star;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-08-09 16:00:16 +00:00
|
|
|
namespace drawinglayer
|
|
|
|
{
|
|
|
|
namespace processor3d
|
|
|
|
{
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::impRenderGradientTexturePrimitive3D(const primitive3d::GradientTexturePrimitive3D& rPrimitive, bool bTransparence)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren();
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
if(rSubSequence.hasElements())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
// rescue values
|
2008-05-14 08:22:09 +00:00
|
|
|
const bool bOldModulate(getModulate()); mbModulate = rPrimitive.getModulate();
|
|
|
|
const bool bOldFilter(getFilter()); mbFilter = rPrimitive.getFilter();
|
|
|
|
const bool bOldSimpleTextureActive(mbSimpleTextureActive);
|
2006-10-19 09:40:02 +00:00
|
|
|
texture::GeoTexSvx* pOldTex = (bTransparence) ? mpTransparenceGeoTexSvx : mpGeoTexSvx;
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// create texture
|
2006-10-19 09:40:02 +00:00
|
|
|
const attribute::FillGradientAttribute& rFillGradient = rPrimitive.getGradient();
|
2006-08-09 16:00:16 +00:00
|
|
|
const basegfx::B2DRange aOutlineRange(0.0, 0.0, rPrimitive.getTextureSize().getX(), rPrimitive.getTextureSize().getY());
|
|
|
|
const attribute::GradientStyle aGradientStyle(rFillGradient.getStyle());
|
|
|
|
sal_uInt32 nSteps(rFillGradient.getSteps());
|
|
|
|
const basegfx::BColor aStart(rFillGradient.getStartColor());
|
|
|
|
const basegfx::BColor aEnd(rFillGradient.getEndColor());
|
|
|
|
const sal_uInt32 nMaxSteps(sal_uInt32((aStart.getMaximumDistance(aEnd) * 127.5) + 0.5));
|
2006-10-19 09:40:02 +00:00
|
|
|
texture::GeoTexSvx* pNewTex = 0L;
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
if(nMaxSteps)
|
|
|
|
{
|
|
|
|
// there IS a color distance
|
|
|
|
if(nSteps == 0L)
|
|
|
|
{
|
|
|
|
nSteps = nMaxSteps;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nSteps < 2L)
|
|
|
|
{
|
|
|
|
nSteps = 2L;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nSteps > nMaxSteps)
|
|
|
|
{
|
|
|
|
nSteps = nMaxSteps;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(aGradientStyle)
|
|
|
|
{
|
|
|
|
case attribute::GRADIENTSTYLE_LINEAR:
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
pNewTex = new texture::GeoTexSvxGradientLinear(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), -rFillGradient.getAngle());
|
2006-08-09 16:00:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case attribute::GRADIENTSTYLE_AXIAL:
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
pNewTex = new texture::GeoTexSvxGradientAxial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), -rFillGradient.getAngle());
|
2006-08-09 16:00:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case attribute::GRADIENTSTYLE_RADIAL:
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
pNewTex = new texture::GeoTexSvxGradientRadial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY());
|
2006-08-09 16:00:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case attribute::GRADIENTSTYLE_ELLIPTICAL:
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
pNewTex = new texture::GeoTexSvxGradientElliptical(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle());
|
2006-08-09 16:00:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case attribute::GRADIENTSTYLE_SQUARE:
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
pNewTex = new texture::GeoTexSvxGradientSquare(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle());
|
2006-08-09 16:00:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case attribute::GRADIENTSTYLE_RECT:
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
pNewTex = new texture::GeoTexSvxGradientRect(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), -rFillGradient.getAngle());
|
2006-08-09 16:00:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-05-14 08:22:09 +00:00
|
|
|
|
|
|
|
mbSimpleTextureActive = false;
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// no color distance -> same color, use simple texture
|
2006-10-19 09:40:02 +00:00
|
|
|
pNewTex = new texture::GeoTexSvxMono(aStart, 1.0 - aStart.luminance());
|
2008-05-14 08:22:09 +00:00
|
|
|
mbSimpleTextureActive = true;
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set created texture
|
|
|
|
if(bTransparence)
|
|
|
|
{
|
|
|
|
mpTransparenceGeoTexSvx = pNewTex;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mpGeoTexSvx = pNewTex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// process sub-list
|
2006-10-19 09:40:02 +00:00
|
|
|
process(rSubSequence);
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// delete texture
|
|
|
|
delete pNewTex;
|
|
|
|
|
|
|
|
// restore values
|
|
|
|
mbModulate = bOldModulate;
|
|
|
|
mbFilter = bOldFilter;
|
2008-05-14 08:22:09 +00:00
|
|
|
mbSimpleTextureActive = bOldSimpleTextureActive;
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
if(bTransparence)
|
|
|
|
{
|
|
|
|
mpTransparenceGeoTexSvx = pOldTex;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mpGeoTexSvx = pOldTex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::impRenderHatchTexturePrimitive3D(const primitive3d::HatchTexturePrimitive3D& rPrimitive)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren();
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
if(rSubSequence.hasElements())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
// rescue values
|
2008-05-14 08:22:09 +00:00
|
|
|
const bool bOldModulate(getModulate()); mbModulate = rPrimitive.getModulate();
|
|
|
|
const bool bOldFilter(getFilter()); mbFilter = rPrimitive.getFilter();
|
2006-10-19 09:40:02 +00:00
|
|
|
texture::GeoTexSvx* pOldTex = mpGeoTexSvx;
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2008-05-27 13:11:34 +00:00
|
|
|
// calculate logic pixel size in world coordinates. Create transformation view
|
|
|
|
// to world by inverting WorldToView
|
|
|
|
basegfx::B3DHomMatrix aInvWorldToView(maWorldToView);
|
|
|
|
aInvWorldToView.invert();
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2008-05-27 13:11:34 +00:00
|
|
|
// back-project discrete coordinates to world coordinates and extract
|
|
|
|
// maximum distance
|
|
|
|
const basegfx::B3DPoint aZero(aInvWorldToView * basegfx::B3DPoint(0.0, 0.0, 0.0));
|
|
|
|
const basegfx::B3DPoint aOne(aInvWorldToView * basegfx::B3DPoint(1.0, 1.0, 1.0));
|
|
|
|
const basegfx::B3DVector aLogicPixel(aOne - aZero);
|
|
|
|
double fLogicPixelSizeWorld(::std::max(::std::max(fabs(aLogicPixel.getX()), fabs(aLogicPixel.getY())), fabs(aLogicPixel.getZ())));
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// calculate logic pixel size in texture coordinates
|
|
|
|
const double fLogicTexSizeX(fLogicPixelSizeWorld / rPrimitive.getTextureSize().getX());
|
|
|
|
const double fLogicTexSizeY(fLogicPixelSizeWorld / rPrimitive.getTextureSize().getY());
|
|
|
|
const double fLogicTexSize(fLogicTexSizeX > fLogicTexSizeY ? fLogicTexSizeX : fLogicTexSizeY);
|
|
|
|
|
|
|
|
// create texture and set
|
2006-10-19 09:40:02 +00:00
|
|
|
texture::GeoTexSvxMultiHatch* pNewTex = new texture::GeoTexSvxMultiHatch(rPrimitive, fLogicTexSize);
|
2006-08-09 16:00:16 +00:00
|
|
|
mpGeoTexSvx = pNewTex;
|
|
|
|
|
|
|
|
// process sub-list
|
2006-10-19 09:40:02 +00:00
|
|
|
process(rSubSequence);
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// delete texture
|
|
|
|
delete mpGeoTexSvx;
|
|
|
|
|
|
|
|
// restore values
|
|
|
|
mbModulate = bOldModulate;
|
|
|
|
mbFilter = bOldFilter;
|
|
|
|
mpGeoTexSvx = pOldTex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::impRenderBitmapTexturePrimitive3D(const primitive3d::BitmapTexturePrimitive3D& rPrimitive)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren();
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
if(rSubSequence.hasElements())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
// rescue values
|
2008-05-14 08:22:09 +00:00
|
|
|
const bool bOldModulate(getModulate()); mbModulate = rPrimitive.getModulate();
|
|
|
|
const bool bOldFilter(getFilter()); mbFilter = rPrimitive.getFilter();
|
2006-10-19 09:40:02 +00:00
|
|
|
texture::GeoTexSvx* pOldTex = mpGeoTexSvx;
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// create texture
|
2006-10-19 09:40:02 +00:00
|
|
|
const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPrimitive.getBitmap();
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
if(rFillBitmapAttribute.getTiling())
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
mpGeoTexSvx = new texture::GeoTexSvxBitmapTiled(
|
2006-08-09 16:00:16 +00:00
|
|
|
rFillBitmapAttribute.getBitmap(),
|
|
|
|
rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(),
|
|
|
|
rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
mpGeoTexSvx = new texture::GeoTexSvxBitmap(
|
2006-08-09 16:00:16 +00:00
|
|
|
rFillBitmapAttribute.getBitmap(),
|
|
|
|
rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(),
|
|
|
|
rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
// process sub-list
|
2006-10-19 09:40:02 +00:00
|
|
|
process(rSubSequence);
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// delete texture
|
|
|
|
delete mpGeoTexSvx;
|
|
|
|
|
|
|
|
// restore values
|
|
|
|
mbModulate = bOldModulate;
|
|
|
|
mbFilter = bOldFilter;
|
|
|
|
mpGeoTexSvx = pOldTex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::impRenderModifiedColorPrimitive3D(const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
const primitive3d::Primitive3DSequence& rSubSequence = rModifiedCandidate.getChildren();
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
if(rSubSequence.hasElements())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2008-05-14 08:22:09 +00:00
|
|
|
// put modifier on stack
|
2006-08-09 16:00:16 +00:00
|
|
|
maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
|
2008-05-14 08:22:09 +00:00
|
|
|
|
|
|
|
// process sub-list
|
2006-10-19 09:40:02 +00:00
|
|
|
process(rModifiedCandidate.getChildren());
|
2008-05-14 08:22:09 +00:00
|
|
|
|
|
|
|
// remove modifier from stack
|
2006-08-09 16:00:16 +00:00
|
|
|
maBColorModifierStack.pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::impRenderPolygonHairlinePrimitive3D(const primitive3d::PolygonHairlinePrimitive3D& rPrimitive)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
basegfx::B3DPolygon aHairline(rPrimitive.getB3DPolygon());
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
if(aHairline.count())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
// hairlines need no extra data, clear it
|
|
|
|
aHairline.clearTextureCoordinates();
|
|
|
|
aHairline.clearNormals();
|
|
|
|
aHairline.clearBColors();
|
|
|
|
|
|
|
|
// transform to device coordinates (-1.0 .. 1.0) and check for visibility
|
|
|
|
aHairline.transform(maWorldToView);
|
|
|
|
const basegfx::B3DRange a3DRange(basegfx::tools::getRange(aHairline));
|
|
|
|
const basegfx::B2DRange a2DRange(a3DRange.getMinX(), a3DRange.getMinY(), a3DRange.getMaxX(), a3DRange.getMaxY());
|
|
|
|
|
|
|
|
if(a2DRange.overlaps(maRasterRange))
|
|
|
|
{
|
2008-05-27 13:11:34 +00:00
|
|
|
const attribute::MaterialAttribute3D aMaterial(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
|
2008-05-14 08:22:09 +00:00
|
|
|
|
|
|
|
rasterconvertB3DPolygon(aMaterial, aHairline);
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::impRenderPolyPolygonMaterialPrimitive3D(const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
basegfx::B3DPolyPolygon aFill(rPrimitive.getB3DPolyPolygon());
|
|
|
|
basegfx::BColor aObjectColor(rPrimitive.getMaterial().getColor());
|
2008-05-14 08:22:09 +00:00
|
|
|
bool bPaintIt(aFill.count());
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
if(bPaintIt)
|
|
|
|
{
|
|
|
|
// get rid of texture coordinates if there is no texture
|
2008-05-14 08:22:09 +00:00
|
|
|
if(aFill.areTextureCoordinatesUsed() && !getGeoTexSvx() && !getTransparenceGeoTexSvx())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
aFill.clearTextureCoordinates();
|
|
|
|
}
|
|
|
|
|
|
|
|
// transform to device coordinates (-1.0 .. 1.0) and check for visibility
|
|
|
|
aFill.transform(maWorldToView);
|
|
|
|
const basegfx::B3DRange a3DRange(basegfx::tools::getRange(aFill));
|
|
|
|
const basegfx::B2DRange a2DRange(a3DRange.getMinX(), a3DRange.getMinY(), a3DRange.getMaxX(), a3DRange.getMaxY());
|
|
|
|
|
|
|
|
bPaintIt = a2DRange.overlaps(maRasterRange);
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if it shall be painted regarding hiding of normals (backface culling)
|
|
|
|
if(bPaintIt && !rPrimitive.getDoubleSided())
|
|
|
|
{
|
|
|
|
// get plane normal of polygon in view coordinates (with ZBuffer values),
|
|
|
|
// left-handed coordinate system
|
|
|
|
const basegfx::B3DVector aPlaneNormal(aFill.getB3DPolygon(0L).getNormal());
|
|
|
|
|
|
|
|
if(aPlaneNormal.getZ() > 0.0)
|
|
|
|
{
|
|
|
|
bPaintIt = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bPaintIt)
|
|
|
|
{
|
2008-05-14 08:22:09 +00:00
|
|
|
::com::sun::star::drawing::ShadeMode aShadeMode(getSdrSceneAttribute().getShadeMode());
|
2006-08-09 16:00:16 +00:00
|
|
|
basegfx::B3DHomMatrix aNormalTransform(maWorldToEye);
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
if(getSdrSceneAttribute().getTwoSidedLighting())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
// get plane normal of polygon in view coordinates (with ZBuffer values),
|
|
|
|
// left-handed coordinate system
|
|
|
|
const basegfx::B3DVector aPlaneNormal(aFill.getB3DPolygon(0L).getNormal());
|
|
|
|
|
|
|
|
if(aPlaneNormal.getZ() > 0.0)
|
|
|
|
{
|
|
|
|
// mirror normals
|
|
|
|
aNormalTransform.scale(-1.0, -1.0, -1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(::com::sun::star::drawing::ShadeMode_PHONG == aShadeMode)
|
|
|
|
{
|
|
|
|
// phong shading
|
|
|
|
if(aFill.areNormalsUsed())
|
|
|
|
{
|
|
|
|
// transform normals to eye coor
|
|
|
|
aFill.transformNormals(aNormalTransform);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fallback to gouraud when no normals available
|
|
|
|
aShadeMode = ::com::sun::star::drawing::ShadeMode_SMOOTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(::com::sun::star::drawing::ShadeMode_SMOOTH == aShadeMode)
|
|
|
|
{
|
|
|
|
// gouraud shading
|
|
|
|
if(aFill.areNormalsUsed())
|
|
|
|
{
|
|
|
|
// transform normals to eye coor
|
|
|
|
aFill.transformNormals(aNormalTransform);
|
|
|
|
|
|
|
|
// prepare color model parameters, evtl. use blend color
|
2008-05-14 08:22:09 +00:00
|
|
|
const basegfx::BColor aColor(getModulate() ? basegfx::BColor(1.0, 1.0, 1.0) : rPrimitive.getMaterial().getColor());
|
2006-08-09 16:00:16 +00:00
|
|
|
const basegfx::BColor& rSpecular(rPrimitive.getMaterial().getSpecular());
|
|
|
|
const basegfx::BColor& rEmission(rPrimitive.getMaterial().getEmission());
|
|
|
|
const sal_uInt16 nSpecularIntensity(rPrimitive.getMaterial().getSpecularIntensity());
|
|
|
|
|
|
|
|
// solve color model for each normal vector, set colors at points. Clear normals.
|
|
|
|
for(sal_uInt32 a(0L); a < aFill.count(); a++)
|
|
|
|
{
|
|
|
|
basegfx::B3DPolygon aPartFill(aFill.getB3DPolygon(a));
|
|
|
|
|
|
|
|
for(sal_uInt32 b(0L); b < aPartFill.count(); b++)
|
|
|
|
{
|
|
|
|
// solve color model. Transform normal to eye coor
|
|
|
|
const basegfx::B3DVector aNormal(aPartFill.getNormal(b));
|
2008-05-14 08:22:09 +00:00
|
|
|
const basegfx::BColor aSolvedColor(getSdrLightingAttribute().solveColorModel(aNormal, aColor, rSpecular, rEmission, nSpecularIntensity));
|
2006-08-09 16:00:16 +00:00
|
|
|
aPartFill.setBColor(b, aSolvedColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear normals on this part polygon and write it back
|
|
|
|
aPartFill.clearNormals();
|
|
|
|
aFill.setB3DPolygon(a, aPartFill);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fallback to flat when no normals available
|
|
|
|
aShadeMode = ::com::sun::star::drawing::ShadeMode_FLAT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(::com::sun::star::drawing::ShadeMode_FLAT == aShadeMode)
|
|
|
|
{
|
|
|
|
// flat shading. Clear normals and colors
|
|
|
|
aFill.clearNormals();
|
|
|
|
aFill.clearBColors();
|
|
|
|
|
|
|
|
// get plane vector in eye coordinates
|
|
|
|
const basegfx::B3DVector aPlaneEyeNormal(aNormalTransform * rPrimitive.getB3DPolyPolygon().getB3DPolygon(0L).getNormal());
|
|
|
|
|
|
|
|
// prepare color model parameters, evtl. use blend color
|
2008-05-14 08:22:09 +00:00
|
|
|
const basegfx::BColor aColor(getModulate() ? basegfx::BColor(1.0, 1.0, 1.0) : rPrimitive.getMaterial().getColor());
|
2006-08-09 16:00:16 +00:00
|
|
|
const basegfx::BColor& rSpecular(rPrimitive.getMaterial().getSpecular());
|
|
|
|
const basegfx::BColor& rEmission(rPrimitive.getMaterial().getEmission());
|
|
|
|
const sal_uInt16 nSpecularIntensity(rPrimitive.getMaterial().getSpecularIntensity());
|
|
|
|
|
|
|
|
// solve color model for plane vector and use that color for whole plane
|
2008-05-14 08:22:09 +00:00
|
|
|
aObjectColor = getSdrLightingAttribute().solveColorModel(aPlaneEyeNormal, aColor, rSpecular, rEmission, nSpecularIntensity);
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(::com::sun::star::drawing::ShadeMode_DRAFT == aShadeMode)
|
|
|
|
{
|
|
|
|
// draft, just use object color which is already set. Delete all other infos
|
|
|
|
aFill.clearNormals();
|
|
|
|
aFill.clearBColors();
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw it to ZBuffer
|
2006-10-19 09:40:02 +00:00
|
|
|
const attribute::MaterialAttribute3D aMaterial(
|
2008-05-27 13:11:34 +00:00
|
|
|
maBColorModifierStack.getModifiedColor(aObjectColor),
|
|
|
|
rPrimitive.getMaterial().getSpecular(),
|
2006-08-09 16:00:16 +00:00
|
|
|
rPrimitive.getMaterial().getEmission(),
|
|
|
|
rPrimitive.getMaterial().getSpecularIntensity());
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
rasterconvertB3DPolyPolygon(aMaterial, aFill);
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::impRenderTransformPrimitive3D(const primitive3d::TransformPrimitive3D& rTransformCandidate)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
// remember current transformations
|
2008-05-14 08:22:09 +00:00
|
|
|
const basegfx::B3DHomMatrix aLastWorldToView(maWorldToView);
|
|
|
|
const basegfx::B3DHomMatrix aLastWorldToEye(maWorldToEye);
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// create new transformations
|
|
|
|
maWorldToView = maWorldToView * rTransformCandidate.getTransformation();
|
|
|
|
maWorldToEye = maWorldToEye * rTransformCandidate.getTransformation();
|
|
|
|
|
|
|
|
// let break down
|
2006-10-19 09:40:02 +00:00
|
|
|
process(rTransformCandidate.getChildren());
|
2006-08-09 16:00:16 +00:00
|
|
|
|
|
|
|
// restore transformations
|
|
|
|
maWorldToView = aLastWorldToView;
|
|
|
|
maWorldToEye = aLastWorldToEye;
|
|
|
|
}
|
|
|
|
|
2008-05-14 08:22:09 +00:00
|
|
|
void DefaultProcessor3D::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rBasePrimitive)
|
|
|
|
{
|
|
|
|
// it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch
|
|
|
|
switch(rBasePrimitive.getPrimitiveID())
|
|
|
|
{
|
|
|
|
case PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// GradientTexturePrimitive3D
|
|
|
|
const primitive3d::GradientTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::GradientTexturePrimitive3D& >(rBasePrimitive);
|
|
|
|
impRenderGradientTexturePrimitive3D(rPrimitive, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// HatchTexturePrimitive3D
|
|
|
|
static bool bDoHatchDecomposition(false);
|
|
|
|
|
|
|
|
if(bDoHatchDecomposition)
|
|
|
|
{
|
|
|
|
// let break down
|
|
|
|
process(rBasePrimitive.get3DDecomposition(getTime()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// hatchTexturePrimitive3D
|
|
|
|
const primitive3d::HatchTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::HatchTexturePrimitive3D& >(rBasePrimitive);
|
|
|
|
impRenderHatchTexturePrimitive3D(rPrimitive);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// BitmapTexturePrimitive3D
|
|
|
|
const primitive3d::BitmapTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::BitmapTexturePrimitive3D& >(rBasePrimitive);
|
|
|
|
impRenderBitmapTexturePrimitive3D(rPrimitive);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_ALPHATEXTUREPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// AlphaTexturePrimitive3D
|
|
|
|
const primitive3d::AlphaTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::AlphaTexturePrimitive3D& >(rBasePrimitive);
|
|
|
|
impRenderGradientTexturePrimitive3D(rPrimitive, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// ModifiedColorPrimitive3D
|
|
|
|
// Force output to unified color.
|
|
|
|
const primitive3d::ModifiedColorPrimitive3D& rPrimitive = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(rBasePrimitive);
|
|
|
|
impRenderModifiedColorPrimitive3D(rPrimitive);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// directdraw of PolygonHairlinePrimitive3D
|
|
|
|
const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rBasePrimitive);
|
|
|
|
impRenderPolygonHairlinePrimitive3D(rPrimitive);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// directdraw of PolyPolygonMaterialPrimitive3D
|
|
|
|
const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rBasePrimitive);
|
|
|
|
impRenderPolyPolygonMaterialPrimitive3D(rPrimitive);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// transform group (TransformPrimitive3D)
|
|
|
|
impRenderTransformPrimitive3D(static_cast< const primitive3d::TransformPrimitive3D& >(rBasePrimitive));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PRIMITIVE3D_ID_SDRLABELPRIMITIVE3D :
|
|
|
|
{
|
|
|
|
// SdrLabelPrimitive3D. Accept, but ignore. Is handled by the scenePrimitive decompose
|
|
|
|
// method which creates 2d text objects at the 3d-projection-dependent positions.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
// process recursively
|
|
|
|
process(rBasePrimitive.get3DDecomposition(getTime()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
void DefaultProcessor3D::process(const primitive3d::Primitive3DSequence& rSource)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
if(rSource.hasElements())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
const sal_Int32 nCount(rSource.getLength());
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
for(sal_Int32 a(0L); a < nCount; a++)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
// get reference
|
|
|
|
const primitive3d::Primitive3DReference xReference(rSource[a]);
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
if(xReference.is())
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
// try to cast to BasePrimitive3D implementation
|
|
|
|
const primitive3d::BasePrimitive3D* pBasePrimitive = dynamic_cast< const primitive3d::BasePrimitive3D* >(xReference.get());
|
2006-08-09 16:00:16 +00:00
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
if(pBasePrimitive)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2008-05-14 08:22:09 +00:00
|
|
|
processBasePrimitive3D(*pBasePrimitive);
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-19 09:40:02 +00:00
|
|
|
// unknown implementation, use UNO API call instead and process recursively
|
2008-02-07 12:42:32 +00:00
|
|
|
const uno::Sequence< beans::PropertyValue > xViewParameters(primitive3d::TimeToViewParameters(getTime()));
|
|
|
|
process(xReference->getDecomposition(xViewParameters));
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
DefaultProcessor3D::DefaultProcessor3D(
|
2008-05-14 08:22:09 +00:00
|
|
|
double fTime,
|
2006-10-19 09:40:02 +00:00
|
|
|
const attribute::SdrSceneAttribute& rSdrSceneAttribute,
|
2008-05-14 08:22:09 +00:00
|
|
|
const attribute::SdrLightingAttribute& rSdrLightingAttribute)
|
|
|
|
: BaseProcessor3D(fTime),
|
2006-08-09 16:00:16 +00:00
|
|
|
mrSdrSceneAttribute(rSdrSceneAttribute),
|
2006-10-19 09:40:02 +00:00
|
|
|
mrSdrLightingAttribute(rSdrLightingAttribute),
|
2008-01-30 11:26:48 +00:00
|
|
|
maWorldToEye(),
|
|
|
|
maWorldToView(),
|
|
|
|
maRasterRange(),
|
|
|
|
maBColorModifierStack(),
|
|
|
|
mpGeoTexSvx(0),
|
|
|
|
mpTransparenceGeoTexSvx(0),
|
2006-08-09 16:00:16 +00:00
|
|
|
mbModulate(false),
|
|
|
|
mbFilter(false),
|
2008-05-14 08:22:09 +00:00
|
|
|
mbSimpleTextureActive(false)
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
2008-05-27 13:11:34 +00:00
|
|
|
// a derivation has to set maWorldToEye, maWorldToView and maRasterRange. Those values are
|
2008-05-14 08:22:09 +00:00
|
|
|
// used in the basic render methods
|
2006-08-09 16:00:16 +00:00
|
|
|
}
|
|
|
|
|
2006-10-19 09:40:02 +00:00
|
|
|
DefaultProcessor3D::~DefaultProcessor3D()
|
2006-08-09 16:00:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
} // end of namespace processor3d
|
|
|
|
} // end of namespace drawinglayer
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// eof
|