summaryrefslogtreecommitdiff
path: root/goodies/source/base3d
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2008-10-17 08:40:10 +0000
committerOliver Bolte <obo@openoffice.org>2008-10-17 08:40:10 +0000
commit98c9f4f4f2506db7385cc3f0fa7bb1b14930a417 (patch)
treee6881eda00d35e22f6ac51732df02db300814385 /goodies/source/base3d
parent52a7bbb9c5d88ee817b4e484696846adbc7b305e (diff)
CWS-TOOLING: integrate CWS aw057
Diffstat (limited to 'goodies/source/base3d')
-rw-r--r--goodies/source/base3d/b3dcolor.cxx333
-rw-r--r--goodies/source/base3d/b3dcommn.cxx1434
-rw-r--r--goodies/source/base3d/b3dcommn.hxx129
-rw-r--r--goodies/source/base3d/b3dcompo.cxx1140
-rw-r--r--goodies/source/base3d/b3ddeflt.cxx1956
-rw-r--r--goodies/source/base3d/b3ddeflt.hxx205
-rw-r--r--goodies/source/base3d/b3dentty.cxx330
-rw-r--r--goodies/source/base3d/b3dgeom.cxx975
-rw-r--r--goodies/source/base3d/b3dlight.cxx749
-rw-r--r--goodies/source/base3d/b3dopngl.cxx1457
-rw-r--r--goodies/source/base3d/b3dopngl.hxx186
-rw-r--r--goodies/source/base3d/b3dtex.cxx1303
-rw-r--r--goodies/source/base3d/b3dtrans.cxx7
-rw-r--r--goodies/source/base3d/base3d.cxx1267
-rw-r--r--goodies/source/base3d/makefile.mk19
-rw-r--r--goodies/source/base3d/matril3d.cxx139
16 files changed, 3 insertions, 11626 deletions
diff --git a/goodies/source/base3d/b3dcolor.cxx b/goodies/source/base3d/b3dcolor.cxx
deleted file mode 100644
index 142964a1119a..000000000000
--- a/goodies/source/base3d/b3dcolor.cxx
+++ /dev/null
@@ -1,333 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dcolor.cxx,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#ifndef GCC
-#endif
-#include <goodies/b3dcolor.hxx>
-
-/*************************************************************************
-|*
-|* Farbwert interpolieren
-|*
-\************************************************************************/
-
-void B3dColor::CalcInBetween(Color& rOld1, Color& rOld2, double t)
-{
- if(rOld1 != rOld2)
- {
- UINT16 nFac = (UINT16)(t * 256.0);
- UINT16 nNegFac = 256 - nFac;
- SetRed((UINT8)(((nFac * (UINT16)rOld2.GetRed())
- + (nNegFac * (UINT16)rOld1.GetRed())) >> 8));
- SetGreen((UINT8)(((nFac * (UINT16)rOld2.GetGreen())
- + (nNegFac * (UINT16)rOld1.GetGreen())) >> 8));
- SetBlue((UINT8)(((nFac * (UINT16)rOld2.GetBlue())
- + (nNegFac * (UINT16)rOld1.GetBlue())) >> 8));
- SetTransparency((UINT8)(((nFac * (UINT16)rOld2.GetTransparency())
- + (nNegFac * (UINT16)rOld1.GetTransparency())) >> 8));
- }
- else
- {
- SetColor(rOld1.GetColor());
- }
-}
-
-/*************************************************************************
-|*
-|* Farbwert Mittelwert finden mit 2 Farben
-|*
-\************************************************************************/
-
-void B3dColor::CalcMiddle(Color& rOld1, Color& rOld2)
-{
- if(rOld1 != rOld2)
- {
- SetRed((UINT8)(((UINT16)rOld1.GetRed()
- + (UINT16)rOld2.GetRed())>>1));
- SetGreen((UINT8)(((UINT16)rOld1.GetGreen()
- + (UINT16)rOld2.GetGreen())>>1));
- SetBlue((UINT8)(((UINT16)rOld1.GetBlue()
- + (UINT16)rOld2.GetBlue())>>1));
- SetTransparency((UINT8)(((UINT16)rOld1.GetTransparency()
- + (UINT16)rOld2.GetTransparency())>>1));
- }
- else
- {
- SetColor(rOld1.GetColor());
- }
-}
-
-/*************************************************************************
-|*
-|* Farbwert Mittelwert finden mit 3 Farben
-|*
-\************************************************************************/
-
-void B3dColor::CalcMiddle(Color& rOld1, Color& rOld2, Color& rOld3)
-{
- if(rOld1 != rOld2)
- {
- if(rOld1 != rOld3)
- {
- // alle 3 unterschiedlich
- SetRed((UINT8)(((UINT16)rOld1.GetRed()
- + (UINT16)rOld2.GetRed()
- + (UINT16)rOld3.GetRed()) / 3L));
- SetGreen((UINT8)(((UINT16)rOld1.GetGreen()
- + (UINT16)rOld2.GetGreen()
- + (UINT16)rOld3.GetGreen()) / 3L));
- SetBlue((UINT8)(((UINT16)rOld1.GetBlue()
- + (UINT16)rOld2.GetBlue()
- + (UINT16)rOld3.GetBlue()) / 3L));
- SetTransparency((UINT8)(((UINT16)rOld1.GetTransparency()
- + (UINT16)rOld2.GetTransparency()
- + (UINT16)rOld3.GetTransparency()) / 3L));
- }
- else
- {
- // 1 != 2, 1 == 3
- CalcMiddle(rOld1, rOld2);
- }
- }
- else
- {
- // 1 == 2
- if(rOld1 != rOld3)
- {
- CalcMiddle(rOld1, rOld3);
- }
- else
- {
- // 1==2, 1==3 -> alle gleich
- SetColor(rOld1.GetColor());
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Ermittle den Abstand der beiden Farben im Farbraum
-|* Dies geschieht OHNE Wurzelziehen, d.h. es wird als Metrik im RGB
-|* Farbraum hier das Quadrat der 'echten' (gewohnten) Entfernung benutzt
-|*
-\************************************************************************/
-
-ULONG B3dColor::GetDistance(Color& rOld)
-{
- // Bei Gleichheit kein Abstand
- if(*this == rOld)
- return 0L;
-
- // Abstand ermitteln
- long nDistRed = rOld.GetRed() > GetRed() ?
- rOld.GetRed() - GetRed() :
- GetRed() - rOld.GetRed();
- long nDistGreen = rOld.GetGreen() > GetGreen() ?
- rOld.GetGreen() - GetGreen() :
- GetGreen() - rOld.GetGreen();
- long nDistBlue = rOld.GetBlue() > GetBlue() ?
- rOld.GetBlue() - GetBlue() :
- GetBlue() - rOld.GetBlue();
- return (ULONG)(nDistRed * nDistRed
- + nDistGreen * nDistGreen
- + nDistBlue * nDistBlue);
-}
-
-/*************************************************************************
-|*
-|* Farbaddition mit clamping
-|*
-\************************************************************************/
-
-B3dColor& B3dColor::operator+= (const B3dColor& rCol)
-{
- UINT16 nZwi;
- if(rCol.GetRed())
- {
- nZwi = (UINT16)GetRed() + (UINT16)rCol.GetRed();
- if(nZwi > 255)
- nZwi = 255;
- SetRed((UINT8)nZwi);
- }
- if(rCol.GetGreen())
- {
- nZwi = (UINT16)GetGreen() + (UINT16)rCol.GetGreen();
- if(nZwi > 255)
- nZwi = 255;
- SetGreen((UINT8)nZwi);
- }
- if(rCol.GetBlue())
- {
- nZwi = (UINT16)GetBlue() + (UINT16)rCol.GetBlue();
- if(nZwi > 255)
- nZwi = 255;
- SetBlue((UINT8)nZwi);
- }
- if(rCol.GetTransparency())
- {
- nZwi = (UINT16)GetTransparency() + (UINT16)rCol.GetTransparency();
- if(nZwi > 255)
- nZwi = 255;
- SetTransparency((UINT8)nZwi);
- }
- return *this;
-}
-
-/*************************************************************************
-|*
-|* Farbsubtraktion mit clamping
-|*
-\************************************************************************/
-
-B3dColor& B3dColor::operator-= (const B3dColor& rCol)
-{
- INT16 nZwi;
- if(rCol.GetRed())
- {
- nZwi = (INT16)GetRed() - (INT16)rCol.GetRed();
- if(nZwi < 0)
- nZwi = 0;
- SetRed((UINT8)nZwi);
- }
- if(rCol.GetGreen())
- {
- nZwi = (INT16)GetGreen() - (INT16)rCol.GetGreen();
- if(nZwi < 0)
- nZwi = 0;
- SetGreen((UINT8)nZwi);
- }
- if(rCol.GetBlue())
- {
- nZwi = (INT16)GetBlue() - (INT16)rCol.GetBlue();
- if(nZwi < 0)
- nZwi = 0;
- SetBlue((UINT8)nZwi);
- }
- if(rCol.GetTransparency())
- {
- nZwi = (INT16)GetTransparency() - (INT16)rCol.GetTransparency();
- if(nZwi < 0)
- nZwi = 0;
- SetTransparency((UINT8)nZwi);
- }
- return *this;
-}
-
-/*************************************************************************
-|*
-|* Farbaddition mit clamping, neue Farbe erzeugen
-|*
-\************************************************************************/
-
-B3dColor B3dColor::operator+ (const B3dColor& rCol) const
-{
- B3dColor aSum = *this;
- aSum += rCol;
- return aSum;
-}
-
-/*************************************************************************
-|*
-|* Farbsubtraktion mit clamping, neue Farbe erzeugen
-|*
-\************************************************************************/
-
-B3dColor B3dColor::operator- (const B3dColor& rCol) const
-{
- B3dColor aSub = *this;
- aSub -= rCol;
- return aSub;
-}
-
-/*************************************************************************
-|*
-|* Farbmultiplikation, d.h. Gewichtung der Farben aneinander
-|*
-\************************************************************************/
-
-B3dColor& B3dColor::operator*= (const B3dColor& rCol)
-{
- // urspruengliches Objekt ist die Farbe, rCol die zu berechnende
- // Gewichtung
- SetRed((UINT8)(((((UINT16)GetRed())+1)
- * (UINT16)rCol.GetRed()) >> 8));
- SetGreen((UINT8)(((((UINT16)GetGreen())+1)
- * (UINT16)rCol.GetGreen()) >> 8));
- SetBlue((UINT8)(((((UINT16)GetBlue())+1)
- * (UINT16)rCol.GetBlue()) >> 8));
- SetTransparency((UINT8)(((((UINT16)GetTransparency())+1)
- * (UINT16)rCol.GetTransparency()) >> 8));
- return *this;
-}
-
-/*************************************************************************
-|*
-|* Farbmultiplikation, neue Farbe erzeugen
-|*
-\************************************************************************/
-
-B3dColor B3dColor::operator* (const B3dColor& rCol) const
-{
- B3dColor aMul = *this;
- aMul *= rCol;
- return aMul;
-}
-
-/*************************************************************************
-|*
-|* Farbmultiplikation mit Faktor im Bereich [0.0 .. 1.0]
-|*
-\************************************************************************/
-
-B3dColor& B3dColor::operator*= (const double fVal)
-{
- ULONG nVal = (ULONG)(fVal * 65536.0);
- SetRed((UINT8)(((ULONG)GetRed() * nVal) >> 16));
- SetGreen((UINT8)(((ULONG)GetGreen() * nVal) >> 16));
- SetBlue((UINT8)(((ULONG)GetBlue() * nVal) >> 16));
- SetTransparency((UINT8)(((ULONG)GetTransparency() * nVal) >> 16));
- return *this;
-}
-
-/*************************************************************************
-|*
-|* Farbmultiplikation mit Faktor, neue Farbe erzeugen
-|*
-\************************************************************************/
-
-B3dColor B3dColor::operator* (const double fVal) const
-{
- B3dColor aMul = *this;
- aMul *= fVal;
- return aMul;
-}
-
diff --git a/goodies/source/base3d/b3dcommn.cxx b/goodies/source/base3d/b3dcommn.cxx
deleted file mode 100644
index 64bf5e127ec4..000000000000
--- a/goodies/source/base3d/b3dcommn.cxx
+++ /dev/null
@@ -1,1434 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dcommn.cxx,v $
- * $Revision: 1.11 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#ifndef GCC
-#endif
-#include "b3dcommn.hxx"
-#include "b3dtrans.hxx"
-#include <tools/debug.hxx>
-#include <vcl/outdev.hxx>
-
-/*************************************************************************
-|*
-|* Bucket fuer Index
-|*
-\************************************************************************/
-
-BASE3D_IMPL_BUCKET(sal_uInt32, Bucket)
-
-/*************************************************************************
-|*
-|* Konstruktor Base3DCommon
-|*
-\************************************************************************/
-
-Base3DCommon::Base3DCommon(OutputDevice* pOutDev)
-: Base3D(pOutDev),
- aBuffers(12) // 4K
-{
-}
-
-/*************************************************************************
-|*
-|* Destruktor Base3DCommon
-|*
-\************************************************************************/
-
-Base3DCommon::~Base3DCommon()
-{
-}
-
-/*************************************************************************
-|*
-|* Start der Szenenbeschreibung:
-|*
-\************************************************************************/
-
-void Base3DCommon::StartScene()
-{
-}
-
-/*************************************************************************
-|*
-|* Ende der Szenenbeschreibung:
-|*
-\************************************************************************/
-
-void Base3DCommon::EndScene()
-{
-}
-
-/*************************************************************************
-|*
-|* Neuen freien Eintrag fuer naechste geometrische Daten liefern
-|*
-\************************************************************************/
-
-B3dEntity& Base3DCommon::ImplGetFreeEntity()
-{
- aBuffers.Append();
- return (aBuffers[aBuffers.Count() - 1]);
-}
-
-/*************************************************************************
-|*
-|* Beleuchtung setzen/lesen
-|*
-\************************************************************************/
-
-void Base3DCommon::SetLightGroup(B3dLightGroup* pSet, sal_Bool bSetGlobal)
-{
- // call parent
- Base3D::SetLightGroup(pSet, bSetGlobal);
-
- if(GetLightGroup())
- {
- basegfx::B3DHomMatrix aOldObjectTrans;
- basegfx::B3DHomMatrix aEmptyTrans;
-
- if(GetTransformationSet() && bSetGlobal)
- {
- aOldObjectTrans = GetTransformationSet()->GetObjectTrans();
- GetTransformationSet()->SetObjectTrans(aEmptyTrans);
- }
-
- for(sal_uInt16 i=0;i<BASE3D_MAX_NUMBER_LIGHTS;i++)
- {
- B3dLight& rLight = GetLightGroup()->GetLightObject((Base3DLightNumber)(Base3DLight0 + i));
-
- if(rLight.IsDirectionalSource())
- {
- basegfx::B3DPoint aPosition(rLight.GetPosition());
-
- if(GetTransformationSet())
- {
- aPosition = GetTransformationSet()->InvTransObjectToEye(aPosition);
- }
-
- rLight.SetPositionEye(aPosition);
- }
- else
- {
- basegfx::B3DPoint aPosition(rLight.GetPosition());
-
- if(GetTransformationSet())
- {
- aPosition = GetTransformationSet()->ObjectToEyeCoor(aPosition);
- }
-
- rLight.SetPositionEye(aPosition);
-
- basegfx::B3DVector aDirection(rLight.GetSpotDirection());
-
- if(GetTransformationSet())
- {
- aDirection = GetTransformationSet()->InvTransObjectToEye(aDirection);
- }
-
- aDirection.normalize();
- rLight.SetSpotDirectionEye(aDirection);
- }
- }
-
- if(GetTransformationSet() && bSetGlobal)
- {
- GetTransformationSet()->SetObjectTrans(aOldObjectTrans);
- }
- }
-}
-
-/*************************************************************************
-|*
-|* entsprechend der impliziten Topologie auf den neuen Punkt reagieren
-|*
-\************************************************************************/
-
-void Base3DCommon::ImplPostAddVertex(B3dEntity& rEntity)
-{
- B3dTransformationSet* pSet = GetTransformationSet();
- if(pSet)
- {
- // Positionen transformieren in ClippingCoordinates
- rEntity.Point() *= pSet->GetObjectToDevice();
-
- // Normalen transformieren in EyeCoordinates
- if((GetLightGroup() && GetLightGroup()->IsLightingEnabled()) && rEntity.IsNormalUsed())
- {
- if(GetForceFlat() || GetShadeModel() == Base3DFlat)
- {
- rEntity.Normal() = pSet->InvTransObjectToEye(rEntity.PlaneNormal());
- }
- else
- {
- rEntity.Normal() = pSet->InvTransObjectToEye(rEntity.Normal());
- }
- }
-
- // Texturkoordinaten transformieren anhand der Texturmatrix
- if(rEntity.IsTexCoorUsed())
- {
- rEntity.TexCoor() = pSet->TransTextureCoor(rEntity.TexCoor());
- }
- }
-
- // Aktuelle Farbe in diesen B3dEntity eintragen
- rEntity.Color() = GetColor();
-
- // Jetzt Topologie beachten und evtl. ein Primitiv ausspucken
- sal_uInt32 aCount = aBuffers.Count();
- switch(GetObjectMode())
- {
- case Base3DPoints:
- {
- Create3DPoint(0);
- aBuffers.Erase();
- break;
- }
- case Base3DLines:
- {
- if(aCount == 2)
- {
- Create3DLine(0, 1);
- aBuffers.Erase();
- }
- break;
- }
- case Base3DLineLoop:
- case Base3DLineStrip:
- {
- if(aCount > 1)
- Create3DLine(aCount - 2, aCount - 1);
- break;
- }
- case Base3DTriangles:
- {
- if(aCount == 3)
- {
- Create3DTriangle(0, 1, 2);
- aBuffers.Erase();
- }
- break;
- }
- case Base3DTriangleStrip:
- {
- if(aCount > 2)
- {
- if(aCount % 2)
- Create3DTriangle(aCount - 3, aCount - 2, aCount - 1);
- else
- Create3DTriangle(aCount - 2, aCount - 3, aCount - 1);
- }
- break;
- }
- case Base3DTriangleFan:
- {
- if(aCount > 2)
- Create3DTriangle(0, aCount - 2, aCount - 1);
- break;
- }
- case Base3DQuads:
- {
- if(aCount == 4)
- {
- // Spezielle Behandlung, da die inneren Kanten
- // eines Quads NICHT sichtbar sein sollen
- B3dEntity& rEnt2 = aBuffers[2];
- B3dEntity& rEnt0 = aBuffers[0];
-
- sal_Bool bZwi = rEnt2.IsEdgeVisible();
- rEnt2.SetEdgeVisible(sal_False);
- Create3DTriangle(0, 1, 2);
- rEnt2.SetEdgeVisible(bZwi);
-
- bZwi = rEnt0.IsEdgeVisible();
- rEnt0.SetEdgeVisible(sal_False);
- Create3DTriangle(0, 2, 3);
- rEnt0.SetEdgeVisible(bZwi);
-
- aBuffers.Erase();
- }
- break;
- }
- case Base3DQuadStrip:
- {
- if(aCount > 2)
- {
- B3dEntity& rEnt = aBuffers[aCount - 2];
- sal_Bool bZwi = rEnt.IsEdgeVisible();
- rEnt.SetEdgeVisible(sal_False);
- if(aCount % 2)
- Create3DTriangle(aCount - 2, aCount - 1, aCount - 3);
- else
- Create3DTriangle(aCount - 3, aCount - 1, aCount - 2);
- rEnt.SetEdgeVisible(bZwi);
- }
- break;
- }
- case Base3DPolygon:
- {
- if(aCount > 2)
- {
- B3dEntity& rEnt = aBuffers[aCount - 1];
- sal_Bool bZwi = rEnt.IsEdgeVisible();
- rEnt.SetEdgeVisible(sal_False);
- Create3DTriangle(0, aCount - 2, aCount - 1);
- rEnt.SetEdgeVisible(bZwi);
- // Ab jetzt nie wieder eine Kante vom 1. Punkt (0)
- // ausgehend generieren
- if(aCount == 3)
- aBuffers[0].SetEdgeVisible(sal_False);
- }
- break;
-
- }
- case Base3DComplexPolygon:
- case Base3DComplexPolygonCut:
- break; // -Wall not handled.
- }
-}
-
-/*************************************************************************
-|*
-|* Ein neues Primitiv, leere die jetzigen buffer
-|*
-\************************************************************************/
-
-void Base3DCommon::ImplStartPrimitive()
-{
- // Buffer leeren
- aBuffers.Erase();
-}
-
-/*************************************************************************
-|*
-|* Primitiv abgeschlossen
-|*
-\************************************************************************/
-
-void Base3DCommon::ImplEndPrimitive()
-{
- // Topologie beachten und evtl. ein Primitiv ausspucken
- sal_uInt32 aCount = aBuffers.Count();
- switch(GetObjectMode())
- {
- case Base3DLineLoop:
- {
- if(aCount > 2)
- Create3DLine(aCount - 1, 0);
- break;
- }
- case Base3DPolygon:
- {
- // Letzte schliessende Linie erzeugen, falls
- // es um das Erzeugen von Linien ging und
- // das letzte Primitiv auch wirklich zur Ausgabe
- // gelangt ist
- if(GetRenderMode() == Base3DRenderLine
- && !WasLastPrimitiveRejected())
- {
- if(aCount > 2)
- Create3DLine(aCount - 1, 0);
- }
- break;
- }
- default:
- break; // -Wall multiple values not handled.
- }
-}
-
-/*************************************************************************
-|*
-|* Funktion fuer Primitiv Punkt
-|* Clipping und Ausgabe, falls noch was ueber ist
-|*
-\************************************************************************/
-
-void Base3DCommon::Create3DPoint(sal_uInt32 nInd)
-{
- bLastPrimitiveRejected = sal_True;
- if(GetRenderMode() != Base3DRenderNone)
- {
- // Sicherstellen, dass die Koordinaten in
- // ClipCoordinates vorliegen
- aBuffers[nInd].To3DCoor(GetTransformationSet());
-
- // Punkt an Einheitswuerfel clippen
- if(Clip3DPoint(nInd))
- Create3DPointClipped(nInd);
- }
-}
-
-void Base3DCommon::Create3DPointClipped(sal_uInt32 nInd)
-{
- // einige Beleuchtungsdinge koennen hier schon geklaert
- // werden
- if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
- {
- B3dEntity& rEnt = aBuffers[nInd];
- if(rEnt.IsNormalUsed() && GetLightGroup())
- {
- // Beleuchtungsmodell loesen, Normale loeschen
- SolveColorModel(rEnt.Color(), rEnt.Normal(), rEnt.Point());
- }
- rEnt.SetNormalUsed(sal_False);
- }
-
- // Punkt wird dargestellt, weiterreichen
- if(GetPointSize() != 1.0)
- {
- // Punkt als Kreis mit dem Durchmesser GetPointSize() ausgeben
- // Hole den Original-Punkt
- B3dEntity& rEnt1 = aBuffers[nInd];
-
- // Umrechnen auf DeviceCoor
- rEnt1.ToDeviceCoor(GetTransformationSet());
-
- // Radius holen
- // Logische Koordinaten nach Pixel
- Point aPnt((long)(GetLineWidth() + 0.5), 0);
- double fRadius = ((double)((
- GetOutputDevice()->PixelToLogic(aPnt).X() -
- GetOutputDevice()->PixelToLogic(Point()).X()) + 0.5)) / 2.0;
-
- // Bereite neue Punkte vor
- // Hole die neuen Punkte
- sal_uInt32 nNew1 = aBuffers.Count();
- aBuffers.Append(rEnt1);
- B3dEntity& rNew1 = aBuffers[nNew1];
-
- sal_uInt32 nNew2 = aBuffers.Count();
- aBuffers.Append(rEnt1);
- B3dEntity& rNew2 = aBuffers[nNew2];
-
- sal_uInt32 nNew3 = aBuffers.Count();
- aBuffers.Append(rEnt1);
- B3dEntity& rNew3 = aBuffers[nNew3];
-
- // Schleife drehen
- Base3DRenderMode eRenderMode = GetRenderMode();
- SetRenderMode(Base3DRenderFill);
- sal_Bool bPolyOffset = GetPolygonOffset(Base3DPolygonOffsetFill);
- SetPolygonOffset(Base3DPolygonOffsetFill, sal_True);
-
- for(double fWink=0.0;fWink<F_2PI-(F_2PI/24.0);fWink+=F_2PI/12.0)
- {
- rNew2.Point().setX(rNew1.Point().getX() + (cos(fWink) * fRadius));
- rNew2.Point().setY(rNew1.Point().getY() + (sin(fWink) * fRadius));
-
- rNew3.Point().setX(rNew1.Point().getX() + (cos(fWink+(F_2PI/12.0)) * fRadius));
- rNew3.Point().setY(rNew1.Point().getY() + (sin(fWink+(F_2PI/12.0)) * fRadius));
-
- // Dreieck Zeichnen
- Create3DTriangle(nNew1, nNew3, nNew2);
- }
-
- SetRenderMode(eRenderMode);
- SetPolygonOffset(Base3DPolygonOffsetFill, bPolyOffset);
-
- bLastPrimitiveRejected = sal_False;
- }
- else
- {
- Clipped3DPoint(nInd);
- bLastPrimitiveRejected = sal_False;
- }
-}
-
-/*************************************************************************
-|*
-|* Funktion fuer Primitiv Linie
-|* Clipping und Ausgabe, falls noch was ueber ist
-|*
-\************************************************************************/
-
-void Base3DCommon::Create3DLine(sal_uInt32 nInd1, sal_uInt32 nInd2)
-{
- bLastPrimitiveRejected = sal_True;
- if(GetRenderMode() != Base3DRenderNone)
- {
- // Sicherstellen, dass die Koordinaten in
- // ClipCoordinates vorliegen
- aBuffers[nInd1].To3DCoor(GetTransformationSet());
- aBuffers[nInd2].To3DCoor(GetTransformationSet());
-
- if(AreEqual(nInd1, nInd2))
- return;
-
- // Linie an Einheitswuerfel clippen, dabei kann eine
- // der Indexvariablen (werden als Referenz uegergeben)
- // veraendert werden
-
- // Alte Buffergroesse merken
- ULONG nCount = aBuffers.Count();
-
- if(Clip3DLine(nInd1, nInd2))
- {
- // EdgeFlag beachten
- if(aBuffers[nInd1].IsEdgeVisible())
- Create3DLineClipped(nInd1, nInd2);
- }
-
- // Alte Buffergroesse wiederherstellen, um fortgesetzte
- // Primitive nicht zu zerstoeren
- while(aBuffers.Count() > nCount)
- aBuffers.Remove();
- }
-}
-
-void Base3DCommon::Create3DLineClipped(sal_uInt32 nInd1, sal_uInt32 nInd2)
-{
- // einige Beleuchtungsdinge koennen hier schon geklaert
- // werden
- if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
- {
- if(GetShadeModel() == Base3DFlat)
- {
- // Beleuchtuungsmodell fuer gemittelte Normale
- // loesen, Normalen loeschen
- B3dEntity& rEnt1 = aBuffers[nInd1];
- B3dEntity& rEnt2 = aBuffers[nInd2];
- if(rEnt1.IsNormalUsed() && rEnt2.IsNormalUsed() && GetLightGroup())
- {
- basegfx::B3DVector aNormal = rEnt1.Normal() + rEnt2.Normal();
- aNormal.normalize();
- basegfx::B3DPoint aPoint = (rEnt1.Point() + rEnt2.Point()) / 2.0;
- SolveColorModel(rEnt1.Color(), aNormal, aPoint);
- rEnt2.Color() = rEnt1.Color();
- }
- rEnt1.SetNormalUsed(sal_False);
- rEnt2.SetNormalUsed(sal_False);
- }
- }
- else
- {
- if(GetShadeModel() == Base3DFlat)
- {
- B3dEntity& rEnt1 = aBuffers[nInd1];
- B3dEntity& rEnt2 = aBuffers[nInd2];
- B3dColor aCol;
- aCol.CalcMiddle(rEnt1.Color(), rEnt2.Color());
- rEnt1.Color() = aCol;
- rEnt2.Color() = aCol;
- }
- }
-
- if(GetRenderMode() == Base3DRenderPoint)
- {
- // Als Punkte ausgeben
- Create3DPointClipped(nInd1);
- Create3DPointClipped(nInd2);
- }
- else
- {
- if(GetLineWidth() != 1.0)
- {
- // Linie als Polygon mit der Breite GetLineWidth() ausgeben
- // Hole die Original-Punkte
- B3dEntity& rEnt1 = aBuffers[nInd1];
- B3dEntity& rEnt2 = aBuffers[nInd2];
-
- // Umrechnen auf DeviceCoor
- rEnt1.ToDeviceCoor(GetTransformationSet());
- rEnt2.ToDeviceCoor(GetTransformationSet());
-
- // Bereite neue Punkte vor
- // Hole die neuen Punkte
- sal_uInt32 nNew1 = aBuffers.Count();
- aBuffers.Append(rEnt1);
- B3dEntity& rNew1 = aBuffers[nNew1];
-
- sal_uInt32 nNew2 = aBuffers.Count();
- aBuffers.Append(rEnt1);
- B3dEntity& rNew2 = aBuffers[nNew2];
-
- sal_uInt32 nNew3 = aBuffers.Count();
- aBuffers.Append(rEnt2);
- B3dEntity& rNew3 = aBuffers[nNew3];
-
- sal_uInt32 nNew4 = aBuffers.Count();
- aBuffers.Append(rEnt2);
- B3dEntity& rNew4 = aBuffers[nNew4];
-
- // Berechnen
- basegfx::B3DVector aEntVector = rEnt2.Point() - rEnt1.Point();
- basegfx::B3DVector aTurned(-aEntVector.getY(), aEntVector.getX(), 0.0);
- aTurned.normalize();
-
- // Logische Koordinaten nach Pixel
- Point aPnt((long)(GetLineWidth() + 0.5), 0);
- double fFac = ((double)((
- GetOutputDevice()->PixelToLogic(aPnt).X() -
- GetOutputDevice()->PixelToLogic(Point()).X()) + 0.5)) / 2.0;
-
- // Aufmuliplizieren
- aTurned *= fFac;
-
- rNew1.Point().setX(rNew1.Point().getX() + aTurned.getX());
- rNew1.Point().setY(rNew1.Point().getY() + aTurned.getY());
- rNew2.Point().setX(rNew2.Point().getX() - aTurned.getX());
- rNew2.Point().setY(rNew2.Point().getY() - aTurned.getY());
-
- rNew3.Point().setX(rNew3.Point().getX() + aTurned.getX());
- rNew3.Point().setY(rNew3.Point().getY() + aTurned.getY());
- rNew4.Point().setX(rNew4.Point().getX() - aTurned.getX());
- rNew4.Point().setY(rNew4.Point().getY() - aTurned.getY());
-
- // Ausgeben
- Base3DRenderMode eRenderMode = GetRenderMode();
- SetRenderMode(Base3DRenderFill);
- sal_Bool bPolyOffset = GetPolygonOffset(Base3DPolygonOffsetFill);
- SetPolygonOffset(Base3DPolygonOffsetFill, sal_True);
-
- Create3DTriangle(nNew2, nNew1, nNew3);
- Create3DTriangle(nNew2, nNew3, nNew4);
-
- SetRenderMode(eRenderMode);
- SetPolygonOffset(Base3DPolygonOffsetFill, bPolyOffset);
-
- bLastPrimitiveRejected = sal_False;
- }
- else
- {
- // Linie ausgeben
- Clipped3DLine(nInd1,nInd2);
- bLastPrimitiveRejected = sal_False;
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Funktion fuer Primitiv Dreieck
-|* Clipping und Ausgabe, falls noch was ueber ist
-|*
-\************************************************************************/
-
-void Base3DCommon::Create3DTriangle(sal_uInt32 nInd1, sal_uInt32 nInd2, sal_uInt32 nInd3)
-{
- bLastPrimitiveRejected = sal_True;
-
- // Sicherstellen, dass die Koordinaten in
- // ClipCoordinates vorliegen
- aBuffers[nInd1].To3DCoor(GetTransformationSet());
- aBuffers[nInd2].To3DCoor(GetTransformationSet());
- aBuffers[nInd3].To3DCoor(GetTransformationSet());
-
- if(AreEqual(nInd1, nInd2)
- || AreEqual(nInd1, nInd3)
- || AreEqual(nInd2, nInd3))
- return;
-
- // Normale vorbereiten, die echte Ebenennormale der Geometrie
- // im Device-Koordinatensystem. Verzerrungen durch perspektivische
- // Projektion sind somit bereits beruecksichtigt.
- const basegfx::B3DPoint& rPnt1 = aBuffers[nInd1].Point();
- const basegfx::B3DPoint& rPnt2 = aBuffers[nInd2].Point();
- const basegfx::B3DPoint& rPnt3 = aBuffers[nInd3].Point();
- basegfx::B3DVector aNormal = basegfx::B3DVector(rPnt2 - rPnt3).getPerpendicular(basegfx::B3DVector(rPnt2 - rPnt1));
- aNormal.normalize();
-
- if(GetCullMode() != Base3DCullNone)
- {
- // Normale ermitteln, eventuell gar nicht zeichnen
- if(GetCullMode() == Base3DCullFront)
- {
- if(aNormal.getZ() > 0.0)
- return;
- }
- else
- {
- if(aNormal.getZ() < 0.0)
- return;
- }
- }
-
- // allgemeines Polygon vorbereiten
- sal_uInt32Bucket aEdgeIndex(8);
- aEdgeIndex.Append(nInd1);
- aEdgeIndex.Append(nInd2);
- aEdgeIndex.Append(nInd3);
-
- // Alte Buffergroesse merken
- ULONG nCount = aBuffers.Count();
-
- // Dreieck an Einheitswuerfel clippen
- if(Clip3DPolygon(aEdgeIndex))
- {
- // #93184# set flag for polygon normal direction
- bNormalPointsAway = sal_Bool(aNormal.getZ() < 0.0);
-
- sal_uInt32 nNumPoints = aEdgeIndex.Count();
-
- // einige Beleuchtungsdinge koennen hier schon geklaert
- // werden
- if(GetLightGroup() && GetLightGroup()->IsLightingEnabled() && nNumPoints != 0)
- {
- if(GetShadeModel() == Base3DFlat)
- {
- B3dEntity& rEntity = aBuffers[nInd1];
- B3dColor aColFlatMode;
-
- // #63505#
- aNormal.setX(-aNormal.getX());
- aNormal.setY(-aNormal.getY());
-
- SolveColorModel(aColFlatMode, aNormal, rEntity.Point());
-
- // Vorberechnete Farbe in Eckpunkten setzen
- for(sal_uInt32 i=0;i<nNumPoints;i++)
- {
- B3dEntity& rEnt = aBuffers[aEdgeIndex[i]];
- rEnt.Color() = aColFlatMode;
- rEnt.SetNormalUsed(sal_False);
- }
- }
- }
- else
- {
- if(GetShadeModel() == Base3DFlat && nNumPoints != 0)
- {
- sal_uInt16 aRed(0), aGreen(0), aBlue(0), aAlpha(0);
- sal_uInt32 i;
- for(i=0;i<nNumPoints;i++)
- {
- B3dEntity& rEnt = aBuffers[aEdgeIndex[i]];
- aRed = aRed + rEnt.Color().GetRed();
- aGreen = aGreen + rEnt.Color().GetGreen();
- aBlue = aBlue + rEnt.Color().GetBlue();
- aAlpha = aAlpha + rEnt.Color().GetTransparency();
- }
- B3dColor aCol((UINT8)(aAlpha / nNumPoints),
- (UINT8)(aRed / nNumPoints),
- (UINT8)(aGreen / nNumPoints),
- (UINT8)(aBlue / nNumPoints));
- for(i=0;i<nNumPoints;i++)
- {
- aBuffers[aEdgeIndex[i]].Color() = aCol;
- }
- }
- }
-
- // Ausgeben, je nach Modus
- Base3DMaterialMode eMat = Base3DMaterialFront;
- if(aNormal.getZ() < 0.0
- && (GetLightGroup() && GetLightGroup()->GetModelTwoSide()))
- eMat = Base3DMaterialBack;
- Base3DRenderMode eMode = GetRenderMode(eMat);
-
- if(eMode == Base3DRenderPoint)
- {
- // Als Punktmenge ausgeben
- for(sal_uInt32 i=0;i<nNumPoints;i++)
- {
- Create3DPointClipped(aEdgeIndex[i]);
- }
- }
- else if(eMode == Base3DRenderLine)
- {
- // Als Linien ausgeben
- sal_uInt32 i2, i3;
- for(sal_uInt32 i=0;i<nNumPoints;i++)
- {
- i2 = i+1;
- if(i2 == nNumPoints)
- i2 = 0;
- i3 = aEdgeIndex[i];
- i2 = aEdgeIndex[i2];
-
- // EdgeFlag beachten
- if(aBuffers[i3].IsEdgeVisible())
- Create3DLineClipped(i3, i2);
- }
- }
- else
- {
- // after clipping the triangle can be a multi-sided, but
- // convex polygon. Render it by dividing it into triangles
- // again. Cause' it is clipped now, no more taking care is
- // necessary. Just give hints which flags are truly edges
- // to allow further computations.
- if(nNumPoints > 2)
- {
- for(sal_uInt32 i=2;i < nNumPoints; i++)
- {
- Clipped3DTriangle(
- aEdgeIndex[0],
- aEdgeIndex[i-1],
- aEdgeIndex[i]);
- bLastPrimitiveRejected = sal_False;
- }
- }
- }
- }
- // Alte Buffergroesse wiederherstellen, um fortgesetzte
- // Primitive nicht zu zerstoeren
- while(aBuffers.Count() > nCount)
- aBuffers.Remove();
-}
-
-/*************************************************************************
-|*
-|* Punkt am canonical view volume clippen
-|*
-\************************************************************************/
-
-sal_Bool Base3DCommon::Clip3DPoint(sal_uInt32 nInd)
-{
- return (!(sal_Bool)GetClipFlags(nInd));
-}
-
-/*************************************************************************
-|*
-|* Vergleicht, ob die beiden Entities geometrisch gleich sind
-|*
-\************************************************************************/
-
-sal_Bool Base3DCommon::AreEqual(sal_uInt32 nInd1, sal_uInt32 nInd2)
-{
- const basegfx::B3DPoint& rPnt1 = aBuffers[nInd1].Point();
- const basegfx::B3DPoint& rPnt2 = aBuffers[nInd2].Point();
-
- return rPnt1.equal(rPnt2);
-}
-
-/*************************************************************************
-|*
-|* Linie am canonical view volume clippen
-|*
-\************************************************************************/
-
-sal_Bool Base3DCommon::Clip3DLine(sal_uInt32& nInd1,sal_uInt32& nInd2)
-{
- sal_uInt16 nFlag0, nFlag1;
- do
- {
- nFlag0 = GetClipFlags(nInd1);
- nFlag1 = GetClipFlags(nInd2);
-
- // Beide Endpunkte drin?
- if(!(nFlag0 | nFlag1))
- return sal_True;
-
- // Linie komplett draussen?
- if(nFlag0 & nFlag1)
- return sal_False;
-
- // Es muss geclippt werden, bereite einen neuen Punkt vor
- sal_uInt32 nNewIndex = aBuffers.Count();
- aBuffers.Append();
-
- if((nFlag0 | nFlag1) & (CLIPFLAG_FRONT | CLIPFLAG_BACK))
- {
- // clippen in Z
- if(nFlag0 & (CLIPFLAG_FRONT | CLIPFLAG_BACK))
- {
- if(nFlag0 & CLIPFLAG_FRONT)
- CalcNewPoint(nNewIndex, nInd2, nInd1, 2, -1.0);
- else
- CalcNewPoint(nNewIndex, nInd1, nInd2, 2, 1.0);
- nInd1 = nNewIndex;
- }
- else
- {
- if(nFlag1 & CLIPFLAG_FRONT)
- CalcNewPoint(nNewIndex, nInd1, nInd2, 2, -1.0);
- else
- CalcNewPoint(nNewIndex, nInd2, nInd1, 2, 1.0);
- nInd2 = nNewIndex;
- }
- }
- else if((nFlag0 | nFlag1) & (CLIPFLAG_LEFT | CLIPFLAG_RIGHT))
- {
- // clippen in X
- if(nFlag0 & (CLIPFLAG_LEFT | CLIPFLAG_RIGHT))
- {
- if(nFlag0 & CLIPFLAG_LEFT)
- CalcNewPoint(nNewIndex, nInd2, nInd1, 0, -1.0);
- else
- CalcNewPoint(nNewIndex, nInd1, nInd2, 0, 1.0);
- nInd1 = nNewIndex;
- }
- else
- {
- if(nFlag1 & CLIPFLAG_LEFT)
- CalcNewPoint(nNewIndex, nInd1, nInd2, 0, -1.0);
- else
- CalcNewPoint(nNewIndex, nInd2, nInd1, 0, 1.0);
- nInd2 = nNewIndex;
- }
- }
- else
- {
- // clippen in Y
- if(nFlag0 & (CLIPFLAG_BOTTOM | CLIPFLAG_TOP))
- {
- if(nFlag0 & CLIPFLAG_BOTTOM)
- CalcNewPoint(nNewIndex, nInd2, nInd1, 1, -1.0);
- else
- CalcNewPoint(nNewIndex, nInd1, nInd2, 1, 1.0);
- nInd1 = nNewIndex;
- }
- else
- {
- if(nFlag1 & CLIPFLAG_BOTTOM)
- CalcNewPoint(nNewIndex, nInd1, nInd2, 1, -1.0);
- else
- CalcNewPoint(nNewIndex, nInd2, nInd1, 1, 1.0);
- nInd2 = nNewIndex;
- }
- }
- } while(nFlag0 | nFlag1);
- return sal_True;
-}
-
-/*************************************************************************
-|*
-|* ClipFlags eines Punktes ermitteln und zurueckgeben
-|*
-\************************************************************************/
-
-sal_uInt16 Base3DCommon::GetClipFlags(sal_uInt32 nInd)
-{
- sal_uInt16 nRetval(0);
- basegfx::B3DPoint& rPoint = aBuffers[nInd].Point();
-
- if(rPoint.getX() < -(1.0 + SMALL_DVALUE))
- nRetval |= CLIPFLAG_LEFT;
- if(rPoint.getX() > 1.0 + SMALL_DVALUE)
- nRetval |= CLIPFLAG_RIGHT;
-
- if(rPoint.getY() < -(1.0 + SMALL_DVALUE))
- nRetval |= CLIPFLAG_BOTTOM;
- if(rPoint.getY() > 1.0 + SMALL_DVALUE)
- nRetval |= CLIPFLAG_TOP;
-
- if(rPoint.getZ() < -(1.0 + SMALL_DVALUE))
- nRetval |= CLIPFLAG_FRONT;
- if(rPoint.getZ() > 1.0 + SMALL_DVALUE)
- nRetval |= CLIPFLAG_BACK;
-
- return nRetval;
-}
-
-/*************************************************************************
-|*
-|* Dreieck am canonical view volume clippen
-|* Ergebnis steht indirekt ueber eine Indizierungstabelle in
-|* aEdgeIndex[nEdgeDestination][0 .. aEdgeIndexFree[nEdgeDestination]]
-|*
-\************************************************************************/
-
-sal_Bool Base3DCommon::Clip3DPolygon(sal_uInt32Bucket& rEdgeIndex)
-{
- sal_uInt32 i;
- sal_uInt16 nAllFlagsOr, nAllFlagsAnd;
-
- do
- {
- // ClipFlags holen
- nAllFlagsOr = 0;
- nAllFlagsAnd = CLIPFLAG_ALL;
-
- for(i=0; i < rEdgeIndex.Count(); i++)
- {
- sal_uInt16 nFlag = GetClipFlags(rEdgeIndex[i]);
- nAllFlagsOr |= nFlag;
- nAllFlagsAnd &= nFlag;
- }
-
- // Alle Endpunkte drin?
- if(!nAllFlagsOr)
- return sal_True;
-
- // Dreieck komplett draussen?
- if(nAllFlagsAnd)
- return sal_False;
-
- if(nAllFlagsOr & (CLIPFLAG_FRONT|CLIPFLAG_BACK))
- {
- // clippen in Z
- if(nAllFlagsOr & CLIPFLAG_FRONT)
- {
- ClipPoly(rEdgeIndex, 2, sal_True);
- }
- else
- {
- ClipPoly(rEdgeIndex, 2, sal_False);
- }
- }
- else if(nAllFlagsOr & (CLIPFLAG_LEFT|CLIPFLAG_RIGHT))
- {
- // clippen in X
- if(nAllFlagsOr & CLIPFLAG_LEFT)
- {
- ClipPoly(rEdgeIndex, 0, sal_True);
- }
- else
- {
- ClipPoly(rEdgeIndex, 0, sal_False);
- }
- }
- else
- {
- // clippen in Y
- if(nAllFlagsOr & CLIPFLAG_BOTTOM)
- {
- ClipPoly(rEdgeIndex, 1, sal_True);
- }
- else
- {
- ClipPoly(rEdgeIndex, 1, sal_False);
- }
- }
- } while(nAllFlagsOr);
- return sal_True;
-}
-
-/*************************************************************************
-|*
-|* Testen, ob die Entitaet nInd innerhalb des canonical view volume liegt
-|*
-\************************************************************************/
-
-sal_Bool Base3DCommon::IsInside(sal_uInt32 nInd, sal_uInt32 nDim, sal_Bool bLow)
-{
- B3dEntity& aEntity = aBuffers[nInd];
-
- // #110270#
- // Add SMALL_DVALUE to this tests
- if(bLow)
- {
- if(aEntity.Point()[nDim] < -(1.0 + SMALL_DVALUE))
- return sal_False;
- }
- else
- {
- if(aEntity.Point()[nDim] > (1.0 + SMALL_DVALUE))
- return sal_False;
- }
- return sal_True;
-}
-
-/*************************************************************************
-|*
-|* Macht einen Clippingdurchgang eines Polygons in der angegebenen
-|* Dimension. Es werden eventuell neue Punkte erzeugt.
-|*
-\************************************************************************/
-
-void Base3DCommon::ClipPoly(sal_uInt32Bucket& rEdgeIndex, sal_uInt16 nDim, sal_Bool bLow)
-{
- sal_uInt32 nNumEdges = rEdgeIndex.Count();
- sal_uInt32 nCurrentInd = rEdgeIndex[0];
- sal_Bool bCurrentInside = IsInside(nCurrentInd, nDim, bLow);
- sal_uInt32 nNextInd;
- sal_Bool bNextInside;
- sal_uInt32Bucket aEdgeIndex(8);
-
- for(sal_uInt32 i=0;i<nNumEdges;i++)
- {
- // hole naechsten Eckpunkt
- nNextInd = i+1;
- if(nNextInd == nNumEdges)
- nNextInd = 0;
- nNextInd = rEdgeIndex[nNextInd];
- bNextInside = IsInside(nNextInd, nDim, bLow);
-
- // behandle die Kante nCurrentInd, nNextInd in der Dimension
- // nDim gegen die Grenze -1.0
- if(bCurrentInside)
- {
- // aktuellen Punkt hinzufuegen
- aEdgeIndex.Append(nCurrentInd);
- if(!bNextInside)
- {
- // drin -> draussen
- // Platz fuer Schnittpunkt allokieren
- sal_uInt32 nNewIndex = aBuffers.Count();
- aBuffers.Append();
-
- // Schnittpunkt berechnen
- if(bLow)
- CalcNewPoint(nNewIndex, nCurrentInd, nNextInd, nDim, -1.0);
- else
- CalcNewPoint(nNewIndex, nNextInd, nCurrentInd, nDim, 1.0);
-
- // EdgeFlag behandeln, beim Verlassen zuruecksetzen
- if(aBuffers[nCurrentInd].IsEdgeVisible())
- aBuffers[nNewIndex].SetEdgeVisible(sal_False);
-
- // Schnittpunkt hinzufuegen
- aEdgeIndex.Append(nNewIndex);
- }
- }
- else
- {
- if(bNextInside)
- {
- // draussen -> drin
- // Platz fuer Schnittpunkt allokieren
- sal_uInt32 nNewIndex = aBuffers.Count();
- aBuffers.Append();
-
- // Schnittpunkt berechnen
- if(bLow)
- CalcNewPoint(nNewIndex, nNextInd, nCurrentInd, nDim, -1.0);
- else
- CalcNewPoint(nNewIndex, nCurrentInd, nNextInd, nDim, 1.0);
-
- // EdgeFlag behandeln, selber Wert wie Vorgaenger
- aBuffers[nNewIndex].SetEdgeVisible(aBuffers[nCurrentInd].IsEdgeVisible());
-
- // Schnittpunkt hinzufuegen
- aEdgeIndex.Append(nNewIndex);
- }
- }
-
- // bereite naechste Kante vor
- nCurrentInd = nNextInd;
- bCurrentInside = bNextInside;
- }
-
- // Indices kopieren
- rEdgeIndex = aEdgeIndex;
-}
-
-/*************************************************************************
-|*
-|* Die Entitaet nNew muss berechnet werden in der angegebenen
-|* Dimension an der Grenze fBound.
-|*
-\************************************************************************/
-
-void Base3DCommon::CalcNewPoint(sal_uInt32 nNew, sal_uInt32 nHigh, sal_uInt32 nLow,
- sal_uInt16 nDim, double fBound)
-{
- B3dEntity& aNew = aBuffers[nNew];
- B3dEntity& aHigh = aBuffers[nHigh];
- B3dEntity& aLow = aBuffers[nLow];
- double fFactor(1.0);
- aNew.Reset();
-
- if(aLow.Point()[nDim] != aHigh.Point()[nDim])
- {
- // #i27159#
- // Still numerical problems here around 0.0 and 1.0. I decided to
- // go the numerically more cautios way and avoid values which get
- // a little bit below 0.0 or above 1.0 here. The original line was:
- // fFactor = (fBound - aHigh.Point()[nDim]) / (aLow.Point()[nDim] - aHigh.Point()[nDim]);
- const double fFactorA(fBound - aHigh.Point()[nDim]);
-
- if(fabs(fFactorA) < SMALL_DVALUE)
- {
- fFactor = 0.0;
- }
- else
- {
- const double fFactorB(aLow.Point()[nDim] - aHigh.Point()[nDim]);
-
- if(fabs(fFactorA - fFactorB) < SMALL_DVALUE)
- {
- fFactor = 1.0;
- }
- else
- {
- fFactor = fFactorA / fFactorB;
- }
- }
- }
-
-#ifdef DBG_UTIL
- if(fFactor > 1.0 || fFactor < 0.0)
- DBG_ERROR("Wrong clipping factor (out of range)!");
-#endif
-
- if(fFactor == 0.0)
- {
- // #110270#
- // If fFactor is 0.0, copy the point
- aNew.Copy(aHigh);
- }
- else if(fFactor == 1.0)
- {
- // #110270#
- // If fFactor is 1.0, copy the point
- aNew.Copy(aLow);
- }
- else
- {
- // Neuen Punkt berechnen, aber Reihenfolge der
- // Punkte aufrecht erhalten um die Sichtbarkeit
- // der Kanten zu retten
- aLow.ForceEqualBase(GetTransformationSet(), aHigh);
-
- if(fBound < 0.0)
- aNew.CalcInBetween(aLow, aHigh, 1.0 - fFactor);
- else
- aNew.CalcInBetween(aHigh, aLow, fFactor);
-
- // WICHTIG fuer die Numerik beim Clippen: Die betroffene
- // Koordinate wirklich auf fBound setzen, nicht berechnen.
- // Beim Berechnen koennen nur wieder Ungenauigkeiten auftreten,
- // die bei der Bestimmung der Clipping-Grenzen zu
- // Endlosschleifen fuehren koennen.
- aNew.Point()[nDim] = fBound;
- }
-}
-
-/*************************************************************************
-|*
-|* Beleuchtungsmodell (ColorModel) in einem Punkt loesen
-|* Dabei das Ergebnis in rCol ablegen, d.h. wirklich modifizieren
-|*
-\************************************************************************/
-
-void Base3DCommon::SolveColorModel(B3dColor& rCol, basegfx::B3DVector& rVec, const basegfx::B3DPoint& rPnt)
-{
- if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
- {
- B3dMaterial& rMat = GetMaterialObject();
- sal_Bool bDoSolve(sal_True);
-
- // Welches Material? Zeigt der Vektor vom Betrachter
- // weg oder auf diesen?
- if(rVec.getZ() < 0.0)
- {
- // Rueckseite, soll diese dargestellt werden?
- if(GetLightGroup() && GetLightGroup()->GetModelTwoSide())
- {
- rMat = GetMaterialObject(Base3DMaterialBack);
- }
- else
- {
- bDoSolve = sal_False;
- }
- }
- if(bDoSolve)
- rCol = SolveColorModel(rMat, rVec, rPnt);
- }
-}
-
-B3dColor Base3DCommon::SolveColorModel(B3dMaterial& rMat, basegfx::B3DVector& rVec, const basegfx::B3DPoint& rPnt)
-{
- // Material emission einbeziehen
- B3dColor aNew = rMat.GetMaterial(Base3DMaterialEmission);
-
- // global ambient light beachten
- aNew += (B3dColor)rMat.GetMaterial(Base3DMaterialAmbient)
- * (B3dColor)GetLightGroup()->GetGlobalAmbientLight();
-
- if(GetTransformationSet())
- {
- // Die Punktkoordinate liegt in ClipCoordinates vor, wird
- // aber zur Farbberechnung in EyeCoordinates benoetigt.
- // Fuehre eine Ruecktransformation durch.
- basegfx::B3DPoint aPnt(rPnt);
- aPnt = GetTransformationSet()->DeviceToEyeCoor(aPnt);
-
- // Falls die Normale vom Betrachter weg zeigt und das Beleuchtungs-
- // modell doppelseitig ist, Normale umdrehen
- basegfx::B3DVector aVec(rVec);
- // #93184# use flag from polygon normal direction to switch local normal eventually
- if(bNormalPointsAway && GetLightGroup()->GetModelTwoSide())
- aVec = -rVec;
-
- // Die einzelnen Lichtquellen einbeziehen
- for(sal_uInt16 i=Base3DLight0; i <= Base3DLight7; i++)
- {
- if(GetLightGroup()->IsEnabled((Base3DLightNumber)i))
- {
- aNew += SolveColorModel(
- GetLightGroup()->GetLightObject((Base3DLightNumber)i),
- rMat, aVec, aPnt);
- }
- }
-
- // Transparenz aus der Diffuse (=Objekt-) Farbe uebernehmen
- aNew.SetTransparency(rMat.GetMaterial(Base3DMaterialDiffuse).GetTransparency());
- }
- return aNew;
-}
-
-/*************************************************************************
-|*
-|* Beleuchtungsmodell (ColorModel) fuer eine Lichtquelle loesen
-|*
-\************************************************************************/
-
-B3dColor Base3DCommon::SolveColorModel(B3dLight& rLight, B3dMaterial& rMat, basegfx::B3DVector& rVec, const basegfx::B3DPoint& rPnt)
-{
- B3dColor aRetval(255, 0, 0, 0);
- if(rLight.IsEnabled())
- {
- // Faktor mit Attenuation 1.0 initialisieren, falls
- // IsDirectionalSource() == sal_True
- double fFac = 1.0;
- basegfx::B3DVector aLightToVertex;
- sal_Bool bLightToVertex(sal_False);
-
- if(!rLight.IsDirectionalSource())
- {
- // positional light
- // echten attenuation Faktor ermitteln
- fFac = rLight.GetConstantAttenuation();
- if(rLight.IsLinearOrQuadratic())
- {
- // jetzt wird die Entfernung zwischen Lichtposition
- // und Punkt benoetigt
- aLightToVertex = rPnt - rLight.GetPositionEye();
- bLightToVertex = sal_True;
- double fLen = aLightToVertex.getLength();
- aLightToVertex.normalize();
-
- fFac += rLight.GetLinearAttenuation() * fLen;
- fFac += rLight.GetQuadraticAttenuation() * fLen * fLen;
- }
- // Kehrwert bilden
- if(fFac != 1.0 && fFac != 0.0)
- fFac = 1.0 / fFac;
-
- if(rLight.IsSpot())
- {
- // Spotlight it immer ein positional light
- // Spotlight effect, wird auf den Faktor multipliziert
- if(!bLightToVertex)
- {
- aLightToVertex = rPnt - rLight.GetPositionEye();
- aLightToVertex.normalize();
- bLightToVertex = sal_True;
- }
- double fCosAngle = aLightToVertex.scalar(rLight.GetSpotDirection());
- // innerhalb des konus?
- if(fCosAngle <= rLight.GetCosSpotCutoff())
- {
- if(fCosAngle > 0.000001)
- {
- if(rLight.GetSpotExponent() != 0.0)
- fCosAngle = pow(fCosAngle, rLight.GetSpotExponent());
- fFac *= fCosAngle;
- }
- else
- {
- fFac = 0.0;
- }
- }
- else
- {
- // Ausserhalb des Konus, keine Beleuchtung
- fFac = 0.0;
- }
- }
- }
-
- // falls es etwas zu beleuchten gibt...
- if(fFac != 0.0)
- {
- // Ambient term
- if(rLight.IsAmbient())
- {
- aRetval += (B3dColor)rLight.GetIntensity(Base3DMaterialAmbient)
- * (B3dColor)rMat.GetMaterial(Base3DMaterialAmbient);
- }
-
- if(rLight.IsDiffuse() || rLight.IsSpecular())
- {
- if(bLightToVertex)
- {
- // Falls hier schon berechnet, handelt es sich
- // auch um ein positional light
- aLightToVertex = -aLightToVertex;
- }
- else
- {
- if(rLight.IsDirectionalSource())
- {
- // Vektor direkt nehmen
- aLightToVertex = rLight.GetPosition();
- }
- else
- {
- // Umgerechnete Lichtposition nehmen
- aLightToVertex = rLight.GetPositionEye();
- // Betrachtete Position abziehen -> Einheitsvektor
- // vom Punkt zur Lichtquelle
- aLightToVertex -= rPnt;
- }
- aLightToVertex.normalize();
- }
- double fCosFac = aLightToVertex.scalar(rVec);
-
- if(fCosFac > 0.000001)
- {
- if(rLight.IsDiffuse())
- {
- // Diffuse term
- aRetval += (B3dColor)rLight.GetIntensity(Base3DMaterialDiffuse)
- * (B3dColor)rMat.GetMaterial(Base3DMaterialDiffuse)
- * fCosFac;
- }
- if(rLight.IsSpecular())
- {
- // Specular term
- if(GetLightGroup()->GetLocalViewer())
- {
- // use vector 0,0,1
- aLightToVertex.setZ(aLightToVertex.getZ() + 1.0);
- }
- else
- {
- // vector Vertex to Viewpoint berechnen in
- // Augkoordinaten, ist 0 - rPnt
- aLightToVertex -= rPnt;
- }
- aLightToVertex.normalize();
- fCosFac = aLightToVertex.scalar(rVec);
- if(fCosFac > 0.000001)
- {
- if(rMat.GetShininess())
- fCosFac = pow(fCosFac, rMat.GetShininess());
- aRetval += (B3dColor)rLight.GetIntensity(Base3DMaterialSpecular)
- * (B3dColor)rMat.GetMaterial(Base3DMaterialSpecular)
- * fCosFac;
- }
- }
- }
- }
-
- // jetzt fFac aufrechnen
- if(fFac != 1.0)
- aRetval *= fFac;
- }
- }
- return aRetval;
-}
-
-// eof
diff --git a/goodies/source/base3d/b3dcommn.hxx b/goodies/source/base3d/b3dcommn.hxx
deleted file mode 100644
index 1c7d500039f6..000000000000
--- a/goodies/source/base3d/b3dcommn.hxx
+++ /dev/null
@@ -1,129 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dcommn.hxx,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _B3D_B3DCOMMN_HXX
-#define _B3D_B3DCOMMN_HXX
-
-#include <goodies/base3d.hxx>
-#include <goodies/b3dgeom.hxx>
-
-// Defines fuer clipping flags (nFlag0,1)
-#define CLIPFLAG_LEFT 0x0001
-#define CLIPFLAG_RIGHT 0x0002
-#define CLIPFLAG_BOTTOM 0x0004
-#define CLIPFLAG_TOP 0x0008
-#define CLIPFLAG_FRONT 0x0010
-#define CLIPFLAG_BACK 0x0020
-#define CLIPFLAG_ALL (CLIPFLAG_LEFT|CLIPFLAG_RIGHT| \
- CLIPFLAG_BOTTOM|CLIPFLAG_TOP| \
- CLIPFLAG_FRONT|CLIPFLAG_BACK)
-
-/*************************************************************************
-|*
-|* Bucket fuer Indices
-|*
-\************************************************************************/
-
-BASE3D_DECL_BUCKET(sal_uInt32, Bucket)
-
-/*************************************************************************
-|*
-|* Die Basisklasse fuer Standard 3D Ausgaben auf StarView Basis
-|*
-\************************************************************************/
-
-#define BUFFER_OVERHEAD (20)
-
-class Base3DCommon : public Base3D
-{
-protected:
- // Buffers fuer temporaere geometrische Daten
- B3dEntityBucket aBuffers;
-
- // Remember if last primitive was rejected
- unsigned bLastPrimitiveRejected : 1;
-
- // #93184# flag for polygon normal direction
- unsigned bNormalPointsAway : 1;
-
-public:
- Base3DCommon(OutputDevice* pOutDev);
- virtual ~Base3DCommon();
-
- // Beleuchtung setzen/lesen
- virtual void SetLightGroup(B3dLightGroup* pSet, sal_Bool bSetGlobal=sal_True);
-
- // Info if last primitive was rejected
- sal_Bool WasLastPrimitiveRejected()
- { return bLastPrimitiveRejected; }
-
- // Szenenverwaltung
- virtual void StartScene();
- virtual void EndScene();
-
-protected:
- // Geometrische Daten uebergeben
- virtual B3dEntity& ImplGetFreeEntity();
-
- virtual void ImplStartPrimitive();
- virtual void ImplEndPrimitive();
- virtual void ImplPostAddVertex(B3dEntity& rEnt);
-
- void Create3DPoint(sal_uInt32 nInd);
- void Create3DPointClipped(sal_uInt32 nInd);
- void Create3DLine(sal_uInt32 nInd1, sal_uInt32 nInd2);
- void Create3DLineClipped(sal_uInt32 nInd1, sal_uInt32 nInd2);
- void Create3DTriangle(sal_uInt32 nInd1, sal_uInt32 nInd2, sal_uInt32 nInd3);
-
- virtual void Clipped3DPoint(sal_uInt32 nInd) = 0;
- virtual void Clipped3DLine(sal_uInt32 nInd1,sal_uInt32 nInd2) = 0;
- virtual void Clipped3DTriangle(sal_uInt32 nInd1,sal_uInt32 nInd2, sal_uInt32 nInd3) = 0;
-
- // clipping functions
- sal_Bool AreEqual(sal_uInt32 nInd1, sal_uInt32 nInd2);
- sal_Bool Clip3DPoint(sal_uInt32 nInd);
- sal_Bool Clip3DLine(sal_uInt32& nInd1,sal_uInt32& nInd2);
- sal_Bool Clip3DPolygon(sal_uInt32Bucket& rEdgeIndex);
- sal_uInt16 GetClipFlags(sal_uInt32 nInd);
- sal_Bool IsInside(sal_uInt32 nInd, sal_uInt32 nDim, sal_Bool bLow);
- void ClipPoly(sal_uInt32Bucket& rEdgeIndex, sal_uInt16 nDim,sal_Bool bLow);
- void CalcNewPoint(sal_uInt32 nNew,sal_uInt32 nHigh,sal_uInt32 nLow,
- sal_uInt16 nDim, double fBound);
-
- // Beleuchtungsmodell (ColorModel) in einem Punkt loesen
- // Punkt MUSS in ClipCoordinates vorliegen !
- void SolveColorModel(B3dColor& rCol, basegfx::B3DVector& rVec, const basegfx::B3DPoint& rPnt);
- B3dColor SolveColorModel(B3dMaterial& rMat, basegfx::B3DVector& rVec, const basegfx::B3DPoint& rPnt);
-
- // Beleuchtungsmodell (ColorModel) fuer eine Lichtquelle loesen
- B3dColor SolveColorModel(B3dLight& rLight, B3dMaterial& rMat, basegfx::B3DVector& rVec, const basegfx::B3DPoint& rPnt);
-};
-
-#endif // _B3D_B3DCOMMN_HXX
diff --git a/goodies/source/base3d/b3dcompo.cxx b/goodies/source/base3d/b3dcompo.cxx
deleted file mode 100644
index 8d694cb22132..000000000000
--- a/goodies/source/base3d/b3dcompo.cxx
+++ /dev/null
@@ -1,1140 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dcompo.cxx,v $
- * $Revision: 1.7 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include <goodies/b3dcompo.hxx>
-#include <goodies/base3d.hxx>
-#include <goodies/b3dgeom.hxx>
-
-#ifndef _INC_FLOAT
-#include <float.h>
-#endif
-#include <tools/debug.hxx>
-
-/*************************************************************************
-|*
-|* Vergleiche fuer doubles mit bound
-|*
-\************************************************************************/
-
-#define DOUBLE_EQUAL(a,b) (fabs(a-b) < SMALL_DVALUE)
-#define DOUBLE_NOT_EQUAL(a,b) (fabs(a-b) > SMALL_DVALUE)
-#define DOUBLE_SMALLER(a,b) ((a + (SMALL_DVALUE / 2.0)) < b)
-#define DOUBLE_BIGGER(a,b) ((a - (SMALL_DVALUE / 2.0)) > b)
-
-/*************************************************************************
-|*
-|* Bucket fuer Kantenliste, vertikaler Teil
-|*
-\************************************************************************/
-
-BASE3D_IMPL_BUCKET(B3dEdgeList, Bucket)
-
-/*************************************************************************
-|*
-|* Bucket fuer Kantenliste, horizontaler Teil
-|*
-\************************************************************************/
-
-BASE3D_IMPL_BUCKET(B3dEdgeEntry, Bucket)
-
-/*************************************************************************
-|*
-|* Konstruktor
-|*
-\************************************************************************/
-
-B3dComplexPolygon::B3dComplexPolygon()
-: aEntityBuffer(14), // 16K
- aEdgeList(12), // 4K
- aEdgeEntry(12) // 4K
-{
- EmptyBuffers();
- bTestForCut = TRUE;
- nHighestEdge = 0L;
- pBase3D = NULL;
- pGeometry = NULL;
- pLastVertex = NULL;
-}
-
-/*************************************************************************
-|*
-|* Gib einen neuen freien Eintrag zurueck
-|*
-\************************************************************************/
-
-B3dEntity &B3dComplexPolygon::GetFreeEntity()
-{
- aEntityBuffer.Append();
- return aEntityBuffer[aEntityBuffer.Count() - 1];
-}
-
-/*************************************************************************
-|*
-|* Ein neuer Punkt ist ausgefuellt
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::PostAddVertex(B3dEntity &rVertex)
-{
- if(pLastVertex && ArePointsEqual(*pLastVertex, rVertex))
- {
- aEntityBuffer.Remove();
- return;
- }
-
- // #i27242#
- // Comparison for finding nHighestEdge has to start with first point. Due
- // to having this part inside of if(pLastVertex) it always started with the
- // second point. Thus, in 50% of the cases where the first point of the polygon
- // is the extreme point, the normal could be wrong.
- if(!nNewPolyStart)
- {
- if(nHighestEdge)
- TestHighestEdge(rVertex);
- else
- nHighestEdge = aEntityBuffer.Count();
- }
-
- // Zeiger auf letzten hinzugefuegten Punkt setzen
- pLastVertex = &rVertex;
-}
-
-/*************************************************************************
-|*
-|* Testet, ob die neue Edge in allen Freiheitsgraden groesser ist
-|* als die momentane
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::TestHighestEdge(B3dEntity& rVertex)
-{
- B3dEntity& rHighest = aEntityBuffer[nHighestEdge - 1];
- if(rVertex.GetX() <= rHighest.GetX())
- {
- if(rVertex.GetX() < rHighest.GetX())
- {
- nHighestEdge = aEntityBuffer.Count();
- }
- else
- {
- if(rVertex.GetY() <= rHighest.GetY())
- {
- if(rVertex.GetY() < rHighest.GetY())
- {
- nHighestEdge = aEntityBuffer.Count();
- }
- else
- {
- if(rVertex.GetZ() < rHighest.GetZ())
- {
- nHighestEdge = aEntityBuffer.Count();
- }
- }
- }
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Vergleicht zwei Punkte auf ihren INHALT
-|* und fuellt die 2D-Koordinaten aus
-|*
-\************************************************************************/
-
-BOOL B3dComplexPolygon::ArePointsEqual(B3dEntity& rFirst,
- B3dEntity& rSecond)
-{
- // Wenn der Punkt dem letzten gleich ist, gar nicht behandeln
- if(rFirst.Point() == rSecond.Point())
- return TRUE;
- return FALSE;
-}
-
-/*************************************************************************
-|*
-|* Alles auf Startzustand, buffer leeren
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::EmptyBuffers()
-{
- aEntityBuffer.Erase();
- nNewPolyStart = 0;
- bOrientationValid = FALSE;
- bNormalValid = FALSE;
-
- // EdgeList und EdgeEntries leeren
- pEdgeList = NULL;
- aEdgeList.Erase();
- aEdgeEntry.Erase();
-}
-
-/*************************************************************************
-|*
-|* Neues Teilpolygon beginnen
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::StartPrimitive()
-{
- // Bisherige Punkte verarbeiten
- if(aEntityBuffer.Count() > nNewPolyStart)
- ComputeLastPolygon();
-
- // Zeiger auf letzten Punkt loeschen
- pLastVertex = NULL;
-
- // Hoechten Punkt vergesset
- nHighestEdge = 0L;
-}
-
-/*************************************************************************
-|*
-|* Teilpolygon abschliessen
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::ComputeLastPolygon(BOOL bIsLast)
-{
- // Letzten Punkt mit erstem vergleichen, evtl
- // wegschmeissen
- if(pLastVertex)
- {
- if(ArePointsEqual(aEntityBuffer[nNewPolyStart], *pLastVertex))
- {
- // HighestEdge korrigieren, falls dieser geloescht werden soll
- if(nHighestEdge && nHighestEdge == aEntityBuffer.Count())
- nHighestEdge = nNewPolyStart + 1;
-
- aEntityBuffer.Remove();
- }
- }
-
- // Sind noch genug Punkte da?
- if(aEntityBuffer.Count() < nNewPolyStart + 3)
- {
- // Geometrie ausgeben, obwohl zuwenig Punkte fuer ein Polygon
- if(pBase3D)
- {
- pBase3D->StartPrimitive(Base3DPolygon);
- for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
- {
- pBase3D->SetEdgeFlag(aEntityBuffer[a].IsEdgeVisible());
- pBase3D->AddVertex(aEntityBuffer[a]);
- }
- pBase3D->EndPrimitive();
- }
- else if(pGeometry)
- {
- pGeometry->StartComplexPrimitive();
- for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
- pGeometry->AddComplexVertex(aEntityBuffer[a], aEntityBuffer[a].IsEdgeVisible());
- pGeometry->EndComplexPrimitive();
- }
- }
- else
- {
- if(!nNewPolyStart && bIsLast && IsConvexPolygon())
- {
- // Falls das PolyPolygon nur aus einem Polygon besteht
- // und es Konvex ist, ist man fertig.
- // Um die Qualitaet zu verbessern, wird fuer
- // Polygone ab einer gewissen Punktzahl ein
- // abschliessender Mittelpunkt generiert.
- if(pBase3D)
- {
- pBase3D->StartPrimitive(Base3DPolygon);
- if(aEntityBuffer.Count() > 4)
- {
- B3dEntity aNew;
- aNew.CalcMiddle(aEntityBuffer[0], aEntityBuffer[aEntityBuffer.Count() / 2]);
- pBase3D->SetEdgeFlag(FALSE);
- pBase3D->AddVertex(aNew);
- for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
- {
- pBase3D->SetEdgeFlag(aEntityBuffer[a].IsEdgeVisible());
- pBase3D->AddVertex(aEntityBuffer[a]);
- }
- pBase3D->SetEdgeFlag(FALSE);
- pBase3D->AddVertex(aEntityBuffer[0]);
- }
- else
- {
- for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
- {
- pBase3D->SetEdgeFlag(aEntityBuffer[a].IsEdgeVisible());
- pBase3D->AddVertex(aEntityBuffer[a]);
- }
- }
- pBase3D->EndPrimitive();
- }
- else if(pGeometry)
- {
- pGeometry->StartComplexPrimitive();
- if(aEntityBuffer.Count() > 4)
- {
- B3dEntity aNew;
- aNew.CalcMiddle(aEntityBuffer[0], aEntityBuffer[aEntityBuffer.Count() / 2]);
- pGeometry->AddComplexVertex(aNew, FALSE);
- for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
- pGeometry->AddComplexVertex(aEntityBuffer[a], aEntityBuffer[a].IsEdgeVisible());
- pGeometry->AddComplexVertex(aEntityBuffer[0], FALSE);
- }
- else
- {
- for(UINT32 a=0; a < aEntityBuffer.Count(); a++)
- pGeometry->AddComplexVertex(aEntityBuffer[a], aEntityBuffer[a].IsEdgeVisible());
- }
- pGeometry->EndComplexPrimitive();
- }
- }
- else
- {
- if(!bNormalValid)
- ChooseNormal();
-
- // Einsortieren
- UINT32 nUpperBound = aEntityBuffer.Count();
-
- // Als Polygon behandeln
- if(GetTestForCut())
- {
- UINT32 a;
- for(a=nNewPolyStart + 1; a < nUpperBound; a++)
- AddEdgeCut(&aEntityBuffer[a-1], &aEntityBuffer[a]);
-
- // Polygon schliessen
- AddEdgeCut(&aEntityBuffer[a-1], &aEntityBuffer[nNewPolyStart]);
- }
- else
- {
- UINT32 a;
- for(a=nNewPolyStart + 1; a < nUpperBound; a++)
- AddEdge(&aEntityBuffer[a-1], &aEntityBuffer[a]);
-
- // Polygon schliessen
- AddEdge(&aEntityBuffer[a-1], &aEntityBuffer[nNewPolyStart]);
- }
-
- // Hier setzen, da evtl. bereits neue Punkte
- // durch Schnitte hinzugekommen sind
- nNewPolyStart = aEntityBuffer.Count();
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Orientierung des ersten Polygons ermitteln
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::ChooseNormal()
-{
- if(nHighestEdge)
- {
- UINT32 nHigh = nHighestEdge - 1;
- UINT32 nPrev = (nHigh != 0) ? nHigh - 1 : aEntityBuffer.Count() - 1;
- UINT32 nNext = (nHigh + 1 != aEntityBuffer.Count()) ? nHigh + 1 : nNewPolyStart;
-
- // Punkt, Vorgaenger und Nachfolger holen
- const basegfx::B3DPoint& rHigh = aEntityBuffer[nHigh].Point();
- const basegfx::B3DPoint& rPrev = aEntityBuffer[nPrev].Point();
- const basegfx::B3DPoint& rNext = aEntityBuffer[nNext].Point();
-
- // Normale bilden
- aNormal = basegfx::B3DVector(rPrev - rHigh).getPerpendicular(basegfx::B3DVector(rNext - rHigh));
- if(!aNormal.equalZero())
- aNormal.normalize();
- else
- aNormal = basegfx::B3DVector(0.0, 0.0, -1.0);
- }
- bNormalValid = TRUE;
-}
-
-/*************************************************************************
-|*
-|* Komplexes Polygon ausgeben
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::EndPrimitive(Base3D* pB3D)
-{
- // Funktionszeiger setzen
- pBase3D = pB3D;
-
- // Letztes angefangenes Poly verarbeiten
- ComputeLastPolygon(TRUE);
-
- // Wenn es Kanten gibt
- if(pEdgeList)
- {
- // Dreiecke generieren und ausgeben
- pBase3D->StartPrimitive(Base3DTriangles);
- while(pEdgeList)
- ExtractTriangle();
- pBase3D->EndPrimitive();
- }
-
- // Buffer leeren
- EmptyBuffers();
-
- // Zeiger wieder loeschen
- pBase3D = NULL;
-}
-
-void B3dComplexPolygon::EndPrimitive(B3dGeometry *pGeom)
-{
- // Funktionszeiger setzen
- pGeometry = pGeom;
-
- // Letztes angefangenes Poly verarbeiten
- ComputeLastPolygon(TRUE);
-
- // Dreiecke generieren und ausgeben
- while(pEdgeList)
- ExtractTriangle();
-
- // Buffer leeren
- EmptyBuffers();
-
- // Zeiger wieder loeschen
- pGeometry = NULL;
-}
-
-/*************************************************************************
-|*
-|* Teste aktuelles Polygon (0..aEntityBuffer.Count()) auf Konvexitaet
-|*
-\************************************************************************/
-
-BOOL B3dComplexPolygon::IsConvexPolygon()
-{
- B3dEntity* pFirst = &aEntityBuffer[aEntityBuffer.Count() - 2];
- B3dEntity* pSecond = &aEntityBuffer[aEntityBuffer.Count() - 1];
- B3dEntity* pThird = &aEntityBuffer[0];
- BOOL bDirection = IsLeft(pSecond, pFirst, pThird);
- BOOL bOrder = CompareOrder(pSecond, pThird);
- UINT16 nDirChanges(0);
-
- for(UINT32 a = 1; nDirChanges <= 2 && a < aEntityBuffer.Count(); a++)
- {
- pFirst = pSecond;
- pSecond = pThird;
- pThird = &aEntityBuffer[a];
-
- if(IsLeft(pSecond, pFirst, pThird) != bDirection)
- return FALSE;
-
- if(CompareOrder(pSecond, pThird) != bOrder)
- {
- nDirChanges++;
- bOrder = !bOrder;
- }
- }
- // Zuviele aenderungen der Ordnung, auf keinen Fall Convex
- if(nDirChanges > 2)
- return FALSE;
-
- return TRUE;
-}
-
-/*************************************************************************
-|*
-|* Lexikografische Ordnung der beiden Punkte
-|*
-\************************************************************************/
-
-BOOL B3dComplexPolygon::CompareOrder(B3dEntity* pFirst, B3dEntity* pSecond)
-{
- if(pFirst->GetX() < pSecond->GetX())
- return FALSE;
- if(pFirst->GetX() > pSecond->GetX())
- return TRUE;
- if(pFirst->GetY() < pSecond->GetY())
- return FALSE;
- return TRUE;
-}
-
-/*************************************************************************
-|*
-|* Teste, ob die Punkte der Kante getauscht werden muessen
-|*
-\************************************************************************/
-
-BOOL B3dComplexPolygon::DoSwap(B3dEntity* pStart, B3dEntity* pEnd)
-{
- if(DOUBLE_EQUAL(pStart->GetY(), pEnd->GetY()))
- {
- if(pStart->GetX() > pEnd->GetX())
- return TRUE;
- }
- else
- {
- if(pStart->GetY() > pEnd->GetY())
- return TRUE;
- }
- return FALSE;
-}
-
-/*************************************************************************
-|*
-|* Kante nInd1, nInd2 zu Kantenliste hinzufuegen
-|*
-\************************************************************************/
-
-B3dEdgeEntry* B3dComplexPolygon::AddEdge(B3dEntity* pStart, B3dEntity* pEnd)
-{
- if(DoSwap(pStart, pEnd))
- return InsertEdge(GetList(pEnd), pStart, TRUE);
- return InsertEdge(GetList(pStart), pEnd, TRUE);
-}
-
-/*************************************************************************
-|*
-|* Einen Listeneintrag suchen oder neu anlegen
-|* Liefert immer einen Listeneintrag zurueck
-|*
-\************************************************************************/
-
-B3dEdgeList* B3dComplexPolygon::GetList(B3dEntity* pStart)
-{
- B3dEdgeList* pList = pEdgeList;
- B3dEdgeList* pLast = NULL;
-
- while(pList && pList->GetStart() != pStart && DoSwap(pStart, pList->GetStart()))
- {
- pLast = pList;
- pList = pList->GetDown();
- }
-
- if(pList)
- {
- if(pList->GetStart() != pStart)
- {
- if(DOUBLE_NOT_EQUAL(pStart->GetX(), pList->GetXPos()) || DOUBLE_NOT_EQUAL(pStart->GetY(), pList->GetYPos()))
- {
- // Auf jeden Fall ein neuer Eintrag
- aEdgeList.Append();
- B3dEdgeList* pNewList = &aEdgeList[aEdgeList.Count() - 1];
- pNewList->Reset();
- pNewList->SetStart(pStart);
-
- // vor pList einhaengen
- // pLast KANN NULL SEIN!
- pNewList->SetDown(pList);
- pList->SetParent(pNewList);
- if(pLast)
- {
- pNewList->SetParent(pLast);
- pLast->SetDown(pNewList);
- }
- else
- {
- pEdgeList = pNewList;
- }
-
- // Returnwert setzen
- pList = pNewList;
- }
- else
- {
- // pList->GetStart() != pStart, aber
- // die Koordinaten sind praktisch identisch!
- // Gib diese Liste zurueck, d.h.
- // tue gar nichts
- }
- }
- }
- else
- {
- // pLast->GetYPos() < pStart->GetY(),
- // Hinten anhaengen
- aEdgeList.Append();
- pList = &aEdgeList[aEdgeList.Count() - 1];
- pList->Reset();
- pList->SetStart(pStart);
- if(pLast)
- {
- pList->SetParent(pLast);
- pLast->SetDown(pList);
- }
- else
- {
- pEdgeList = pList;
- }
- }
- return pList;
-}
-
-/*************************************************************************
-|*
-|* Eine Kante in eine Kantenliste einsortieren
-|* Die Kante wird dabei neu erzeugt
-|*
-\************************************************************************/
-
-B3dEdgeEntry* B3dComplexPolygon::InsertEdge(B3dEdgeList* pList,
- B3dEntity* pEnd, BOOL bEdgeVisible)
-{
- B3dEdgeEntry* pEntry = pList->GetEntries();
-
- // Immer ein neuer Eintrag
- aEdgeEntry.Append();
- B3dEdgeEntry* pNewEntry = &aEdgeEntry[aEdgeEntry.Count() - 1];
- pNewEntry->Reset();
- pNewEntry->SetEnd(pEnd);
- pNewEntry->SetParent(pList);
- pNewEntry->SetEdgeVisible(bEdgeVisible);
-
- if(pEntry)
- {
- B3dEdgeEntry* pLast = NULL;
- double fSlant = GetSlant(pNewEntry);
- while(pEntry
- && GetSlant(pEntry) < fSlant)
- {
- pLast = pEntry;
- pEntry = pEntry->GetRight();
- }
-
- if(pEntry)
- {
- // GetSlant(pEntry) < fSlant
- // GetSlant(pLast) >= fSlant
- // Neuen Eintrag hinter pLast einfuegen
- // pLast KANN NULL SEIN!
- pNewEntry->SetRight(pEntry);
- if(pLast)
- {
- pLast->SetRight(pNewEntry);
- }
- else
- {
- pList->SetEntries(pNewEntry);
- }
- }
- else
- {
- // GetSlant(pEntry) >= fSlant
- // Neuen Eintrag am Ende anhaengen
- pLast->SetRight(pNewEntry);
- }
- }
- else
- {
- pList->SetEntries(pNewEntry);
- }
- // Returnwert
- return pNewEntry;
-}
-
-/*************************************************************************
-|*
-|* Steigung der Kante liefern
-|*
-\************************************************************************/
-
-double B3dComplexPolygon::GetSlant(B3dEdgeEntry* pEdge)
-{
- double fDivisor = pEdge->GetYPos() - pEdge->GetParent()->GetYPos();
- if(fabs(fDivisor) < SMALL_DVALUE)
- return DBL_MAX;
- return (pEdge->GetXPos() - pEdge->GetParent()->GetXPos()) / fDivisor;
-}
-
-/*************************************************************************
-|*
-|* Auf Schnitt mit einer vorhandenen Kante testen
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::TestForCut(B3dEdgeEntry* pEntry)
-{
- // pEntry: die bereits eingefuegte neue Kante, die mit allen
- // aelteren Kanten geschnitten werden soll
- B3dEdgeList* pList = pEdgeList;
-
- while(pList && DOUBLE_SMALLER(pList->GetYPos(), pEntry->GetYPos()))
- {
- // nur in Gruppen mit anderem Startpunkt suchen
- if(pList != pEntry->GetParent())
- {
- B3dEdgeEntry* pTestEntry = pList->GetEntries();
-
- while(pTestEntry)
- {
- if(DOUBLE_BIGGER(pTestEntry->GetYPos(), pEntry->GetParent()->GetYPos()))
- {
- // es existiert eine vertikale Bereichsueberschneidung
- // Min/Max fuer pEntry holen
- double fXMin = pEntry->GetXPos();
- double fXMax = pEntry->GetParent()->GetXPos();
- if(fXMin > fXMax)
- {
- double fSwap = fXMin;
- fXMin = fXMax;
- fXMax = fSwap;
- }
-
- // Min/Max in X fuer Kandidat holen
- double fTestXMin = pTestEntry->GetXPos();
- double fTestXMax = pList->GetXPos();
- if(fTestXMin > fTestXMax)
- {
- double fSwap = fTestXMin;
- fTestXMin = fTestXMax;
- fTestXMax = fSwap;
- }
-
- if(fTestXMin < fXMax && fTestXMax > fXMin)
- {
- // es existiert eine horizontale Bereichsueberschneidung
- // ein Schnitt ist moeglich
- double fCut = FindCut(pEntry, pTestEntry);
-
- if(fCut != 0.0)
- {
- // Schnitt existiert! fCut ist aus dem Parameterbereich
- // der ersten Kante, also pEntry. Neuen Punkt erzeugen.
- B3dEntity& rNew = GetFreeEntity();
- rNew.CalcInBetween(*pEntry->GetParent()->GetStart(), *pEntry->GetEnd(), fCut);
-
- // Neuen Punkt und neue von diesem ausgehende Kanten erzeugen
- B3dEdgeList* pNewPointList = GetList(&rNew);
- B3dEdgeEntry* pEntry2 = InsertEdge(pNewPointList, pEntry->GetEnd(), pEntry->IsEdgeVisible());
- InsertEdge(pNewPointList, pTestEntry->GetEnd(), pTestEntry->IsEdgeVisible());
-
- // Beteiligte Entries kuerzen
- pEntry->SetEnd(&rNew);
- pTestEntry->SetEnd(&rNew);
-
- // Das neue Ende von pEntry kann weitere Linien
- // schneiden, also geht der test mit diesem weiter
- TestForCut(pEntry2);
-
- // Test mit gekuerztem pEntry fortsetzen
- }
- }
- }
-
- // naechster Entry
- pTestEntry = pTestEntry->GetRight();
- }
- }
-
- // naechste Liste
- pList = pList->GetDown();
- }
-}
-
-/*************************************************************************
-|*
-|* Berechne den Schnitt zwischen den beiden Kanten und gib den
-|* Schnittpunkt im Parameterbereich der 1. Kante zurueck
-|*
-\************************************************************************/
-
-double B3dComplexPolygon::FindCut(B3dEdgeEntry* pEdge1, B3dEdgeEntry* pEdge2)
-{
- double fRetval = 0.0;
- double fDeltaEdge2Y = pEdge2->GetYPos() - pEdge2->GetParent()->GetYPos();
- double fDeltaEdge2X = pEdge2->GetXPos() - pEdge2->GetParent()->GetXPos();
- double fDeltaEdge1X = pEdge1->GetXPos() - pEdge1->GetParent()->GetXPos();
- double fDeltaEdge1Y = pEdge1->GetYPos() - pEdge1->GetParent()->GetYPos();
-
- // Dynamische Grenze fuer parallelitaet berechnen
- double fSmallValue = fabs((fDeltaEdge2Y + fDeltaEdge2X + fDeltaEdge1X + fDeltaEdge1Y) * (SMALL_DVALUE / 4.0));
- double fZwi = (fDeltaEdge1X * fDeltaEdge2Y) - (fDeltaEdge1Y * fDeltaEdge2X);
-
- if(fabs(fZwi) > fSmallValue)
- {
- fZwi = (fDeltaEdge2Y * (pEdge2->GetParent()->GetXPos() - pEdge1->GetParent()->GetXPos())
- + fDeltaEdge2X * (pEdge1->GetParent()->GetYPos() - pEdge2->GetParent()->GetYPos())) / fZwi;
-
- // Im Parameterbereich der ersten Kante (ohne Punkte) ?
- if(fZwi > fSmallValue && fZwi < 1.0 - fSmallValue)
- {
- // Schnitt liegt im Parameterbereich der ersten
- // Linie, aber auch in dem der zweiten?
- if(fabs(fDeltaEdge2X) > fSmallValue && fabs(fDeltaEdge2X) > fabs(fDeltaEdge2Y))
- {
- fDeltaEdge2Y = (pEdge1->GetParent()->GetXPos() + fZwi
- * fDeltaEdge1X - pEdge2->GetParent()->GetXPos()) / fDeltaEdge2X;
-
- // Parameterbereich der zweiten schliesst Start/Ende mit ein!
- if(fDeltaEdge2Y > -fSmallValue && fDeltaEdge2Y < 1.0 + fSmallValue)
- {
- // Ja. Zuweisen.
- fRetval = fZwi;
- }
- }
- else if(fabs(fDeltaEdge2Y) > fSmallValue)
- {
- fDeltaEdge2X = (pEdge1->GetParent()->GetYPos() + fZwi
- * fDeltaEdge1Y - pEdge2->GetParent()->GetYPos()) / fDeltaEdge2Y;
-
- // Parameterbereich der zweiten schliesst Start/Ende mit ein!
- if(fDeltaEdge2X > -fSmallValue && fDeltaEdge2X < 1.0 + fSmallValue)
- {
- // Ja. Zuweisen.
- fRetval = fZwi;
- }
- }
- }
- }
- return fRetval;
-}
-
-/*************************************************************************
-|*
-|* Testet, ob die angegebene Kante schon existiert
-|* Ja: Entfernen
-|* Nein: Einfuegen
-|*
-\************************************************************************/
-
-BOOL B3dComplexPolygon::SwitchEdgeExistance(B3dEntity* pStart,
- B3dEntity* pEnd)
-{
- if(DoSwap(pStart, pEnd))
- {
- B3dEntity* pZwi = pStart;
- pStart = pEnd;
- pEnd = pZwi;
- }
-
- if(pEdgeList)
- {
- // Suchen
- B3dEdgeList* pList = pEdgeList;
- while(pList && pList->GetStart() != pStart)
- pList = pList->GetDown();
-
- if(pList && pList->GetStart() == pStart)
- {
- // Liste gefunden, Eintrag mit Endpunkt
- // pEnd finden
- B3dEdgeEntry* pEntry = pList->GetEntries();
- B3dEdgeEntry* pLeft = NULL;
-
- while(pEntry)
- {
- if(pEntry->GetEnd() == pEnd)
- {
- // Kante existiert, austragen
- // Liste ist pList
- // Links ist pLeft
- if(pLeft)
- {
- pLeft->SetRight(pEntry->GetRight());
- }
- else
- {
- if(pEntry->GetRight())
- pList->SetEntries(pEntry->GetRight());
- else
- RemoveEdgeList(pList);
- }
- // fertig
- return TRUE;
- }
-
- // naechste Kante
- pLeft = pEntry;
- pEntry = pEntry->GetRight();
- }
-
- // Liste existiert, aber der EdgeEintrag nicht.
- // Fuege diesen hinzu
- InsertEdge(pList, pEnd, FALSE);
-
- // fertig
- return FALSE;
- }
- }
- // Liste und Eintrag existieren nicht
- // Erzeuge beides
- InsertEdge(GetList(pStart), pEnd, FALSE);
-
- return FALSE;
-}
-
-/*************************************************************************
-|*
-|* Entferne die Kante aus der Kantenliste. Tue alles weitere,
-|* um die Struktur weiter aufzuloesen
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::RemoveFirstEdge(B3dEdgeList* pList)
-{
- if(pList->GetEntries()->GetRight())
- pList->SetEntries(pList->GetEntries()->GetRight());
- else
- RemoveEdgeList(pList);
-}
-
-/*************************************************************************
-|*
-|* Entferne die Kantenliste. Tue alles weitere,
-|* um die Struktur weiter aufzuloesen
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::RemoveEdgeList(B3dEdgeList* pList)
-{
- if(pList->GetDown())
- pList->GetDown()->SetParent(pList->GetParent());
- if(pList->GetParent())
- pList->GetParent()->SetDown(pList->GetDown());
- else
- {
- // Es gibt keinen parent mehr
- pEdgeList = pList->GetDown();
- }
-}
-
-/*************************************************************************
-|*
-|* Extrahiere das naechste Dreieck aus der Kantenliste
-|* und zeichne es
-|*
-\************************************************************************/
-
-void B3dComplexPolygon::ExtractTriangle()
-{
- B3dEdgeEntry* pLeft = pEdgeList->GetEntries();
- B3dEdgeEntry* pRight = pLeft->GetRight();
-
- if(!pRight)
- {
-// DBG_ASSERT(0, "AW: Einzelne Kante als Startpunkt!");
- RemoveFirstEdge(pEdgeList);
- return;
- }
-
- B3dEdgeList* pList = FindStartInTriangle();
- BOOL bNotAllAligned = (fabs(GetSlant(pLeft) - GetSlant(pRight)) > SMALL_DVALUE);
- BOOL bStartIsEdgePoint = FALSE;
- if(pList)
- {
- const basegfx::B3DPoint& rListStart = pList->GetStart()->Point();
- if(rListStart.equal(pEdgeList->GetStart()->Point()))
- bStartIsEdgePoint = TRUE;
- else if(rListStart.equal(pLeft->GetEnd()->Point()))
- bStartIsEdgePoint = TRUE;
- else if(rListStart.equal(pRight->GetEnd()->Point()))
- bStartIsEdgePoint = TRUE;
- }
-
- if(pList && bNotAllAligned && !bStartIsEdgePoint)
- {
- // Zerlegen in 2 Teildreiecke
- // Erstes Teildreieck
- InsertEdge(pEdgeList, pList->GetStart(), FALSE);
- ExtractTriangle();
-
- // Zweites Teildreieck
- InsertEdge(pEdgeList, pList->GetStart(), FALSE);
- ExtractTriangle();
- }
- else
- {
- B3dEntity* pEntLeft = pLeft->GetEnd();
- B3dEntity* pEntRight = pRight->GetEnd();
- B3dEntity* pEntTop = pEdgeList->GetStart();
- BOOL bLeftVisible = pLeft->IsEdgeVisible();
- BOOL bRightVisible = pRight->IsEdgeVisible();
-
- RemoveFirstEdge(pEdgeList);
- RemoveFirstEdge(pEdgeList);
-
- if(pEntLeft != pEntRight)
- {
- // Merken, ob die Abschlusslinie existiert hat oder nicht
- BOOL bDidEdgeExist = SwitchEdgeExistance(pEntLeft, pEntRight);
-
- if(DOUBLE_NOT_EQUAL(pEntLeft->GetY(), pEntTop->GetY())
- || DOUBLE_NOT_EQUAL(pEntRight->GetY(), pEntTop->GetY()))
- {
- if(!bOrientationValid)
- {
- // Anhand des ersten Dreiecks entscheiden,
- // in welcher Orientierung die Dreiecke
- // auszugeben sind
- basegfx::B3DVector aTmpNormal(basegfx::B3DVector(pEntLeft->Point() - pEntTop->Point()).getPerpendicular(pEntRight->Point() - pEntTop->Point()));
- bOrientation = (aNormal.scalar(aTmpNormal) > 0.0) ? TRUE : FALSE;
- bOrientationValid = TRUE;
- }
-
- // Dreieck ausgeben
- if(pBase3D)
- {
- if(bOrientation)
- {
- // Rechtsrum
- pBase3D->SetEdgeFlag(bRightVisible);
- pBase3D->AddVertex(*pEntTop);
- pBase3D->SetEdgeFlag(bDidEdgeExist);
- pBase3D->AddVertex(*pEntRight);
- pBase3D->SetEdgeFlag(bLeftVisible);
- pBase3D->AddVertex(*pEntLeft);
- }
- else
- {
- // Linksrum
- pBase3D->SetEdgeFlag(bLeftVisible);
- pBase3D->AddVertex(*pEntTop);
- pBase3D->SetEdgeFlag(bDidEdgeExist);
- pBase3D->AddVertex(*pEntLeft);
- pBase3D->SetEdgeFlag(bRightVisible);
- pBase3D->AddVertex(*pEntRight);
- }
- }
- else if(pGeometry)
- {
- pGeometry->StartComplexPrimitive();
- if(bOrientation)
- {
- // Rechtsrum
- pGeometry->AddComplexVertex(*pEntTop, bRightVisible);
- pGeometry->AddComplexVertex(*pEntRight, bDidEdgeExist);
- pGeometry->AddComplexVertex(*pEntLeft, bLeftVisible);
- }
- else
- {
- // Linksrum
- pGeometry->AddComplexVertex(*pEntTop, bLeftVisible);
- pGeometry->AddComplexVertex(*pEntLeft, bDidEdgeExist);
- pGeometry->AddComplexVertex(*pEntRight, bRightVisible);
- }
- pGeometry->EndComplexPrimitive();
- }
- }
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Suche nach einem fremden Startpunkt innerhalb des zu zeichnenden
-|* naechsten Dreiecks
-|*
-\************************************************************************/
-
-B3dEdgeList* B3dComplexPolygon::FindStartInTriangle()
-{
- B3dEdgeList* pList = pEdgeList->GetDown();
- if(pList)
- {
- B3dEdgeEntry* pLeft = pEdgeList->GetEntries();
- B3dEdgeEntry* pRight = pLeft->GetRight();
-
- double fYMax = pLeft->GetYPos();
- double fZwi = pRight->GetYPos();
- if(fZwi > fYMax)
- fYMax = fZwi;
-
- if(pList->GetYPos() <= fYMax)
- {
- B3dEntity* pTop = pEdgeList->GetStart();
- double fXMin = pLeft->GetXPos();
- double fXMax = pRight->GetXPos();
- if(fXMin > fXMax)
- {
- fZwi = fXMin;
- fXMin = fXMax;
- fXMax = fZwi;
- }
-
- double fXTop = pTop->GetX();
- if(fXMin > fXTop)
- fXMin = fXTop;
- if(fXMax < fXTop)
- fXMax = fXTop;
-
- while(pList
- && pList->GetYPos() <= fYMax)
- {
- if(pList->GetXPos() > fXMin && pList->GetXPos() < fXMax)
- {
- if(pList->GetStart() != pLeft->GetEnd()
- && pList->GetStart() != pRight->GetEnd())
- {
- if(IsLeft(pTop, pLeft->GetEnd(), pList->GetStart()))
- {
- if(DOUBLE_NOT_EQUAL(pList->GetXPos(), pLeft->GetXPos())
- || DOUBLE_NOT_EQUAL(pList->GetYPos(), pLeft->GetYPos()))
- {
- if(IsLeft(pRight->GetEnd(), pTop, pList->GetStart()))
- {
- if(DOUBLE_NOT_EQUAL(pList->GetXPos(), pRight->GetXPos())
- || DOUBLE_NOT_EQUAL(pList->GetYPos(), pRight->GetYPos()))
- {
- if(IsLeft(pLeft->GetEnd(), pRight->GetEnd(),
- pList->GetStart()))
- {
- return pList;
- }
- }
- }
- }
- }
- }
- }
- // naechste Liste
- pList = pList->GetDown();
- }
- }
- }
- return NULL;
-}
-
-/*************************************************************************
-|*
-|* Testen, auf welcher Seite pPoint von der Linie pTop, pDirection liegt
-|*
-\************************************************************************/
-
-BOOL B3dComplexPolygon::IsLeft(B3dEntity* pTop, B3dEntity* pDirection,
- B3dEntity* pPoint)
-{
- double fDirX = pDirection->GetX() - pTop->GetX();
- double fDirY = pDirection->GetY() - pTop->GetY();
- double fPntX = pPoint->GetX() - pTop->GetX();
- double fPntY = pPoint->GetY() - pTop->GetY();
-
- return ((fDirX * fPntY - fDirY * fPntX) <= 0.0);
-}
-
diff --git a/goodies/source/base3d/b3ddeflt.cxx b/goodies/source/base3d/b3ddeflt.cxx
deleted file mode 100644
index 17081629b704..000000000000
--- a/goodies/source/base3d/b3ddeflt.cxx
+++ /dev/null
@@ -1,1956 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3ddeflt.cxx,v $
- * $Revision: 1.11 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include "b3ddeflt.hxx"
-#include "b3dtrans.hxx"
-#include <vcl/outdev.hxx>
-#include <vcl/bmpacc.hxx>
-#include <vcl/bitmapex.hxx>
-#include "b3dtex.hxx"
-
-/*************************************************************************
-|*
-|* Konstruktor Base3DDefault
-|*
-\************************************************************************/
-
-Base3DDefault::Base3DDefault(OutputDevice* pOutDev)
-: Base3DCommon(pOutDev),
- aZBuffer(),
- aPicture(),
- aMonoTransparence(),
- aAlphaTransparence(),
- aClearValue(Color(0x00ffffff)),
- pZBufferWrite(NULL),
- pPictureWrite(NULL),
- pTransparenceWrite(NULL),
- fDetail(1.0),
- fDetailBackup( -1.0 ),
- nMaxPixels(500000),
- bReducedDetail(FALSE),
- bDetailBackedup(FALSE),
- mbPTCorrection(sal_True)
-
-{
-}
-
-/*************************************************************************
-|*
-|* Destruktor Base3DDefault
-|*
-\************************************************************************/
-
-Base3DDefault::~Base3DDefault()
-{
- // Alle Bitmap-Zugriffe freigeben
- ReleaseAccess();
-}
-
-/*************************************************************************
-|*
-|* Typbestimmung
-|*
-\************************************************************************/
-
-UINT16 Base3DDefault::GetBase3DType()
-{
- return BASE3D_TYPE_DEFAULT;
-}
-
-/*************************************************************************
-|*
-|* Darstellungsqualitaet setzen
-|*
-\************************************************************************/
-
-void Base3DDefault::SetDisplayQuality(sal_uInt8 nNew)
-{
- // Entsprechende PixelGrenze setzen
- SetMaxPixels(((sal_Int32)nNew * 3500) + 3500);
-
- // call parent
- Base3D::SetDisplayQuality(nNew);
-}
-
-/*************************************************************************
-|*
-|* Vergroeberungsstufe setzen
-|*
-\************************************************************************/
-
-void Base3DDefault::SetDetail(double fNew)
-{
- // nach unten begrenzen
- if(fNew > 1.0)
- fNew = 1.0;
-
- fDetail = fNew;
- if(fDetail < 1.0)
- {
- bReducedDetail = TRUE;
- }
- else
- {
- bReducedDetail = FALSE;
- }
-}
-
-/*************************************************************************
-|*
-|* BitmapAccess holen
-|*
-\************************************************************************/
-
-void Base3DDefault::AcquireAccess()
-{
- // Alle accesses holen
- pZBufferWrite = aZBuffer.AcquireWriteAccess();
- pPictureWrite = aPicture.AcquireWriteAccess();
- pTransparenceWrite = (GetTransparentPartsContainedHint())
- ? aAlphaTransparence.AcquireWriteAccess()
- : aMonoTransparence.AcquireWriteAccess();
-}
-
-/*************************************************************************
-|*
-|* BitmapAccess freigeben
-|*
-\************************************************************************/
-
-void Base3DDefault::ReleaseAccess()
-{
- // Alle accesses wieder freigeben
- if(pZBufferWrite)
- {
- delete pZBufferWrite;
- pZBufferWrite = NULL;
- }
-
- if(pPictureWrite)
- {
- delete pPictureWrite;
- pPictureWrite = NULL;
- }
-
- if(pTransparenceWrite)
- {
- delete pTransparenceWrite;
- pTransparenceWrite = NULL;
- }
-}
-
-/*************************************************************************
-|*
-|* Start der Szenenbeschreibung:
-|*
-\************************************************************************/
-
-void Base3DDefault::StartScene()
-{
- // Zugriffe freigeben
- ReleaseAccess();
-
- // Groesse der Bitmaps anpassen?
- sal_Bool bSizeHasChanged = (aLocalSizePixel.GetSize() != aPicture.GetSizePixel());
-
- // Neue BitMaps fuer ZBuffer und Picture allokieren
- if(bSizeHasChanged || !aZBuffer || !aPicture)
- {
- aZBuffer = Bitmap(aLocalSizePixel.GetSize(), 24);
- aPicture = Bitmap(aLocalSizePixel.GetSize(), 24);
- }
-
- // ZBuffer loeschen
- aZBuffer.Erase(aClearValue);
-
- // Bild loeschen
- aPicture.Erase( GetOutputDevice()->GetBackground().GetColor() );
-
- // Neue Transparenz-Bitmap allokieren
- if(GetTransparentPartsContainedHint())
- {
- // Alpha-Channel
- if(bSizeHasChanged || !aAlphaTransparence)
- {
- aAlphaTransparence = AlphaMask(aLocalSizePixel.GetSize());
- if(!!aMonoTransparence)
- aMonoTransparence = Bitmap();
- }
-
- // zu Beginn alles transparent
- aAlphaTransparence.Erase(BYTE(0xff));
- }
- else
- {
- // Mono-Channel
- if(bSizeHasChanged || !aMonoTransparence)
- {
- aMonoTransparence = Bitmap(aLocalSizePixel.GetSize(), 1);
- if(!!aAlphaTransparence)
- aAlphaTransparence = AlphaMask();
- }
-
- // zu Beginn alles transparent
- Color aEraseCol(COL_WHITE);
- aMonoTransparence.Erase(aEraseCol);
- }
-
- // Zugriffe wieder holen
- AcquireAccess();
-
- // lokale ClipRegion anpassen
- if(IsScissorRegionActive())
- {
- // Default specifics for scissoring
- aDefaultScissorRectangle = GetScissorRegionPixel();
- aDefaultScissorRectangle -= aSizePixel.TopLeft();
-
- // Detailstufe beachten
- if(bReducedDetail && fDetail != 0.0)
- {
- sal_Int32 nReducedWidth = (sal_Int32)((double)(aDefaultScissorRectangle.GetWidth() - 1) * fDetail);
- sal_Int32 nReducedHeight = (sal_Int32)((double)(aDefaultScissorRectangle.GetHeight() - 1)* fDetail);
- aDefaultScissorRectangle.SetSize(Size(nReducedWidth + 1, nReducedHeight + 1));
- }
- }
-
- // #i71618#
- // derive maPolygonOffset from mfPolygonOffset and use instead of old
- // POLYGONOFFSET_VALUE which was much to low with default of 120
- maPolygonOffset = (sal_uInt32)(getPolygonOffset() * ZBUFFER_DEPTH_RANGE);
-
- // call parent
- Base3DCommon::StartScene();
-}
-
-/*************************************************************************
-|*
-|* Ende der Szenenbeschreibung:
-|*
-\************************************************************************/
-
-void Base3DDefault::EndScene()
-{
- // Zugriffe freigeben
- ReleaseAccess();
-
- // Ausgabe der erzeugten BitMap
- BitmapEx aBitmapEx;
-
- if(GetTransparentPartsContainedHint())
- {
- // Alpha-Transparenz
- aBitmapEx = BitmapEx(aPicture, aAlphaTransparence);
- }
- else
- {
- // Mono-Transparenz
- aBitmapEx = BitmapEx(aPicture, aMonoTransparence);
- }
-
- // Dithern
- UINT16 nBitCount = GetOutputDevice()->GetBitCount();
- if( GetOutputDevice()->GetOutDevType() != OUTDEV_PRINTER && nBitCount <= 16 && GetDither())
- {
- aBitmapEx.Dither(nBitCount <= 8
- ? BMP_DITHER_MATRIX
- : BMP_DITHER_FLOYD_16);
- }
-
- if(GetOutputDevice()->GetConnectMetaFile() != NULL)
- {
- Rectangle aLogicRect;
- aLogicRect = GetOutputDevice()->PixelToLogic(aSizePixel);
- aBitmapEx.Draw(GetOutputDevice(), aLogicRect.TopLeft(), aLogicRect.GetSize());
- }
- else
- {
- sal_Bool bWasEnabled = GetOutputDevice()->IsMapModeEnabled();
- GetOutputDevice()->EnableMapMode(FALSE);
-
-#ifdef DBG_UTIL // draw for testing
- static sal_Bool bDoDrawBitmapForTesting(FALSE);
- if(bDoDrawBitmapForTesting)
- {
- Bitmap aBmp( aBitmapEx.GetMask() );
- aBmp.Convert( BMP_CONVERSION_4BIT_COLORS );
- aBmp.Replace( COL_WHITE, COL_LIGHTRED );
- GetOutputDevice()->DrawBitmap( aSizePixel.TopLeft(), aSizePixel.GetSize(), aBmp );
- GetOutputDevice()->SetFillColor( COL_LIGHTRED );
- GetOutputDevice()->SetLineColor( COL_LIGHTRED );
- GetOutputDevice()->DrawRect( aSizePixel );
- }
-#endif
-
- aBitmapEx.Draw(GetOutputDevice(), aSizePixel.TopLeft(), aSizePixel.GetSize());
- GetOutputDevice()->EnableMapMode(bWasEnabled);
- }
-
- // Zugriffe wieder holen
- AcquireAccess();
-
- // eventuelle temporaere Reduzierung der Aufloesung zuruecknehmen
- if(bDetailBackedup)
- {
- SetDetail(fDetailBackup);
- bDetailBackedup = FALSE;
- }
-
- // call parent
- Base3DCommon::EndScene();
-}
-
-/*************************************************************************
-|*
-|* Callbacks bei Matrixaenderungen
-|*
-|* Ausgaberechteck innerhalb des OutputDevice festlegen. Die Koordinaten
-|* sind device-spezifisch, muessen also evtl. erst auf pixelkoordinaten
-|* umgerechnet werden
-|*
-\************************************************************************/
-
-void Base3DDefault::SetTransformationSet(B3dTransformationSet* pSet)
-{
- // call parent
- Base3DCommon::SetTransformationSet(pSet);
-
- if(GetTransformationSet())
- {
- // eventuelle temporaere Reduzierung der Aufloesung zuruecknehmen
- if(bDetailBackedup)
- {
- SetDetail(fDetailBackup);
- bDetailBackedup = FALSE;
- }
-
- // Neue Groesse fuer die Ausgabe
- aSizePixel = GetOutputDevice()->LogicToPixel(
- GetTransformationSet()->GetLogicalViewportBounds());
-
- // Eventuell durch ClipRegion eingeschraenkt? Dies
- // muss beachtet werden
- if(IsScissorRegionActive())
- {
- // draw region even smaller
- aSizePixel.Intersection(GetScissorRegionPixel());
- }
-
- // Testen, ob die Bitmap zu gross wird
- aLocalSizePixel = aSizePixel;
-
- double fQuadSize = aLocalSizePixel.GetWidth(); // sj: #i40320# solved overrun
- fQuadSize *= aLocalSizePixel.GetHeight();
-
- if( fQuadSize > GetMaxPixels() )
- {
- // Groesse reduzieren
- double fFactor = sqrt((double)GetMaxPixels() / fQuadSize);
-
- // Bei Druckjobs die Reduzierung einschraenken
- if(fFactor < 0.25 && GetOutputDevice()->GetOutDevType() == OUTDEV_PRINTER)
- fFactor = 0.25;
-
- // Wird hier mehr reduziert als sowieso schon eingestellt ist?
- if(fFactor < fDetail)
- {
- fDetailBackup = GetDetail();
- bDetailBackedup = TRUE;
- SetDetail(fFactor);
- }
- }
-
- // Detailstufe beachten
- if(bReducedDetail && fDetail != 0.0)
- {
- sal_Int32 nReducedWidth = (sal_Int32)((double)(aLocalSizePixel.GetWidth() - 1) * fDetail);
- sal_Int32 nReducedHeight = (sal_Int32)((double)(aLocalSizePixel.GetHeight() - 1)* fDetail);
- aLocalSizePixel.SetSize(Size(nReducedWidth + 1, nReducedHeight + 1));
- }
-
- // Falls die Groesse null ist, groesse auf 1,1 setzen
- if(aLocalSizePixel.GetSize().Width() < 1)
- aLocalSizePixel.SetSize(Size(1 , aLocalSizePixel.GetSize().Height()));
- if(aLocalSizePixel.GetSize().Height() < 1)
- aLocalSizePixel.SetSize(Size(aLocalSizePixel.GetSize().Width(), 1));
- }
-}
-
-/*************************************************************************
-|*
-|* Pixelkoordinaten des Punktes innerhalb der Bitmap holen
-|*
-\************************************************************************/
-
-Point Base3DDefault::GetPixelCoor(B3dEntity& rEntity)
-{
- if(bReducedDetail && fDetail != 0.0)
- {
- Point aRetval = GetOutputDevice()->LogicToPixel(
- Point((sal_Int32)(rEntity.Point().getX()),
- (sal_Int32)(rEntity.Point().getY()))) - aSizePixel.TopLeft();
- aRetval.X() = (sal_Int32)((double)aRetval.X() * fDetail);
- aRetval.Y() = (sal_Int32)((double)aRetval.Y() * fDetail);
- return aRetval;
- }
- else
- {
- return GetOutputDevice()->LogicToPixel(
- Point((sal_Int32)(rEntity.Point().getX()),
- (sal_Int32)(rEntity.Point().getY()))) - aSizePixel.TopLeft();
- }
-}
-
-/*************************************************************************
-|*
-|* 3DPunkt aus Pixelkoordinaten und Tiefe rekonstruieren
-|*
-\************************************************************************/
-
-basegfx::B3DPoint Base3DDefault::Get3DCoor(Point& rPnt, double fDepth)
-{
- if(bReducedDetail && fDetail != 0.0)
- {
- Point aPnt(rPnt);
- aPnt.X() = (sal_Int32)((double)aPnt.X() / fDetail);
- aPnt.Y() = (sal_Int32)((double)aPnt.Y() / fDetail);
- aPnt = GetOutputDevice()->PixelToLogic(aPnt + aSizePixel.TopLeft());
- return basegfx::B3DPoint(aPnt.X(), aPnt.Y(), fDepth);
- }
- else
- {
- Point aPnt = GetOutputDevice()->PixelToLogic(rPnt + aSizePixel.TopLeft());
- return basegfx::B3DPoint(aPnt.X(), aPnt.Y(), fDepth);
- }
-}
-
-/*************************************************************************
-|*
-|* ZBuffer Sichtbarkeitstest
-|*
-\************************************************************************/
-
-sal_Bool Base3DDefault::IsVisibleAndScissor(sal_Int32 nX, sal_Int32 nY, sal_uInt32 nDepth)
-{
- // #112303#
- // Do not allow pixels smaller then the bitmap
- if(nX < 0L || nY < 0L)
- return FALSE;
-
- // #112303#
- // Do not allow pixels bigger then the bitmap
- if(nX > aLocalSizePixel.GetWidth() || nY >aLocalSizePixel.GetHeight())
- return FALSE;
-
- if(!IsScissorRegionActive() || IsInScissorRegion(nX, nY))
- {
- const BitmapColor& rBmCol = pZBufferWrite->GetPixel(nY, nX);
- Color aColor(rBmCol.GetRed(), rBmCol.GetGreen(), rBmCol.GetBlue());
-
- return (aColor.GetColor() >= nDepth);
- }
-
- return FALSE;
-}
-
-/*************************************************************************
-|*
-|* Scissoring Sichtbarkeitstest
-|*
-\************************************************************************/
-
-sal_Bool Base3DDefault::IsInScissorRegion(sal_Int32 nX, sal_Int32 nY)
-{
- if(nX < aDefaultScissorRectangle.Left())
- return FALSE;
- if(nY < aDefaultScissorRectangle.Top())
- return FALSE;
- if(nX > aDefaultScissorRectangle.Right())
- return FALSE;
- if(nY > aDefaultScissorRectangle.Bottom())
- return FALSE;
- return TRUE;
-}
-
-/*************************************************************************
-|*
-|* Pixel setzen in allen Buffern
-|*
-\************************************************************************/
-
-void Base3DDefault::WritePixel(sal_Int32 nX, sal_Int32 nY, Color aColor, sal_uInt32 nDepth)
-{
- // #112303#
- // WritePixel requires the pixel coordinates to be safely on the buffer
- // bitmaps where the paint will take place. Thus, this asserts will
- // ensure that.
- DBG_ASSERT(nX >= 0L, "Base3DDefault::WritePixel: X-Coor negative (!)");
- DBG_ASSERT(nY >= 0L, "Base3DDefault::WritePixel: Y-Coor negative (!)");
- DBG_ASSERT(nX <= aPicture.GetSizePixel().Width(), "Base3DDefault::WritePixel: X-Coor too big (!)");
- DBG_ASSERT(nY <= aPicture.GetSizePixel().Height(), "Base3DDefault::WritePixel: Y-Coor too big (!)");
-
- // In Transparenz-Map eintragen
- if(GetTransparentPartsContainedHint())
- {
- if(aColor.GetTransparency())
- {
- BYTE nOldTrans = pTransparenceWrite->GetPixel(nY, nX).GetIndex();
-
- if(nOldTrans != (BYTE)0xff)
- {
- // Farbe mischen
- BitmapColor aOldCol = pPictureWrite->GetPixel(nY, nX);
- UINT16 nNegTrans = 0x0100 - (UINT16)aColor.GetTransparency();
- aColor.SetRed((BYTE)((((UINT16)aOldCol.GetRed() * (UINT16)aColor.GetTransparency())
- + (aColor.GetRed() * nNegTrans)) >> 8));
- aColor.SetGreen((BYTE)((((UINT16)aOldCol.GetGreen() * (UINT16)aColor.GetTransparency())
- + (aColor.GetGreen() * nNegTrans)) >> 8));
- aColor.SetBlue((BYTE)((((UINT16)aOldCol.GetBlue() * (UINT16)aColor.GetTransparency())
- + (aColor.GetBlue() * nNegTrans)) >> 8));
- pPictureWrite->SetPixel(nY, nX, aColor);
-
- // Transparenz mischen
- pTransparenceWrite->SetPixel(nY, nX,
- (BYTE)(((UINT16)(nOldTrans+1) * (UINT16)aColor.GetTransparency()) >> 8));
- }
- else
- {
- // Pixel setzen
- pPictureWrite->SetPixel(nY, nX, aColor);
-
- // Alpha-Wert setzen
- pTransparenceWrite->SetPixel(nY, nX, aColor.GetTransparency());
- }
- }
- else
- {
- // Pixel setzen
- pPictureWrite->SetPixel(nY, nX, aColor);
-
- // Alpha-Wert setzen
- pTransparenceWrite->SetPixel(nY, nX, (BYTE)0x00);
-
- // Z-Buffer setzen
- Color aZBufCol(nDepth);
- pZBufferWrite->SetPixel(nY, nX, aZBufCol);
- }
- }
- else
- {
- // Dieser Punkt in der Mono-Transparenz ist nicht transparent
- BitmapColor aColBlack(BYTE(0));
- pTransparenceWrite->SetPixel(nY, nX, aColBlack);
-
- // Pixel setzen
- pPictureWrite->SetPixel(nY, nX, aColor);
-
- // Z-Buffer setzen
- Color aZBufCol(nDepth);
- pZBufferWrite->SetPixel(nY, nX, aZBufCol);
- }
-}
-
-/*************************************************************************
-|*
-|* Zeichenfunktionen; alle Objekte sind geclippt
-|* Einzelner Punkt
-|*
-\************************************************************************/
-
-void Base3DDefault::Clipped3DPoint(sal_uInt32 nInd)
-{
- B3dEntity& rEntity = aBuffers[nInd];
-
- // Geometrie holen
- rEntity.ToDeviceCoor(GetTransformationSet());
- Point aOutPoint = GetPixelCoor(rEntity);
- sal_uInt32 nDepth = (sal_uInt32)rEntity.Point().getZ();
-
- // PolygonOffset beachten
- if(GetPolygonOffset(Base3DPolygonOffsetPoint))
- {
- if(nDepth >= maPolygonOffset)
- nDepth -= maPolygonOffset;
- else
- nDepth = 0;
- }
-
- // Zeichnen
- if(IsVisibleAndScissor(aOutPoint.X(), aOutPoint.Y(), nDepth))
- WritePixel(aOutPoint.X(), aOutPoint.Y(), rEntity.Color(), nDepth);
-}
-
-/*************************************************************************
-|*
-|* Zeichenfunktionen; alle Objekte sind geclippt
-|* Linie
-|*
-\************************************************************************/
-
-void Base3DDefault::Clipped3DLine(sal_uInt32 nInd1, sal_uInt32 nInd2)
-{
- B3dEntity& rEntity1 = aBuffers[nInd1];
- B3dEntity& rEntity2 = aBuffers[nInd2];
- bNormalsUsed = rEntity1.IsNormalUsed() && rEntity2.IsNormalUsed();
- bTextureUsed = IsTextureActive() && rEntity1.IsTexCoorUsed() && rEntity2.IsTexCoorUsed();
-
- // ColorModel fuer diese Punkte anwenden, falls Normale vorhanden
- // Danach Normale als ungueltig markieren, da nur noch die berechnete
- // Farbe bei Aufteilungen weiter interpoliert wird
- if(bNormalsUsed)
- {
- // Vektoren normalisieren
- rEntity1.Normal().normalize();
- rEntity2.Normal().normalize();
-
- if(GetShadeModel() != Base3DPhong)
- {
- // Farben auswerten
- rEntity1.Color() = SolveColorModel(GetMaterialObject(),
- rEntity1.Normal(), rEntity1.Point());
- rEntity2.Color() = SolveColorModel(GetMaterialObject(),
- rEntity2.Normal(), rEntity2.Point());
-
- // Die Normalen NICHT ungueltig machen, da die Entities
- // eventuell noch fuer weitere Primitive benutzt werden.
- // Aber lokal merken, dass die Normalen bereits ausgewertet sind
- bNormalsUsed = FALSE;
- }
- }
-
- // Geometrie holen
- rEntity1.ToDeviceCoor(GetTransformationSet());
- rEntity2.ToDeviceCoor(GetTransformationSet());
- Rectangle aPrimitiveArea;
-
- aOutPointTop = GetPixelCoor(rEntity1);
- aOutPointLeft = GetPixelCoor(rEntity2);
-
- if(IsScissorRegionActive())
- {
- aPrimitiveArea.Union(Rectangle(aOutPointTop, aOutPointTop));
- aPrimitiveArea.Union(Rectangle(aOutPointLeft, aOutPointLeft));
- }
-
- if(!IsScissorRegionActive()
- || (IsScissorRegionActive()
- && !aDefaultScissorRectangle.GetIntersection(aPrimitiveArea).IsEmpty()))
- {
- if(bTextureUsed)
- {
- fTexWidth = (double)GetActiveTexture()->GetBitmapSize().Width();
- fTexHeight = (double)GetActiveTexture()->GetBitmapSize().Height();
- }
-
- // Punkt, Farbe und Z-Wert interpolieren und die Linie gererieren
- sal_Int32 nDx = aOutPointLeft.X() - aOutPointTop.X();
- sal_Int32 nDy = aOutPointLeft.Y() - aOutPointTop.Y();
- sal_Int32 nCount;
-
- // Werte fuer Schleife vorbereiten
- if(labs(nDx) > labs(nDy))
- // ueber X gehen
- nCount = labs(nDx);
- else
- // ueber Y gehen
- nCount = labs(nDy);
-
- if(nCount)
- {
- // Interpolatoren vorbereiten
- aIntXPosLeft.Load(aOutPointTop.X(), aOutPointLeft.X(), nCount);
- aIntXPosRight.Load(aOutPointTop.Y(), aOutPointLeft.Y(), nCount);
- sal_uInt32 nDepth;
-
- // PolygonOffset beachten
- if(GetPolygonOffset())
- {
- double fDepthLeft = rEntity1.Point().getZ();
- double fDepthRight = rEntity2.Point().getZ();
-
- if(fDepthLeft >= double(maPolygonOffset))
- fDepthLeft -= double(maPolygonOffset);
- else
- fDepthLeft = 0.0;
-
- if(fDepthRight >= double(maPolygonOffset))
- fDepthRight -= double(maPolygonOffset);
- else
- fDepthRight = 0.0;
-
- aIntDepthLine.Load(fDepthLeft, fDepthRight, nCount);
- }
- else
- {
- aIntDepthLine.Load(rEntity1.Point().getZ(), rEntity2.Point().getZ(), nCount);
- }
-
- // Texturkoordinateninterpolation?
- if(bTextureUsed)
- {
- aIntTexSLine.Load(
- rEntity1.TexCoor().getX() * fTexWidth,
- rEntity2.TexCoor().getX() * fTexWidth,
- nCount);
-
- aIntTexTLine.Load(
- rEntity1.TexCoor().getY() * fTexHeight,
- rEntity2.TexCoor().getY() * fTexHeight,
- nCount);
- }
-
- if(bNormalsUsed && GetShadeModel() == Base3DPhong)
- {
- // Normalen und Geometrie interpolieren
- if(GetTransformationSet())
- {
- basegfx::B3DVector aInvTrans(GetTransformationSet()->GetTranslate());
- basegfx::B3DVector aInvScale(GetTransformationSet()->GetScale());
-
- // Tiefe und Normale vorbereiten
- aIntVectorLine.Load(rEntity1.Normal(), rEntity2.Normal(), nCount);
-
- // Linie zeichnen
- if(bTextureUsed)
- {
- while(nCount--)
- {
- // weiterer Punkt
- nDx = aIntXPosLeft.GetLongValue();
- nDy = aIntXPosRight.GetLongValue();
- nDepth = aIntDepthLine.GetUINT32Value();
-
- if(IsVisibleAndScissor(nDx, nDy, nDepth))
- {
- Point aTmpPoint(nDx, nDy);
- basegfx::B3DPoint aPoint = Get3DCoor(aTmpPoint, nDepth);
- aPoint -= aInvTrans;
- aPoint /= aInvScale;
- basegfx::B3DVector aNormal;
- aIntVectorLine.GetVector3DValue(aNormal);
- aNormal.normalize();
- Color aCol = SolveColorModel(GetMaterialObject(), aNormal, aPoint);
- GetActiveTexture()->ModifyColor(aCol,
- aIntTexSLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue());
- WritePixel(nDx, nDy, aCol, nDepth);
- }
-
- if(nCount)
- {
- // Weiterschalten
- aIntXPosLeft.Increment();
- aIntXPosRight.Increment();
- aIntDepthLine.Increment();
- aIntVectorLine.Increment();
- aIntTexSLine.Increment();
- aIntTexTLine.Increment();
- }
- }
- }
- else
- {
- while(nCount--)
- {
- // weiterer Punkt
- nDx = aIntXPosLeft.GetLongValue();
- nDy = aIntXPosRight.GetLongValue();
- nDepth = aIntDepthLine.GetUINT32Value();
-
- if(IsVisibleAndScissor(nDx, nDy, nDepth))
- {
- Point aTmpPoint(nDx, nDy);
- basegfx::B3DPoint aPoint = Get3DCoor(aTmpPoint, nDepth);
- aPoint -= aInvTrans;
- aPoint /= aInvScale;
- basegfx::B3DVector aNormal;
- aIntVectorLine.GetVector3DValue(aNormal);
- aNormal.normalize();
- Color aCol = SolveColorModel(GetMaterialObject(), aNormal, aPoint);
- WritePixel(nDx, nDy, aCol, nDepth);
- }
-
- if(nCount)
- {
- // Weiterschalten
- aIntXPosLeft.Increment();
- aIntXPosRight.Increment();
- aIntDepthLine.Increment();
- aIntVectorLine.Increment();
- }
- }
- }
- }
- }
- else
- {
- if(rEntity1.Color() != rEntity2.Color())
- {
- // Farbe und Geometrie interpolieren
- // Tiefe und Farbe vorbereiten
- aIntColorLine.Load(rEntity1.Color(), rEntity2.Color(), nCount);
-
- // Linie zeichnen
- if(bTextureUsed)
- {
- while(nCount--)
- {
- // weiterer Punkt
- nDx = aIntXPosLeft.GetLongValue();
- nDy = aIntXPosRight.GetLongValue();
- nDepth = aIntDepthLine.GetUINT32Value();
-
- if(IsVisibleAndScissor(nDx, nDy, nDepth))
- {
- Color aCol = aIntColorLine.GetColorValue();
- GetActiveTexture()->ModifyColor(aCol,
- aIntTexSLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue());
- WritePixel(nDx, nDy, aCol, nDepth);
- }
-
- if(nCount)
- {
- // Weiterschalten
- aIntXPosLeft.Increment();
- aIntXPosRight.Increment();
- aIntDepthLine.Increment();
- aIntColorLine.Increment();
- aIntTexSLine.Increment();
- aIntTexTLine.Increment();
- }
- }
- }
- else
- {
- while(nCount--)
- {
- // weiterer Punkt
- nDx = aIntXPosLeft.GetLongValue();
- nDy = aIntXPosRight.GetLongValue();
- nDepth = aIntDepthLine.GetUINT32Value();
-
- if(IsVisibleAndScissor(nDx, nDy, nDepth))
- WritePixel(nDx, nDy, aIntColorLine.GetColorValue(), nDepth);
-
- if(nCount)
- {
- // Weiterschalten
- aIntXPosLeft.Increment();
- aIntXPosRight.Increment();
- aIntDepthLine.Increment();
- aIntColorLine.Increment();
- }
- }
- }
- }
- else
- {
- // Nur die Geometrie interpolieren
- // Linie zeichnen
- if(bTextureUsed)
- {
- while(nCount--)
- {
- // weiterer Punkt
- nDx = aIntXPosLeft.GetLongValue();
- nDy = aIntXPosRight.GetLongValue();
- nDepth = aIntDepthLine.GetUINT32Value();
-
- if(IsVisibleAndScissor(nDx, nDy, nDepth))
- {
- Color aCol = rEntity1.Color();
- GetActiveTexture()->ModifyColor(aCol,
- aIntTexSLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue());
- WritePixel(nDx, nDy, aCol, nDepth);
- }
-
- if(nCount)
- {
- // Weiterschalten
- aIntXPosLeft.Increment();
- aIntXPosRight.Increment();
- aIntDepthLine.Increment();
- aIntTexSLine.Increment();
- aIntTexTLine.Increment();
- }
- }
- }
- else
- {
- while(nCount--)
- {
- // weiterer Punkt
- nDx = aIntXPosLeft.GetLongValue();
- nDy = aIntXPosRight.GetLongValue();
- nDepth = aIntDepthLine.GetUINT32Value();
-
- if(IsVisibleAndScissor(nDx, nDy, nDepth))
- WritePixel(nDx, nDy, rEntity1.Color(), nDepth);
-
- if(nCount)
- {
- // Weiterschalten
- aIntXPosLeft.Increment();
- aIntXPosRight.Increment();
- aIntDepthLine.Increment();
- aIntTexSLine.Increment();
- aIntTexTLine.Increment();
- }
- }
- }
- }
- }
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Zeichenfunktionen; alle Objekte sind geclippt
-|* Polygon
-|*
-\************************************************************************/
-
-void Base3DDefault::Clipped3DTriangle(sal_uInt32 nInd1, sal_uInt32 nInd2, sal_uInt32 nInd3)
-{
- B3dEntity& rEntity1 = aBuffers[nInd1];
- B3dEntity& rEntity2 = aBuffers[nInd2];
- B3dEntity& rEntity3 = aBuffers[nInd3];
-
- bNormalsUsed = rEntity1.IsNormalUsed() && rEntity2.IsNormalUsed() && rEntity3.IsNormalUsed();
- bTextureUsed = IsTextureActive() && rEntity1.IsTexCoorUsed() && rEntity2.IsTexCoorUsed() && rEntity3.IsTexCoorUsed();
- Base3DMaterialMode eMode = Base3DMaterialFront;
-
- // ColorModel fuer diese Punkte anwenden, falls Normale vorhanden
- // Danach Normale als ungueltig markieren, da nur noch die berechnete
- // Farbe bei Aufteilungen weiter interpoliert wird
- if(bNormalsUsed)
- {
- // Vektoren normalisieren
- rEntity1.Normal().normalize();
- rEntity2.Normal().normalize();
- rEntity3.Normal().normalize();
-
- if(GetShadeModel() != Base3DPhong)
- {
- // Normale berechnen, Farben auswerten
- if(rEntity1.PlaneNormal().getZ() < 0.0 && (GetLightGroup() && GetLightGroup()->GetModelTwoSide()))
- eMode = Base3DMaterialBack;
-
- rEntity1.Color() = SolveColorModel(
- GetMaterialObject(eMode),
- rEntity1.Normal(),
- rEntity1.Point()
- );
-
- rEntity2.Color() = SolveColorModel(
- GetMaterialObject(eMode),
- rEntity2.Normal(),
- rEntity2.Point()
- );
-
- rEntity3.Color() = SolveColorModel(
- GetMaterialObject(eMode),
- rEntity3.Normal(),
- rEntity3.Point()
- );
-
- // Die Normalen NICHT ungueltig machen, da die Entities
- // eventuell noch fuer weitere Primitive benutzt werden.
- // Aber lokal merken, dass die Normalen bereits ausgewertet sind
- bNormalsUsed = FALSE;
- }
- }
-
- // Geometrie holen
- rEntity1.ToDeviceCoor(GetTransformationSet());
- rEntity2.ToDeviceCoor(GetTransformationSet());
- rEntity3.ToDeviceCoor(GetTransformationSet());
-
- // Punkte ordnen. Oberster nach pEntTop
- if(rEntity1.Point().getY() < rEntity2.Point().getY() && rEntity1.Point().getY() < rEntity3.Point().getY())
- {
- // rEntity1 ist der oberste
- pEntTop = &rEntity1;
-
- // Left, Right erst mal zuweisen
- pEntRight = &rEntity3;
- pEntLeft = &rEntity2;
- }
- else
- {
- if(rEntity2.Point().getY() < rEntity3.Point().getY())
- {
- // rEntity2 ist der oberste
- pEntTop = &rEntity2;
-
- // Left, Right erst mal zuweisen
- pEntRight = &rEntity1;
- pEntLeft = &rEntity3;
- }
- else
- {
- // rEntity3 ist der oberste
- pEntTop = &rEntity3;
-
- // Left, Right erst mal zuweisen
- pEntRight = &rEntity2;
- pEntLeft = &rEntity1;
- }
- }
-
- // Werte holen
- Rectangle aPrimitiveArea;
-
- aOutPointTop = GetPixelCoor(*pEntTop);
- aOutPointLeft = GetPixelCoor(*pEntLeft);
- aOutPointRight = GetPixelCoor(*pEntRight);
-
- if(IsScissorRegionActive())
- {
- aPrimitiveArea.Union(Rectangle(aOutPointTop, aOutPointTop));
- aPrimitiveArea.Union(Rectangle(aOutPointLeft, aOutPointLeft));
- aPrimitiveArea.Union(Rectangle(aOutPointRight, aOutPointRight));
- }
-
- if(!IsScissorRegionActive()
- || (IsScissorRegionActive()
- && !aDefaultScissorRectangle.GetIntersection(aPrimitiveArea).IsEmpty()))
- {
- if(bTextureUsed)
- {
- fTexWidth = (double)GetActiveTexture()->GetBitmapSize().Width();
- fTexHeight = (double)GetActiveTexture()->GetBitmapSize().Height();
- }
-
- // Links und rechts ordnen
- sal_Int32 nDeltaYLeft = aOutPointLeft.Y() - aOutPointTop.Y();
- sal_Int32 nDeltaYRight = aOutPointRight.Y() - aOutPointTop.Y();
- sal_Int32 nYLine;
-
- if((aOutPointLeft.X() - aOutPointTop.X()) * nDeltaYRight
- - nDeltaYLeft * (aOutPointRight.X() - aOutPointTop.X()) > 0)
- {
- // Links und rechts vertauschen
- // Punkte
- nYLine = aOutPointLeft.X();
- aOutPointLeft.X() = aOutPointRight.X();
- aOutPointRight.X() = nYLine;
- nYLine = aOutPointLeft.Y();
- aOutPointLeft.Y() = aOutPointRight.Y();
- aOutPointRight.Y() = nYLine;
-
- // Deltas
- nYLine = nDeltaYLeft; nDeltaYLeft = nDeltaYRight; nDeltaYRight = nYLine;
-
- // Zeiger auf Entities
- B3dEntity* pTmp = pEntLeft; pEntLeft = pEntRight; pEntRight = pTmp;
- }
-
- // YStart, Links und rechts laden
- nYLine = aOutPointTop.Y();
-
- aIntXPosLeft.Load(aOutPointTop.X(), aOutPointLeft.X(), nDeltaYLeft);
- aIntDepthLeft.Load(pEntTop->Point().getZ(), pEntLeft->Point().getZ(), nDeltaYLeft);
-
- aIntXPosRight.Load(aOutPointTop.X(), aOutPointRight.X(), nDeltaYRight);
- aIntDepthRight.Load(pEntTop->Point().getZ(), pEntRight->Point().getZ(), nDeltaYRight);
-
- if(bTextureUsed)
- {
- // #96837#
- if(mbPTCorrection)
- {
- // Load real depth interpolators (if needed)
- const double fRealDepthLeft(1.0 / GetTransformationSet()->ViewToEyeCoor(pEntLeft->Point()).getZ());
- const double fRealDepthRight(1.0 / GetTransformationSet()->ViewToEyeCoor(pEntRight->Point()).getZ());
- const double fRealDepthTop(1.0 / GetTransformationSet()->ViewToEyeCoor(pEntTop->Point()).getZ());
- aRealDepthLeft.Load(fRealDepthTop, fRealDepthLeft, nDeltaYLeft);
- aRealDepthRight.Load(fRealDepthTop, fRealDepthRight, nDeltaYRight);
-
- // #96837#
- aIntTexSLeft.Load(
- pEntTop->TexCoor().getX() * fTexWidth * fRealDepthTop,
- pEntLeft->TexCoor().getX() * fTexWidth * fRealDepthLeft,
- nDeltaYLeft);
-
- aIntTexTLeft.Load(
- pEntTop->TexCoor().getY() * fTexHeight * fRealDepthTop,
- pEntLeft->TexCoor().getY() * fTexHeight * fRealDepthLeft,
- nDeltaYLeft);
-
- aIntTexSRight.Load(
- pEntTop->TexCoor().getX() * fTexWidth * fRealDepthTop,
- pEntRight->TexCoor().getX() * fTexWidth * fRealDepthRight,
- nDeltaYRight);
-
- aIntTexTRight.Load(
- pEntTop->TexCoor().getY() * fTexHeight * fRealDepthTop,
- pEntRight->TexCoor().getY() * fTexHeight * fRealDepthRight,
- nDeltaYRight);
- }
- else
- {
- aIntTexSLeft.Load(
- pEntTop->TexCoor().getX() * fTexWidth,
- pEntLeft->TexCoor().getX() * fTexWidth,
- nDeltaYLeft);
-
- aIntTexTLeft.Load(
- pEntTop->TexCoor().getY() * fTexHeight,
- pEntLeft->TexCoor().getY() * fTexHeight,
- nDeltaYLeft);
-
- aIntTexSRight.Load(
- pEntTop->TexCoor().getX() * fTexWidth,
- pEntRight->TexCoor().getX() * fTexWidth,
- nDeltaYRight);
-
- aIntTexTRight.Load(
- pEntTop->TexCoor().getY() * fTexHeight,
- pEntRight->TexCoor().getY() * fTexHeight,
- nDeltaYRight);
- }
- }
-
- if(bNormalsUsed && GetShadeModel() == Base3DPhong)
- {
- // Normalen und Geometrie interpolieren
- aIntVectorLeft.Load(pEntTop->Normal(), pEntLeft->Normal(), nDeltaYLeft);
- aIntVectorRight.Load(pEntTop->Normal(), pEntRight->Normal(), nDeltaYRight);
- B3dMaterial& rMat = GetMaterialObject(eMode);
-
- if(bTextureUsed)
- {
- // Schleife
- while(nDeltaYLeft || nDeltaYRight)
- {
- // Zeile ausgeben
- DrawLinePhongTexture(nYLine, rMat);
-
- // naechste Zeile vorbereiten rechts
- if(!nDeltaYRight && nDeltaYLeft)
- {
- // Rechts ist zuende, lade neu mit Rest nach links
- nDeltaYRight = nDeltaYLeft;
- LoadRightTexture(nDeltaYRight);
- aIntVectorRight.Load(pEntRight->Normal(), pEntLeft->Normal(), nDeltaYRight);
- }
-
- // naechste Zeile vorbereiten links
- if(!nDeltaYLeft && nDeltaYRight)
- {
- // Links ist zuende, lade neu mit Rest nach rechts
- nDeltaYLeft = nDeltaYRight;
- LoadLeftTexture(nDeltaYLeft);
- aIntVectorLeft.Load(pEntLeft->Normal(), pEntRight->Normal(), nDeltaYLeft);
- }
-
- // naechste Zeile rechts
- if(nDeltaYRight || nDeltaYLeft)
- {
- nDeltaYRight--;
- NextStepRightTexture();
- aIntVectorRight.Increment();
-
- nDeltaYLeft--;
- NextStepLeftTexture();
- aIntVectorLeft.Increment();
-
- nYLine++;
- }
- }
- }
- else
- {
- // Schleife
- while(nDeltaYLeft || nDeltaYRight)
- {
- // Zeile ausgeben
- DrawLinePhong(nYLine, rMat);
-
- // naechste Zeile vorbereiten rechts
- if(!nDeltaYRight && nDeltaYLeft)
- {
- // Rechts ist zuende, lade neu mit Rest nach links
- nDeltaYRight = nDeltaYLeft;
- LoadRight(nDeltaYRight);
- aIntVectorRight.Load(pEntRight->Normal(), pEntLeft->Normal(), nDeltaYRight);
- }
-
- // naechste Zeile vorbereiten links
- if(!nDeltaYLeft && nDeltaYRight)
- {
- // Links ist zuende, lade neu mit Rest nach rechts
- nDeltaYLeft = nDeltaYRight;
- LoadLeft(nDeltaYLeft);
- aIntVectorLeft.Load(pEntLeft->Normal(), pEntRight->Normal(), nDeltaYLeft);
- }
-
- // naechste Zeile rechts
- if(nDeltaYRight || nDeltaYLeft)
- {
- nDeltaYRight--;
- NextStepRight();
- aIntVectorRight.Increment();
-
- nDeltaYLeft--;
- NextStepLeft();
- aIntVectorLeft.Increment();
-
- nYLine++;
- }
- }
- }
- }
- else
- {
- if(!(rEntity1.Color() == rEntity2.Color() && rEntity1.Color() == rEntity3.Color()))
- {
- // Farbe und Geometrie interpolieren
- aIntColorLeft.Load(pEntTop->Color(), pEntLeft->Color(), nDeltaYLeft);
- aIntColorRight.Load(pEntTop->Color(), pEntRight->Color(), nDeltaYRight);
-
- if(bTextureUsed)
- {
- // Schleife
- while(nDeltaYLeft || nDeltaYRight)
- {
- // Zeile ausgeben
- DrawLineColorTexture(nYLine);
-
- // naechste Zeile vorbereiten rechts
- if(!nDeltaYRight && nDeltaYLeft)
- {
- // Rechts ist zuende, lade neu mit Rest nach links
- nDeltaYRight = nDeltaYLeft;
- LoadRightTexture(nDeltaYRight);
- aIntColorRight.Load(pEntRight->Color(), pEntLeft->Color(), nDeltaYRight);
- }
-
- // naechste Zeile vorbereiten links
- if(!nDeltaYLeft && nDeltaYRight)
- {
- // Links ist zuende, lade neu mit Rest nach rechts
- nDeltaYLeft = nDeltaYRight;
- LoadLeftTexture(nDeltaYLeft);
- aIntColorLeft.Load(pEntLeft->Color(), pEntRight->Color(), nDeltaYLeft);
- }
-
- // naechste Zeile rechts
- if(nDeltaYRight || nDeltaYLeft)
- {
- nDeltaYRight--;
- NextStepRightTexture();
- aIntColorRight.Increment();
-
- nDeltaYLeft--;
- NextStepLeftTexture();
- aIntColorLeft.Increment();
-
- nYLine++;
- }
- }
- }
- else
- {
- // Schleife
- while(nDeltaYLeft || nDeltaYRight)
- {
- // Zeile ausgeben
- DrawLineColor(nYLine);
-
- // naechste Zeile vorbereiten rechts
- if(!nDeltaYRight && nDeltaYLeft)
- {
- // Rechts ist zuende, lade neu mit Rest nach links
- nDeltaYRight = nDeltaYLeft;
- LoadRight(nDeltaYRight);
- aIntColorRight.Load(pEntRight->Color(), pEntLeft->Color(), nDeltaYRight);
- }
-
- // naechste Zeile vorbereiten links
- if(!nDeltaYLeft && nDeltaYRight)
- {
- // Links ist zuende, lade neu mit Rest nach rechts
- nDeltaYLeft = nDeltaYRight;
- LoadLeft(nDeltaYLeft);
- aIntColorLeft.Load(pEntLeft->Color(), pEntRight->Color(), nDeltaYLeft);
- }
-
- // naechste Zeile rechts
- if(nDeltaYRight || nDeltaYLeft)
- {
- nDeltaYRight--;
- NextStepRight();
- aIntColorRight.Increment();
-
- nDeltaYLeft--;
- NextStepLeft();
- aIntColorLeft.Increment();
-
- nYLine++;
- }
- }
- }
- }
- else
- {
- // Nur die Geometrie interpolieren
- if(bTextureUsed)
- {
- // Schleife
- while(nDeltaYLeft || nDeltaYRight)
- {
- // Zeile ausgeben
- DrawLineTexture(nYLine, pEntTop->Color());
-
- // naechste Zeile vorbereiten rechts
- if(!nDeltaYRight && nDeltaYLeft)
- {
- // Rechts ist zuende, lade neu mit Rest nach links
- nDeltaYRight = nDeltaYLeft;
- LoadRightTexture(nDeltaYRight);
- }
-
- // naechste Zeile vorbereiten links
- if(!nDeltaYLeft && nDeltaYRight)
- {
- // Links ist zuende, lade neu mit Rest nach rechts
- nDeltaYLeft = nDeltaYRight;
- LoadLeftTexture(nDeltaYLeft);
- }
-
- // naechste Zeile rechts
- if(nDeltaYRight || nDeltaYLeft)
- {
- nDeltaYRight--;
- NextStepRightTexture();
-
- nDeltaYLeft--;
- NextStepLeftTexture();
-
- nYLine++;
- }
- }
- }
- else
- {
- // Schleife
- while(nDeltaYLeft || nDeltaYRight)
- {
- // Zeile ausgeben
- DrawLine(nYLine, pEntTop->Color());
-
- // naechste Zeile vorbereiten rechts
- if(!nDeltaYRight && nDeltaYLeft)
- {
- // Rechts ist zuende, lade neu mit Rest nach links
- nDeltaYRight = nDeltaYLeft;
- LoadRight(nDeltaYRight);
- }
-
- // naechste Zeile vorbereiten links
- if(!nDeltaYLeft && nDeltaYRight)
- {
- // Links ist zuende, lade neu mit Rest nach rechts
- nDeltaYLeft = nDeltaYRight;
- LoadLeft(nDeltaYLeft);
- }
-
- // naechste Zeile rechts
- if(nDeltaYRight || nDeltaYLeft)
- {
- nDeltaYRight--;
- NextStepRight();
-
- nDeltaYLeft--;
- NextStepLeft();
-
- nYLine++;
- }
- }
- }
- }
- }
- }
-}
-
-void Base3DDefault::DrawLinePhongTexture(sal_Int32 nYPos, B3dMaterial& rMat)
-{
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && (nYPos < aDefaultScissorRectangle.Top()
- || nYPos > aDefaultScissorRectangle.Bottom()))
- return;
-
- // Von links bis rechts zeichnen
- sal_Int32 nXLineStart = aIntXPosLeft.GetLongValue();
- sal_Int32 nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
-
- if(nXLineDelta > 0)
- {
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
- || nXLineStart > aDefaultScissorRectangle.Right()))
- return;
-
- basegfx::B3DVector aVectorLeft;
- aIntVectorLeft.GetVector3DValue(aVectorLeft);
- basegfx::B3DVector aVectorRight;
- aIntVectorRight.GetVector3DValue(aVectorRight);
- aIntVectorLine.Load(aVectorLeft, aVectorRight, nXLineDelta);
- aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
-
- // #96837##
- if(mbPTCorrection)
- {
- aRealDepthLine.Load(aRealDepthLeft.GetDoubleValue(), aRealDepthRight.GetDoubleValue(), nXLineDelta);
- }
-
- aIntTexSLine.Load(aIntTexSLeft.GetDoubleValue(), aIntTexSRight.GetDoubleValue(), nXLineDelta);
- aIntTexTLine.Load(aIntTexTLeft.GetDoubleValue(), aIntTexTRight.GetDoubleValue(), nXLineDelta);
-
- if(GetTransformationSet())
- {
- basegfx::B3DVector aInvTrans = GetTransformationSet()->GetTranslate();
- basegfx::B3DVector aInvScale = GetTransformationSet()->GetScale();
-
- while(nXLineDelta--)
- {
- // Werte vorbereiten
- sal_uInt32 nDepth = aIntDepthLine.GetUINT32Value();
-
- // Punkt ausgeben
- if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
- {
- Point aTmpPoint(nXLineStart, nYPos);
- basegfx::B3DPoint aPoint = Get3DCoor(aTmpPoint, nDepth);
- aPoint -= aInvTrans;
- aPoint /= aInvScale;
- basegfx::B3DVector aNormal;
- aIntVectorLine.GetVector3DValue(aNormal);
- aNormal.normalize();
- Color aCol = SolveColorModel(rMat, aNormal, aPoint);
-
- // #96837#
- if(mbPTCorrection)
- {
- GetActiveTexture()->ModifyColor(
- aCol,
- aIntTexSLine.GetDoubleValue() / aRealDepthLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue() / aRealDepthLine.GetDoubleValue()
- );
- }
- else
- {
- GetActiveTexture()->ModifyColor(
- aCol,
- aIntTexSLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue()
- );
- }
-
- WritePixel(nXLineStart, nYPos, aCol, nDepth);
- }
-
- if(nXLineDelta)
- {
- // naechste Spalte
- nXLineStart++;
-
- // naechste Tiefe und Farbe
- aIntDepthLine.Increment();
- aIntVectorLine.Increment();
-
- // #96837#
- if(mbPTCorrection)
- {
- aRealDepthLine.Increment();
- }
-
- aIntTexSLine.Increment();
- aIntTexTLine.Increment();
- }
- }
- }
- }
-}
-
-void Base3DDefault::DrawLinePhong(sal_Int32 nYPos, B3dMaterial& rMat)
-{
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && (nYPos < aDefaultScissorRectangle.Top()
- || nYPos > aDefaultScissorRectangle.Bottom()))
- return;
-
- // Von links bis rechts zeichnen
- sal_Int32 nXLineStart = aIntXPosLeft.GetLongValue();
- sal_Int32 nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
-
- if(nXLineDelta > 0)
- {
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
- || nXLineStart > aDefaultScissorRectangle.Right()))
- return;
-
- basegfx::B3DVector aVectorLeft;
- aIntVectorLeft.GetVector3DValue(aVectorLeft);
- basegfx::B3DVector aVectorRight;
- aIntVectorRight.GetVector3DValue(aVectorRight);
- aIntVectorLine.Load(aVectorLeft, aVectorRight, nXLineDelta);
- aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
-
- if(GetTransformationSet())
- {
- basegfx::B3DVector aInvTrans = GetTransformationSet()->GetTranslate();
- basegfx::B3DVector aInvScale = GetTransformationSet()->GetScale();
- while(nXLineDelta--)
- {
- // Werte vorbereiten
- sal_uInt32 nDepth = aIntDepthLine.GetUINT32Value();
-
- // Punkt ausgeben
- if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
- {
- Point aTmpPoint(nXLineStart, nYPos);
- basegfx::B3DPoint aPoint = Get3DCoor(aTmpPoint, nDepth);
- aPoint -= aInvTrans;
- aPoint /= aInvScale;
- basegfx::B3DVector aNormal;
- aIntVectorLine.GetVector3DValue(aNormal);
- aNormal.normalize();
- Color aCol = SolveColorModel(rMat, aNormal, aPoint);
- WritePixel(nXLineStart, nYPos, aCol, nDepth);
- }
-
- if(nXLineDelta)
- {
- // naechste Spalte
- nXLineStart++;
-
- // naechste Tiefe und Farbe
- aIntDepthLine.Increment();
- aIntVectorLine.Increment();
- }
- }
- }
- }
-}
-
-void Base3DDefault::DrawLineColorTexture(sal_Int32 nYPos)
-{
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && (nYPos < aDefaultScissorRectangle.Top()
- || nYPos > aDefaultScissorRectangle.Bottom()))
- return;
-
- // Von links bis rechts zeichnen
- sal_Int32 nXLineStart = aIntXPosLeft.GetLongValue();
- sal_Int32 nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
-
- if(nXLineDelta > 0)
- {
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
- || nXLineStart > aDefaultScissorRectangle.Right()))
- return;
-
- aIntColorLine.Load(aIntColorLeft.GetColorValue(), aIntColorRight.GetColorValue(), nXLineDelta);
- aIntTexSLine.Load(aIntTexSLeft.GetDoubleValue(), aIntTexSRight.GetDoubleValue(), nXLineDelta);
- aIntTexTLine.Load(aIntTexTLeft.GetDoubleValue(), aIntTexTRight.GetDoubleValue(), nXLineDelta);
- aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
-
- // #96837#
- if(mbPTCorrection)
- {
- aRealDepthLine.Load(aRealDepthLeft.GetDoubleValue(), aRealDepthRight.GetDoubleValue(), nXLineDelta);
- }
-
- while(nXLineDelta--)
- {
- // Werte vorbereiten
- sal_uInt32 nDepth = aIntDepthLine.GetUINT32Value();
-
- // Punkt ausgeben
- if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
- {
- Color aCol = aIntColorLine.GetColorValue();
-
- // #96837#
- if(mbPTCorrection)
- {
- GetActiveTexture()->ModifyColor(
- aCol,
- aIntTexSLine.GetDoubleValue() / aRealDepthLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue() / aRealDepthLine.GetDoubleValue()
- );
- }
- else
- {
- GetActiveTexture()->ModifyColor(
- aCol,
- aIntTexSLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue()
- );
- }
-
- WritePixel(nXLineStart, nYPos, aCol, nDepth);
- }
-
- if(nXLineDelta)
- {
- // naechste Spalte
- nXLineStart++;
-
- // naechste Tiefe und Farbe
- aIntDepthLine.Increment();
- aIntColorLine.Increment();
- aIntTexSLine.Increment();
- aIntTexTLine.Increment();
-
- // #96837#
- if(mbPTCorrection)
- {
- aRealDepthLine.Increment();
- }
- }
- }
- }
-}
-
-void Base3DDefault::DrawLineColor(sal_Int32 nYPos)
-{
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && (nYPos < aDefaultScissorRectangle.Top()
- || nYPos > aDefaultScissorRectangle.Bottom()))
- return;
-
- // Von links bis rechts zeichnen
- sal_Int32 nXLineStart = aIntXPosLeft.GetLongValue();
- sal_Int32 nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
-
- if(nXLineDelta > 0)
- {
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
- || nXLineStart > aDefaultScissorRectangle.Right()))
- return;
-
- aIntColorLine.Load(aIntColorLeft.GetColorValue(), aIntColorRight.GetColorValue(), nXLineDelta);
- aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
-
- while(nXLineDelta--)
- {
- // Werte vorbereiten
- sal_uInt32 nDepth = aIntDepthLine.GetUINT32Value();
-
- // Punkt ausgeben
- if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
- WritePixel(nXLineStart, nYPos, aIntColorLine.GetColorValue(), nDepth);
-
- if(nXLineDelta)
- {
- // naechste Spalte
- nXLineStart++;
-
- // naechste Tiefe und Farbe
- aIntDepthLine.Increment();
- aIntColorLine.Increment();
- }
- }
- }
-}
-
-void Base3DDefault::DrawLineTexture(sal_Int32 nYPos, Color& rCol)
-{
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && (nYPos < aDefaultScissorRectangle.Top()
- || nYPos > aDefaultScissorRectangle.Bottom()))
- return;
-
- // Von links bis rechts zeichnen
- sal_Int32 nXLineStart = aIntXPosLeft.GetLongValue();
- sal_Int32 nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
-
- if(nXLineDelta > 0)
- {
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
- || nXLineStart > aDefaultScissorRectangle.Right()))
- return;
-
- aIntTexSLine.Load(aIntTexSLeft.GetDoubleValue(), aIntTexSRight.GetDoubleValue(), nXLineDelta);
- aIntTexTLine.Load(aIntTexTLeft.GetDoubleValue(), aIntTexTRight.GetDoubleValue(), nXLineDelta);
- aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
-
- // #96837#
- if(mbPTCorrection)
- {
- aRealDepthLine.Load(aRealDepthLeft.GetDoubleValue(), aRealDepthRight.GetDoubleValue(), nXLineDelta);
- }
-
- while(nXLineDelta--)
- {
- // Werte vorbereiten
- sal_uInt32 nDepth = aIntDepthLine.GetUINT32Value();
-
- // Punkt ausgeben
- if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
- {
- // Texturkoordinateninterpolation?
- Color aCol = rCol;
-
- // #96837#
- if(mbPTCorrection)
- {
- GetActiveTexture()->ModifyColor(
- aCol,
- aIntTexSLine.GetDoubleValue() / aRealDepthLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue() / aRealDepthLine.GetDoubleValue()
- );
- }
- else
- {
- GetActiveTexture()->ModifyColor(
- aCol,
- aIntTexSLine.GetDoubleValue(),
- aIntTexTLine.GetDoubleValue()
- );
- }
-
- WritePixel(nXLineStart, nYPos, aCol, nDepth);
- }
-
- if(nXLineDelta)
- {
- // naechste Spalte
- nXLineStart++;
-
- // naechste Tiefe und Farbe
- aIntDepthLine.Increment();
- aIntTexSLine.Increment();
- aIntTexTLine.Increment();
-
- // #96837#
- if(mbPTCorrection)
- {
- aRealDepthLine.Increment();
- }
- }
- }
- }
-}
-
-void Base3DDefault::DrawLine(sal_Int32 nYPos, Color& rCol)
-{
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && (nYPos < aDefaultScissorRectangle.Top()
- || nYPos > aDefaultScissorRectangle.Bottom()))
- return;
-
- // Von links bis rechts zeichnen
- sal_Int32 nXLineStart = aIntXPosLeft.GetLongValue();
- sal_Int32 nXLineDelta = aIntXPosRight.GetLongValue() - nXLineStart;
-
- if(nXLineDelta > 0)
- {
- // Ausserhalb des Clipping-Bereichs?
- if(IsScissorRegionActive()
- && ( nXLineStart+nXLineDelta < aDefaultScissorRectangle.Left()
- || nXLineStart > aDefaultScissorRectangle.Right()))
- return;
-
- aIntDepthLine.Load(aIntDepthLeft.GetDoubleValue(), aIntDepthRight.GetDoubleValue(), nXLineDelta);
-
- while(nXLineDelta--)
- {
- // Werte vorbereiten
- sal_uInt32 nDepth = aIntDepthLine.GetUINT32Value();
-
- // Punkt ausgeben
- if(IsVisibleAndScissor(nXLineStart, nYPos, nDepth))
- WritePixel(nXLineStart, nYPos, rCol, nDepth);
-
- if(nXLineDelta)
- {
- // naechste Spalte
- nXLineStart++;
-
- // naechste Tiefe und Farbe
- aIntDepthLine.Increment();
- }
- }
- }
-}
-
-void Base3DDefault::LoadLeftTexture(sal_Int32 nSize)
-{
- aIntXPosLeft.Load(aOutPointLeft.X(), aOutPointRight.X(), nSize);
- aIntDepthLeft.Load(pEntLeft->Point().getZ(), pEntRight->Point().getZ(), nSize);
-
- // #96837#
- if(mbPTCorrection)
- {
- const double fRealDepthLeft = 1.0 / GetTransformationSet()->ViewToEyeCoor(pEntLeft->Point()).getZ();
- const double fRealDepthRight = 1.0 / GetTransformationSet()->ViewToEyeCoor(pEntRight->Point()).getZ();
- aRealDepthLeft.Load(fRealDepthLeft, fRealDepthRight, nSize);
-
- aIntTexSLeft.Load(
- pEntLeft->TexCoor().getX() * fTexWidth * fRealDepthLeft,
- pEntRight->TexCoor().getX() * fTexWidth * fRealDepthRight,
- nSize);
-
- aIntTexTLeft.Load(
- pEntLeft->TexCoor().getY() * fTexHeight * fRealDepthLeft,
- pEntRight->TexCoor().getY() * fTexHeight * fRealDepthRight,
- nSize);
- }
- else
- {
- aIntTexSLeft.Load(
- pEntLeft->TexCoor().getX() * fTexWidth,
- pEntRight->TexCoor().getX() * fTexWidth,
- nSize);
-
- aIntTexTLeft.Load(
- pEntLeft->TexCoor().getY() * fTexHeight,
- pEntRight->TexCoor().getY() * fTexHeight,
- nSize);
- }
-}
-
-void Base3DDefault::LoadLeft(sal_Int32 nSize)
-{
- aIntXPosLeft.Load(aOutPointLeft.X(), aOutPointRight.X(), nSize);
- aIntDepthLeft.Load(pEntLeft->Point().getZ(), pEntRight->Point().getZ(), nSize);
-}
-
-void Base3DDefault::LoadRightTexture(sal_Int32 nSize)
-{
- aIntXPosRight.Load(aOutPointRight.X(), aOutPointLeft.X(), nSize);
- aIntDepthRight.Load(pEntRight->Point().getZ(), pEntLeft->Point().getZ(), nSize);
-
- // #96837#
- if(mbPTCorrection)
- {
- const double fRealDepthLeft = 1.0 / GetTransformationSet()->ViewToEyeCoor(pEntLeft->Point()).getZ();
- const double fRealDepthRight = 1.0 / GetTransformationSet()->ViewToEyeCoor(pEntRight->Point()).getZ();
- aRealDepthRight.Load(fRealDepthRight, fRealDepthLeft, nSize);
-
- // #96837#
- aIntTexSRight.Load(
- pEntRight->TexCoor().getX() * fTexWidth * fRealDepthRight,
- pEntLeft->TexCoor().getX() * fTexWidth * fRealDepthLeft,
- nSize);
-
- aIntTexTRight.Load(
- pEntRight->TexCoor().getY() * fTexHeight * fRealDepthRight,
- pEntLeft->TexCoor().getY() * fTexHeight * fRealDepthLeft,
- nSize);
- }
- else
- {
- aIntTexSRight.Load(
- pEntRight->TexCoor().getX() * fTexWidth,
- pEntLeft->TexCoor().getX() * fTexWidth,
- nSize);
-
- aIntTexTRight.Load(
- pEntRight->TexCoor().getY() * fTexHeight,
- pEntLeft->TexCoor().getY() * fTexHeight,
- nSize);
- }
-}
-
-void Base3DDefault::LoadRight(sal_Int32 nSize)
-{
- aIntXPosRight.Load(aOutPointRight.X(), aOutPointLeft.X(), nSize);
- aIntDepthRight.Load(pEntRight->Point().getZ(), pEntLeft->Point().getZ(), nSize);
-}
-
-void Base3DDefault::NextStepRightTexture()
-{
- aIntXPosRight.Increment();
- aIntDepthRight.Increment();
-
- // #96837#
- if(mbPTCorrection)
- {
- aRealDepthRight.Increment();
- }
-
- aIntTexSRight.Increment();
- aIntTexTRight.Increment();
-}
-
-void Base3DDefault::NextStepRight()
-{
- aIntXPosRight.Increment();
- aIntDepthRight.Increment();
-}
-
-void Base3DDefault::NextStepLeftTexture()
-{
- aIntXPosLeft.Increment();
- aIntDepthLeft.Increment();
-
- // #96837#
- if(mbPTCorrection)
- {
- aRealDepthLeft.Increment();
- }
-
- aIntTexSLeft.Increment();
- aIntTexTLeft.Increment();
-}
-
-void Base3DDefault::NextStepLeft()
-{
- aIntXPosLeft.Increment();
- aIntDepthLeft.Increment();
-}
-
-// eof
diff --git a/goodies/source/base3d/b3ddeflt.hxx b/goodies/source/base3d/b3ddeflt.hxx
deleted file mode 100644
index 4e19c3b7ea6a..000000000000
--- a/goodies/source/base3d/b3ddeflt.hxx
+++ /dev/null
@@ -1,205 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3ddeflt.hxx,v $
- * $Revision: 1.7 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _B3D_B3DDEFLT_HXX
-#define _B3D_B3DDEFLT_HXX
-
-#include "b3dcommn.hxx"
-#include <vcl/bitmap.hxx>
-#include <vcl/salbtype.hxx>
-#include <vcl/alpha.hxx>
-#include <goodies/bxdintpo.hxx>
-
-/*************************************************************************
-|*
-|* Die Basisklasse fuer Standard 3D Ausgaben auf StarView Basis
-|*
-\************************************************************************/
-
-class Base3DDefault : public Base3DCommon
-{
-private:
- // ZBuffer auch als BitMap
- Bitmap aZBuffer;
-
- // Bitmap zum Zeichnen im Hintergrund
- Bitmap aPicture;
-
- // Bitmaps fuer die Transparenz
- Bitmap aMonoTransparence;
- AlphaMask aAlphaTransparence;
-
- // Position der oberen linken Ecke aus ImplSetViewport
- Rectangle aSizePixel;
-
- // Mit faktoren umgerechnete echte Bitmap-Groesse
- Rectangle aLocalSizePixel;
-
- // ZBuffer loeschwert
- BitmapColor aClearValue;
-
- // Zugriffe auf die BitMaps
- BitmapWriteAccess* pZBufferWrite;
- BitmapWriteAccess* pPictureWrite;
- BitmapWriteAccess* pTransparenceWrite;
-
- // Vergroeberungsstufe und dazugehoerige Variablen
- double fDetail;
- double fDetailBackup;
- sal_Int32 nMaxPixels;
-
- // Groesse der Textur, falls benutzt
- double fTexWidth;
- double fTexHeight;
-
- // Punktkoodinaten fuer Primitive
- Point aOutPointTop;
- Point aOutPointLeft;
- Point aOutPointRight;
-
- // Zeiger auf die Ursprungsdaten
- B3dEntity* pEntTop;
- B3dEntity* pEntLeft;
- B3dEntity* pEntRight;
-
- // benoetigte Interpolatoren
- BxdInterpolator aIntXPosLeft;
- BxdInterpolator aIntXPosRight;
-
- BxdInterpolator aIntDepthLeft;
- BxdInterpolator aIntDepthRight;
- BxdInterpolator aIntDepthLine;
-
- // #96837#
- // Added interpolators for real z coordinate in eye coor. In these,
- // 1/z is interpolated to have a base for perspective corrected texturing.
- BxdInterpolator aRealDepthLeft;
- BxdInterpolator aRealDepthRight;
- BxdInterpolator aRealDepthLine;
-
- BxdInterpolator aIntTexSLeft;
- BxdInterpolator aIntTexSRight;
- BxdInterpolator aIntTexTLeft;
- BxdInterpolator aIntTexTRight;
- BxdInterpolator aIntTexSLine;
- BxdInterpolator aIntTexTLine;
- B3dVectorInterpolator aIntVectorLeft;
- B3dVectorInterpolator aIntVectorRight;
- B3dVectorInterpolator aIntVectorLine;
- BxdColorInterpolator aIntColorLeft;
- BxdColorInterpolator aIntColorRight;
- BxdColorInterpolator aIntColorLine;
-
- // Lokale Scissor Region (ohne TopLeft)
- Rectangle aDefaultScissorRectangle;
-
- // #i71618#
- // derived from mfPolygonOffset in StartScene() using Z-Buffer depth
- sal_uInt32 maPolygonOffset;
-
- // bitfileld
- // Booleans fuer Zeichenoperationen
- unsigned bNormalsUsed : 1;
- unsigned bTextureUsed : 1;
-
- // Bool fuer Detailreduzierung
- unsigned bReducedDetail : 1;
- unsigned bDetailBackedup : 1;
-
- // #96837#
- // Bool for enabling/disabling perspective texture correction
- unsigned mbPTCorrection : 1;
-
- // Funktionen fuer erlangen/freigeben der BitmapAccesses
- void AcquireAccess();
- void ReleaseAccess();
-
- // Umrechnung auf PixelCoor der Bitmaps und zurueck
- Point GetPixelCoor(B3dEntity& rEntity);
- basegfx::B3DPoint Get3DCoor(Point& rPnt, double fDepth);
-
- // ZBuffer funktionen
- inline sal_Bool IsInScissorRegion(sal_Int32 nX, sal_Int32 nY);
- inline sal_Bool IsVisibleAndScissor(sal_Int32 nX, sal_Int32 nY, sal_uInt32 nDepth);
- inline void WritePixel(sal_Int32 nX, sal_Int32 nY, Color aColor, sal_uInt32 nDepth);
-
- // Zeilenerzeuger fuer Polygon
- /*inline*/ void DrawLinePhongTexture(sal_Int32 nYPos, B3dMaterial& rMat);
- /*inline*/ void DrawLinePhong(sal_Int32 nYPos, B3dMaterial& rMat);
- /*inline*/ void DrawLineColorTexture(sal_Int32 nYPos);
- /*inline*/ void DrawLineColor(sal_Int32 nYPos);
- /*inline*/ void DrawLineTexture(sal_Int32 nYPos, Color& rCol);
- /*inline*/ void DrawLine(sal_Int32 nYPos, Color& rCol);
-
- inline void LoadLeft(sal_Int32 nSize);
- inline void LoadLeftTexture(sal_Int32 nSize);
- inline void LoadRight(sal_Int32 nSize);
- inline void LoadRightTexture(sal_Int32 nSize);
-
- inline void NextStepRight();
- inline void NextStepRightTexture();
- inline void NextStepLeft();
- inline void NextStepLeftTexture();
-
-public:
- Base3DDefault(OutputDevice* pOutDev);
- virtual ~Base3DDefault();
-
- // Typbestimmung
- virtual UINT16 GetBase3DType();
-
- // Szenenverwaltung
- virtual void StartScene();
- virtual void EndScene();
-
- // Nullwert des ZBuffers setzen
- void SetClearValue(sal_uInt32 nNew) { aClearValue = Color(nNew); }
-
- // Detailstufe/Vergroeberung der Ausgabe setzen/lesen
- void SetDetail(double fNew=1.0);
- double GetDetail() { return fDetail; }
- void SetMaxPixels(sal_Int32 nNew=500000) { nMaxPixels = nNew; }
- sal_Int32 GetMaxPixels() { return nMaxPixels; }
- virtual void SetDisplayQuality(sal_uInt8 nNew);
-
- // Callbacks bei Matrixaenderungen
- virtual void SetTransformationSet(B3dTransformationSet* pSet);
-
-protected:
-
- // Geometrie
- virtual void Clipped3DPoint(sal_uInt32 nInd);
- virtual void Clipped3DLine(sal_uInt32 nInd1, sal_uInt32 nInd2);
- virtual void Clipped3DTriangle(sal_uInt32 nInd1, sal_uInt32 nInd2, sal_uInt32 nInd3);
-};
-
-
-
-#endif // _B3D_B3DDEFLT_HXX
diff --git a/goodies/source/base3d/b3dentty.cxx b/goodies/source/base3d/b3dentty.cxx
deleted file mode 100644
index 54ad3c01c8c8..000000000000
--- a/goodies/source/base3d/b3dentty.cxx
+++ /dev/null
@@ -1,330 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dentty.cxx,v $
- * $Revision: 1.7 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include <goodies/b3dentty.hxx>
-#include "b3dcommn.hxx"
-#include "b3dtrans.hxx"
-#include <tools/debug.hxx>
-
-/*************************************************************************
-|*
-|* Kopieren eine 3DEntity
-|*
-\************************************************************************/
-
-void B3dEntity::Copy(B3dEntity& rEnt)
-{
- maPoint = rEnt.maPoint;
- mbDeviceCoor = rEnt.IsDeviceCoor();
- mbValid = rEnt.IsValid();
- mbEdgeFlag = rEnt.mbEdgeFlag;
- maPlaneNormal = rEnt.maPlaneNormal;
-
- mbNormalUsed = rEnt.IsNormalUsed();
- if( mbNormalUsed )
- maNormal = rEnt.maNormal;
-
- mbTexCoorUsed = rEnt.IsTexCoorUsed();
- if( mbTexCoorUsed )
- maTexCoor = rEnt.maTexCoor;
-
- maColor = rEnt.maColor;
-}
-
-/*************************************************************************
-|*
-|* Flags auf Ausgangsposition
-|*
-\************************************************************************/
-
-void B3dEntity::Reset()
-{
- mbValid = mbNormalUsed = mbTexCoorUsed = mbDeviceCoor = sal_False;
- mbEdgeFlag = sal_True;
-}
-
-/*************************************************************************
-|*
-|* Device Koordinaten des Punktes berechnen
-|*
-\************************************************************************/
-
-void B3dEntity::ImplToDeviceCoor(B3dTransformationSet* pSet)
-{
- if(pSet && !mbDeviceCoor)
- {
- const basegfx::B3DVector& rScale = pSet->GetScale();
- const basegfx::B3DVector& rTrans = pSet->GetTranslate();
-
- maPoint.setX((maPoint.getX() * rScale.getX()) + rTrans.getX());
- maPoint.setY((maPoint.getY() * rScale.getY()) + rTrans.getY());
- maPoint.setZ((maPoint.getZ() * rScale.getZ()) + rTrans.getZ());
-
- mbDeviceCoor = sal_True;
- }
-}
-
-/*************************************************************************
-|*
-|* aus Device Koordinaten des Punktes 3D Koor im canonical view volume
-|* berechnen
-|*
-\************************************************************************/
-
-void B3dEntity::ImplTo3DCoor(B3dTransformationSet* pSet)
-{
- if(pSet && mbDeviceCoor)
- {
- const basegfx::B3DVector& rScale = pSet->GetScale();
- const basegfx::B3DVector& rTrans = pSet->GetTranslate();
-
- if(rScale.getX() != 0.0)
- maPoint.setX((maPoint.getX() - rTrans.getX()) / rScale.getX());
- if(rScale.getY() != 0.0)
- maPoint.setY((maPoint.getY() - rTrans.getY()) / rScale.getY());
- if(rScale.getZ() != 0.0)
- maPoint.setZ((maPoint.getZ() - rTrans.getZ()) / rScale.getZ());
-
- mbDeviceCoor = sal_False;
- }
-}
-
-/*************************************************************************
-|*
-|* Garantiere eine gemeinsame Datenbasis (ClipKoordinaten oder
-|* Devicekoordinaten)
-|*
-\************************************************************************/
-
-void B3dEntity::ForceEqualBase(B3dTransformationSet* pSet, B3dEntity& rOld)
-{
- if(IsDeviceCoor() && rOld.IsDeviceCoor())
- {
- SetDeviceCoor();
- }
- else
- {
- if(IsDeviceCoor())
- To3DCoor(pSet);
- if(rOld.IsDeviceCoor())
- rOld.To3DCoor(pSet);
- }
-}
-
-/*************************************************************************
-|*
-|* Garantiere eine gemeinsame Datenbasis (ClipKoordinaten oder
-|* Devicekoordinaten)
-|*
-\************************************************************************/
-
-void B3dEntity::ForceEqualBase(B3dTransformationSet* pSet, B3dEntity& rOld1,
- B3dEntity& rOld2)
-{
- if(!IsDeviceCoor() && rOld1.IsDeviceCoor() && rOld2.IsDeviceCoor())
- {
- if(IsDeviceCoor())
- To3DCoor(pSet);
- if(rOld1.IsDeviceCoor())
- rOld1.To3DCoor(pSet);
- if(rOld2.IsDeviceCoor())
- rOld2.To3DCoor(pSet);
- }
-}
-
-/*************************************************************************
-|*
-|* Neuen Punkt an der stelle t des parametrisierten Vektors rOld1, rOld2
-|* berechnen und fuellen
-|*
-\************************************************************************/
-
-void B3dEntity::CalcInBetween(B3dEntity& rOld1, B3dEntity& rOld2, double t)
-{
- // DeviceCoor der ersten Quelle benutzen, die Basis sollte
- // vorher abgeglichen sein
- SetDeviceCoor(rOld1.IsDeviceCoor());
-
- // Punktkoordinaten berechnen
- maPoint = interpolate(rOld1.Point(), rOld2.Point(), t);
- SetValid();
-
- // PlaneNormal Koordinaten berechnen
- rOld1.PlaneNormal().normalize();
- rOld2.PlaneNormal().normalize();
- maPlaneNormal = interpolate(rOld1.PlaneNormal(), rOld2.PlaneNormal(), t);
- maPlaneNormal.normalize();
-
- // Vektor berechnen
- if(rOld1.IsNormalUsed() && rOld2.IsNormalUsed())
- {
- rOld1.Normal().normalize();
- rOld2.Normal().normalize();
- maNormal = interpolate(rOld1.Normal(), rOld2.Normal(), t);
- maNormal.normalize();
- SetNormalUsed();
- }
-
- // Texturkoordinaten berechnen
- if(rOld1.IsTexCoorUsed() && rOld2.IsTexCoorUsed())
- {
- maTexCoor = interpolate(rOld1.TexCoor(), rOld2.TexCoor(), t);
- SetTexCoorUsed();
- }
-
- // EdgeVisible berechnen
- SetEdgeVisible(rOld1.IsEdgeVisible());
-
- // Farbe berechnen
- maColor.CalcInBetween(rOld1.Color(), rOld2.Color(), t);
-}
-
-/*************************************************************************
-|*
-|* Neuen Punkt in der Mitte des parametrisierten Vektors rOld1, rOld2
-|* berechnen und fuellen
-|*
-\************************************************************************/
-
-void B3dEntity::CalcMiddle(B3dEntity& rOld1, B3dEntity& rOld2)
-{
- // DeviceCoor der ersten Quelle benutzen, die Basis sollte
- // vorher abgeglichen sein
- SetDeviceCoor(rOld1.IsDeviceCoor());
-
- // Punktkoordinaten berechnen
- maPoint = average(rOld1.Point(), rOld2.Point());
- SetValid();
-
- // PlaneNormal Koordinaten berechnen
- rOld1.PlaneNormal().normalize();
- rOld2.PlaneNormal().normalize();
- maPlaneNormal = average(rOld1.PlaneNormal(), rOld2.PlaneNormal());
- maPlaneNormal.normalize();
-
- // Vektor berechnen
- if(rOld1.IsNormalUsed() && rOld2.IsNormalUsed())
- {
- rOld1.Normal().normalize();
- rOld2.Normal().normalize();
- maNormal = average(rOld1.Normal(), rOld2.Normal());
- maNormal.normalize();
- SetNormalUsed();
- }
-
- // Texturkoordinaten berechnen
- if(rOld1.IsTexCoorUsed() && rOld2.IsTexCoorUsed())
- {
- maTexCoor = average(rOld1.TexCoor(), rOld2.TexCoor());
- SetTexCoorUsed();
- }
-
- // EdgeVisible berechnen
- SetEdgeVisible(rOld1.IsEdgeVisible());
-
- // Farbe berechnen
- maColor.CalcMiddle(rOld1.Color(), rOld2.Color());
-}
-
-/*************************************************************************
-|*
-|* Neuen Punkt in der Mitte des Dreiecks rOld1, rOld2, rOld3
-|* berechnen und fuellen
-|*
-\************************************************************************/
-
-void B3dEntity::CalcMiddle(B3dEntity& rOld1, B3dEntity& rOld2,
- B3dEntity& rOld3)
-{
- // DeviceCoor der ersten Quelle benutzen, die Basis sollte
- // vorher abgeglichen sein
- SetDeviceCoor(rOld1.IsDeviceCoor());
-
- // Punktkoordinaten berechnen
- maPoint = average(rOld1.Point(), rOld2.Point(), rOld3.Point());
- SetValid();
-
- // PlaneNormal Koordinaten berechnen
- rOld1.PlaneNormal().normalize();
- rOld2.PlaneNormal().normalize();
- rOld3.PlaneNormal().normalize();
- maPlaneNormal = average(rOld1.PlaneNormal(), rOld2.PlaneNormal(), rOld3.PlaneNormal());
- maPlaneNormal.normalize();
-
- // Vektor berechnen
- if(rOld1.IsNormalUsed() && rOld2.IsNormalUsed() && rOld3.IsNormalUsed())
- {
- rOld1.Normal().normalize();
- rOld2.Normal().normalize();
- rOld3.Normal().normalize();
- maNormal = average(rOld1.Normal(), rOld2.Normal(), rOld3.Normal());
- maNormal.normalize();
- SetNormalUsed();
- }
-
- // Texturkoordinaten berechnen
- if(rOld1.IsTexCoorUsed() && rOld2.IsTexCoorUsed() && rOld3.IsTexCoorUsed())
- {
- maTexCoor = average(rOld1.TexCoor(), rOld2.TexCoor(), rOld3.TexCoor());
- SetTexCoorUsed();
- }
-
- // Farbe berechnen
- maColor.CalcMiddle(rOld1.Color(), rOld2.Color(), rOld3.Color());
-}
-
-/*************************************************************************
-|*
-|* Eine beliebige Transformation auf die Geometrie anwenden
-|*
-\************************************************************************/
-
-void B3dEntity::Transform(const basegfx::B3DHomMatrix& rMat)
-{
- maPoint *= rMat;
-
- if(mbNormalUsed)
- {
- maNormal *= rMat; // RotateAndNormalize
- maNormal.normalize();
- }
-}
-
-/*************************************************************************
-|*
-|* Bucket fuer geometrische Daten
-|*
-\************************************************************************/
-
-BASE3D_IMPL_BUCKET(B3dEntity, Bucket)
-
-// eof
diff --git a/goodies/source/base3d/b3dgeom.cxx b/goodies/source/base3d/b3dgeom.cxx
deleted file mode 100644
index af107ee15411..000000000000
--- a/goodies/source/base3d/b3dgeom.cxx
+++ /dev/null
@@ -1,975 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dgeom.cxx,v $
- * $Revision: 1.13 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include <goodies/b3dgeom.hxx>
-#include <goodies/b3dcompo.hxx>
-
-//#ifndef _B3D_HMATRIX_HXX
-//#include "hmatrix.hxx"
-//#endif
-#include <goodies/base3d.hxx>
-#include <tools/debug.hxx>
-
-#ifndef _INC_MATH
-#include <math.h>
-#endif
-#include <basegfx/matrix/b3dhommatrix.hxx>
-
-/*************************************************************************
-|*
-|* Bucket fuer Index
-|*
-\************************************************************************/
-
-BASE3D_IMPL_BUCKET(GeometryIndexValue, Bucket)
-
-/*************************************************************************
-|*
-|* Konstruktor
-|*
-\************************************************************************/
-
-B3dGeometry::B3dGeometry()
-: pComplexPolygon(NULL),
- aEntityBucket(14), // 16K
- aIndexBucket(8) // 256Byte
-{
- Reset();
-}
-
-/*************************************************************************
-|*
-|* Ausgangszustand der Variablen herstellen
-|*
-\************************************************************************/
-
-void B3dGeometry::Reset()
-{
- bHintIsComplex = sal_False;
- if(pComplexPolygon)
- delete pComplexPolygon;
- pComplexPolygon = NULL;
-
- // #93136# since #92030# uses bOutline flag now as indication
- // if the filled object is to be drawn, it MUST be initialized now.
- bOutline = sal_False;
-}
-
-/*************************************************************************
-|*
-|* Freien Eintrag zum fuellen holen
-|*
-\************************************************************************/
-
-B3dEntity& B3dGeometry::GetFreeEntity()
-{
- aEntityBucket.Append();
- return aEntityBucket[aEntityBucket.Count() - 1];
-}
-
-/*************************************************************************
-|*
-|* Inhalte loeschen
-|*
-\************************************************************************/
-
-void B3dGeometry::Erase()
-{
- aEntityBucket.Erase();
- aIndexBucket.Erase();
- Reset();
-}
-
-/*************************************************************************
-|*
-|* Inhalte loeschen und Speicher freigeben
-|*
-\************************************************************************/
-
-void B3dGeometry::Empty()
-{
- aEntityBucket.Empty();
- aIndexBucket.Empty();
- Reset();
-}
-
-/*************************************************************************
-|*
-|* Start der Geometriebeschreibung
-|*
-\************************************************************************/
-
-void B3dGeometry::StartDescription()
-{
- Erase();
-}
-
-/*************************************************************************
-|*
-|* Ende der Geometriebeschreibung
-|*
-\************************************************************************/
-
-void B3dGeometry::EndDescription()
-{
- if(pComplexPolygon)
- delete pComplexPolygon;
- pComplexPolygon = NULL;
-}
-
-/*************************************************************************
-|*
-|* Neues Primitiv beginnen
-|*
-\************************************************************************/
-
-void B3dGeometry::StartObject(sal_Bool bHintComplex, sal_Bool bOutl)
-{
- // Hint uebernehmen
- bHintIsComplex = bHintComplex;
- bOutline = bOutl;
-
- // ComplexPolygon anlegen falls nicht vorhanden
- if(bHintIsComplex)
- {
- if(!pComplexPolygon)
- pComplexPolygon = new B3dComplexPolygon;
- pComplexPolygon->StartPrimitive();
- }
- else
- {
- // Direkt neues Polygon beginnen
- StartPolygon();
- }
-}
-
-/*************************************************************************
-|*
-|* Primitiv abschliessen
-|*
-\************************************************************************/
-
-void B3dGeometry::EndObject()
-{
- // Unteren Index holen
- sal_uInt32 nLow = 0L;
- if(aIndexBucket.Count())
- nLow = aIndexBucket[aIndexBucket.Count()-1].GetIndex();
-
- if(bHintIsComplex)
- {
- pComplexPolygon->EndPrimitive(this);
- }
- else
- {
- // Polygon abschliessen
- EndPolygon();
- }
-
- // EbenenNormale berechnen und setzen; bei Linien und
- // Punkten wird PlaneNormal auf (0,0,0) gesetzt
- if(aIndexBucket.Count())
- {
- sal_uInt32 nHigh = aIndexBucket[aIndexBucket.Count()-1].GetIndex();
- basegfx::B3DVector aPlaneNormal = -CalcNormal(nLow, nHigh);
- while(nLow < nHigh)
- aEntityBucket[nLow++].PlaneNormal() = aPlaneNormal;
- }
-}
-
-/*************************************************************************
-|*
-|* Geometrieuebergabe
-|*
-\************************************************************************/
-
-void B3dGeometry::AddEdge(const basegfx::B3DPoint& rPoint)
-{
- if(bHintIsComplex)
- {
- B3dEntity& rNew = pComplexPolygon->GetFreeEntity();
-
- rNew.Reset();
- rNew.Point() = rPoint;
- rNew.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rNew.SetValid();
- rNew.SetEdgeVisible(sal_True);
-
- pComplexPolygon->PostAddVertex(rNew);
- }
- else
- {
- B3dEntity& rNew = GetFreeEntity();
-
- rNew.Reset();
- rNew.Point() = rPoint;
- rNew.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rNew.SetValid();
- rNew.SetEdgeVisible(sal_True);
- }
-}
-
-void B3dGeometry::AddEdge(const basegfx::B3DPoint& rPoint, const basegfx::B3DVector& rNormal)
-{
- if(bHintIsComplex)
- {
- B3dEntity& rNew = pComplexPolygon->GetFreeEntity();
-
- rNew.Reset();
- rNew.Point() = rPoint;
- rNew.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rNew.SetValid();
- rNew.Normal() = rNormal;
- rNew.SetNormalUsed();
- rNew.SetEdgeVisible(sal_True);
-
- pComplexPolygon->PostAddVertex(rNew);
- }
- else
- {
- B3dEntity& rNew = GetFreeEntity();
-
- rNew.Reset();
- rNew.Point() = rPoint;
- rNew.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rNew.SetValid();
- rNew.Normal() = rNormal;
- rNew.SetNormalUsed();
- rNew.SetEdgeVisible(sal_True);
- }
-}
-
-void B3dGeometry::AddEdge(const basegfx::B3DPoint& rPoint, const basegfx::B3DVector& rNormal, const basegfx::B2DPoint& rTexture)
-{
- if(bHintIsComplex)
- {
- B3dEntity& rNew = pComplexPolygon->GetFreeEntity();
-
- rNew.Reset();
- rNew.Point() = rPoint;
- rNew.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rNew.SetValid();
- rNew.Normal() = rNormal;
- rNew.SetNormalUsed();
- rNew.TexCoor() = rTexture;
- rNew.SetTexCoorUsed();
- rNew.SetEdgeVisible(sal_True);
-
- pComplexPolygon->PostAddVertex(rNew);
- }
- else
- {
- B3dEntity& rNew = GetFreeEntity();
-
- rNew.Reset();
- rNew.Point() = rPoint;
- rNew.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rNew.SetValid();
- rNew.Normal() = rNormal;
- rNew.SetNormalUsed();
- rNew.TexCoor() = rTexture;
- rNew.SetTexCoorUsed();
- rNew.SetEdgeVisible(sal_True);
- }
-}
-
-/*************************************************************************
-|*
-|* Copy-Operator
-|*
-\************************************************************************/
-
-void B3dGeometry::operator=(const B3dGeometry& rObj)
-{
- // Bucket kopieren
- aEntityBucket = rObj.aEntityBucket;
- aIndexBucket = rObj.aIndexBucket;
-
- // ComplexPolygon nicht kopieren
- pComplexPolygon = NULL;
-
- // Hint auch nicht
- bHintIsComplex = sal_False;
-}
-
-/*************************************************************************
-|*
-|* Callbacks bei komplexen Primitiven
-|*
-\************************************************************************/
-
-void B3dGeometry::StartComplexPrimitive()
-{
- StartPolygon();
-}
-
-void B3dGeometry::EndComplexPrimitive()
-{
- EndPolygon();
-}
-
-void B3dGeometry::AddComplexVertex(B3dEntity& rNew, sal_Bool bIsVisible)
-{
- // Kopieren
- B3dEntity& rLocal = GetFreeEntity();
- rLocal = rNew;
-
- // EdgeFlag anpassen
- rLocal.SetEdgeVisible(bIsVisible);
-}
-
-/*************************************************************************
-|*
-|* PolygonStart und -Ende aufzeichnen
-|*
-\************************************************************************/
-
-void B3dGeometry::StartPolygon()
-{
-}
-
-void B3dGeometry::EndPolygon()
-{
- GeometryIndexValue aNewIndex(aEntityBucket.Count());
- if(bOutline)
- aNewIndex.SetMode(B3D_INDEX_MODE_LINE);
- aIndexBucket.Append(aNewIndex);
-}
-
-/*************************************************************************
-|*
-|* Eine beliebige Transformation auf die Geometrie anwenden
-|*
-\************************************************************************/
-
-void B3dGeometry::Transform(const basegfx::B3DHomMatrix& rMat)
-{
- for(sal_uInt32 a=0;a<aEntityBucket.Count();a++)
- aEntityBucket[a].Transform(rMat);
-}
-
-/*************************************************************************
-|*
-|* Hittest auf Geometrie
-|* Liegt der angegebene Schnittpunkt innerhalb eines der Polygone?
-|*
-\************************************************************************/
-
-sal_Bool B3dGeometry::CheckHit(const basegfx::B3DPoint& rFront, const basegfx::B3DPoint& rBack, sal_uInt16 /*nTol*/)
-{
- sal_uInt32 nPolyCounter(0L);
- sal_uInt32 nEntityCounter(0L);
- sal_uInt32 nUpperBound(0L);
-
- while(nPolyCounter < aIndexBucket.Count())
- {
- // Obergrenze neues Polygon holen
- nUpperBound = aIndexBucket[nPolyCounter++].GetIndex();
-
- // Hittest fuer momentanes Polygon
- basegfx::B3DPoint aCut;
-
- if(CheckSinglePolygonHit(nEntityCounter, nUpperBound, rFront, rBack, aCut))
- {
- return sal_True;
- }
-
- // Auf naechstes Polygon
- nEntityCounter = nUpperBound;
- }
-
- return sal_False;
-}
-
-// #110988# get all cuts of the geometry with the given vector defined by the two positions
-void B3dGeometry::GetAllCuts(::std::vector< basegfx::B3DPoint >& rVector, const basegfx::B3DPoint& rFront, const basegfx::B3DPoint& rBack) const
-{
- sal_uInt32 nPolyCounter(0L);
- sal_uInt32 nEntityCounter(0L);
- sal_uInt32 nUpperBound;
-
- while(nPolyCounter < ((B3dGeometry*)this)->aIndexBucket.Count())
- {
- // get upper bound for new polygon
- nUpperBound = ((B3dGeometry*)this)->aIndexBucket[nPolyCounter++].GetIndex();
-
- // get cut for that polygon
- basegfx::B3DPoint aCut;
-
- if(CheckSinglePolygonHit(nEntityCounter, nUpperBound, rFront, rBack, aCut))
- {
- rVector.push_back(aCut);
- }
-
- // Auf naechstes Polygon
- nEntityCounter = nUpperBound;
- }
-}
-
-sal_Bool B3dGeometry::CheckSinglePolygonHit(sal_uInt32 nLow, sal_uInt32 nHigh, const basegfx::B3DPoint& rFront, const basegfx::B3DPoint& rBack, basegfx::B3DPoint& rCut) const
-{
- if(nLow + 2 < nHigh)
- {
- // calculate cut with plane
- if(GetCutPoint(nLow, rCut, rFront, rBack))
- {
- // cut exists, is it inside the polygon?
- if(IsInside(nLow, nHigh, rCut))
- {
- return sal_True;
- }
- }
- }
-
- return sal_False;
-}
-
-sal_Bool B3dGeometry::GetCutPoint(sal_uInt32 nLow, basegfx::B3DPoint& rCut, const basegfx::B3DPoint& rFront, const basegfx::B3DPoint& rBack) const
-{
- sal_Bool bCutValid = sal_False;
-
- // Normale und Skalar der Ebenengleichung ermitteln
- const basegfx::B3DVector aNormal = ((B3dGeometry*)this)->aEntityBucket[nLow].PlaneNormal();
- const basegfx::B3DVector aPointAsVec = ((B3dGeometry*)this)->aEntityBucket[nLow + 1].Point();
- double fScalar = -(aPointAsVec.scalar(aNormal));
- basegfx::B3DVector aLineVec = rFront - rBack;
- double fZwi = aNormal.scalar(aLineVec);
-
- if(fabs(fZwi) > SMALL_DVALUE)
- {
- fZwi = (-fScalar - (basegfx::B3DVector(rBack).scalar(aNormal))) / fZwi;
- rCut.setX(rBack.getX() + (aLineVec.getX() * fZwi));
- rCut.setY(rBack.getY() + (aLineVec.getY() * fZwi));
- rCut.setZ(rBack.getZ() + (aLineVec.getZ() * fZwi));
-
- bCutValid = sal_True;
- }
- return bCutValid;
-}
-
-sal_Bool B3dGeometry::IsInside(sal_uInt32 nLow, sal_uInt32 nHigh, const basegfx::B3DPoint& rPnt) const
-{
- sal_Bool bInside(sal_False);
- basegfx::B3DRange aVolume;
-
- // Volume von genau dieser Flaeche feststellen
- for(sal_uInt32 a=nLow;a<nHigh;a++)
- aVolume.expand(((B3dGeometry*)this)->aEntityBucket[a].Point());
-
- // Hier eigentlich ein aVolume.IsInside(rPnt), doch da hier ein
- // Vergleich mit Epsilon-Umgebung gebraucht wird, vergleiche selbst
- sal_Bool bIsInside =
- (rPnt.getX() + SMALL_DVALUE >= aVolume.getMinX() && rPnt.getX() - SMALL_DVALUE <= aVolume.getMaxX()
- && rPnt.getY() + SMALL_DVALUE >= aVolume.getMinY() && rPnt.getY() - SMALL_DVALUE <= aVolume.getMaxY()
- && rPnt.getZ() + SMALL_DVALUE >= aVolume.getMinZ() && rPnt.getZ() - SMALL_DVALUE <= aVolume.getMaxZ());
-
- if(bIsInside)
- {
- sal_Bool bInsideXY(sal_False);
- sal_Bool bInsideXZ(sal_False);
- sal_Bool bInsideYZ(sal_False);
- const basegfx::B3DPoint* pPrev = &(((B3dGeometry*)this)->aEntityBucket[nHigh - 1].Point());
- const basegfx::B3DPoint* pActual;
- basegfx::B3DVector aDiffPrev, aDiffActual;
-
- while(nLow < nHigh)
- {
- // Neuen Punkt holen
- pActual = &(((B3dGeometry*)this)->aEntityBucket[nLow++].Point());
-
- // Diffs bilden
- aDiffPrev = *pPrev - rPnt;
- aDiffActual = *pActual - rPnt;
-
- // Ueberschneidung in Y moeglich?
- if((aDiffPrev.getY() > 0.0 && aDiffActual.getY() <= 0.0) || (aDiffActual.getY() > 0.0 && aDiffPrev.getY() <= 0.0))
- {
- // in welchem Bereich liegt X?
- if(aDiffPrev.getX() >= 0.0 && aDiffActual.getX() >= 0.0)
- {
- // Ueberschneidung
- bInsideXY = !bInsideXY;
- }
- else if((aDiffPrev.getX() > 0.0 && aDiffActual.getX() <= 0.0) || (aDiffActual.getX() > 0.0 && aDiffPrev.getX() <= 0.0))
- {
- // eventuell Ueberschneidung
- // wo liegt die X-Koordinate des Schnitts mit der X-Achse?
- if(aDiffActual.getY() != aDiffPrev.getY())
- if(aDiffPrev.getX() - ((aDiffPrev.getY() * (aDiffActual.getX() - aDiffPrev.getX())) / (aDiffActual.getY() - aDiffPrev.getY())) >= 0.0)
- // Ueberschneidung
- bInsideXY = !bInsideXY;
- }
-
- // in welchem Bereich liegt Z?
- if(aDiffPrev.getZ() >= 0.0 && aDiffActual.getZ() >= 0.0)
- {
- // Ueberschneidung
- bInsideYZ = !bInsideYZ;
- }
- else if((aDiffPrev.getZ() > 0.0 && aDiffActual.getZ() <= 0.0) || (aDiffActual.getZ() > 0.0 && aDiffPrev.getZ() <= 0.0))
- {
- // eventuell Ueberschneidung
- // wo liegt die X-Koordinate des Schnitts mit der X-Achse?
- if(aDiffActual.getY() != aDiffPrev.getY())
- if(aDiffPrev.getZ() - ((aDiffPrev.getY() * (aDiffActual.getZ() - aDiffPrev.getZ())) / (aDiffActual.getY() - aDiffPrev.getY())) >= 0.0)
- // Ueberschneidung
- bInsideYZ = !bInsideYZ;
- }
- }
-
- // Ueberschneidung in X moeglich?
- if((aDiffPrev.getX() > 0.0 && aDiffActual.getX() <= 0.0) || (aDiffActual.getX() > 0.0 && aDiffPrev.getX() <= 0.0))
- {
- // in welchem Bereich liegt Z?
- if(aDiffPrev.getZ() >= 0.0 && aDiffActual.getZ() >= 0.0)
- {
- // Ueberschneidung
- bInsideXZ = !bInsideXZ;
- }
- else if((aDiffPrev.getZ() > 0.0 && aDiffActual.getZ() <= 0.0) || (aDiffActual.getZ() > 0.0 && aDiffPrev.getZ() <= 0.0))
- {
- // eventuell Ueberschneidung
- // wo liegt die X-Koordinate des Schnitts mit der X-Achse?
- if(aDiffActual.getX() != aDiffPrev.getX())
- if(aDiffPrev.getZ() - ((aDiffPrev.getX() * (aDiffActual.getZ() - aDiffPrev.getZ())) / (aDiffActual.getX() - aDiffPrev.getX())) >= 0.0)
- // Ueberschneidung
- bInsideXZ = !bInsideXZ;
- }
- }
-
- // Punkt als Vorgaenger merken
- pPrev = pActual;
- }
- // Wahrheitswert bilden
- bInside = bInsideXY || bInsideXZ || bInsideYZ;
- }
- return bInside;
-}
-
-/*************************************************************************
-|*
-|* BoundVolume liefern
-|*
-\************************************************************************/
-
-basegfx::B3DRange B3dGeometry::GetBoundVolume() const
-{
- basegfx::B3DRange aRetval;
-
- for(sal_uInt32 a=0;a<((B3dGeometry*)this)->aEntityBucket.Count();a++)
- {
- aRetval.expand(((B3dGeometry*)this)->aEntityBucket[a].Point());
- }
-
- return aRetval;
-}
-
-/*************************************************************************
-|*
-|* Mittelpunkt liefern
-|*
-\************************************************************************/
-
-basegfx::B3DPoint B3dGeometry::GetCenter() const
-{
- basegfx::B3DRange aVolume = GetBoundVolume();
- return aVolume.getCenter();
-}
-
-/*************************************************************************
-|*
-|* Standard - Normalen generieren
-|*
-\************************************************************************/
-
-void B3dGeometry::CreateDefaultNormalsSphere()
-{
- // Alle Normalen ausgehend vom Zentrum der Geometrie bilden
- basegfx::B3DPoint aCenter = GetCenter();
-
- for(sal_uInt32 a=0;a<aEntityBucket.Count();a++)
- {
- const basegfx::B3DPoint& aPoint = aEntityBucket[a].Point();
- basegfx::B3DVector aNewNormal = aPoint - aCenter;
- aNewNormal.normalize();
- aEntityBucket[a].Normal() = aNewNormal;
- aEntityBucket[a].SetNormalUsed(sal_True);
- }
-}
-
-/*************************************************************************
-|*
-|* Normale ermitteln fuer einzelnes Polygon
-|*
-\************************************************************************/
-
-basegfx::B3DVector B3dGeometry::CalcNormal(sal_uInt32 nLow, sal_uInt32 nHigh) const
-{
- const basegfx::B3DPoint* pVec1 = NULL;
- const basegfx::B3DPoint* pVec2 = NULL;
- const basegfx::B3DPoint* pVec3 = NULL;
- basegfx::B3DVector aNormal;
-
- while(nLow < nHigh && !(pVec1 && pVec2 && pVec3))
- {
- if(!pVec1)
- {
- pVec1 = &(((B3dGeometry*)this)->aEntityBucket[nLow++].Point());
- }
- else if(!pVec2)
- {
- pVec2 = &(((B3dGeometry*)this)->aEntityBucket[nLow++].Point());
- if(*pVec2 == *pVec1)
- pVec2 = NULL;
- }
- else if(!pVec3)
- {
- pVec3 = &(((B3dGeometry*)this)->aEntityBucket[nLow++].Point());
- if(*pVec3 == *pVec2 || *pVec3 == *pVec1) // #125865#
- pVec3 = NULL;
- }
- }
- if(pVec1 && pVec2 && pVec3)
- {
- aNormal = basegfx::B3DVector(*pVec2 - *pVec1).getPerpendicular(basegfx::B3DVector(*pVec2 - *pVec3));
- aNormal.normalize();
- }
- return aNormal;
-}
-
-/*************************************************************************
-|*
-|* Normaleninformationen ungueltig machen
-|*
-\************************************************************************/
-
-void B3dGeometry::RemoveNormals()
-{
- for(sal_uInt32 a=0;a<aEntityBucket.Count();a++)
- aEntityBucket[a].SetNormalUsed(sal_False);
-}
-
-/*************************************************************************
-|*
-|* Standard - Texturkoordinaten generieren
-|*
-\************************************************************************/
-
-void B3dGeometry::CreateDefaultTexture(sal_uInt16 nCreateWhat, sal_Bool bUseSphere)
-{
- if(nCreateWhat)
- {
- if(bUseSphere)
- {
- // Texturkoordinaten mittels Kugelprojektion ermitteln,
- // dazu das Zentrum der Geometrie benutzen
- // Alle Normalen ausgehend vom Zentrum der Geometrie bilden
- basegfx::B3DPoint aCenter = GetCenter();
- sal_uInt32 nPointCounter = 0;
-
- for(sal_uInt32 a=0;a<aIndexBucket.Count();a++)
- {
- // Lokales Zentrum der zu behandelnden Flaeche bilden,
- // um zu wissen von welcher Seite sich diese Flaeche
- // dem Winkel F_PI bzw. -F_PI naehert
- basegfx::B3DVector aLocalCenter;
- for(sal_uInt32 b=nPointCounter;b<aIndexBucket[a].GetIndex();b++)
- aLocalCenter += aEntityBucket[b].Point();
- aLocalCenter /= aIndexBucket[a].GetIndex() - nPointCounter;
-
- // Vektor vom Mittelpunkt zum lokalen Zentrum bilden
- if(fabs(aLocalCenter.getX()) < SMALL_DVALUE)
- aLocalCenter.setX(0.0);
- if(fabs(aLocalCenter.getY()) < SMALL_DVALUE)
- aLocalCenter.setY(0.0);
- if(fabs(aLocalCenter.getZ()) < SMALL_DVALUE)
- aLocalCenter.setZ(0.0);
-
- // X,Y fuer das lokale Zentrum bilden
- double fXCenter = atan2(aLocalCenter.getZ(), aLocalCenter.getX());
- double fYCenter = atan2(aLocalCenter.getY(), aLocalCenter.getXZLength());
- fXCenter = 1.0 - ((fXCenter + F_PI) / F_2PI);
- fYCenter = 1.0 - ((fYCenter + F_PI2) / F_PI);
-
- // Einzelne Punkte behandeln
- sal_uInt32 nRememberPointCounter = nPointCounter;
- while(nPointCounter < aIndexBucket[a].GetIndex())
- {
- // Vektor vom Mittelpunkt zum Punkt bilden
- const basegfx::B3DPoint& aPoint = aEntityBucket[nPointCounter].Point();
- basegfx::B3DVector aDirection = aPoint - aCenter;
- if(fabs(aDirection.getX()) < SMALL_DVALUE)
- aDirection.setX(0.0);
- if(fabs(aDirection.getY()) < SMALL_DVALUE)
- aDirection.setY(0.0);
- if(fabs(aDirection.getZ()) < SMALL_DVALUE)
- aDirection.setZ(0.0);
-
- // X,Y fuer Punkt bilden
- double fXPoint = atan2(aDirection.getZ(), aDirection.getX());
- double fYPoint = atan2(aDirection.getY(), aDirection.getXZLength());
- fXPoint = 1.0 - ((fXPoint + F_PI) / F_2PI);
- fYPoint = 1.0 - ((fYPoint + F_PI2) / F_PI);
-
- // X,Y des Punktes korrigieren
- if(fXPoint > fXCenter + 0.5)
- fXPoint -= 1.0;
- if(fXPoint < fXCenter - 0.5)
- fXPoint += 1.0;
-
- // Polarkoordinaten als Texturkoordinaten zuweisen
- if(nCreateWhat & B3D_CREATE_DEFAULT_X)
- aEntityBucket[nPointCounter].TexCoor().setX(fXPoint);
- if(nCreateWhat & B3D_CREATE_DEFAULT_Y)
- aEntityBucket[nPointCounter].TexCoor().setY(fYPoint);
-
- aEntityBucket[nPointCounter++].SetTexCoorUsed(sal_True);
- }
-
- // Punkte korrigieren, die direkt in den Polarregionen liegen. Deren
- // X-Koordinate kann nicht korrekt sein. Die korrekte X-Koordinate
- // ist diejenige des Punktes, der in den Pol hinein oder aus diesem heraus
- // fuehrt, auf der Kugel also direkt darauf zu.
- if(nCreateWhat & B3D_CREATE_DEFAULT_X)
- {
- nPointCounter = nRememberPointCounter;
- while(nPointCounter < aIndexBucket[a].GetIndex())
- {
- basegfx::B2DPoint& aCoor = aEntityBucket[nPointCounter].TexCoor();
- if(fabs(aCoor.getY()) < SMALL_DVALUE || fabs(aCoor.getY() - 1.0) < SMALL_DVALUE)
- {
- // Nachfolger finden
- sal_uInt32 nNextIndex = (nPointCounter + 1 < aIndexBucket[a].GetIndex())
- ? nPointCounter + 1 : nRememberPointCounter;
- basegfx::B2DPoint& aNextCoor = aEntityBucket[nNextIndex].TexCoor();
-
- // Vorgaenger finden
- sal_uInt32 nPrevIndex = (nPointCounter && nPointCounter - 1 >= nRememberPointCounter)
- ? nPointCounter - 1 : aIndexBucket[a].GetIndex() - 1;
- basegfx::B2DPoint& aPrevCoor = aEntityBucket[nPrevIndex].TexCoor();
-
- // Nachfolger testen: Liegt dieser ausserhalb des Pols?
- if(fabs(aNextCoor.getY()) > SMALL_DVALUE && fabs(aNextCoor.getY() - 1.0) > SMALL_DVALUE)
- {
- // falls ja: X-Koordinate uebernehmen
- aCoor.setX(aNextCoor.getX());
- }
- // Vorgaenger testen: Liegt dieser ausserhalb des Pols?
- else if(fabs(aPrevCoor.getY()) > SMALL_DVALUE && fabs(aPrevCoor.getY() - 1.0) > SMALL_DVALUE)
- {
- // falls ja, X-Koordinate uebernehmen
- aCoor.setX(aPrevCoor.getX());
- }
- else
- {
- // Weder Vorgaenger noch Nachfolger liegen ausserhalb des Pols.
- // Uebernimm daher wenigstens den bereits korrigierten X-Wert
- // des Vorgaengers
- aCoor.setX(aPrevCoor.getX());
- }
- }
- // naechster Punkt
- nPointCounter++;
- }
- }
- }
- }
- else
- {
- // Texturkoordinaten als Parallelprojektion auf X,Y,Z - Koordinaten
- // im Bereich 1.0 bis 0.0 der Geometrie abstellen
- // Gesamtabmessungen holen
- basegfx::B3DRange aVolume = GetBoundVolume();
-
- for(sal_uInt32 a=0;a<aEntityBucket.Count();a++)
- {
- const basegfx::B3DPoint& aPoint = aEntityBucket[a].Point();
-
- if(nCreateWhat & B3D_CREATE_DEFAULT_X)
- {
- if(aVolume.getWidth())
- aEntityBucket[a].TexCoor().setX((aPoint.getX() - aVolume.getMinX()) / aVolume.getWidth());
- else
- aEntityBucket[a].TexCoor().setX(0.0);
- }
-
- if(nCreateWhat & B3D_CREATE_DEFAULT_Y)
- {
- if(aVolume.getHeight())
- aEntityBucket[a].TexCoor().setY(1.0 - ((aPoint.getY() - aVolume.getMinY()) / aVolume.getHeight()));
- else
- aEntityBucket[a].TexCoor().setY(1.0);
- }
-
- aEntityBucket[a].SetTexCoorUsed(sal_True);
- }
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Texturinformationen ungueltig machen
-|*
-\************************************************************************/
-
-void B3dGeometry::RemoveTexture()
-{
- for(sal_uInt32 a=0;a<aEntityBucket.Count();a++)
- aEntityBucket[a].SetTexCoorUsed(sal_False);
-}
-
-/*************************************************************************
-|*
-|* Default-Geometrien erstellen
-|*
-\************************************************************************/
-
-void B3dGeometry::CreateCube(const basegfx::B3DRange& rVolume)
-{
- Erase();
- StartDescription();
- basegfx::B3DPoint A(rVolume.getMinX(), rVolume.getMaxY(), rVolume.getMinZ());
- basegfx::B3DPoint B(rVolume.getMaxX(), rVolume.getMaxY(), rVolume.getMinZ());
- basegfx::B3DPoint C(rVolume.getMaxX(), rVolume.getMinY(), rVolume.getMinZ());
- basegfx::B3DPoint D(rVolume.getMinX(), rVolume.getMinY(), rVolume.getMinZ());
- basegfx::B3DPoint E(rVolume.getMinX(), rVolume.getMaxY(), rVolume.getMaxZ());
- basegfx::B3DPoint F(rVolume.getMaxX(), rVolume.getMaxY(), rVolume.getMaxZ());
- basegfx::B3DPoint G(rVolume.getMaxX(), rVolume.getMinY(), rVolume.getMaxZ());
- basegfx::B3DPoint H(rVolume.getMinX(), rVolume.getMinY(), rVolume.getMaxZ());
- StartObject(sal_False);
- AddEdge(A);
- AddEdge(B);
- AddEdge(C);
- AddEdge(D);
- EndObject();
- StartObject(sal_False);
- AddEdge(A);
- AddEdge(E);
- AddEdge(F);
- AddEdge(B);
- EndObject();
- StartObject(sal_False);
- AddEdge(B);
- AddEdge(F);
- AddEdge(G);
- AddEdge(C);
- EndObject();
- StartObject(sal_False);
- AddEdge(C);
- AddEdge(G);
- AddEdge(H);
- AddEdge(D);
- EndObject();
- StartObject(sal_False);
- AddEdge(D);
- AddEdge(H);
- AddEdge(E);
- AddEdge(A);
- EndObject();
- StartObject(sal_False);
- AddEdge(E);
- AddEdge(H);
- AddEdge(G);
- AddEdge(F);
- EndObject();
- EndDescription();
- CreateDefaultNormalsSphere();
- CreateDefaultTexture(B3D_CREATE_DEFAULT_ALL, sal_False);
-}
-
-void B3dGeometry::CreateSphere(const basegfx::B3DRange& rVolume, double fX, double fY)
-{
- Erase();
- StartDescription();
- basegfx::B3DPoint A,B,C,D;
- double fXInc, fYInc;
- if(fX == 0.0)
- fX = 4.0;
- fXInc = F_2PI / fX;
- if(fY == 0.0)
- fY = 4.0;
- fYInc = F_PI / fY;
- sal_uInt16 nX = (sal_uInt16)fX;
- sal_uInt16 nY = (sal_uInt16)fY;
- fX = 0.0;
- for(sal_uInt16 a=0;a<nX;a++,fX+=fXInc)
- {
- fY = -F_PI2;
- for(sal_uInt16 b=0;b<nY;b++,fY+=fYInc)
- {
- A.setY(sin(fY+fYInc));
- B.setY(A.getY());
- D.setY(sin(fY));
- C.setY(D.getY());
- A.setX(cos(fX) * cos(fY+fYInc));
- D.setX(cos(fX) * cos(fY));
- B.setX(cos(fX+fXInc) * cos(fY+fYInc));
- C.setX(cos(fX+fXInc) * cos(fY));
- A.setZ(sin(fX) * cos(fY+fYInc));
- D.setZ(sin(fX) * cos(fY));
- B.setZ(sin(fX+fXInc) * cos(fY+fYInc));
- C.setZ(sin(fX+fXInc) * cos(fY));
- StartObject(sal_False);
- AddEdge(A);
- AddEdge(B);
- AddEdge(C);
- AddEdge(D);
- EndObject();
- }
- }
- EndDescription();
- CreateDefaultNormalsSphere();
- CreateDefaultTexture(B3D_CREATE_DEFAULT_ALL, sal_True);
- basegfx::B3DHomMatrix aTransform;
- aTransform.translate(1.0, 1.0, 1.0);
- aTransform.scale(
- (rVolume.getMaxX() - rVolume.getMinX())/2.0,
- (rVolume.getMaxY() - rVolume.getMinY())/2.0,
- (rVolume.getMaxZ() - rVolume.getMinZ())/2.0);
- aTransform.translate(rVolume.getMinX(), rVolume.getMinY(), rVolume.getMinZ());
- Transform(aTransform);
-}
-
-/*************************************************************************
-|*
-|* Normalen invertieren
-|*
-\************************************************************************/
-
-void B3dGeometry::InvertNormals()
-{
- for(sal_uInt32 a=0;a<aEntityBucket.Count();a++)
- aEntityBucket[a].Normal() = -aEntityBucket[a].Normal();
-}
-
-// eof
diff --git a/goodies/source/base3d/b3dlight.cxx b/goodies/source/base3d/b3dlight.cxx
deleted file mode 100644
index dbd7e2f10fb5..000000000000
--- a/goodies/source/base3d/b3dlight.cxx
+++ /dev/null
@@ -1,749 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dlight.cxx,v $
- * $Revision: 1.8 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include <goodies/b3dlight.hxx>
-#include <tools/debug.hxx>
-
-/*************************************************************************
-|*
-|* Konstruktor B3dLight
-|*
-\************************************************************************/
-
-B3dLight::B3dLight()
-{
-}
-
-/*************************************************************************
-|*
-|* Intensitaet einer bestimmten Lichtkomponente setzen
-|*
-\************************************************************************/
-
-void B3dLight::SetIntensity(const Color rNew, Base3DMaterialValue eVal)
-{
- switch(eVal)
- {
- case Base3DMaterialAmbient:
- {
- aAmbient = rNew;
- if(rNew.GetRed() || rNew.GetGreen() || rNew.GetBlue())
- bIsAmbient = sal_True;
- else
- bIsAmbient = sal_False;
- break;
- }
- case Base3DMaterialDiffuse:
- {
- aDiffuse = rNew;
- if(rNew.GetRed() || rNew.GetGreen() || rNew.GetBlue())
- bIsDiffuse = sal_True;
- else
- bIsDiffuse = sal_False;
- break;
- }
- default:
- {
- aSpecular = rNew;
- if(rNew.GetRed() || rNew.GetGreen() || rNew.GetBlue())
- bIsSpecular = sal_True;
- else
- bIsSpecular = sal_False;
- break;
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Intensitaet einer bestimmten Lichtkomponente lesen
-|*
-\************************************************************************/
-
-const Color B3dLight::GetIntensity(Base3DMaterialValue eVal)
-{
- switch(eVal)
- {
- case Base3DMaterialAmbient:
- {
- return aAmbient;
- }
- case Base3DMaterialDiffuse:
- {
- return aDiffuse;
- }
- default:
- {
- return aSpecular;
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Lichtquelle initialisieren (selbe defaults wie OpenGL)
-|*
-\************************************************************************/
-
-void B3dLight::Init()
-{
- aAmbient = Color(255, 0, 0, 0);
- if(IsFirst())
- {
- aDiffuse = Color(255, 204, 204, 204);
- aSpecular = Color(255, 255, 255, 255);
- basegfx::B3DVector aTiltVector(1.0, 1.0, 1.0);
- aTiltVector.normalize();
- aPosition = aTiltVector;
- bIsDiffuse = sal_True;
- bIsSpecular = sal_True;
- bIsEnabled = sal_True;
- }
- else
- {
- aDiffuse = Color(0, 0, 0, 0);
- aSpecular = Color(0, 0, 0, 0);
- aPosition = basegfx::B3DPoint(0.0, 0.0, 1.0);
- bIsDiffuse = sal_False;
- bIsSpecular = sal_False;
- bIsEnabled = sal_False;
- }
- aPositionEye = basegfx::B3DPoint(0.0, 0.0, 0.0);
- aSpotDirection = basegfx::B3DVector(0.0, 0.0, -1.0);
- aSpotDirectionEye = basegfx::B3DVector(0.0, 0.0, 0.0);
- nSpotExponent = 0;
- fSpotCutoff = 180.0;
- fConstantAttenuation = 1.0;
- fLinearAttenuation = 0.0;
- fQuadraticAttenuation = 0.0;
- bLinearOrQuadratic = sal_False;
- bIsDirectionalSource = sal_True;
- bIsSpot = sal_False;
- bIsAmbient = sal_False;
-}
-
-/*************************************************************************
-|*
-|* Richtung der Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLight::SetSpotDirection(const basegfx::B3DVector& rNew)
-{
- aSpotDirection=rNew;
- aSpotDirection.normalize();
-}
-
-/*************************************************************************
-|*
-|* Richtung der Lichtquelle in Augkoordinaten setzen
-|*
-\************************************************************************/
-
-void B3dLight::SetSpotDirectionEye(const basegfx::B3DVector& rNew)
-{
- aSpotDirectionEye=rNew;
- aSpotDirectionEye.normalize();
-}
-
-/*************************************************************************
-|*
-|* Kegel der Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLight::SetSpotCutoff(double fNew)
-{
- fSpotCutoff = fNew;
- bIsSpot = (fNew == 180.0) ? sal_False : sal_True;
- fCosSpotCutoff = cos(fNew * F_PI180);
-}
-
-/*************************************************************************
-|*
-|* Lineare Attenuation setzen
-|*
-\************************************************************************/
-
-void B3dLight::SetLinearAttenuation(double fNew)
-{
- fLinearAttenuation = fNew;
- bLinearOrQuadratic =
- (fNew + fQuadraticAttenuation == 0.0) ? sal_False : sal_True;
-}
-
-/*************************************************************************
-|*
-|* Quadratische Attenuation setzen
-|*
-\************************************************************************/
-
-void B3dLight::SetQuadraticAttenuation(double fNew)
-{
- fQuadraticAttenuation = fNew;
- bLinearOrQuadratic =
- (fNew + fLinearAttenuation == 0.0) ? sal_False : sal_True;
-}
-
-/*************************************************************************
-|*
-|* Gruppe von Lichtquellen, Konstruktor
-|*
-\************************************************************************/
-
-B3dLightGroup::B3dLightGroup()
-: aGlobalAmbientLight(255, 102, 102, 102),
- bLightingEnabled(sal_True),
- bLocalViewer(sal_True),
- bModelTwoSide(sal_False)
-{
- // Lichtquellen initialisieren
- for(sal_uInt16 i=0; i < BASE3D_MAX_NUMBER_LIGHTS;i++)
- {
- aLight[i].SetFirst(i==0);
- aLight[i].Init();
- }
-}
-
-B3dLightGroup::~B3dLightGroup()
-{
-}
-
-/*************************************************************************
-|*
-|* globales Umgebungslicht setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetGlobalAmbientLight(const Color rNew)
-{
- if(aGlobalAmbientLight != rNew)
- {
- aGlobalAmbientLight = rNew;
- }
-}
-
-/*************************************************************************
-|*
-|* globales Umgebungslicht lesen
-|*
-\************************************************************************/
-
-const Color B3dLightGroup::GetGlobalAmbientLight()
-{
- return aGlobalAmbientLight;
-}
-
-/*************************************************************************
-|*
-|* Modus globaler Viewer bei Berechnung specular reflection setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetLocalViewer(sal_Bool bNew)
-{
- if(bLocalViewer != bNew)
- {
- bLocalViewer = bNew;
- }
-}
-
-/*************************************************************************
-|*
-|* Modus globaler Viewer bei Berechnung specular reflection lesen
-|*
-\************************************************************************/
-
-sal_Bool B3dLightGroup::GetLocalViewer()
-{
- return bLocalViewer;
-}
-
-/*************************************************************************
-|*
-|* Modus Beleuchtungsmodell beidseitig anwenden setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetModelTwoSide(sal_Bool bNew)
-{
- if(bModelTwoSide != bNew)
- {
- bModelTwoSide = bNew;
- }
-}
-
-/*************************************************************************
-|*
-|* Modus Beleuchtungsmodell beidseitig anwenden lesen
-|*
-\************************************************************************/
-
-sal_Bool B3dLightGroup::GetModelTwoSide()
-{
- return bModelTwoSide;
-}
-
-/*************************************************************************
-|*
-|* Beleuchtungsmodell aktivieren/deaktivieren
-|*
-\************************************************************************/
-
-void B3dLightGroup::EnableLighting(sal_Bool bNew)
-{
- if(bLightingEnabled != bNew)
- {
- bLightingEnabled = bNew;
- }
-}
-
-/*************************************************************************
-|*
-|* Abfrage, ob das Beleuchtungsmodell aktiviert/deaktiviert ist
-|*
-\************************************************************************/
-
-sal_Bool B3dLightGroup::IsLightingEnabled()
-{
- return bLightingEnabled;
-}
-
-/*************************************************************************
-|*
-|* Die Intensitaet eines bestimmten Aspekts einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetIntensity(const Color rNew,
- Base3DMaterialValue eMat, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetIntensity(rNew, eMat);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Die Intensitaet eines bestimmten Aspekts einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-const Color B3dLightGroup::GetIntensity(Base3DMaterialValue eMat,
- Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].GetIntensity(eMat);
-}
-
-/*************************************************************************
-|*
-|* Die Position einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetPosition(const basegfx::B3DPoint& rNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetPosition(rNew);
- aLight[eNum].SetDirectionalSource(sal_False);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Die Position einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-const basegfx::B3DPoint& B3dLightGroup::GetPosition(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
-#ifdef DBG_UTIL
- if(IsDirectionalSource())
- DBG_ERROR("Zugriff auf die Position einer gerichteten Lichtquelle!");
-#endif
- return aLight[eNum].GetPosition();
-}
-
-/*************************************************************************
-|*
-|* Die Richtung einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetDirection(const basegfx::B3DVector& rNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetPosition(rNew);
- aLight[eNum].SetDirectionalSource(sal_True);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Die Richtung einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-const basegfx::B3DVector& B3dLightGroup::GetDirection(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
-#ifdef DBG_UTIL
- if(!IsDirectionalSource())
- DBG_ERROR("Zugriff auf die Richtung einer ungerichteten Lichtquelle!");
-#endif
- return (basegfx::B3DVector&)aLight[eNum].GetPosition();
-}
-
-/*************************************************************************
-|*
-|* Die Richtung einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetSpotDirection(const basegfx::B3DVector& rNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetSpotDirection(rNew);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Die Richtung einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-const basegfx::B3DVector& B3dLightGroup::GetSpotDirection(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].GetSpotDirection();
-}
-
-/*************************************************************************
-|*
-|* Den SpotExponent einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetSpotExponent(sal_uInt16 nNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetSpotExponent(nNew);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Den SpotExponent einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-sal_uInt16 B3dLightGroup::GetSpotExponent(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].GetSpotExponent();
-}
-
-/*************************************************************************
-|*
-|* Die Einengung des Lichtkegels einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetSpotCutoff(double fNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetSpotCutoff(fNew);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Die Einengung des Lichtkegels einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-double B3dLightGroup::GetSpotCutoff(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].GetSpotCutoff();
-}
-
-/*************************************************************************
-|*
-|* Den konstanten AttenuationFactor einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetConstantAttenuation(double fNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetConstantAttenuation(fNew);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Den konstanten AttenuationFactor einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-double B3dLightGroup::GetConstantAttenuation(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].GetConstantAttenuation();
-}
-
-/*************************************************************************
-|*
-|* Den linearen AttenuationFactor einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetLinearAttenuation(double fNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetLinearAttenuation(fNew);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Den linearen AttenuationFactor einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-double B3dLightGroup::GetLinearAttenuation(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].GetLinearAttenuation();
-}
-
-/*************************************************************************
-|*
-|* Den quadratischen AttenuationFactor einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void B3dLightGroup::SetQuadraticAttenuation(double fNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].SetQuadraticAttenuation(fNew);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Den quadratischen AttenuationFactor einer Lichtquelle lesen
-|*
-\************************************************************************/
-
-double B3dLightGroup::GetQuadraticAttenuation(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].GetQuadraticAttenuation();
-}
-
-/*************************************************************************
-|*
-|* Eine Lichtquelle aktivieren/deaktivieren
-|*
-\************************************************************************/
-
-void B3dLightGroup::Enable(sal_Bool bNew, Base3DLightNumber eNum)
-{
- if(eNum >= Base3DLight0 && eNum <= Base3DLight7)
- {
- aLight[eNum].Enable(bNew);
- }
-#ifdef DBG_UTIL
- else
- DBG_ERROR("Access to Light out of range");
-#endif
-}
-
-/*************************************************************************
-|*
-|* Abfrage, ob eine Lichtquelle aktiviert/deaktiviert ist
-|*
-\************************************************************************/
-
-sal_Bool B3dLightGroup::IsEnabled(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].IsEnabled();
-}
-
-/*************************************************************************
-|*
-|* Abfrage, ob eine Lichtquelle als directional source eingerichtet ist
-|*
-\************************************************************************/
-
-sal_Bool B3dLightGroup::IsDirectionalSource(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum].IsDirectionalSource();
-}
-
-/*************************************************************************
-|*
-|* Direkter Zugriff auf B3dLight fuer abgeleitete Klassen
-|*
-\************************************************************************/
-
-B3dLight& B3dLightGroup::GetLightObject(Base3DLightNumber eNum)
-{
- if(eNum < Base3DLight0 || eNum > Base3DLight7)
- {
- eNum = Base3DLight0;
-#ifdef DBG_UTIL
- DBG_ERROR("Access to Light out of range");
-#endif
- }
- return aLight[eNum];
-}
-
-// eof
diff --git a/goodies/source/base3d/b3dopngl.cxx b/goodies/source/base3d/b3dopngl.cxx
deleted file mode 100644
index 5b0d940ceb25..000000000000
--- a/goodies/source/base3d/b3dopngl.cxx
+++ /dev/null
@@ -1,1457 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dopngl.cxx,v $
- * $Revision: 1.9 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include <vcl/outdev.hxx>
-#include <tools/debug.hxx>
-#include <svtools/options3d.hxx>
-#include "b3dopngl.hxx"
-
-//#ifndef _B3D_HMATRIX_HXX
-//#include "hmatrix.hxx"
-//#endif
-#include "b3dtex.hxx"
-#include "b3dtrans.hxx"
-#include <goodies/b3dgeom.hxx>
-
-/*************************************************************************
-|*
-|* Konstruktor Base3DOpenGL
-|*
-\************************************************************************/
-
-Base3DOpenGL::Base3DOpenGL(OutputDevice* pOutDev)
-: Base3D(pOutDev),
- aOpenGL(pOutDev),
- aLastNormal(DBL_MAX, DBL_MAX, DBL_MAX),
- aLastTexCoor(DBL_MAX, DBL_MAX),
- fOffFacMul100((float)(-0.2 * 100.0)),
- fOffUniMul100((float)(-1.0 * 100.0)),
- aPhongBuffer(12), // 4K
- nPhongDivideSize(20),
- bForceToSinglePrimitiveOutput(sal_True) // (#70626#)
-{
- // create OpenGL context for pOutDev; pOutDev is NOT a printer,
- // so don't care about printers in this place
- if(aOpenGL.IsValid())
- {
- // setup default parameters
- aOpenGL.ClearDepth( 1.0 );
- aOpenGL.DepthFunc( GL_LEQUAL );
- aOpenGL.Enable( GL_DEPTH_TEST );
- aOpenGL.Enable( GL_DITHER );
- aOpenGL.Enable( GL_NORMALIZE );
- aOpenGL.Disable( GL_CULL_FACE );
- aOpenGL.Disable( GL_LIGHTING );
- aOpenGL.Disable( GL_LINE_SMOOTH );
- aOpenGL.Disable( GL_POINT_SMOOTH );
- aOpenGL.Disable( GL_POLYGON_SMOOTH );
- aOpenGL.Disable( GL_POLYGON_STIPPLE );
- aOpenGL.Disable( GL_LINE_STIPPLE );
- aOpenGL.Disable( GL_TEXTURE_1D );
- aOpenGL.Disable( GL_TEXTURE_2D );
- aOpenGL.Disable( GL_BLEND );
- aOpenGL.DepthMask( GL_TRUE );
- aOpenGL.ShadeModel( GL_SMOOTH );
- aOpenGL.EdgeFlag( GL_TRUE );
- aOpenGL.Disable( GL_SCISSOR_TEST );
- }
- SetContextIsValid(aOpenGL.IsValid());
- CalcInternPhongDivideSize();
- bForceToSinglePrimitiveOutput = SvtOptions3D().IsOpenGL_Faster();
-}
-
-/*************************************************************************
-|*
-|* Typbestimmung
-|*
-\************************************************************************/
-
-sal_uInt16 Base3DOpenGL::GetBase3DType()
-{
- return BASE3D_TYPE_OPENGL;
-}
-
-/*************************************************************************
-|*
-|* Start der Szenenbeschreibung: Evtl. neuer HDC, Loesche Tiefenbuffer
-|*
-\************************************************************************/
-
-void Base3DOpenGL::StartScene()
-{
- // Falls Transparenz an war, diese zuruecknehmen
- aOpenGL.Disable( GL_BLEND );
- aOpenGL.DepthMask( sal_True );
-
- // OutputDevice setzen und ZBuffer loeschen
- aOpenGL.SetConnectOutputDevice(GetOutputDevice());
- aOpenGL.Clear( GL_DEPTH_BUFFER_BIT );
-}
-
-/*************************************************************************
-|*
-|* Scissoring Region setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetScissorRegionPixel(const Rectangle& rRect, sal_Bool bActivate)
-{
- // OpenGL specifics
- aOpenGL.Scissor( rRect.Left(), rRect.Top(),
- rRect.GetWidth(), rRect.GetHeight());
-
- // call parent
- Base3D::SetScissorRegionPixel(rRect, bActivate);
-}
-
-/*************************************************************************
-|*
-|* Dithering
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetDither(sal_Bool bNew)
-{
- // call parent
- Base3D::SetDither(bNew);
-
- // OpenGL specifics
- if(GetDither())
- aOpenGL.Enable( GL_DITHER );
- else
- aOpenGL.Disable( GL_DITHER );
-}
-
-/*************************************************************************
-|*
-|* Scissoring aktivieren/deaktivieren
-|*
-\************************************************************************/
-
-void Base3DOpenGL::ActivateScissorRegion(sal_Bool bNew)
-{
- // OpenGL specifics
- if(bNew)
- {
- aOpenGL.Enable(GL_SCISSOR_TEST);
- }
- else
- {
- aOpenGL.Disable(GL_SCISSOR_TEST);
- }
-
- // call parent
- Base3D::ActivateScissorRegion(bNew);
-}
-
-/*************************************************************************
-|*
-|* Ende der Szenenbeschreibung: Erzwinge bisher nicht erzeugte Ausgaben
-|*
-\************************************************************************/
-
-void Base3DOpenGL::EndScene()
-{
- aOpenGL.Flush();
- aOpenGL.Finish();
-}
-
-/*************************************************************************
-|*
-|* Neuen freien Eintrag fuer naechste geometrische Daten liefern
-|*
-\************************************************************************/
-
-B3dEntity& Base3DOpenGL::ImplGetFreeEntity()
-{
- return aEntity;
-}
-
-/*************************************************************************
-|*
-|* starte primitiv auch in OpenGL
-|*
-\************************************************************************/
-
-void Base3DOpenGL::ImplStartPrimitive()
-{
- bPhongBufferedMode = (GetShadeModel() == Base3DPhong
- && GetRenderMode() == Base3DRenderFill
- && (GetObjectMode() == Base3DTriangles
- || GetObjectMode() == Base3DTriangleStrip
- || GetObjectMode() == Base3DTriangleFan
- || GetObjectMode() == Base3DQuads
- || GetObjectMode() == Base3DQuadStrip
- || GetObjectMode() == Base3DPolygon ));
-
- // Transparenz beachten
- if(GetMaterial(Base3DMaterialDiffuse).GetTransparency())
- {
- aOpenGL.Enable( GL_BLEND );
- aOpenGL.DepthMask( sal_False );
- aOpenGL.BlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- }
- else
- {
- aOpenGL.Disable( GL_BLEND );
- aOpenGL.DepthMask( sal_True );
- }
-
- if(bPhongBufferedMode)
- {
- // Phong-Modus: Ausgabe sammeln und in kleinere
- // Dreiecke zerlegt bei ImplEndPrimitive() rendern
- aPhongBuffer.Erase();
- }
- else
- {
- // OpenGL direkt benutzen
- aOpenGL.Begin(GetObjectMode());
- }
-}
-
-/*************************************************************************
-|*
-|* beende primitiv auch in OpenGL
-|*
-\************************************************************************/
-
-void Base3DOpenGL::ImplEndPrimitive()
-{
- if(bPhongBufferedMode)
- {
- DrawPhongPrimitives();
- }
- else
- {
- aOpenGL.End();
- }
-}
-
-/*************************************************************************
-|*
-|* Darstellungsqualitaet setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetDisplayQuality(UINT8 nNew)
-{
- // call parent
- Base3D::SetDisplayQuality(nNew);
-
- // endgueltige Splittinggroesse neuberechnen
- CalcInternPhongDivideSize();
-}
-
-/*************************************************************************
-|*
-|* PhongMode Splitting-Groesse neu setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetPhongDivideSize(long nNew)
-{
- nPhongDivideSize = nNew;
-
- // endgueltige Splittinggroesse neuberechnen
- CalcInternPhongDivideSize();
-}
-
-/*************************************************************************
-|*
-|* PhongMode interne Splitting-Groesse neu setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::CalcInternPhongDivideSize()
-{
- if(GetDisplayQuality() != 255)
- {
- long nNew = GetPhongDivideSize() +
- ((255L - (INT32)GetDisplayQuality())>>2);
- nInternPhongDivideSize = nNew * nNew;
- }
- else
- nInternPhongDivideSize = GetPhongDivideSize() * GetPhongDivideSize();
-}
-
-/*************************************************************************
-|*
-|* Zeichne fuer Phong gebufferte primitive als Dreiecke
-|*
-\************************************************************************/
-
-void Base3DOpenGL::DrawPhongPrimitives()
-{
- sal_uInt32 aCount = aPhongBuffer.Count();
- sal_uInt32 aPos(0L);
- bPhongBufferedMode = sal_False;
- aOpenGL.Begin(Base3DTriangles);
-
- switch(GetObjectMode())
- {
- case Base3DTriangles :
- {
- while(aPos < aCount)
- {
- DrawPhongTriangle(aPos, aPos+1, aPos+2);
- aPos += 3;
- }
- break;
- }
- case Base3DTriangleStrip:
- {
- aPos = 1;
- while(aPos < aCount)
- {
- if(aPos%2)
- DrawPhongTriangle(aPos-1, aPos, aPos+1);
- else
- DrawPhongTriangle(aPos-1, aPos+1, aPos);
- aPos++;
- }
- break;
- }
- case Base3DTriangleFan:
- {
- aPos = 1;
- while(aPos < aCount)
- {
- DrawPhongTriangle(0, aPos, aPos+1);
- aPos++;
- }
- break;
- }
- case Base3DQuads:
- {
- while(aPos < aCount)
- {
- DrawPhongTriangle(aPos, aPos+1, aPos+2);
- DrawPhongTriangle(aPos+2, aPos+3, aPos);
- aPos += 4;
- }
- break;
- }
- case Base3DQuadStrip:
- {
- aPos = 1;
- while(aPos < aCount)
- {
- DrawPhongTriangle(aPos, aPos+1, aPos+3);
- DrawPhongTriangle(aPos, aPos+3, aPos+2);
- aPos+=2;
- }
- break;
- }
- case Base3DPolygon:
- {
- aPos = 2;
- while(aPos < aCount)
- {
- DrawPhongTriangle(0, aPos-1, aPos);
- aPos++;
- }
- break;
- }
- default:
- break; // -Wall multiple values not handled.
- }
- aOpenGL.End();
-}
-
-/*************************************************************************
-|*
-|* Zeichne fuer Phong gebufferte Dreiecke
-|*
-\************************************************************************/
-
-void Base3DOpenGL::DrawPhongTriangle(sal_uInt32 nInd1, sal_uInt32 nInd2, sal_uInt32 nInd3)
-{
- basegfx::B3DPoint aPos1 = GetTransformationSet()->ObjectToViewCoor(aPhongBuffer[nInd1].Point());
- double fXMin = aPos1.getX();
- double fXMax = aPos1.getX();
- double fYMin = aPos1.getY();
- double fYMax = aPos1.getY();
- basegfx::B3DPoint aPos2 = GetTransformationSet()->ObjectToViewCoor(aPhongBuffer[nInd2].Point());
- if(aPos2.getX() < fXMin)
- fXMin = aPos2.getX();
- if(aPos2.getX() > fXMax)
- fXMax = aPos2.getX();
- if(aPos2.getY() < fYMin)
- fYMin = aPos2.getY();
- if(aPos2.getY() > fYMax)
- fYMax = aPos2.getY();
- aPos2 = GetTransformationSet()->ObjectToViewCoor(aPhongBuffer[nInd3].Point());
- if(aPos2.getX() < fXMin)
- fXMin = aPos2.getX();
- if(aPos2.getX() > fXMax)
- fXMax = aPos2.getX();
- if(aPos2.getY() < fYMin)
- fYMin = aPos2.getY();
- if(aPos2.getY() > fYMax)
- fYMax = aPos2.getY();
-
- Size aPixelSize = GetOutputDevice()->LogicToPixel(
- Size((long)(fXMax - fXMin),(long)(fYMax - fYMin)));
- if(aPixelSize.Width() * aPixelSize.Height() > nInternPhongDivideSize)
- {
- sal_uInt32 aCount = aPhongBuffer.Count();
- aPhongBuffer.Append();
- aPhongBuffer.Append();
- aPhongBuffer.Append();
-
- aPhongBuffer[aCount ].CalcMiddle(aPhongBuffer[nInd1], aPhongBuffer[nInd2]);
- aPhongBuffer[aCount+1].CalcMiddle(aPhongBuffer[nInd2], aPhongBuffer[nInd3]);
- aPhongBuffer[aCount+2].CalcMiddle(aPhongBuffer[nInd3], aPhongBuffer[nInd1]);
-
- DrawPhongTriangle(nInd1, aCount, aCount+2);
- DrawPhongTriangle(aCount, nInd2, aCount+1);
- DrawPhongTriangle(aCount+1, nInd3, aCount+2);
- DrawPhongTriangle(aCount, aCount+1, aCount+2);
-
- aPhongBuffer.Remove();
- aPhongBuffer.Remove();
- aPhongBuffer.Remove();
- }
- else
- {
- ImplPostAddVertex(aPhongBuffer[nInd1]);
- ImplPostAddVertex(aPhongBuffer[nInd2]);
- ImplPostAddVertex(aPhongBuffer[nInd3]);
- }
-}
-
-/*************************************************************************
-|*
-|* Geometrische Daten direkt an OpenGL weitergeben
-|* ACHTUNG! Es wird die aktuelle Farbe benutzt, NICHT die in Enttity3D
-|* enthaltene!
-|*
-\************************************************************************/
-
-// hack to get the address of the mfX member for OpenGL
-class LocVecAcc : public basegfx::B3DVector
-{
-public:
- double& getXDirect() { return mfX; }
-};
-
-void Base3DOpenGL::ImplPostAddVertex(B3dEntity& rEntity)
-{
- if(bPhongBufferedMode)
- {
- aPhongBuffer.Append(rEntity);
- }
- else
- {
- // Normale setzen
- if(rEntity.IsNormalUsed())
- {
- if(GetForceFlat() || GetShadeModel() == Base3DFlat)
- {
- if(rEntity.PlaneNormal() != aLastNormal)
- {
- aLastNormal = rEntity.PlaneNormal();
- aOpenGL.Normal3dv(&(((LocVecAcc*)&aLastNormal)->getXDirect()));
- }
- }
- else
- {
- if(rEntity.Normal() != aLastNormal)
- {
- aLastNormal = rEntity.Normal();
- aOpenGL.Normal3dv(&(((LocVecAcc*)&aLastNormal)->getXDirect()));
- }
- }
- }
- else
- {
- if(!aLastNormal.equalZero())
- {
- aLastNormal = basegfx::B3DVector(0.0, 0.0, 0.0);
- aOpenGL.Normal3dv(&(((LocVecAcc*)&aLastNormal)->getXDirect()));
- }
- }
-
- // Texturkoordinate setzen
- if(rEntity.IsTexCoorUsed())
- {
- if(rEntity.TexCoor() != aLastTexCoor)
- {
- aLastTexCoor = rEntity.TexCoor();
- aOpenGL.TexCoord2dv(&(((LocVecAcc*)&aLastTexCoor)->getXDirect()));
- }
- }
- else
- {
- if(!aLastTexCoor.equalZero())
- {
- aLastTexCoor = basegfx::B2DPoint(0.0, 0.0);
- aOpenGL.TexCoord2dv(&(((LocVecAcc*)&aLastTexCoor)->getXDirect()));
- }
- }
-
- // Punkt erzeugen
- aOpenGL.Vertex3dv(&(((LocVecAcc*)&(rEntity.Point()))->getXDirect()));
- }
-}
-
-/*************************************************************************
-|*
-|* beim setzen von color und alpha reagieren
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetColor(Color aNew)
-{
- // call parent
- Base3D::SetColor(aNew);
-
- // Normale Farbausgabe
- aOpenGL.Color4ub(GetColor().GetRed(), GetColor().GetGreen(),
- GetColor().GetBlue(), 0xff - GetColor().GetTransparency());
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetMaterial(Color rNew, Base3DMaterialValue eVal,
- Base3DMaterialMode eMode)
-{
- // call parent
- Base3D::SetMaterial(rNew, eVal, eMode);
-
- // OpenGL Specifics
- GLenum eFace = GL_FRONT_AND_BACK;
- if(eMode == Base3DMaterialFront)
- eFace = GL_FRONT;
- if(eMode == Base3DMaterialBack)
- eFace = GL_BACK;
- GLenum eName = GL_SPECULAR;
- if(eVal == Base3DMaterialAmbient)
- eName = GL_AMBIENT;
- if(eVal == Base3DMaterialDiffuse)
- eName = GL_DIFFUSE;
- if(eVal == Base3DMaterialEmission)
- eName = GL_EMISSION;
-
- // Array fuellen
- float fArray[4] = {
- ((float)GetMaterial(eVal, eMode).GetRed()) / (float)255.0,
- ((float)GetMaterial(eVal, eMode).GetGreen()) / (float)255.0,
- ((float)GetMaterial(eVal, eMode).GetBlue()) / (float)255.0,
- ((float)(255 - GetMaterial(eVal, eMode).GetTransparency())) / (float)255.0
- };
-
- aOpenGL.Materialfv(eFace, eName, fArray);
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften setzen, exponent der specular-Eigenschaft
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetShininess(sal_uInt16 nExponent,
- Base3DMaterialMode eMode)
-{
- // call parent
- Base3D::SetShininess(nExponent, eMode);
-
- // OpenGL Specifics
- GLenum eFace = GL_FRONT_AND_BACK;
- if(eMode == Base3DMaterialFront)
- eFace = GL_FRONT;
- if(eMode == Base3DMaterialBack)
- eFace = GL_BACK;
- aOpenGL.Materialf(eFace, GL_SHININESS, (float)nExponent);
-}
-
-/*************************************************************************
-|*
-|* Aktuell zu benutzende Textur setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetActiveTexture(B3dTexture* pTex)
-{
- // call parent
- Base3D::SetActiveTexture(pTex);
-
- // make current texture, cast ist unkritisch, da innerhalb von
- // Base3DOpenGL nur Texturen von diesem Typ angelegt worden
- // sein koennen
- if(GetActiveTexture())
- {
- aOpenGL.Enable(GL_TEXTURE_2D);
- ((B3dTextureOpenGL*)GetActiveTexture())->MakeCurrentTexture(aOpenGL);
- }
- else
- {
- aOpenGL.BindTexture(GL_TEXTURE_2D, 0);
- aOpenGL.Disable(GL_TEXTURE_2D);
- }
-}
-
-/*************************************************************************
-|*
-|* Ein Textur-Objekt inkarnieren
-|*
-\************************************************************************/
-
-B3dTexture* Base3DOpenGL::CreateTexture(TextureAttributes& rAtt, BitmapEx& rBitmapEx)
-{
- // Hier Parent NICHT rufen! Sonst wird auch noch eine normale Textur erzeugt
- B3dTextureOpenGL* pRetval = new B3dTextureOpenGL(rAtt, rBitmapEx, aOpenGL);
- DBG_ASSERT(pRetval,"AW: Kein Speicher fuer OpenGL-Textur bekommen!");
- return pRetval;
-}
-
-/*************************************************************************
-|*
-|* OpenGL - Textur loeschen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::DestroyTexture(B3dTexture* pTex)
-{
- // Spezielle Loeschaufgaben im Zusammenhang mit OpenGL
- ((B3dTextureOpenGL*)pTex)->DestroyOpenGLTexture(aOpenGL);
-
- // call parent, endgueltig loeschen
- Base3D::DestroyTexture(pTex);
-}
-
-/*************************************************************************
-|*
-|* PolygonOffset setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetPolygonOffset(Base3DPolygonOffset eNew, sal_Bool bNew)
-{
- // call parent
- Base3D::SetPolygonOffset(eNew, bNew);
-
- if(GetPolygonOffset())
- aOpenGL.PolygonOffset((float)(fOffFacMul100 / 100.0), (float)(fOffUniMul100 / 100.0));
- else
- aOpenGL.PolygonOffset((float)0.0, (float)0.0);
-
- // OpenGL Specifics
- switch(eNew)
- {
- case Base3DPolygonOffsetFill :
- if(bNew)
- aOpenGL.Enable( GL_POLYGON_OFFSET_FILL );
- else
- aOpenGL.Disable( GL_POLYGON_OFFSET_FILL );
- break;
-
- case Base3DPolygonOffsetLine :
- if(bNew)
- aOpenGL.Enable( GL_POLYGON_OFFSET_LINE );
- else
- aOpenGL.Disable( GL_POLYGON_OFFSET_LINE );
- break;
-
- case Base3DPolygonOffsetPoint :
- if(bNew)
- aOpenGL.Enable( GL_POLYGON_OFFSET_POINT );
- else
- aOpenGL.Disable( GL_POLYGON_OFFSET_POINT );
- break;
- }
-}
-
-/*************************************************************************
-|*
-|* Beleuchtung setzen/lesen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetLightGroup(B3dLightGroup* pSet, sal_Bool bSetGlobal)
-{
- // call parent
- Base3D::SetLightGroup(pSet, bSetGlobal);
-
- if(GetLightGroup())
- {
- // Allgemeine Parameter setzen
- SetGlobalAmbientLight(GetLightGroup()->GetGlobalAmbientLight());
- SetLocalViewer(GetLightGroup()->GetLocalViewer());
- SetModelTwoSide(GetLightGroup()->GetModelTwoSide());
- EnableLighting(GetLightGroup()->IsLightingEnabled());
-
- // Einzelne Lampen setzen
- if(GetTransformationSet() && bSetGlobal)
- {
- aOpenGL.MatrixMode(GL_MODELVIEW);
- aOpenGL.LoadIdentity();
- }
-
- // Set and enable lights from the beginning of array in
- // OpenGL
- sal_uInt16 nNumAlloc = 0;
-
- sal_uInt16 a;
- for(a=0;a<BASE3D_MAX_NUMBER_LIGHTS;a++)
- {
- Base3DLightNumber eNum = (Base3DLightNumber)(Base3DLight0 + a);
- B3dLight& rLight = GetLightGroup()->GetLightObject(eNum);
-
- if(rLight.IsEnabled())
- {
- Base3DLightNumber eNumAlloc = (Base3DLightNumber)(Base3DLight0 + nNumAlloc);
- nNumAlloc++;
-
- Enable(sal_True, eNumAlloc);
-
- SetIntensity(rLight.GetIntensity(Base3DMaterialAmbient),
- Base3DMaterialAmbient, eNumAlloc);
- SetIntensity(rLight.GetIntensity(Base3DMaterialDiffuse),
- Base3DMaterialDiffuse, eNumAlloc);
- SetIntensity(rLight.GetIntensity(Base3DMaterialSpecular),
- Base3DMaterialSpecular, eNumAlloc);
-
- if(rLight.IsDirectionalSource())
- {
- SetDirection(rLight.GetPosition(), eNumAlloc);
- }
- else
- {
- SetPosition(rLight.GetPosition(), eNumAlloc);
- SetSpotDirection(rLight.GetSpotDirection(), eNumAlloc);
- SetSpotExponent(rLight.GetSpotExponent(), eNumAlloc);
- SetSpotCutoff(rLight.GetSpotCutoff(), eNumAlloc);
- }
-
- SetConstantAttenuation(rLight.GetConstantAttenuation(), eNumAlloc);
- SetLinearAttenuation(rLight.GetLinearAttenuation(), eNumAlloc);
- SetQuadraticAttenuation(rLight.GetQuadraticAttenuation(), eNumAlloc);
- }
- }
-
- for(a=nNumAlloc;a<BASE3D_MAX_NUMBER_LIGHTS;a++)
- {
- Base3DLightNumber eNum = (Base3DLightNumber)(Base3DLight0 + a);
- Enable(sal_False, eNum);
- }
-
- if(GetTransformationSet() && bSetGlobal)
- PostSetObjectOrientation(GetTransformationSet());
- }
-}
-
-/*************************************************************************
-|*
-|* globales Umgebungslicht setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetGlobalAmbientLight(const Color rNew)
-{
- // OpenGL Specifics
- Color aSource;
- if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
- {
- // Graustufen
- UINT8 nLuminance = rNew.GetLuminance();
- aSource.SetRed(nLuminance);
- aSource.SetGreen(nLuminance);
- aSource.SetBlue(nLuminance);
- aSource.SetTransparency(rNew.GetTransparency());
- }
- else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
- {
- // Keine Ausgabe, hier Weiss als Farbe setzen
- aSource = Color(COL_WHITE);
- }
- else
- {
- // Normale Farbausgabe
- aSource = rNew;
- }
-
- // Array fuellen
- float fArray[4] = {
- ((float)aSource.GetRed()) / (float)255.0,
- ((float)aSource.GetGreen()) / (float)255.0,
- ((float)aSource.GetBlue()) / (float)255.0,
- ((float)aSource.GetTransparency()) / (float)255.0
- };
- aOpenGL.LightModelfv(GL_LIGHT_MODEL_AMBIENT, fArray);
-}
-
-/*************************************************************************
-|*
-|* Modus globaler Viewer bei Berechnung specular reflection setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetLocalViewer(sal_Bool bNew)
-{
- // OpenGL Specifics
- aOpenGL.LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER,
- bNew ? (float)0.0 : (float)1.0);
-}
-
-/*************************************************************************
-|*
-|* Modus Beleuchtungsmodell beidseitig anwenden setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetModelTwoSide(sal_Bool bNew)
-{
- // OpenGL Specifics
- aOpenGL.LightModelf(GL_LIGHT_MODEL_TWO_SIDE,
- bNew ? (float)1.0 : (float)0.0);
-}
-
-/*************************************************************************
-|*
-|* Beleuchtungsmodell aktivieren/deaktivieren
-|*
-\************************************************************************/
-
-void Base3DOpenGL::EnableLighting(sal_Bool bNew)
-{
- // OpenGL Specifics
- if(bNew)
- aOpenGL.Enable( GL_LIGHTING );
- else
- aOpenGL.Disable( GL_LIGHTING );
-}
-
-/*************************************************************************
-|*
-|* Die Intensitaet eines bestimmten Aspekts einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetIntensity(const Color rNew,
- Base3DMaterialValue eVal, Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- Color aSource;
- if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
- {
- // Graustufen
- UINT8 nLuminance = rNew.GetLuminance();
- aSource.SetRed(nLuminance);
- aSource.SetGreen(nLuminance);
- aSource.SetBlue(nLuminance);
- aSource.SetTransparency(rNew.GetTransparency());
- }
- else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
- {
- // Keine Ausgabe, hier Weiss als Farbe setzen
- aSource = Color(COL_WHITE);
- }
- else
- {
- // Normale Farbausgabe
- aSource = rNew;
- }
-
- // Array fuellen
- float fArray[4] = {
- ((float)aSource.GetRed()) / (float)255.0,
- ((float)aSource.GetGreen()) / (float)255.0,
- ((float)aSource.GetBlue()) / (float)255.0,
- ((float)aSource.GetTransparency()) / (float)255.0
- };
-
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- GLenum eName = GL_SPECULAR;
- if(eVal == Base3DMaterialAmbient)
- eName = GL_AMBIENT;
- if(eVal == Base3DMaterialDiffuse)
- eName = GL_DIFFUSE;
- aOpenGL.Lightfv(eLight, eName, fArray);
-}
-
-/*************************************************************************
-|*
-|* Die Position einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetPosition(const basegfx::B3DPoint& rNew, Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- float fArray[4] = {
- (float)rNew.getX(), (float)rNew.getY(), (float)rNew.getZ(), (float)1.0
- };
- aOpenGL.Lightfv(eLight, GL_POSITION, fArray);
-}
-
-/*************************************************************************
-|*
-|* Die Richtung einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetDirection(const basegfx::B3DVector& rNew, Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- float fArray[4] = {
- (float)rNew.getX(), (float)rNew.getY(), (float)rNew.getZ(), (float)0.0
- };
- aOpenGL.Lightfv(eLight, GL_POSITION, fArray);
-}
-
-/*************************************************************************
-|*
-|* Die Richtung einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetSpotDirection(const basegfx::B3DVector& rNew, Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- float fArray[4] = {
- (float)rNew.getX(), (float)rNew.getY(), (float)rNew.getZ(), (float)0.0
- };
- aOpenGL.Lightfv(eLight, GL_SPOT_DIRECTION, fArray);
-}
-
-/*************************************************************************
-|*
-|* Den SpotExponent einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetSpotExponent(sal_uInt16 nNew, Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- aOpenGL.Lightf(eLight, GL_SPOT_EXPONENT, (float)nNew);
-}
-
-/*************************************************************************
-|*
-|* Die Einengung des Lichtkegels einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetSpotCutoff(double fNew, Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- aOpenGL.Lightf(eLight, GL_SPOT_CUTOFF, (float)fNew);
-}
-
-/*************************************************************************
-|*
-|* Den konstanten AttenuationFactor einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetConstantAttenuation(double fNew,
- Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- aOpenGL.Lightf(eLight, GL_CONSTANT_ATTENUATION, (float)fNew);
-}
-
-/*************************************************************************
-|*
-|* Den linearen AttenuationFactor einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetLinearAttenuation(double fNew,
- Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- aOpenGL.Lightf(eLight, GL_LINEAR_ATTENUATION, (float)fNew);
-}
-
-/*************************************************************************
-|*
-|* Den quadratischen AttenuationFactor einer Lichtquelle setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetQuadraticAttenuation(double fNew,
- Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- aOpenGL.Lightf(eLight, GL_QUADRATIC_ATTENUATION, (float)fNew);
-}
-
-/*************************************************************************
-|*
-|* Eine Lichtquelle aktivieren/deaktivieren
-|*
-\************************************************************************/
-
-void Base3DOpenGL::Enable(sal_Bool bNew, Base3DLightNumber eNum)
-{
- // OpenGL Specifics
- GLenum eLight = GL_LIGHT0 + (eNum - Base3DLight0);
- if(bNew)
- aOpenGL.Enable(eLight);
- else
- aOpenGL.Disable(eLight);
-}
-
-/*************************************************************************
-|*
-|* RenderMode setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetRenderMode(Base3DRenderMode eNew,
- Base3DMaterialMode eMode)
-{
- // call parent
- Base3D::SetRenderMode(eNew, eMode);
-
- // OpenGL Specifics
- GLenum eFace = GL_FRONT_AND_BACK;
- if(eMode == Base3DMaterialFront)
- eFace = GL_FRONT;
- if(eMode == Base3DMaterialBack)
- eFace = GL_BACK;
-
- switch(eNew)
- {
- case Base3DRenderNone :
- {
- break;
- }
- case Base3DRenderPoint :
- {
- aOpenGL.PolygonMode(eFace, GL_POINT);
- break;
- }
- case Base3DRenderLine :
- {
- aOpenGL.PolygonMode(eFace, GL_LINE);
- break;
- }
- case Base3DRenderFill :
- {
- aOpenGL.PolygonMode(eFace, GL_FILL);
- break;
- }
- }
-}
-
-/*************************************************************************
-|*
-|* ShadeModel setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetShadeModel(Base3DShadeModel eNew)
-{
- // call parent
- Base3D::SetShadeModel(eNew);
-
- switch(eNew)
- {
- case Base3DSmooth :
- case Base3DPhong :
- {
- aOpenGL.ShadeModel(GL_SMOOTH);
- break;
- }
- case Base3DFlat :
- {
- aOpenGL.ShadeModel(GL_FLAT);
- break;
- }
- }
-}
-
-/*************************************************************************
-|*
-|* CullingMode setzen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetCullMode(Base3DCullMode eNew)
-{
- // call parent
- Base3D::SetCullMode(eNew);
-
- switch(eNew)
- {
- case Base3DCullFront :
- {
- aOpenGL.CullFace(GL_FRONT);
- aOpenGL.Enable(GL_CULL_FACE);
- break;
- }
- case Base3DCullBack :
- {
- aOpenGL.CullFace(GL_BACK);
- aOpenGL.Enable(GL_CULL_FACE);
- break;
- }
- case Base3DCullNone :
- {
- aOpenGL.Disable(GL_CULL_FACE);
- break;
- }
- }
-}
-
-/*************************************************************************
-|*
-|* EdgeFlag schreiben
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetEdgeFlag(sal_Bool bNew)
-{
- // EdgeFlag fuer OpenGL setzen
- if(bNew)
- aOpenGL.EdgeFlag(GL_TRUE);
- else
- aOpenGL.EdgeFlag(GL_FALSE);
-
- // call parent
- Base3D::SetEdgeFlag(bNew);
-}
-
-/*************************************************************************
-|*
-|* PointSize schreiben
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetPointSize(double fNew)
-{
- // PointSize fuer OpenGL setzen
- aOpenGL.PointSize((GLfloat)fNew);
-
- // call parent
- Base3D::SetPointSize(fNew);
-}
-
-/*************************************************************************
-|*
-|* LineWidth schreiben
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetLineWidth(double fNew)
-{
- // LineWidth fuer OpenGL setzen
- aOpenGL.LineWidth((GLfloat)fNew);
-
- // call parent
- Base3D::SetLineWidth(fNew);
-}
-
-/*************************************************************************
-|*
-|* Callbacks bei Matrixaenderungen, Default-Implementierungen
-|*
-\************************************************************************/
-
-void Base3DOpenGL::SetTransformationSet(B3dTransformationSet* pSet)
-{
- // call parent
- Base3D::SetTransformationSet(pSet);
-
- if(GetTransformationSet())
- {
- PostSetObjectOrientation(GetTransformationSet());
- PostSetProjection(GetTransformationSet());
- PostSetTexture(GetTransformationSet());
- PostSetViewport(GetTransformationSet());
- }
-}
-
-void Base3DOpenGL::PostSetObjectOrientation(B3dTransformationSet* pCaller)
-{
- // OpenGL specifics
- basegfx::B3DHomMatrix aMat = pCaller->GetObjectTrans();
- aMat *= pCaller->GetOrientation();
- double fBuffer[16] = {
- aMat.get(0, 0), aMat.get(1, 0), aMat.get(2, 0), aMat.get(3, 0),
- aMat.get(0, 1), aMat.get(1, 1), aMat.get(2, 1), aMat.get(3, 1),
- aMat.get(0, 2), aMat.get(1, 2), aMat.get(2, 2), aMat.get(3, 2),
- aMat.get(0, 3), aMat.get(1, 3), aMat.get(2, 3), aMat.get(3, 3)
- };
- aOpenGL.MatrixMode(GL_MODELVIEW);
- aOpenGL.LoadMatrixd(fBuffer);
-}
-
-void Base3DOpenGL::PostSetProjection(B3dTransformationSet* pCaller)
-{
- // OpenGL specifics
- const basegfx::B3DHomMatrix& rMat = pCaller->GetProjection();
- double fBuffer[16] = {
- rMat.get(0, 0), rMat.get(1, 0), rMat.get(2, 0), rMat.get(3, 0),
- rMat.get(0, 1), rMat.get(1, 1), rMat.get(2, 1), rMat.get(3, 1),
- rMat.get(0, 2), rMat.get(1, 2), rMat.get(2, 2), rMat.get(3, 2),
- rMat.get(0, 3), rMat.get(1, 3), rMat.get(2, 3), rMat.get(3, 3)
- };
- aOpenGL.MatrixMode(GL_PROJECTION);
- aOpenGL.LoadMatrixd(fBuffer);
-}
-
-void Base3DOpenGL::PostSetTexture(B3dTransformationSet* pCaller)
-{
- // OpenGL specifics
- const basegfx::B2DHomMatrix& rMat = pCaller->GetTexture();
- double fBuffer[16] = {
- rMat.get(0, 0), rMat.get(1, 0), 0.0, rMat.get(2, 0),
- rMat.get(0, 1), rMat.get(1, 1), 0.0, rMat.get(2, 1),
- 0.0, 0.0, 0.0, 0.0,
- rMat.get(0, 2), rMat.get(1, 2), 0.0, rMat.get(3, 3)
- };
- aOpenGL.MatrixMode(GL_TEXTURE);
- aOpenGL.LoadMatrixd(fBuffer);
-}
-
-void Base3DOpenGL::PostSetViewport(B3dTransformationSet* pCaller)
-{
- // OpenGL specifics
- Rectangle aBoundPixel(GetOutputDevice()->
- LogicToPixel(pCaller->GetLogicalViewportBounds()));
- aOpenGL.Viewport( aBoundPixel.Left(), aBoundPixel.Top(),
- aBoundPixel.GetWidth() - 1, aBoundPixel.GetHeight() - 1);
-}
-
-/*************************************************************************
-|*
-|* Ein Objekt in Form einer B3dGeometry direkt ausgeben
-|*
-\************************************************************************/
-
-void Base3DOpenGL::DrawPolygonGeometry(const B3dGeometry& rGeometry, sal_Bool bOutline)
-{
- // bForceToSinglePrimitiveOutput: (#70626#)
- if(bForceToSinglePrimitiveOutput || (GetShadeModel() == Base3DPhong && GetRenderMode() == Base3DRenderFill))
- {
- // call parent, render with many primitives
- Base3D::DrawPolygonGeometry(rGeometry, bOutline);
- }
- else
- {
- // Buckets der Geometrie holen
- const B3dEntityBucket& rEntityBucket = rGeometry.GetEntityBucket();
- const GeometryIndexValueBucket& rIndexBucket = rGeometry.GetIndexBucket();
-
- if(rEntityBucket.Count() && rIndexBucket.Count())
- {
- // Arrays aktivieren
- aOpenGL.EnableClientState(GL_VERTEX_ARRAY);
-
- sal_uInt32 nPolyCounter = 0;
- sal_uInt32 nEntityCounter = 0;
- sal_uInt32 nArrayStartIndex = 0;
- sal_uInt32 nUpperBound;
-
- // Pointer setzen
- sal_uInt16 nArray = 0;
- aOpenGL.VertexPointer(3, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].Point());
-
- if(bOutline)
- {
- // Transparenz Linien beachten
- if(GetColor().GetTransparency())
- {
- aOpenGL.Enable( GL_BLEND );
- aOpenGL.DepthMask( sal_False );
- aOpenGL.BlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- }
- else
- {
- aOpenGL.Disable( GL_BLEND );
- aOpenGL.DepthMask( sal_True );
- }
-
- // ALLE Linien Zeichnen
- aOpenGL.Disable(GL_CULL_FACE);
-
- // Polygone als Outline ausgeben
- aOpenGL.PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- aOpenGL.PolygonOffset((float)(fOffFacMul100 / 100.0), (float)(fOffUniMul100 / 100.0));
- aOpenGL.Enable( GL_POLYGON_OFFSET_LINE );
- aOpenGL.EnableClientState(GL_EDGE_FLAG_ARRAY);
- aOpenGL.EdgeFlagPointer(rEntityBucket.GetSlotSize(), &rEntityBucket[0].EdgeFlag());
-
- while(nPolyCounter < rIndexBucket.Count())
- {
- // Naechstes Primitiv
- nUpperBound = rIndexBucket[nPolyCounter].GetIndex();
- sal_Bool bLineMode = (rIndexBucket[nPolyCounter++].GetMode() == B3D_INDEX_MODE_LINE);
-
- if(nUpperBound >> rEntityBucket.GetBlockShift() != nArray)
- {
- // Einzelschritt, Bereichsueberschreitung im Buffer
- // Als Polygon ausgeben
- aOpenGL.Begin(bLineMode ? Base3DLineStrip : Base3DPolygon);
-
- // Polygon ausgeben
- while(nEntityCounter < nUpperBound)
- {
- const B3dEntity& rEntity = rEntityBucket[nEntityCounter++];
- aOpenGL.EdgeFlag(rEntity.IsEdgeVisible() ? GL_TRUE : GL_FALSE);
- aOpenGL.Vertex3dv((const double *)(&rEntity.Point()));
- }
-
- // Primitiv abschliessen
- aOpenGL.End();
-
- // NUR auf neues Array setzen, wenn noch was da ist (#59941#)
- if(nEntityCounter < rEntityBucket.Count())
- {
- // Pointer auf neues Array setzen
- nArray = (sal_uInt16)(nEntityCounter >> rEntityBucket.GetBlockShift());
- nArrayStartIndex = nEntityCounter;
- const B3dEntity& rStart = rEntityBucket[nEntityCounter];
-
- aOpenGL.VertexPointer(3, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rStart);
- aOpenGL.EdgeFlagPointer(rEntityBucket.GetSlotSize(), &(rStart.EdgeFlag()));
- }
- }
- else
- {
- // Primitiv komplett raushauen, liegt in einem Buffer
- aOpenGL.DrawArrays(bLineMode ? Base3DLineStrip : Base3DPolygon,
- nEntityCounter - nArrayStartIndex,
- nUpperBound - nEntityCounter);
- nEntityCounter = nUpperBound;
- }
- }
-
- // Arrays deaktivieren
- aOpenGL.DisableClientState(GL_VERTEX_ARRAY);
- aOpenGL.DisableClientState(GL_EDGE_FLAG_ARRAY);
- }
- else
- {
- // Transparenz Flaechen beachten
- if(GetMaterial(Base3DMaterialDiffuse).GetTransparency()
- || (GetActiveTexture() && !!(GetActiveTexture()->GetAlphaMask())))
- {
- aOpenGL.Enable( GL_BLEND );
- aOpenGL.DepthMask( sal_False );
- aOpenGL.BlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- }
- else
- {
- aOpenGL.Disable( GL_BLEND );
- aOpenGL.DepthMask( sal_True );
- }
-
- // Polygone gefuellt ausgeben
- aOpenGL.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- aOpenGL.EnableClientState(GL_NORMAL_ARRAY);
- aOpenGL.EnableClientState(GL_TEXTURE_COORD_ARRAY);
- if(GetForceFlat() || GetShadeModel() == Base3DFlat)
- aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].PlaneNormal());
- else
- aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].Normal());
- aOpenGL.TexCoordPointer(2, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rEntityBucket[0].TexCoor());
-
- while(nPolyCounter < rIndexBucket.Count())
- {
- // Naechstes Primitiv
- nUpperBound = rIndexBucket[nPolyCounter].GetIndex();
- sal_Bool bLineMode = (rIndexBucket[nPolyCounter++].GetMode() == B3D_INDEX_MODE_LINE);
-
- if(nUpperBound >> rEntityBucket.GetBlockShift() != nArray)
- {
- // Einzelschritt, Bereichsueberschreitung im Buffer
- // Als Polygon ausgeben
- aOpenGL.Begin(bLineMode ? Base3DLineStrip : Base3DPolygon);
-
- // Polygon ausgeben
- while(nEntityCounter < nUpperBound)
- {
- const B3dEntity& rEntity = rEntityBucket[nEntityCounter++];
- if(GetForceFlat() || GetShadeModel() == Base3DFlat)
- aOpenGL.Normal3dv((const double *)(&rEntity.PlaneNormal()));
- else
- aOpenGL.Normal3dv((const double *)(&rEntity.Normal()));
- aOpenGL.TexCoord3dv((const double *)(&rEntity.TexCoor()));
- aOpenGL.Vertex3dv((const double *)(&rEntity.Point()));
- }
-
- // Primitiv abschliessen
- aOpenGL.End();
-
- // NUR auf neues Array setzen, wenn noch was da ist (#58702#)
- if(nEntityCounter < rEntityBucket.Count())
- {
- // Pointer auf neues Array setzen
- nArray = (sal_uInt16)(nEntityCounter >> rEntityBucket.GetBlockShift());
- nArrayStartIndex = nEntityCounter;
- const B3dEntity& rStart = rEntityBucket[nEntityCounter];
-
- aOpenGL.VertexPointer(3, GL_DOUBLE, rEntityBucket.GetSlotSize(), &rStart);
- if(GetForceFlat() || GetShadeModel() == Base3DFlat)
- aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &(rStart.PlaneNormal()));
- else
- aOpenGL.NormalPointer(GL_DOUBLE, rEntityBucket.GetSlotSize(), &(rStart.Normal()));
- aOpenGL.TexCoordPointer(2, GL_DOUBLE, rEntityBucket.GetSlotSize(), &(rStart.TexCoor()));
- }
- }
- else
- {
- // Primitiv komplett raushauen, liegt in einem Buffer
- aOpenGL.DrawArrays(bLineMode ? Base3DLineStrip : Base3DPolygon,
- nEntityCounter - nArrayStartIndex,
- nUpperBound - nEntityCounter);
- nEntityCounter = nUpperBound;
- }
- }
-
- // Arrays deaktivieren
- aOpenGL.DisableClientState(GL_VERTEX_ARRAY);
- aOpenGL.DisableClientState(GL_NORMAL_ARRAY);
- aOpenGL.DisableClientState(GL_TEXTURE_COORD_ARRAY);
- }
- }
- }
-}
-
diff --git a/goodies/source/base3d/b3dopngl.hxx b/goodies/source/base3d/b3dopngl.hxx
deleted file mode 100644
index 6446321e2b2a..000000000000
--- a/goodies/source/base3d/b3dopngl.hxx
+++ /dev/null
@@ -1,186 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dopngl.hxx,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _B3D_B3DOPNGL_HXX
-#define _B3D_B3DOPNGL_HXX
-
-#include <goodies/base3d.hxx>
-#include <vcl/opengl.hxx>
-
-/*************************************************************************
-|*
-|* Die Basisklasse fuer Standard 3D Ausgaben mittels OpenGL unter
-|* Windows (Win95 und Windows NT)
-|*
-\************************************************************************/
-
-class Base3DOpenGL : public Base3D
-{
-private:
- // Datenuebergabe
- B3dEntity aEntity;
-
- // OpenGL Objekt
- OpenGL aOpenGL;
-
- // Letzte Normale und letzte Texturkoordinate
- basegfx::B3DVector aLastNormal;
- basegfx::B2DPoint aLastTexCoor;
-
- float fOffFacMul100;
- float fOffUniMul100;
-
- // Simulation Phong-Mode
- sal_Bool bPhongBufferedMode;
- B3dEntityBucket aPhongBuffer;
- long nPhongDivideSize;
- long nInternPhongDivideSize;
-
- // flags (#70626#)
- sal_Bool bForceToSinglePrimitiveOutput;
-
- void DrawPhongPrimitives();
- void DrawPhongTriangle(UINT32 nInd1, UINT32 nInd2, UINT32 nInd3);
- void CalcInternPhongDivideSize();
-
-public:
- Base3DOpenGL(OutputDevice* pOutDev);
-
- // DivideSize bei Phong-Simulation
- long GetPhongDivideSize() { return nPhongDivideSize; }
- void SetPhongDivideSize(long nNew);
-
- // Get/Set force to single primitive output (#70626#)
- sal_Bool IsForceToSinglePrimitiveOutput() const { return bForceToSinglePrimitiveOutput; }
- void SetForceToSinglePrimitiveOutput(sal_Bool bNew) { bForceToSinglePrimitiveOutput = bNew; }
-
- // Typbestimmung
- virtual sal_uInt16 GetBase3DType();
-
- virtual void StartScene();
- virtual void EndScene();
-
- // Scissoring
- virtual void SetScissorRegionPixel(const Rectangle& rRect, sal_Bool bActivate=sal_True);
- virtual void ActivateScissorRegion(sal_Bool bNew);
-
- // Dithering
- virtual void SetDither(sal_Bool bNew);
-
- // Farbe
- virtual void SetColor(Color aNew);
-
- // Material
- virtual void SetMaterial(Color rNew,
- Base3DMaterialValue=Base3DMaterialAmbient,
- Base3DMaterialMode=Base3DMaterialFrontAndBack);
- virtual void SetShininess(sal_uInt16 nExponent,
- Base3DMaterialMode=Base3DMaterialFrontAndBack);
-
- // Texturen
-private:
- virtual B3dTexture* CreateTexture(TextureAttributes& rAtt, BitmapEx& rBitmapEx);
- virtual void DestroyTexture(B3dTexture*);
-public:
- virtual void SetActiveTexture(B3dTexture* pTex=NULL);
-
- // Darstellungsqualitaet
- virtual void SetDisplayQuality(UINT8 nNew);
-
- // PolygonOffset
- virtual void SetPolygonOffset(
- Base3DPolygonOffset eNew=Base3DPolygonOffsetLine, sal_Bool bNew=sal_False);
-
- // Beleuchtung setzen/lesen
- virtual void SetLightGroup(B3dLightGroup* pSet, sal_Bool bSetGlobal=sal_True);
-
- virtual void SetRenderMode(Base3DRenderMode eNew,
- Base3DMaterialMode=Base3DMaterialFrontAndBack);
- virtual void SetShadeModel(Base3DShadeModel eNew);
- virtual void SetCullMode(Base3DCullMode eNew);
-
- virtual void SetEdgeFlag(sal_Bool bNew=sal_True);
- virtual void SetPointSize(double fNew=1.0);
- virtual void SetLineWidth(double fNew=1.0);
-
- // Ein Objekt in Form einer B3dGeometry direkt ausgeben
- virtual void DrawPolygonGeometry(const B3dGeometry& rGeometry, sal_Bool bOutline=sal_False);
-
- // Callbacks bei Matrixaenderungen
- virtual void SetTransformationSet(B3dTransformationSet* pSet);
-
-protected:
- // Geometrische Daten uebergeben
- virtual B3dEntity& ImplGetFreeEntity();
- virtual void ImplPostAddVertex(B3dEntity& rEnt);
-
- virtual void ImplStartPrimitive();
- virtual void ImplEndPrimitive();
-
- // Callbacks bei Matrixaenderungen
- void PostSetObjectOrientation(B3dTransformationSet* pCaller);
- void PostSetProjection(B3dTransformationSet* pCaller);
- void PostSetTexture(B3dTransformationSet* pCaller);
- void PostSetViewport(B3dTransformationSet* pCaller);
-
- // lokale Parameter des LightModels
- void SetGlobalAmbientLight(const Color rNew);
- void SetLocalViewer(sal_Bool bNew=sal_True);
- void SetModelTwoSide(sal_Bool bNew=sal_False);
-
- // Hauptschalter fuer die Beleuchtung
- void EnableLighting(sal_Bool bNew=sal_True);
-
- // Lichtquellen Interface
- void SetIntensity(const Color rNew,
- Base3DMaterialValue=Base3DMaterialAmbient,
- Base3DLightNumber=Base3DLight0);
- void SetPosition(const basegfx::B3DPoint& rNew,
- Base3DLightNumber=Base3DLight0);
- void SetDirection(const basegfx::B3DVector& rNew,
- Base3DLightNumber=Base3DLight0);
- void SetSpotDirection(const basegfx::B3DVector& rNew,
- Base3DLightNumber=Base3DLight0);
- void SetSpotExponent(sal_uInt16 nNew,
- Base3DLightNumber=Base3DLight0);
- void SetSpotCutoff(double fNew,
- Base3DLightNumber=Base3DLight0);
- void SetConstantAttenuation(double fNew,
- Base3DLightNumber=Base3DLight0);
- void SetLinearAttenuation(double fNew,
- Base3DLightNumber=Base3DLight0);
- void SetQuadraticAttenuation(double fNew,
- Base3DLightNumber=Base3DLight0);
- void Enable(sal_Bool bNew=sal_True,
- Base3DLightNumber=Base3DLight0);
-};
-
-
-#endif // _B3D_B3DOPNGL_HXX
diff --git a/goodies/source/base3d/b3dtex.cxx b/goodies/source/base3d/b3dtex.cxx
deleted file mode 100644
index 67c678431f14..000000000000
--- a/goodies/source/base3d/b3dtex.cxx
+++ /dev/null
@@ -1,1303 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: b3dtex.cxx,v $
- * $Revision: 1.12.38.1 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include "b3dtex.hxx"
-#include "b3dopngl.hxx"
-#include <vcl/bmpacc.hxx>
-
-#include "rtl/alloc.h"
-
-/*************************************************************************
-|*
-|* Klassen fuer TexturAttribute beim Anfordern von Texturen
-|*
-\************************************************************************/
-
-TextureAttributes::TextureAttributes(sal_Bool bGhosted, void* pFT)
-: mpFloatTrans(pFT),
- mbGhosted(bGhosted)
-{
-}
-
-sal_Bool TextureAttributes::operator==(const TextureAttributes& rAtt) const
-{
- return ( GetTextureAttributeType() == rAtt.GetTextureAttributeType()
- && rAtt.mbGhosted == mbGhosted
- && rAtt.mpFloatTrans == mpFloatTrans);
-}
-
-// Fuer Colors
-
-TextureAttributesColor::TextureAttributesColor(sal_Bool bGhosted, void* pFT, Color aColor)
-: TextureAttributes(bGhosted, pFT),
- maColorAttribute(aColor)
-{
-}
-
-sal_Bool TextureAttributesColor::operator==(const TextureAttributes& rAtt) const
-{
- if(TextureAttributes::operator==(rAtt))
- {
- const TextureAttributesColor& rAttCol = (const TextureAttributesColor&)rAtt;
- if(rAttCol.maColorAttribute == maColorAttribute)
- return sal_True;
- }
- return sal_False;
-}
-
-sal_uInt16 TextureAttributesColor::GetTextureAttributeType() const
-{
- return TEXTURE_ATTRIBUTE_TYPE_COLOR;
-}
-
-// Fuer Bitmaps
-
-TextureAttributesBitmap::TextureAttributesBitmap(sal_Bool bGhosted, void* pFT, Bitmap aBmp)
-: TextureAttributes(bGhosted, pFT),
- maBitmapAttribute(aBmp)
-{
-}
-
-TextureAttributesBitmap::~TextureAttributesBitmap()
-{
-}
-
-sal_Bool TextureAttributesBitmap::operator==(const TextureAttributes& rAtt) const
-{
- if(TextureAttributes::operator==(rAtt))
- {
- const TextureAttributesBitmap& rAttBmp = (const TextureAttributesBitmap&)rAtt;
- if(rAttBmp.maBitmapAttribute == maBitmapAttribute)
- return sal_True;
- }
- return sal_False;
-}
-
-sal_uInt16 TextureAttributesBitmap::GetTextureAttributeType() const
-{
- return TEXTURE_ATTRIBUTE_TYPE_BITMAP;
-}
-
-// Fuer Gradientfills
-
-TextureAttributesGradient::TextureAttributesGradient(sal_Bool bGhosted, void* pFT, void* pF, void *pSC)
-: TextureAttributes(bGhosted, pFT),
- mpFill(pF),
- mpStepCount(pSC)
-{
-}
-
-sal_Bool TextureAttributesGradient::operator==(const TextureAttributes& rAtt) const
-{
- if(TextureAttributes::operator==(rAtt))
- {
- const TextureAttributesGradient& rAttGra = (const TextureAttributesGradient&)rAtt;
-
- if(rAttGra.mpFill == mpFill
- && rAttGra.mpStepCount == mpStepCount)
- return sal_True;
- }
- return sal_False;
-}
-
-sal_uInt16 TextureAttributesGradient::GetTextureAttributeType() const
-{
- return TEXTURE_ATTRIBUTE_TYPE_GRADIENT;
-}
-
-// Fuer Hatchfills
-
-TextureAttributesHatch::TextureAttributesHatch(sal_Bool bGhosted, void* pFT, void* pF)
-: TextureAttributes(bGhosted, pFT),
- mpFill(pF)
-{
-}
-
-sal_Bool TextureAttributesHatch::operator==(const TextureAttributes& rAtt) const
-{
- if(TextureAttributes::operator==(rAtt))
- {
- const TextureAttributesHatch& rAttHat = (const TextureAttributesHatch&)rAtt;
-
- if(rAttHat.mpFill == mpFill)
- return sal_True;
- }
- return sal_False;
-}
-
-sal_uInt16 TextureAttributesHatch::GetTextureAttributeType() const
-{
- return TEXTURE_ATTRIBUTE_TYPE_HATCH;
-}
-
-/*************************************************************************
-|*
-|* Konstruktor Textur
-|*
-\************************************************************************/
-
-B3dTexture::B3dTexture(
- TextureAttributes& rAtt,
- BitmapEx& rBmpEx,
- Base3DTextureKind eKnd,
- Base3DTextureMode eMod,
- Base3DTextureFilter eFlt,
- Base3DTextureWrap eS,
- Base3DTextureWrap eT)
-: aBitmap(rBmpEx.GetBitmap()),
- aAlphaMask(rBmpEx.GetAlpha()),
- aBitmapSize(rBmpEx.GetSizePixel()), // #i72895#
- pReadAccess(NULL),
- pAlphaReadAccess(NULL),
- eKind(eKnd),
- eMode(eMod),
- eFilter(eFlt),
- eWrapS(eS),
- eWrapT(eT),
- nSwitchVal(0),
- bTextureKindChanged(sal_False)
-{
- // ReadAccess auf Textur anfordern
- pReadAccess = aBitmap.AcquireReadAccess();
- pAlphaReadAccess = (!aAlphaMask) ? NULL : aAlphaMask.AcquireReadAccess();
- DBG_ASSERT(pReadAccess, "AW: Keinen Lesezugriff auf Textur-Bitmap bekommen");
-
- // Attribute kopieren
- switch(rAtt.GetTextureAttributeType())
- {
- case TEXTURE_ATTRIBUTE_TYPE_COLOR :
- pAttributes = new TextureAttributesColor(
- rAtt.GetGhostedAttribute(),
- rAtt.GetFloatTransAttribute(),
- ((TextureAttributesColor&)rAtt).GetColorAttribute());
- break;
-
- case TEXTURE_ATTRIBUTE_TYPE_BITMAP :
- pAttributes = new TextureAttributesBitmap(
- rAtt.GetGhostedAttribute(),
- rAtt.GetFloatTransAttribute(),
- ((TextureAttributesBitmap&)rAtt).GetBitmapAttribute());
- break;
-
- case TEXTURE_ATTRIBUTE_TYPE_GRADIENT :
- pAttributes = new TextureAttributesGradient(
- rAtt.GetGhostedAttribute(),
- rAtt.GetFloatTransAttribute(),
- ((TextureAttributesGradient&)rAtt).GetFillAttribute(),
- ((TextureAttributesGradient&)rAtt).GetStepCountAttribute());
- break;
-
- case TEXTURE_ATTRIBUTE_TYPE_HATCH :
- pAttributes = new TextureAttributesHatch(
- rAtt.GetGhostedAttribute(),
- rAtt.GetFloatTransAttribute(),
- ((TextureAttributesHatch&)rAtt).GetHatchFillAttribute());
- break;
- }
-
- // SwitchVal setzen
- SetSwitchVal();
-}
-
-/*************************************************************************
-|*
-|* Destruktor Textur
-|*
-\************************************************************************/
-
-B3dTexture::~B3dTexture()
-{
- // ReadAccess auf Textur freigeben
- if(pReadAccess)
- {
- aBitmap.ReleaseAccess(pReadAccess);
- pReadAccess = NULL;
- }
-
- // free ReadAccess to transparency bitmap
- if(pAlphaReadAccess)
- {
- aAlphaMask.ReleaseAccess(pAlphaReadAccess);
- pAlphaReadAccess = NULL;
- }
-
- // Attribute wegschmeissen
- if(pAttributes)
- delete pAttributes;
- pAttributes = NULL;
-}
-
-// Zugriff auf die Attribute der Textur
-TextureAttributes& B3dTexture::GetAttributes()
-{
- return *pAttributes;
-}
-
-/*************************************************************************
-|*
-|* Art des Wrappings in X setzen
-|*
-\************************************************************************/
-
-void B3dTexture::SetTextureWrapS(Base3DTextureWrap eNew)
-{
- if(eNew != eWrapS)
- {
- eWrapS = eNew;
- bTextureKindChanged = sal_True;
- }
-}
-
-/*************************************************************************
-|*
-|* Art des Wrappings in Y setzen
-|*
-\************************************************************************/
-
-void B3dTexture::SetTextureWrapT(Base3DTextureWrap eNew)
-{
- if(eNew != eWrapT)
- {
- eWrapT = eNew;
- bTextureKindChanged = sal_True;
- }
-}
-
-/*************************************************************************
-|*
-|* Blend-Color lesen/bestimmen
-|*
-\************************************************************************/
-
-void B3dTexture::SetBlendColor(Color rNew)
-{
- if(rNew.GetRed() != aColBlend.GetRed()
- || rNew.GetGreen() != aColBlend.GetGreen()
- || rNew.GetBlue() != aColBlend.GetBlue())
- {
- aColBlend.SetRed(rNew.GetRed());
- aColBlend.SetGreen(rNew.GetGreen());
- aColBlend.SetBlue(rNew.GetBlue());
- if(eWrapS == Base3DTextureSingle || eWrapT == Base3DTextureSingle)
- bTextureKindChanged = sal_True;
- }
-}
-
-Color B3dTexture::GetBlendColor()
-{
- Color aRetval(aColBlend.GetRed(),
- aColBlend.GetGreen(),
- aColBlend.GetBlue());
- return aRetval;
-}
-
-/*************************************************************************
-|*
-|* Textur-Ersatz-Color lesen/bestimmen
-|*
-\************************************************************************/
-
-void B3dTexture::SetTextureColor(Color rNew)
-{
- if(rNew.GetRed() != aColTexture.GetRed()
- || rNew.GetGreen() != aColTexture.GetGreen()
- || rNew.GetBlue() != aColTexture.GetBlue())
- {
- aColTexture.SetRed(rNew.GetRed());
- aColTexture.SetGreen(rNew.GetGreen());
- aColTexture.SetBlue(rNew.GetBlue());
- if(eWrapS == Base3DTextureSingle || eWrapT == Base3DTextureSingle)
- bTextureKindChanged = sal_True;
- }
-}
-
-Color B3dTexture::GetTextureColor()
-{
- Color aRetval(aColTexture.GetRed(),
- aColTexture.GetGreen(),
- aColTexture.GetBlue());
- return aRetval;
-}
-
-/*************************************************************************
-|*
-|* Internen Verteilungswert setzen
-|*
-\************************************************************************/
-
-void B3dTexture::SetSwitchVal()
-{
- nSwitchVal = 0;
-
- // Kind
- if(GetTextureKind() == Base3DTextureLuminance)
- nSwitchVal |= B3D_TXT_KIND_LUM;
- else if(GetTextureKind() == Base3DTextureIntensity)
- nSwitchVal |= B3D_TXT_KIND_INT;
- else if(GetTextureKind() == Base3DTextureColor)
- nSwitchVal |= B3D_TXT_KIND_COL;
-
- // Mode
- if(GetTextureMode() == Base3DTextureReplace)
- nSwitchVal |= B3D_TXT_MODE_REP;
- else if(GetTextureMode() == Base3DTextureModulate)
- nSwitchVal |= B3D_TXT_MODE_MOD;
- else if(GetTextureMode() == Base3DTextureBlend)
- nSwitchVal |= B3D_TXT_MODE_BND;
-
- // Filter
- if(GetTextureFilter() == Base3DTextureNearest)
- nSwitchVal |= B3D_TXT_FLTR_NEA;
-}
-
-/*************************************************************************
-|*
-|* Zugriffsfunktion auf die Farben der Bitmap
-|*
-\************************************************************************/
-
-BitmapColor B3dTexture::GetBitmapColor(long nX, long nY) const
-{
- return pReadAccess->GetColor(nY, nX);
-}
-
-sal_uInt8 B3dTexture::GetBitmapTransparency(long nX, long nY) const
-{
- if(pAlphaReadAccess)
- return pAlphaReadAccess->GetColor(nY, nX).GetIndex();
- return 0;
-}
-
-/*************************************************************************
-|*
-|* Art der Pixeldaten lesen/bestimmen
-|*
-\************************************************************************/
-
-void B3dTexture::SetTextureKind(Base3DTextureKind eNew)
-{
- if(eKind != eNew)
- {
- eKind = eNew;
- bTextureKindChanged = sal_True;
- }
- SetSwitchVal();
-}
-
-/*************************************************************************
-|*
-|* Texturmodus lesen/bestimmen
-|*
-\************************************************************************/
-
-void B3dTexture::SetTextureMode(Base3DTextureMode eNew)
-{
- eMode = eNew;
- SetSwitchVal();
-}
-
-/*************************************************************************
-|*
-|* Filtermodus lesen/bestimmen
-|*
-\************************************************************************/
-
-void B3dTexture::SetTextureFilter(Base3DTextureFilter eNew)
-{
- eFilter = eNew;
- SetSwitchVal();
-}
-
-/*************************************************************************
-|*
-|* Die Texturfunktion selbst. Die ursruengliche Farbe des Punktes
-|* innerhalb der Grenzen des Parameterbereiches S,T (in Bitmapkoordinaten)
-|* wird modifiziert.
-|*
-\************************************************************************/
-
-void B3dTexture::ModifyColor(Color& rCol, double fS, double fT)
-{
- // Integer-Koordinaten der Texturposition bilden
- long nX((long)fS);
- long nY((long)fT);
- BitmapColor aBmCol = aColTexture;
- sal_Bool bOnTexture(sal_True);
-
- // Wrapping in S-Richtung
- if(eWrapS == Base3DTextureClamp)
- {
- // Clamping
- if(nX < 0)
- nX = 0;
- else if(nX >= GetBitmapSize().Width())
- nX = GetBitmapSize().Width() - 1;
- }
- else if(eWrapS == Base3DTextureRepeat)
- {
- // Repeating
- nX %= GetBitmapSize().Width();
- if(nX < 0)
- nX += GetBitmapSize().Width();
- }
- else
- {
- // Single
- if(nX < 0 || nX >= GetBitmapSize().Width())
- bOnTexture = sal_False;
- }
-
- // Wrapping in T-Richtung
- if(bOnTexture)
- {
- if(eWrapT == Base3DTextureClamp)
- {
- // Clamping
- if(nY < 0)
- nY = 0;
- else if(nY >= GetBitmapSize().Height())
- nY = GetBitmapSize().Height() - 1;
- }
- else if(eWrapT == Base3DTextureRepeat)
- {
- // Repeating
- nY %= GetBitmapSize().Height();
- if(nY < 0)
- nY += GetBitmapSize().Height();
- }
- else
- {
- // Single
- if(nY < 0 || nY >= GetBitmapSize().Height())
- bOnTexture = sal_False;
- }
-
- if(bOnTexture)
- aBmCol = pReadAccess->GetColor(nY, nX);
- }
-
- // transparence
- if(bOnTexture && pAlphaReadAccess)
- rCol.SetTransparency(pAlphaReadAccess->GetLuminance(nY, nX));
-
- // Falls die Position nicht innerhalb der Textur ist, auch das Filtern
- // unterdruecken um keine falschen BitmapAcesses zu bekommen
- sal_uInt8 nLocalSwitchVal(nSwitchVal);
- if(!bOnTexture)
- nLocalSwitchVal |= B3D_TXT_FLTR_NEA;
-
- switch(nLocalSwitchVal)
- {
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_REP|B3D_TXT_KIND_COL) :
- {
- rCol.SetRed(aBmCol.GetRed());
- rCol.SetGreen(aBmCol.GetGreen());
- rCol.SetBlue(aBmCol.GetBlue());
- break;
- }
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_MOD|B3D_TXT_KIND_COL) :
- {
- rCol.SetRed((sal_uInt8)( ((sal_uInt16)rCol.GetRed() * (sal_uInt16)aBmCol.GetRed())>>8 ));
- rCol.SetGreen((sal_uInt8)( ((sal_uInt16)rCol.GetGreen() * (sal_uInt16)aBmCol.GetGreen())>>8 ));
- rCol.SetBlue((sal_uInt8)( ((sal_uInt16)rCol.GetBlue() * (sal_uInt16)aBmCol.GetBlue())>>8 ));
- break;
- }
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_BND|B3D_TXT_KIND_COL) :
- {
- rCol.SetRed((sal_uInt8)( ((sal_uInt16)rCol.GetRed() * (0x00ff - (sal_uInt16)aBmCol.GetRed()))
- + ((sal_uInt16)aColBlend.GetRed() * (sal_uInt16)aBmCol.GetRed()) ));
- rCol.SetGreen((sal_uInt8)( ((sal_uInt16)rCol.GetGreen() * (0x00ff - (sal_uInt16)aBmCol.GetGreen()))
- + ((sal_uInt16)aColBlend.GetGreen() * (sal_uInt16)aBmCol.GetGreen()) ));
- rCol.SetBlue((sal_uInt8)( ((sal_uInt16)rCol.GetBlue() * (0x00ff - (sal_uInt16)aBmCol.GetBlue()))
- + ((sal_uInt16)aColBlend.GetBlue() * (sal_uInt16)aBmCol.GetBlue()) ));
- break;
- }
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_REP|B3D_TXT_KIND_INT) :
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_REP|B3D_TXT_KIND_LUM) :
- {
- rCol.SetRed((aBmCol.GetRed() + aBmCol.GetGreen() + aBmCol.GetBlue()) / 3);
- rCol.SetGreen(rCol.GetRed());
- rCol.SetBlue(rCol.GetRed());
- break;
- }
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_MOD|B3D_TXT_KIND_INT) :
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_MOD|B3D_TXT_KIND_LUM) :
- {
- sal_uInt16 nMidCol = (aBmCol.GetRed() + aBmCol.GetGreen() + aBmCol.GetBlue()) / 3;
- rCol.SetRed((sal_uInt8)( ((sal_uInt16)rCol.GetRed() * nMidCol)>>8 ));
- rCol.SetGreen((sal_uInt8)( ((sal_uInt16)rCol.GetGreen() * nMidCol)>>8 ));
- rCol.SetBlue((sal_uInt8)( ((sal_uInt16)rCol.GetBlue() * nMidCol)>>8 ));
- break;
- }
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_BND|B3D_TXT_KIND_INT) :
- case (B3D_TXT_FLTR_NEA|B3D_TXT_MODE_BND|B3D_TXT_KIND_LUM) :
- {
- sal_uInt16 nMidCol = (aBmCol.GetRed() + aBmCol.GetGreen() + aBmCol.GetBlue()) / 3;
- sal_uInt16 nInvMidCol = 0x00ff - nMidCol;
- rCol.SetRed((sal_uInt8)( ((sal_uInt16)rCol.GetRed() * nInvMidCol)
- + ((sal_uInt16)aColBlend.GetRed() * nMidCol) ));
- rCol.SetGreen((sal_uInt8)( ((sal_uInt16)rCol.GetGreen() * nInvMidCol)
- + ((sal_uInt16)aColBlend.GetGreen() * nMidCol) ));
- rCol.SetBlue((sal_uInt8)( ((sal_uInt16)rCol.GetBlue() * nInvMidCol)
- + ((sal_uInt16)aColBlend.GetBlue() * nMidCol) ));
- break;
- }
- case (B3D_TXT_MODE_REP|B3D_TXT_KIND_COL) :
- {
- fS = fS - floor(fS);
- fT = fT - floor(fT);
- long nX2, nY2;
-
- if(fS > 0.5) {
- nX2 = (nX + 1) % GetBitmapSize().Width();
- fS = 1.0 - fS;
- } else
- nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
-
- if(fT > 0.5) {
- nY2 = (nY + 1) % GetBitmapSize().Height();
- fT = 1.0 - fT;
- } else
- nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
-
- fS += 0.5;
- fT += 0.5;
- double fRight = 1.0 - fS;
- double fBottom = 1.0 - fT;
-
- BitmapColor aColTL = pReadAccess->GetColor(nY, nX);
- BitmapColor aColTR = pReadAccess->GetColor(nY, nX2);
- BitmapColor aColBL = pReadAccess->GetColor(nY2, nX);
- BitmapColor aColBR = pReadAccess->GetColor(nY2, nX2);
-
- rCol.SetRed((sal_uInt8)(((double)aColTL.GetRed() * fS + (double)aColTR.GetRed() * fRight) * fT
- + ((double)aColBL.GetRed() * fS + (double)aColBR.GetRed() * fRight) * fBottom));
- rCol.SetGreen((sal_uInt8)(((double)aColTL.GetGreen() * fS + (double)aColTR.GetGreen() * fRight) * fT
- + ((double)aColBL.GetGreen() * fS + (double)aColBR.GetGreen() * fRight) * fBottom));
- rCol.SetBlue((sal_uInt8)(((double)aColTL.GetBlue() * fS + (double)aColTR.GetBlue() * fRight) * fT
- + ((double)aColBL.GetBlue() * fS + (double)aColBR.GetBlue() * fRight) * fBottom));
- break;
- }
- case (B3D_TXT_MODE_MOD|B3D_TXT_KIND_COL) :
- {
- fS = fS - floor(fS);
- fT = fT - floor(fT);
- long nX2, nY2;
-
- if(fS > 0.5) {
- nX2 = (nX + 1) % GetBitmapSize().Width();
- fS = 1.0 - fS;
- } else
- nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
-
- if(fT > 0.5) {
- nY2 = (nY + 1) % GetBitmapSize().Height();
- fT = 1.0 - fT;
- } else
- nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
-
- fS += 0.5;
- fT += 0.5;
- double fRight = 1.0 - fS;
- double fBottom = 1.0 - fT;
-
- BitmapColor aColTL = pReadAccess->GetColor(nY, nX);
- BitmapColor aColTR = pReadAccess->GetColor(nY, nX2);
- BitmapColor aColBL = pReadAccess->GetColor(nY2, nX);
- BitmapColor aColBR = pReadAccess->GetColor(nY2, nX2);
-
- double fRed = ((double)aColTL.GetRed() * fS + (double)aColTR.GetRed() * fRight) * fT
- + ((double)aColBL.GetRed() * fS + (double)aColBR.GetRed() * fRight) * fBottom;
- double fGreen = ((double)aColTL.GetGreen() * fS + (double)aColTR.GetGreen() * fRight) * fT
- + ((double)aColBL.GetGreen() * fS + (double)aColBR.GetGreen() * fRight) * fBottom;
- double fBlue = ((double)aColTL.GetBlue() * fS + (double)aColTR.GetBlue() * fRight) * fT
- + ((double)aColBL.GetBlue() * fS + (double)aColBR.GetBlue() * fRight) * fBottom;
-
- rCol.SetRed((sal_uInt8)(((double)rCol.GetRed() * fRed) / 255.0));
- rCol.SetGreen((sal_uInt8)(((double)rCol.GetGreen() * fGreen) / 255.0));
- rCol.SetBlue((sal_uInt8)(((double)rCol.GetBlue() * fBlue) / 255.0));
- break;
- }
- case (B3D_TXT_MODE_BND|B3D_TXT_KIND_COL) :
- {
- fS = fS - floor(fS);
- fT = fT - floor(fT);
- long nX2, nY2;
-
- if(fS > 0.5) {
- nX2 = (nX + 1) % GetBitmapSize().Width();
- fS = 1.0 - fS;
- } else
- nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
-
- if(fT > 0.5) {
- nY2 = (nY + 1) % GetBitmapSize().Height();
- fT = 1.0 - fT;
- } else
- nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
-
- fS += 0.5;
- fT += 0.5;
- double fRight = 1.0 - fS;
- double fBottom = 1.0 - fT;
-
- BitmapColor aColTL = pReadAccess->GetColor(nY, nX);
- BitmapColor aColTR = pReadAccess->GetColor(nY, nX2);
- BitmapColor aColBL = pReadAccess->GetColor(nY2, nX);
- BitmapColor aColBR = pReadAccess->GetColor(nY2, nX2);
-
- double fRed = ((double)aColTL.GetRed() * fS + (double)aColTR.GetRed() * fRight) * fT
- + ((double)aColBL.GetRed() * fS + (double)aColBR.GetRed() * fRight) * fBottom;
- double fGreen = ((double)aColTL.GetGreen() * fS + (double)aColTR.GetGreen() * fRight) * fT
- + ((double)aColBL.GetGreen() * fS + (double)aColBR.GetGreen() * fRight) * fBottom;
- double fBlue = ((double)aColTL.GetBlue() * fS + (double)aColTR.GetBlue() * fRight) * fT
- + ((double)aColBL.GetBlue() * fS + (double)aColBR.GetBlue() * fRight) * fBottom;
-
- rCol.SetRed((sal_uInt8)((((double)rCol.GetRed() * (255.0 - fRed)) + ((double)aColBlend.GetRed() * fRed)) / 255.0));
- rCol.SetGreen((sal_uInt8)((((double)rCol.GetGreen() * (255.0 - fGreen)) + ((double)aColBlend.GetGreen() * fGreen)) / 255.0));
- rCol.SetBlue((sal_uInt8)((((double)rCol.GetBlue() * (255.0 - fBlue)) + ((double)aColBlend.GetBlue() * fBlue)) / 255.0));
- break;
- }
- case (B3D_TXT_MODE_REP|B3D_TXT_KIND_INT) :
- case (B3D_TXT_MODE_REP|B3D_TXT_KIND_LUM) :
- {
- fS = fS - floor(fS);
- fT = fT - floor(fT);
- long nX2, nY2;
-
- if(fS > 0.5) {
- nX2 = (nX + 1) % GetBitmapSize().Width();
- fS = 1.0 - fS;
- } else
- nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
-
- if(fT > 0.5) {
- nY2 = (nY + 1) % GetBitmapSize().Height();
- fT = 1.0 - fT;
- } else
- nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
-
- fS += 0.5;
- fT += 0.5;
- double fRight = 1.0 - fS;
- double fBottom = 1.0 - fT;
-
- sal_uInt8 nMidVal = (sal_uInt8)((
- (double)pReadAccess->GetLuminance(nY, nX) * fS +
- (double)pReadAccess->GetLuminance(nY, nX2) * fRight) * fT + (
- (double)pReadAccess->GetLuminance(nY2, nX) * fS +
- (double)pReadAccess->GetLuminance(nY2, nX2) * fRight) * fBottom);
-
- rCol.SetRed(nMidVal);
- rCol.SetGreen(nMidVal);
- rCol.SetBlue(nMidVal);
- break;
- }
- case (B3D_TXT_MODE_MOD|B3D_TXT_KIND_INT) :
- case (B3D_TXT_MODE_MOD|B3D_TXT_KIND_LUM) :
- {
- fS = fS - floor(fS);
- fT = fT - floor(fT);
- long nX2, nY2;
-
- if(fS > 0.5) {
- nX2 = (nX + 1) % GetBitmapSize().Width();
- fS = 1.0 - fS;
- } else
- nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
-
- if(fT > 0.5) {
- nY2 = (nY + 1) % GetBitmapSize().Height();
- fT = 1.0 - fT;
- } else
- nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
-
- fS += 0.5;
- fT += 0.5;
- double fRight = 1.0 - fS;
- double fBottom = 1.0 - fT;
-
- double fMidVal = (
- (double)pReadAccess->GetLuminance(nY, nX) * fS +
- (double)pReadAccess->GetLuminance(nY, nX2) * fRight) * fT + (
- (double)pReadAccess->GetLuminance(nY2, nX) * fS +
- (double)pReadAccess->GetLuminance(nY2, nX2) * fRight) * fBottom;
-
- rCol.SetRed((sal_uInt8)(((double)rCol.GetRed() * fMidVal) / 255.0));
- rCol.SetGreen((sal_uInt8)(((double)rCol.GetGreen() * fMidVal) / 255.0));
- rCol.SetBlue((sal_uInt8)(((double)rCol.GetBlue() * fMidVal) / 255.0));
- break;
- }
- case (B3D_TXT_MODE_BND|B3D_TXT_KIND_INT) :
- case (B3D_TXT_MODE_BND|B3D_TXT_KIND_LUM) :
- {
- fS = fS - floor(fS);
- fT = fT - floor(fT);
- long nX2, nY2;
-
- if(fS > 0.5) {
- nX2 = (nX + 1) % GetBitmapSize().Width();
- fS = 1.0 - fS;
- } else
- nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
-
- if(fT > 0.5) {
- nY2 = (nY + 1) % GetBitmapSize().Height();
- fT = 1.0 - fT;
- } else
- nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
-
- fS += 0.5;
- fT += 0.5;
- double fRight = 1.0 - fS;
- double fBottom = 1.0 - fT;
-
- double fMidVal = (
- (double)pReadAccess->GetLuminance(nY, nX) * fS +
- (double)pReadAccess->GetLuminance(nY, nX2) * fRight) * fT + (
- (double)pReadAccess->GetLuminance(nY2, nX) * fS +
- (double)pReadAccess->GetLuminance(nY2, nX2) * fRight) * fBottom;
- double fInvMidVal(255.0 - fMidVal);
-
- rCol.SetRed((sal_uInt8)((((double)rCol.GetRed() * fInvMidVal) + ((double)aColBlend.GetRed() * fMidVal)) / 255.0));
- rCol.SetGreen((sal_uInt8)((((double)rCol.GetGreen() * fInvMidVal) + ((double)aColBlend.GetGreen() * fMidVal)) / 255.0));
- rCol.SetBlue((sal_uInt8)((((double)rCol.GetBlue() * fInvMidVal) + ((double)aColBlend.GetBlue() * fMidVal)) / 255.0));
- break;
- }
- }
-
-// Funktionsfaehige Version komplett auf double precision und
-// kuerzesten Pfaden
-//
-// // Parameter fuer Farbe der Texturstelle bereitstellen
-// double fRed, fGreen, fBlue;
-//
-// // Eventuell glaetten?
-// if(GetTextureFilter() == Base3DTextureLinear)
-// {
-// // Filtern
-// double fLeft = fS - floor(fS);
-// double fTop = fT - floor(fT);
-// double fRight, fBottom;
-// long nX2, nY2;
-//
-// if(fLeft > 0.5)
-// {
-// nX2 = (nX + 1) % GetBitmapSize().Width();
-// fLeft = (1.0 - fLeft) + 0.5;
-// fRight = 1.0 - fLeft;
-// }
-// else
-// {
-// nX2 = nX ? nX - 1 : GetBitmapSize().Width() - 1;
-// fLeft = fLeft + 0.5;
-// fRight = 1.0 - fLeft;
-// }
-//
-//
-// if(fTop > 0.5)
-// {
-// nY2 = (nY + 1) % GetBitmapSize().Height();
-// fTop = (1.0 - fTop) + 0.5;
-// fBottom = 1.0 - fTop;
-// }
-// else
-// {
-// nY2 = nY ? nY - 1 : GetBitmapSize().Height() - 1;
-// fTop = fTop + 0.5;
-// fBottom = 1.0 - fTop;
-// }
-//
-// const BitmapColor& rColTL = GetBitmapColor(nX, nY);
-// const BitmapColor& rColTR = GetBitmapColor(nX2, nY);
-// const BitmapColor& rColBL = GetBitmapColor(nX, nY2);
-// const BitmapColor& rColBR = GetBitmapColor(nX2, nY2);
-//
-// fRed = ((double)rColTL.GetRed() * fLeft + (double)rColTR.GetRed() * fRight) * fTop
-// + ((double)rColBL.GetRed() * fLeft + (double)rColBR.GetRed() * fRight) * fBottom;
-//
-// fGreen = ((double)rColTL.GetGreen() * fLeft + (double)rColTR.GetGreen() * fRight) * fTop
-// + ((double)rColBL.GetGreen() * fLeft + (double)rColBR.GetGreen() * fRight) * fBottom;
-//
-// fBlue = ((double)rColTL.GetBlue() * fLeft + (double)rColTR.GetBlue() * fRight) * fTop
-// + ((double)rColBL.GetBlue() * fLeft + (double)rColBR.GetBlue() * fRight) * fBottom;
-// }
-// else
-// {
-// // Nearest Pixel
-// const BitmapColor& rBmCol = GetBitmapColor(nX, nY);
-// fRed = (double)rBmCol.GetRed();
-// fGreen = (double)rBmCol.GetGreen();
-// fBlue = (double)rBmCol.GetBlue();
-// }
-//
-// // Jetzt anhand der TextureKind entscheiden
-// if(eKind == Base3DTextureColor)
-// {
-// if(eMode == Base3DTextureReplace)
-// {
-// rCol.SetRed((sal_uInt8)fRed);
-// rCol.SetGreen((sal_uInt8)fGreen);
-// rCol.SetBlue((sal_uInt8)fBlue);
-// }
-// else if(eMode == Base3DTextureModulate)
-// {
-// rCol.SetRed((sal_uInt8)(((double)rCol.GetRed() * fRed) / 255.0));
-// rCol.SetGreen((sal_uInt8)(((double)rCol.GetGreen() * fGreen) / 255.0));
-// rCol.SetBlue((sal_uInt8)(((double)rCol.GetBlue() * fBlue) / 255.0));
-// }
-// else // Base3DTextureBlend
-// {
-// rCol.SetRed((sal_uInt8)((((double)rCol.GetRed() * (255.0 - fRed)) + ((double)aColBlend.GetRed() * fRed)) / 255.0));
-// rCol.SetGreen((sal_uInt8)((((double)rCol.GetGreen() * (255.0 - fGreen)) + ((double)aColBlend.GetGreen() * fGreen)) / 255.0));
-// rCol.SetBlue((sal_uInt8)((((double)rCol.GetBlue() * (255.0 - fBlue)) + ((double)aColBlend.GetBlue() * fBlue)) / 255.0));
-// }
-// }
-// else
-// {
-// double fMidVal((fRed + fGreen + fBlue) / 3.0);
-// if(eMode == Base3DTextureReplace)
-// {
-// rCol.SetRed((sal_uInt8)fMidVal);
-// rCol.SetGreen((sal_uInt8)fMidVal);
-// rCol.SetBlue((sal_uInt8)fMidVal);
-// }
-// else if(eMode == Base3DTextureModulate)
-// {
-// rCol.SetRed((sal_uInt8)(((double)rCol.GetRed() * fMidVal) / 255.0));
-// rCol.SetGreen((sal_uInt8)(((double)rCol.GetGreen() * fMidVal) / 255.0));
-// rCol.SetBlue((sal_uInt8)(((double)rCol.GetBlue() * fMidVal) / 255.0));
-// }
-// else // Base3DTextureBlend
-// {
-// double fInvMidVal(255.0 - fMidVal);
-// rCol.SetRed((sal_uInt8)((((double)rCol.GetRed() * fInvMidVal) + ((double)aColBlend.GetRed() * fRed)) / 255.0));
-// rCol.SetGreen((sal_uInt8)((((double)rCol.GetGreen() * fInvMidVal) + ((double)aColBlend.GetGreen() * fGreen)) / 255.0));
-// rCol.SetBlue((sal_uInt8)((((double)rCol.GetBlue() * fInvMidVal) + ((double)aColBlend.GetBlue() * fBlue)) / 255.0));
-// }
-// }
-}
-
-/*************************************************************************
-|*
-|* Konstruktor TexturOpenGL
-|*
-\************************************************************************/
-
-B3dTextureOpenGL::B3dTextureOpenGL(
- TextureAttributes& rAtt,
- BitmapEx& rBmpEx,
- OpenGL& rOGL,
- Base3DTextureKind eKnd,
- Base3DTextureMode eMod,
- Base3DTextureFilter eFlt,
- Base3DTextureWrap eS,
- Base3DTextureWrap eT)
-: B3dTexture(rAtt, rBmpEx, eKnd, eMod, eFlt, eS, eT),
- nTextureName(0)
-{
- // TextureName anfordern
- rOGL.GenTextures(1, &nTextureName);
-}
-
-/*************************************************************************
-|*
-|* Destruktor TexturOpenGL
-|*
-\************************************************************************/
-
-B3dTextureOpenGL::~B3dTextureOpenGL()
-{
-}
-
-/*************************************************************************
-|*
-|* In OpenGL die Textur zerstoeren
-|*
-\************************************************************************/
-
-void B3dTextureOpenGL::DestroyOpenGLTexture(OpenGL& rOpenGL)
-{
- // OpenGL Textur wieder freigeben
- rOpenGL.DeleteTextures(1, &nTextureName);
-}
-
-/*************************************************************************
-|*
-|* Setze diese Textur in OpenGL als aktuelle Textur
-|*
-\************************************************************************/
-
-void B3dTextureOpenGL::MakeCurrentTexture(OpenGL& rOpenGL)
-{
- // Eventuell Textur erst erzeugen?
- if(!rOpenGL.IsTexture(nTextureName) || bTextureKindChanged)
- {
- // Textur erzeugen und binden
- CreateOpenGLTexture(rOpenGL);
- }
- else
- {
- // Jetzt Textur binden
- rOpenGL.BindTexture(GL_TEXTURE_2D, nTextureName);
- }
-
- // Nun die Parameter an der Textur setzen
- switch(GetTextureWrapS())
- {
- case Base3DTextureSingle :
- case Base3DTextureClamp :
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- break;
- case Base3DTextureRepeat :
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- break;
- }
- switch(GetTextureWrapT())
- {
- case Base3DTextureSingle :
- case Base3DTextureClamp :
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- break;
- case Base3DTextureRepeat :
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- break;
- }
- switch(GetTextureFilter())
- {
- case Base3DTextureNearest :
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- break;
- case Base3DTextureLinear :
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- rOpenGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- break;
- }
- switch(GetTextureMode())
- {
- case Base3DTextureReplace :
- rOpenGL.TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- break;
- case Base3DTextureModulate :
- rOpenGL.TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- break;
- case Base3DTextureBlend :
- {
- rOpenGL.TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
- float fArray[4] = {
- ((float)GetBlendColor().GetRed()) / (float)255.0,
- ((float)GetBlendColor().GetGreen()) / (float)255.0,
- ((float)GetBlendColor().GetBlue()) / (float)255.0,
- ((float)GetBlendColor().GetTransparency()) / (float)255.0
- };
- rOpenGL.TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, fArray);
- break;
- }
- }
-}
-
-/*************************************************************************
-|*
-|* Erzeuge diese Textur als OpenGL-Textur
-|*
-\************************************************************************/
-
-void B3dTextureOpenGL::CreateOpenGLTexture(OpenGL& rOpenGL)
-{
- Size aSize(0,0);
-
- // Groesse entscheiden (auf 1024 begrenzen)
- for(sal_uInt16 a=1;a<0x0400 && (!aSize.Width() || !aSize.Height());a<<=1)
- {
- if(!aSize.Width() && (a>=GetBitmapSize().Width()))
- aSize.Width() = a;
- if(!aSize.Height() && (a>=GetBitmapSize().Height()))
- aSize.Height() = a;
- }
-
- // begrenzen falls groesser als 1024
- if(!aSize.Width())
- aSize.Width() = 0x0400;
- if(!aSize.Height())
- aSize.Height() = 0x0400;
-
- // Minimalgroesse garantieren, auch an 4Byte-Alignment denken
- // falls hier mal geaendert wird... (siehe OpenGL Bitmap Befehle)
- if(aSize.Width() < 8)
- aSize.Width() = 8;
- if(aSize.Height() < 8)
- aSize.Height() = 8;
-
- // Skalierte Bitmap anlegen
- sal_Bool bUsesAlpha(!!GetAlphaMask());
- Bitmap aLocalBitmap(GetBitmap());
- AlphaMask aTransAlphaMask;
-
- if(bUsesAlpha)
- {
- aTransAlphaMask = GetAlphaMask();
- }
-
- if(aSize != GetBitmapSize())
- {
- aLocalBitmap.Scale((double)aSize.Width() / (double)GetBitmapSize().Width(),
- (double)aSize.Height() / (double)GetBitmapSize().Height());
-
- if(bUsesAlpha)
- {
- aTransAlphaMask.Scale((double)aSize.Width() / (double)GetBitmapSize().Width(),
- (double)aSize.Height() / (double)GetBitmapSize().Height());
- }
- }
-
- // Falls es sich um eine nur einmal zu wiederholende Bitmap
- // handelt, lege nun eine mit einem definierten Rand an
- if(GetTextureWrapS() == Base3DTextureSingle || GetTextureWrapT() == Base3DTextureSingle)
- {
- Bitmap aHelpBitmap(aLocalBitmap);
- AlphaMask aTransAlphaHelpMask;
-
- if(bUsesAlpha)
- {
- aTransAlphaHelpMask = aTransAlphaMask;
- }
-
- Size aNewSize(aSize);
- Point aNewPos(0, 0);
-
- if(GetTextureWrapS() == Base3DTextureSingle)
- {
- aNewSize.Width() -= 4;
- aNewPos.X() = 2;
- }
- if(GetTextureWrapT() == Base3DTextureSingle)
- {
- aNewSize.Height() -= 4;
- aNewPos.Y() = 2;
- }
-
- aHelpBitmap.Scale((double)aNewSize.Width() / (double)aSize.Width(),
- (double)aNewSize.Height() / (double)aSize.Height());
- Color aEraseCol = GetTextureColor();
- aLocalBitmap.Erase(aEraseCol);
- Point aPoint;
- Rectangle aCopySrc(aPoint, aNewSize);
- Rectangle aCopyDest(aNewPos, aNewSize);
- aLocalBitmap.CopyPixel(aCopyDest, aCopySrc, &aHelpBitmap);
-
- if(bUsesAlpha)
- {
- aTransAlphaHelpMask.Scale((double)aNewSize.Width() / (double)aSize.Width(),
- (double)aNewSize.Height() / (double)aSize.Height());
- aTransAlphaMask.Erase(0);
- aTransAlphaMask.CopyPixel(aCopyDest, aCopySrc, &aTransAlphaHelpMask);
- }
- }
-
- // Lesezugriff auf neue Bitmap holen
- BitmapReadAccess* pLocalReadAccess = aLocalBitmap.AcquireReadAccess();
- BitmapReadAccess* pLocalAlphaReadAccess = (bUsesAlpha) ? aTransAlphaMask.AcquireReadAccess() : NULL;
- sal_Bool bGotReadAccess((bUsesAlpha)
- ? (pLocalReadAccess != 0 && pLocalAlphaReadAccess != 0) : pLocalReadAccess != 0);
-
- if(bGotReadAccess)
- {
- // Buffer holen
- sal_Int32 nSize(aSize.Width() * aSize.Height());
- sal_Int32 nAllocSize(nSize);
-
- if(GetTextureKind() == Base3DTextureColor)
- {
- nAllocSize += (2 * nSize);
- }
- if(bUsesAlpha)
- {
- nAllocSize += nSize;
- }
-
- GL_UINT8 pBuffer = (GL_UINT8) rtl_allocateMemory(nAllocSize);
-
- if(pBuffer)
- {
- // Daten kopieren
- GL_UINT8 pRunner = pBuffer;
- if(GetTextureKind() == Base3DTextureColor)
- {
- if(pLocalReadAccess->HasPalette())
- {
- for(long a=0;a<aSize.Height();a++)
- {
- for(long b=0;b<aSize.Width();b++)
- {
- BitmapColor rCol = pLocalReadAccess->GetPaletteColor(pLocalReadAccess->GetPixel(a, b));
- *pRunner++ = rCol.GetRed();
- *pRunner++ = rCol.GetGreen();
- *pRunner++ = rCol.GetBlue();
-
- if(bUsesAlpha)
- {
- BitmapColor rTrn = pLocalAlphaReadAccess->GetPixel(a, b);
- *pRunner++ = (BYTE)255 - rTrn.GetIndex();
- }
- }
- }
- }
- else
- {
- for(long a=0;a<aSize.Height();a++)
- {
- for(long b=0;b<aSize.Width();b++)
- {
- BitmapColor rCol = pLocalReadAccess->GetPixel(a, b);
- *pRunner++ = rCol.GetRed();
- *pRunner++ = rCol.GetGreen();
- *pRunner++ = rCol.GetBlue();
-
- if(bUsesAlpha)
- {
- BitmapColor rTrn = pLocalAlphaReadAccess->GetPixel(a, b);
- *pRunner++ = (BYTE)255 - rTrn.GetIndex();
- }
- }
- }
- }
- }
- else
- {
- if(pLocalReadAccess->HasPalette())
- {
- for(long a=0;a<aSize.Height();a++)
- {
- for(long b=0;b<aSize.Width();b++)
- {
- BitmapColor rCol = pLocalReadAccess->GetPaletteColor(pLocalReadAccess->GetPixel(a, b));
- *pRunner++ = (rCol.GetRed() + rCol.GetGreen() + rCol.GetBlue()) / 3;
-
- if(bUsesAlpha)
- {
- BitmapColor rTrn = pLocalAlphaReadAccess->GetPixel(a, b);
- *pRunner++ = (BYTE)255 - rTrn.GetIndex();
- }
- }
- }
- }
- else
- {
- for(long a=0;a<aSize.Height();a++)
- {
- for(long b=0;b<aSize.Width();b++)
- {
- BitmapColor rCol = pLocalReadAccess->GetPixel(a, b);
- *pRunner++ = (rCol.GetRed() + rCol.GetGreen() + rCol.GetBlue()) / 3;
-
- if(bUsesAlpha)
- {
- BitmapColor rTrn = pLocalAlphaReadAccess->GetPixel(a, b);
- *pRunner++ = (BYTE)255 - rTrn.GetIndex();
- }
- }
- }
- }
- }
-
- // Textur das erste mal binden und damit initialisieren
- rOpenGL.BindTexture(GL_TEXTURE_2D, nTextureName);
-
- // Jetzt ein glTexImage2D() ausfuehren
- GLint nInternalFormat = 0;
- GLint nFormat = 0;
-
- switch(GetTextureKind())
- {
- case Base3DTextureLuminance:
- {
- if(bUsesAlpha)
- {
- nInternalFormat = GL_LUMINANCE_ALPHA;
- nFormat = GL_LUMINANCE_ALPHA;
- }
- else
- {
- nInternalFormat = GL_LUMINANCE;
- nFormat = GL_LUMINANCE;
- }
- break;
- }
- case Base3DTextureIntensity:
- {
- if(bUsesAlpha)
- {
- nInternalFormat = GL_LUMINANCE_ALPHA;
- nFormat = GL_LUMINANCE_ALPHA;
- }
- else
- {
- nInternalFormat = GL_INTENSITY;
- nFormat = GL_LUMINANCE;
- }
- break;
- }
- case Base3DTextureColor:
- {
- if(bUsesAlpha)
- {
- nInternalFormat = GL_RGBA;
- nFormat = GL_RGBA;
- }
- else
- {
- nInternalFormat = GL_RGB;
- nFormat = GL_RGB;
- }
- break;
- }
- }
-
- rOpenGL.TexImage2D(GL_TEXTURE_2D, 0, nInternalFormat,
- (GLsizei)aSize.Width(),
- (GLsizei)aSize.Height(),
- 0, nFormat, GL_UNSIGNED_BYTE, pBuffer);
-
- rtl_freeMemory(pBuffer);
- }
- }
-
- // Lesezugriff freigeben
- if (pLocalReadAccess) aLocalBitmap.ReleaseAccess(pLocalReadAccess);
- if (pLocalAlphaReadAccess) aTransAlphaMask.ReleaseAccess(pLocalAlphaReadAccess);
-
- // Hinweis auf Veraenderung der Texturart auf jeden Fall elliminieren
- bTextureKindChanged = sal_False;
-}
-
-// eof
diff --git a/goodies/source/base3d/b3dtrans.cxx b/goodies/source/base3d/b3dtrans.cxx
index 96f6e6476405..fd2908c3ea2e 100644
--- a/goodies/source/base3d/b3dtrans.cxx
+++ b/goodies/source/base3d/b3dtrans.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: b3dtrans.cxx,v $
- * $Revision: 1.10 $
+ * $Revision: 1.10.42.1 $
*
* This file is part of OpenOffice.org.
*
@@ -31,13 +31,8 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_goodies.hxx"
#include "b3dtrans.hxx"
-#include <goodies/base3d.hxx>
#include <tools/debug.hxx>
-//#ifndef _B3D_VOLUM_HXX
-//#include "b3dvolum.hxx"
-//#endif
-
/*************************************************************************
|*
|* Transformationen fuer alle 3D Ausgaben
diff --git a/goodies/source/base3d/base3d.cxx b/goodies/source/base3d/base3d.cxx
deleted file mode 100644
index 1bad12fbe062..000000000000
--- a/goodies/source/base3d/base3d.cxx
+++ /dev/null
@@ -1,1267 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: base3d.cxx,v $
- * $Revision: 1.17 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include <svtools/options3d.hxx>
-#include <goodies/base3d.hxx>
-#include <goodies/b3dentty.hxx>
-#include "b3dtex.hxx"
-#include "b3dopngl.hxx"
-#include "b3ddeflt.hxx"
-
-//#ifndef _B3D_B3DPRINT_HXX
-//#include "b3dprint.hxx"
-//#endif
-#include <goodies/b3dgeom.hxx>
-#include "b3dtrans.hxx"
-#include <tools/shl.hxx>
-#include <tools/poly.hxx>
-#include <vcl/outdev.hxx>
-
-/*************************************************************************
-|*
-|* Konstruktor B3dGlobalData
-|*
-\************************************************************************/
-
-B3dGlobalData::B3dGlobalData()
-: maTextureStore(64, 16, 16) // init Container
-{
- // init timer
- maTimer.SetTimeout(10000); // ten seconds
- maTimer.SetTimeoutHdl(LINK(this, B3dGlobalData, TimerHdl));
- maTimer.Start();
-}
-
-/*************************************************************************
-|*
-|* Destruktor B3dGlobalData
-|*
-\************************************************************************/
-
-B3dGlobalData::~B3dGlobalData()
-{
- // stop timer
- maTimer.Stop();
- DeleteAllTextures();
-}
-
-/*************************************************************************
-|*
-|* Methods B3dGlobalData
-|*
-\************************************************************************/
-
-IMPL_LINK(B3dGlobalData, TimerHdl, AutoTimer*, EMPTYARG)
-{
- if(maTextureStore.Count())
- {
- maMutex.acquire();
- Time aTimeNow;
- for(sal_uInt16 a(0); a < maTextureStore.Count();)
- {
- B3dTexture* pRetval = (B3dTexture*)maTextureStore.GetObject(a);
- if(pRetval->GetTimeStamp() < aTimeNow)
- {
- maTextureStore.Remove(a);
- delete pRetval;
- }
- else
- a++;
- }
- maMutex.release();
- }
- return 0;
-}
-
-B3dTexture* B3dGlobalData::ObtainTexture(TextureAttributes& rAtt)
-{
- maMutex.acquire();
- for(sal_uInt16 a(0); a < maTextureStore.Count(); a++)
- {
- B3dTexture* pRetval = (B3dTexture*)maTextureStore.GetObject(a);
- if(pRetval->GetAttributes() == rAtt)
- {
- pRetval->Touch();
- maMutex.release();
- return pRetval;
- }
- }
- maMutex.release();
- return NULL;
-}
-
-void B3dGlobalData::InsertTexture(B3dTexture* pNew)
-{
- if(pNew)
- {
- maMutex.acquire();
- for(sal_uInt16 a(0); a < maTextureStore.Count(); a++)
- {
- B3dTexture* pRetval = (B3dTexture*)maTextureStore.GetObject(a);
- if(pRetval == pNew)
- {
- maMutex.release();
- return;
- }
- }
-
- pNew->Touch();
- maTextureStore.Insert(pNew, CONTAINER_APPEND);
- maMutex.release();
- }
-}
-
-void B3dGlobalData::DeleteTexture(B3dTexture* pOld)
-{
- if(pOld)
- {
- maMutex.acquire();
- for(sal_uInt16 a(0); a < maTextureStore.Count(); a++)
- {
- B3dTexture* pRetval = (B3dTexture*)maTextureStore.GetObject(a);
- if(pRetval == pOld)
- {
- maTextureStore.Remove(a);
- delete pOld;
- maMutex.release();
- return;
- }
- }
- maMutex.release();
- }
-}
-
-void B3dGlobalData::DeleteAllTextures()
-{
- if(maTextureStore.Count())
- {
- maMutex.acquire();
- for(sal_uInt16 a(0); a < maTextureStore.Count(); a++)
- {
- B3dTexture* pRetval = (B3dTexture*)maTextureStore.GetObject(a);
- delete pRetval;
- }
- maTextureStore.Clear();
- maMutex.release();
- }
-}
-
-/*************************************************************************
-|*
-|* Konstruktor Base3D
-|*
-\************************************************************************/
-
-Base3D::Base3D(OutputDevice* pOutDev)
-: OutDev3D(),
- pDevice(pOutDev),
- eObjectMode(Base3DPoints),
- aCurrentColor(Color(0xff, 0xff, 0xff)),
- aComplexPolygon(),
- eRenderModeFront(Base3DRenderFill),
- eRenderModeBack(Base3DRenderFill),
- eShadeModel(Base3DSmooth),
- eCullMode(Base3DCullNone),
- fPointSize(1.0),
- fLineWidth(1.0),
- pActiveTexture(NULL),
- pTransformationSet(NULL),
- pLightGroup(NULL),
- aMaterialFront(),
- aMaterialBack(),
- nDisplayQuality(127),
- mfPolygonOffset(0.005), // #i71618#
- bEdgeFlag(TRUE),
- bContextIsValid(TRUE),
- bPolyOffsetFill(FALSE),
- bPolyOffsetLine(FALSE),
- bPolyOffsetPoint(FALSE),
- bScissorRegionActive(FALSE),
- bDitherActive(TRUE)
-{
- // Grundsaetzliche Materialeigenschaften setzen
- ResetMaterial(Base3DMaterialFrontAndBack);
-
- // Fuer OS/2 die FP-Exceptions abschalten
-#if defined(OS2)
-#define SC_FPEXCEPTIONS_ON() _control87( MCW_EM, 0 )
-#define SC_FPEXCEPTIONS_OFF() _control87( MCW_EM, MCW_EM )
- SC_FPEXCEPTIONS_OFF();
-#endif
-
- // Fuer WIN95/NT die FP-Exceptions abschalten
-#if defined(WNT) || defined(WIN)
-#define SC_FPEXCEPTIONS_ON() _control87( _MCW_EM, 0 )
-#define SC_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
- SC_FPEXCEPTIONS_OFF();
-#endif
-}
-
-/*************************************************************************
-|*
-|* Destruktor Base3D
-|*
-\************************************************************************/
-
-Base3D::~Base3D()
-{
-}
-
-/*************************************************************************
-|*
-|* Erzeuge einen Base3D Kontext in Anhaengigkeit vom uebergebenen
-|* OutputDevice und trage Ihn dort ein
-|*
-\************************************************************************/
-
-Base3D* Base3D::Create(OutputDevice* pOutDev, BOOL bForcePrinter)
-{
- Base3D* pRetval = NULL;
- if(pOutDev)
- {
- // Anforderungen feststellen
- BOOL bOwnDevice = FALSE;
- if(pOutDev->GetOutDevType() == OUTDEV_VIRDEV
- || pOutDev->GetOutDevType() == OUTDEV_PRINTER
- || pOutDev->GetConnectMetaFile() != NULL)
- bOwnDevice = TRUE;
-
- // Existiert schon ein 3D-Kontext, der auch an dieses
- // OutputDevice gebunden ist?
- if(pOutDev->Get3DContext()
- && ((Base3D*)(pOutDev->Get3DContext()))->GetOutputDevice() == pOutDev)
- {
- pRetval = (Base3D*)pOutDev->Get3DContext();
- }
-
- // Falls Ja, ist er den Anforderungen gewachsen?
- if(pRetval)
- {
- BOOL bForceNew(FALSE);
-
- if((!bForceNew) && (bOwnDevice)&&(pRetval->GetBase3DType() == BASE3D_TYPE_OPENGL))
- {
- bForceNew = TRUE;
- }
-
- if((!bForceNew) && (bForcePrinter)&&(pRetval->GetBase3DType() != BASE3D_TYPE_PRINTER))
- {
- bForceNew = TRUE;
- }
-
- if((!bForceNew) && (!bForcePrinter)&&(pRetval->GetBase3DType() == BASE3D_TYPE_PRINTER))
- {
- bForceNew = TRUE;
- }
-
- if(!bForceNew && !bOwnDevice)
- {
- // Versuchen, einen OpenGL Kontext zu bekommen? Teste das
- // globale Flag aus der .INI
- BOOL bUseOpenGL = SvtOptions3D().IsOpenGL();
-
- if((bUseOpenGL && pRetval->GetBase3DType() != BASE3D_TYPE_OPENGL)
- || (!bUseOpenGL && pRetval->GetBase3DType() == BASE3D_TYPE_OPENGL))
- {
- bForceNew = TRUE;
- bOwnDevice = !bUseOpenGL;
- }
- }
-
- if(bForceNew)
- {
- pRetval->Destroy(pOutDev);
- pRetval = NULL;
- }
- }
-
- if(!pRetval)
- {
- // zerstoere altes Base3D, war nicht mehr an das
- // OutputDevice gebunden
- if(pOutDev->Get3DContext())
- pOutDev->Get3DContext()->Destroy(pOutDev);
-
- // erzeuge neues Base3D, je nach Anforderungen
- if(bForcePrinter)
- {
- DBG_ERROR("Base3D::Create(): Printer renderer not supported ATM, if needed migrate from old goodies lib.");
- // #i82966# fallback to default renderer instead of returning NULL
- pRetval = new Base3DDefault(pOutDev);
- //pRetval = new Base3DPrinter(pOutDev);
- }
- else if(bOwnDevice)
- {
- pRetval = new Base3DDefault(pOutDev);
- }
- else
- {
- // Versuche OpenGL, fallback auf default
- // falls OpenGL nicht verfuegbar
- pRetval = CreateScreenRenderer(pOutDev);
- }
-
- // 3D-Kontext eintragen als Renderer im angegebenen OutputDevice
- if(pRetval)
- pOutDev->Set3DContext((Base3D*)pRetval);
- }
- }
- return pRetval;
-}
-
-/*************************************************************************
-|*
-|* Versuche, einen 3D Kontext zur Bildschirmdarstellung zu generieren.
-|* Diese Funktion wird nur bei WNT realisiert. Sie muss entscheiden,
-|* ob OpenGL-DLL's verfuegbar sind und entsprechend den OpenGL
-|* Renderer oder einen Default Renderer erzeugen.
-|*
-\************************************************************************/
-
-Base3D* Base3D::CreateScreenRenderer(OutputDevice* pOutDev)
-{
- // OpenGL Kontext erzeugen
- Base3D* pRetval = NULL;
-
- // Versuchen, einen OpenGL Kontext zu bekommen? Teste das
- // globale Flag aus der .INI
- BOOL bUseOpenGL = SvtOptions3D().IsOpenGL();
-
- // Versuchen, einen OpenGL Kontext zu bekommen
- if(bUseOpenGL)
- pRetval = new Base3DOpenGL(pOutDev);
-
- if(!pRetval || !pRetval->IsContextValid())
- {
- if(pRetval)
- {
- delete pRetval;
- pRetval = NULL;
- }
- }
-
- // versuche alternativ, einen Default Renderer zu inkarnieren
- if(!pRetval)
- pRetval = new Base3DDefault(pOutDev);
-
- return pRetval;
-}
-
-/*************************************************************************
-|*
-|* Entferne den Kontext aus dem assoziierten OutputDevice und zerstoere
-|* sich selbst
-|*
-|* Als Platzhalter fuer den Zeiger auf einen Kontext im OutputDevice
-|* wird momentan pTheCurrentBase3DIncarnation benutzt
-|*
-\************************************************************************/
-
-void Base3D::Destroy(OutputDevice *)
-{
- Base3D* pTmp;
- if((pTmp = (Base3D*)GetOutputDevice()->Get3DContext()) == this)
- {
- GetOutputDevice()->Set3DContext(NULL);
- delete pTmp;
- }
-}
-
-/*************************************************************************
-|*
-|* TransformationSet setzen
-|*
-\************************************************************************/
-
-void Base3D::SetTransformationSet(B3dTransformationSet* pSet)
-{
- // Aktuelles TransformationSet eintragen
- pTransformationSet = pSet;
-}
-
-/*************************************************************************
-|*
-|* Beleuchtung setzen
-|*
-\************************************************************************/
-
-void Base3D::SetLightGroup(B3dLightGroup* pSet, BOOL /*bSetGlobal*/)
-{
- // Aktuelle Beleuchtung eintragen
- pLightGroup = pSet;
-}
-
-/*************************************************************************
-|*
-|* Scissoring Region setzen
-|*
-\************************************************************************/
-
-void Base3D::SetScissorRegionPixel(const Rectangle& rRect, BOOL bActivate)
-{
- aScissorRectangle = rRect;
- ActivateScissorRegion(bActivate);
-}
-
-void Base3D::SetScissorRegion(const Rectangle& rRect, BOOL bActivate)
-{
- SetScissorRegionPixel(pDevice->LogicToPixel(rRect), bActivate);
-}
-
-/*************************************************************************
-|*
-|* Scissoring aktivieren/deaktivieren
-|*
-\************************************************************************/
-
-void Base3D::ActivateScissorRegion(BOOL bNew)
-{
- if(bNew != bScissorRegionActive)
- bScissorRegionActive = bNew;
-}
-
-/*************************************************************************
-|*
-|* Dithering setzen
-|*
-\************************************************************************/
-
-void Base3D::SetDither(BOOL bNew)
-{
- bDitherActive = bNew;
-}
-
-/*************************************************************************
-|*
-|* Objektmodus holen
-|*
-\************************************************************************/
-
-Base3DObjectMode Base3D::GetObjectMode() const
-{
- return eObjectMode;
-}
-
-/*************************************************************************
-|*
-|* Ein neues Primitiv vom Typ nMode starten
-|*
-\************************************************************************/
-
-void Base3D::StartPrimitive(Base3DObjectMode eMode)
-{
- eObjectMode = eMode;
- if(eObjectMode > Base3DPolygon)
- {
- switch(eObjectMode)
- {
- case Base3DComplexPolygonCut :
- {
- // Neues Polygon beginnen
- aComplexPolygon.SetTestForCut(TRUE);
- aComplexPolygon.StartPrimitive();
- break;
- }
- case Base3DComplexPolygon :
- {
- // Neues Polygon beginnen
- aComplexPolygon.SetTestForCut(FALSE);
- aComplexPolygon.StartPrimitive();
- break;
- }
- default:
- break; // -Wall multiple cases not handled.
- }
- }
- else
- {
- ImplStartPrimitive();
- }
-}
-
-/*************************************************************************
-|*
-|* Primitiv beenden
-|*
-\************************************************************************/
-
-void Base3D::EndPrimitive()
-{
- if(eObjectMode > Base3DPolygon)
- {
- switch(eObjectMode)
- {
- case Base3DComplexPolygon :
- case Base3DComplexPolygonCut :
- {
- // Selbst fuer Darstellung sorgen
- aComplexPolygon.EndPrimitive(this);
- break;
- }
- default:
- break; // -Wall multiple values not handled.
- }
- }
- else
- {
- ImplEndPrimitive();
- }
-}
-
-/*************************************************************************
-|*
-|* Ein Objekt in Form einer B3dGeometry direkt ausgeben
-|*
-\************************************************************************/
-
-void Base3D::DrawPolygonGeometry(const B3dGeometry& rGeometry, sal_Bool bOutline)
-{
- // Buckets der Geometrie holen
- const B3dEntityBucket& rEntityBucket = rGeometry.GetEntityBucket();
- const GeometryIndexValueBucket& rIndexBucket = rGeometry.GetIndexBucket();
-
- UINT32 nPolyCounter = 0;
- UINT32 nEntityCounter = 0;
- UINT32 nUpperBound;
-
- while(nPolyCounter < rIndexBucket.Count())
- {
- // Naechstes Primitiv
- nUpperBound = rIndexBucket[nPolyCounter].GetIndex();
-
- if(bOutline)
- {
- // Polygon als Outline ausgeben
- SetRenderMode(Base3DRenderLine);
- SetPolygonOffset(Base3DPolygonOffsetLine, TRUE);
-
- // ALLE Linien Zeichnen
- SetCullMode(Base3DCullNone);
- }
- else
- {
- // Polygone gefuellt ausgeben
- SetRenderMode(Base3DRenderFill);
- SetPolygonOffset(Base3DPolygonOffsetLine, FALSE);
- }
-
- if(rIndexBucket[nPolyCounter++].GetMode() == B3D_INDEX_MODE_LINE)
- {
- eObjectMode = Base3DLineStrip;
- }
- else
- {
- eObjectMode = Base3DPolygon;
- }
-
- // Neues Polygon beginnen
- ImplStartPrimitive();
-
- // Polygon ausgeben
- while(nEntityCounter < nUpperBound)
- {
- B3dEntity& rEntity = ImplGetFreeEntity();
- rEntity = rEntityBucket[nEntityCounter++];
- if(bOutline)
- {
- rEntity.SetNormalUsed(FALSE);
- rEntity.SetTexCoorUsed(FALSE);
- SetEdgeFlag(rEntity.IsEdgeVisible());
- }
- ImplPostAddVertex(rEntity);
- }
-
- // Primitiv abschliessen
- ImplEndPrimitive();
- }
-}
-
-/*************************************************************************
-|*
-|* Direkter Zugriff auf B3dMaterial fuer abgeleitete Klassen
-|*
-\************************************************************************/
-
-B3dMaterial& Base3D::GetMaterialObject(Base3DMaterialMode eMode)
-{
- if(eMode == Base3DMaterialFront)
- return aMaterialFront;
- return aMaterialBack;
-}
-
-/*************************************************************************
-|*
-|* geometrische Daten uebernehmen
-|*
-\************************************************************************/
-
-void Base3D::AddVertex(basegfx::B3DPoint& rVertex)
-{
- // Platz fuer neue Daten holen
- B3dEntity& rEntity = GetFreeEntity();
- rEntity.Reset();
-
- // geometrische Daten
- rEntity.Point() = rVertex;
- rEntity.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rEntity.SetValid();
-
- // Nachbehandlung
- PostAddVertex(rEntity);
-}
-
-void Base3D::AddVertex(basegfx::B3DPoint& rVertex, basegfx::B3DVector& rNormal)
-{
- // Platz fuer neue Daten holen
- B3dEntity& rEntity = GetFreeEntity();
- rEntity.Reset();
-
- // geometrische Daten
- rEntity.Point() = rVertex;
- rEntity.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rEntity.SetValid();
-
- // Normale
- if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
- {
- rEntity.Normal() = rNormal;
- rEntity.SetNormalUsed();
- }
-
- // Nachbehandlung
- PostAddVertex(rEntity);
-}
-
-void Base3D::AddVertex(basegfx::B3DPoint& rVertex, basegfx::B3DVector& rNormal, basegfx::B2DPoint& rTexPos)
-{
- // Platz fuer neue Daten holen
- B3dEntity& rEntity = GetFreeEntity();
- rEntity.Reset();
-
- // geometrische Daten
- rEntity.Point() = rVertex;
- rEntity.PlaneNormal() = basegfx::B3DVector(); // #i68442# Init PlaneNormal
- rEntity.SetValid();
-
- // Normale
- if(GetLightGroup() && GetLightGroup()->IsLightingEnabled())
- {
- rEntity.Normal() = rNormal;
- rEntity.SetNormalUsed();
- }
-
- // Texturdaten
- rEntity.TexCoor() = rTexPos;
- rEntity.SetTexCoorUsed();
-
- // Nachbehandlung
- PostAddVertex(rEntity);
-}
-
-void Base3D::AddVertex(B3dEntity& rEnt)
-{
- // Platz fuer neue Daten holen
- B3dEntity& rEntity = GetFreeEntity();
-
- // Kopieren
- rEntity = rEnt;
-
- // Nachbehandlung
- PostAddVertex(rEntity);
-}
-
-void Base3D::PostAddVertex(B3dEntity& rEntity)
-{
- // Flag fuer die Sichtbarkeit von Kanten kopieren
- rEntity.SetEdgeVisible(GetEdgeFlag());
-
- // aktuelle Farbe eintragen
- rEntity.Color().SetColor(GetColor().GetColor());
-
- if(eObjectMode > Base3DPolygon)
- {
- switch(eObjectMode)
- {
- case Base3DComplexPolygon :
- case Base3DComplexPolygonCut :
- {
- // Punkt ist nun ausgefuellt
- aComplexPolygon.PostAddVertex(rEntity);
- break;
- }
- default:
- break; // -Wall multiple values not handled.
- }
- }
- else
- {
- ImplPostAddVertex(rEntity);
- }
-}
-
-/*************************************************************************
-|*
-|* Platz fuer neuen Punkt anfordern
-|*
-\************************************************************************/
-
-B3dEntity& Base3D::GetFreeEntity()
-{
- if(eObjectMode > Base3DPolygon)
- {
- switch(eObjectMode)
- {
- case Base3DComplexPolygon :
- case Base3DComplexPolygonCut :
- {
- // Im eigenen Buffer anlegen
- return aComplexPolygon.GetFreeEntity();
- }
- default:
- break;
- }
- }
- return ImplGetFreeEntity();
-}
-
-/*************************************************************************
-|*
-|* Farbe setzen
-|*
-\************************************************************************/
-
-void Base3D::SetColor(Color aNew)
-{
- // Farbe setzen
- if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
- {
- // Graustufen
- UINT8 nLuminance = aNew.GetLuminance();
- aCurrentColor = Color(nLuminance, nLuminance, nLuminance);
- }
- else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
- {
- // Keine Ausgabe, hier Schwarz als Farbe setzen, wird
- // als Linienfarbe benutzt
- aCurrentColor = Color(COL_BLACK);
- }
- else
- {
- // Normale Farbausgabe
- aCurrentColor = aNew;
- }
-}
-
-/*************************************************************************
-|*
-|* Farbe liefern
-|*
-\************************************************************************/
-
-Color Base3D::GetColor()
-{
- return aCurrentColor;
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften setzen
-|*
-\************************************************************************/
-
-void Base3D::SetMaterial(Color aNew,
- Base3DMaterialValue eVal,
- Base3DMaterialMode eMode)
-{
- Color aSource;
- if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
- {
- // Graustufen
- UINT8 nLuminance = aNew.GetLuminance();
- aSource.SetRed(nLuminance);
- aSource.SetGreen(nLuminance);
- aSource.SetBlue(nLuminance);
- aSource.SetTransparency(aNew.GetTransparency());
- }
- else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
- {
- // Keine Ausgabe, hier Weiss als Farbe setzen
- aSource = Color(COL_WHITE);
- }
- else
- {
- // Normale Farbausgabe
- aSource = aNew;
- }
-
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialFront)
- {
- aMaterialFront.SetMaterial(aSource, eVal);
- }
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialBack)
- {
- aMaterialBack.SetMaterial(aSource, eVal);
- }
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften abfragen
-|*
-\************************************************************************/
-
-Color Base3D::GetMaterial(Base3DMaterialValue eVal,
- Base3DMaterialMode eMode) const
-{
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialFront)
- {
- return aMaterialFront.GetMaterial(eVal);
- }
- return aMaterialBack.GetMaterial(eVal);
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften setzen, exponent der specular-Eigenschaft
-|*
-\************************************************************************/
-
-void Base3D::SetShininess(UINT16 nExponent,
- Base3DMaterialMode eMode)
-{
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialFront)
- {
- aMaterialFront.SetShininess(nExponent);
- }
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialBack)
- {
- aMaterialBack.SetShininess(nExponent);
- }
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften abfragen, exponent der specular-Eigenschaft
-|*
-\************************************************************************/
-
-UINT16 Base3D::GetShininess(Base3DMaterialMode eMode) const
-{
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialFront)
- {
- return aMaterialFront.GetShininess();
- }
- return aMaterialBack.GetShininess();
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften auf Ausgangszustand
-|*
-\************************************************************************/
-
-void Base3D::ResetMaterial(Base3DMaterialMode eMode)
-{
- Color aColor(255, 51, 51, 51);
- SetMaterial(aColor, Base3DMaterialAmbient, eMode);
- aColor.SetColor(TRGB_COLORDATA(255, 204, 204, 204));
- SetMaterial(aColor, Base3DMaterialDiffuse, eMode);
- aColor.SetColor(TRGB_COLORDATA(255, 0, 0, 0));
- SetMaterial(aColor, Base3DMaterialSpecular, eMode);
- aColor.SetColor(TRGB_COLORDATA(255, 0, 0, 0));
- SetMaterial(aColor, Base3DMaterialEmission, eMode);
- SetShininess(0, eMode);
-}
-
-/*************************************************************************
-|*
-|* GlobalData holen
-|*
-\************************************************************************/
-
-B3dGlobalData& Base3D::GetGlobalData()
-{
- B3dGlobalData** ppGlobalData = (B3dGlobalData**)GetAppData(SHL_BASE3D);
- if(*ppGlobalData)
- return **ppGlobalData;
-
- // GlobalData anlegen
- *ppGlobalData = new B3dGlobalData;
- return **ppGlobalData;
-}
-
-/*************************************************************************
-|*
-|* Textur mit den angegebenen Attributen als Grundlage anfordern.
-|*
-\************************************************************************/
-
-B3dTexture* Base3D::ObtainTexture(TextureAttributes& rAtt)
-{
- return GetGlobalData().ObtainTexture(rAtt);
-}
-
-/*************************************************************************
-|*
-|* Textur mit den angegebenen Attributen als Grundlage anfordern. Falls
-|* eine solche Textur nicht existiert, erzeuge eine und gib diese zurueck
-|*
-\************************************************************************/
-
-B3dTexture* Base3D::ObtainTexture(TextureAttributes& rAtt, BitmapEx& rBitmapEx)
-{
- B3dTexture* pRetval = GetGlobalData().ObtainTexture(rAtt);
- if(!pRetval)
- {
- pRetval = CreateTexture(rAtt, rBitmapEx);
- GetGlobalData().InsertTexture(pRetval);
- }
- return pRetval;
-}
-
-/*************************************************************************
-|*
-|* Gezielt eine Textur freigeben
-|*
-\************************************************************************/
-
-void Base3D::DeleteTexture(TextureAttributes& rAtt)
-{
- B3dTexture* pTexture = GetGlobalData().ObtainTexture(rAtt);
- if(pTexture)
- {
- if(pTexture == pActiveTexture)
- pActiveTexture = NULL;
-
- GetGlobalData().DeleteTexture(pTexture);
- }
-}
-
-/*************************************************************************
-|*
-|* Alle Texturen freigeben
-|*
-\************************************************************************/
-
-void Base3D::DeleteAllTextures()
-{
- pActiveTexture = NULL;
- GetGlobalData().DeleteAllTextures();
-}
-
-/*************************************************************************
-|*
-|* Ein Textur-Objekt inkarnieren
-|*
-\************************************************************************/
-
-B3dTexture* Base3D::CreateTexture(TextureAttributes& rAtt, BitmapEx& rBitmapEx)
-{
- B3dTexture* pRetval = new B3dTexture(rAtt, rBitmapEx);
- DBG_ASSERT(pRetval,"AW: Kein Speicher fuer Textur bekommen!");
- return pRetval;
-}
-
-/*************************************************************************
-|*
-|* Normale Textur loeschen
-|*
-\************************************************************************/
-
-void Base3D::DestroyTexture(B3dTexture* pTex)
-{
- delete pTex;
-}
-
-/*************************************************************************
-|*
-|* Aktuell zu benutzende Textur setzen
-|*
-\************************************************************************/
-
-void Base3D::SetActiveTexture(B3dTexture* pTex)
-{
- if(pTex)
- {
- if(GetOutputDevice()->GetDrawMode() & DRAWMODE_GRAYFILL)
- {
- // Graustufen
- pTex->SetTextureKind(Base3DTextureIntensity);
- }
- else if(GetOutputDevice()->GetDrawMode() & DRAWMODE_WHITEFILL)
- {
- // Keine Ausgabe, keine Textur setzen
- pTex = NULL;
- }
- }
-
- // ... und setzen
- pActiveTexture = pTex;
-}
-
-/*************************************************************************
-|*
-|* Darstellungsqualitaet setzen
-|*
-\************************************************************************/
-
-void Base3D::SetDisplayQuality(UINT8 nNew)
-{
- nDisplayQuality = nNew;
-}
-
-/*************************************************************************
-|*
-|* Darstellungsqualitaet lesen
-|*
-\************************************************************************/
-
-UINT8 Base3D::GetDisplayQuality() const
-{
- return nDisplayQuality;
-}
-
-/*************************************************************************
-|*
-|* PolygonOffset setzen
-|*
-\************************************************************************/
-
-void Base3D::SetPolygonOffset(Base3DPolygonOffset eNew, BOOL bNew)
-{
- switch(eNew)
- {
- case Base3DPolygonOffsetFill :
- bPolyOffsetFill = bNew;
- break;
-
- case Base3DPolygonOffsetLine :
- bPolyOffsetLine = bNew;
- break;
-
- case Base3DPolygonOffsetPoint :
- bPolyOffsetPoint = bNew;
- break;
- }
-}
-
-/*************************************************************************
-|*
-|* PolygonOffset lesen
-|*
-\************************************************************************/
-
-BOOL Base3D::GetPolygonOffset(Base3DPolygonOffset eNew) const
-{
- if(eNew == Base3DPolygonOffsetLine)
- return bPolyOffsetLine;
- if(eNew == Base3DPolygonOffsetFill)
- return bPolyOffsetFill;
- return bPolyOffsetPoint;
-}
-
-/*************************************************************************
-|*
-|* EdgeFlag lesen
-|*
-\************************************************************************/
-
-BOOL Base3D::GetEdgeFlag() const
-{
- return bEdgeFlag;
-}
-
-/*************************************************************************
-|*
-|* EdgeFlag schreiben
-|*
-\************************************************************************/
-
-void Base3D::SetEdgeFlag(BOOL bNew)
-{
- bEdgeFlag = bNew;
-}
-
-/*************************************************************************
-|*
-|* PointSize lesen
-|*
-\************************************************************************/
-
-double Base3D::GetPointSize() const
-{
- return fPointSize;
-}
-
-/*************************************************************************
-|*
-|* PointSize schreiben
-|*
-\************************************************************************/
-
-void Base3D::SetPointSize(double fNew)
-{
- fPointSize = fNew;
-}
-
-/*************************************************************************
-|*
-|* LineWidth lesen
-|*
-\************************************************************************/
-
-double Base3D::GetLineWidth() const
-{
- return fLineWidth;
-}
-
-/*************************************************************************
-|*
-|* LineWidth schreiben
-|*
-\************************************************************************/
-
-void Base3D::SetLineWidth(double fNew)
-{
- fLineWidth = fNew;
-}
-
-// #i71618#
-void Base3D::setPolygonOffset(double fNew)
-{
- if(fNew != mfPolygonOffset)
- {
- mfPolygonOffset = fNew;
- }
-}
-
-double Base3D::getPolygonOffset() const
-{
- return mfPolygonOffset;
-}
-
-/*************************************************************************
-|*
-|* RenderMode setzen
-|*
-\************************************************************************/
-
-void Base3D::SetRenderMode(Base3DRenderMode eNew,
- Base3DMaterialMode eMode)
-{
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialFront)
- {
- eRenderModeFront = eNew;
- }
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialBack)
- {
- eRenderModeBack = eNew;
- }
-}
-
-/*************************************************************************
-|*
-|* RenderMode lieferen
-|*
-\************************************************************************/
-
-Base3DRenderMode Base3D::GetRenderMode(Base3DMaterialMode eMode) const
-{
- if(eMode == Base3DMaterialFrontAndBack
- || eMode == Base3DMaterialFront)
- {
- return eRenderModeFront;
- }
- return eRenderModeBack;
-}
-
-/*************************************************************************
-|*
-|* ShadeModel setzen
-|*
-\************************************************************************/
-
-void Base3D::SetShadeModel(Base3DShadeModel eNew)
-{
- eShadeModel = eNew;
-}
-
-/*************************************************************************
-|*
-|* ShadeModel lieferen
-|*
-\************************************************************************/
-
-Base3DShadeModel Base3D::GetShadeModel() const
-{
- return eShadeModel;
-}
-
-/*************************************************************************
-|*
-|* CullingMode setzen
-|*
-\************************************************************************/
-
-void Base3D::SetCullMode(Base3DCullMode eNew)
-{
- eCullMode = eNew;
-}
-
-/*************************************************************************
-|*
-|* CullingMode liefern
-|*
-\************************************************************************/
-
-Base3DCullMode Base3D::GetCullMode() const
-{
- return eCullMode;
-}
-
-/*************************************************************************
-|*
-|* Texturenverwaltung
-|*
-\************************************************************************/
-
-SV_IMPL_PTRARR(B3dTextureStore, B3dTexture*);
-
-// eof
diff --git a/goodies/source/base3d/makefile.mk b/goodies/source/base3d/makefile.mk
index 0a162fc112cb..0203f7e1d3d4 100644
--- a/goodies/source/base3d/makefile.mk
+++ b/goodies/source/base3d/makefile.mk
@@ -8,7 +8,7 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.6.42.1 $
#
# This file is part of OpenOffice.org.
#
@@ -40,23 +40,8 @@ AUTOSEG=true
.INCLUDE : settings.mk
# --- Files --------------------------------------------------------
-EXCEPTIONSFILES=\
- $(SLO)$/b3dgeom.obj
-
-SLOFILES= \
- $(SLO)$/base3d.obj \
- $(SLO)$/b3dtrans.obj \
- $(SLO)$/b3ddeflt.obj \
- $(SLO)$/b3dopngl.obj \
- $(SLO)$/b3dcommn.obj \
- $(SLO)$/matril3d.obj \
- $(SLO)$/b3dcolor.obj \
- $(SLO)$/b3dlight.obj \
- $(SLO)$/b3dentty.obj \
- $(SLO)$/b3dcompo.obj \
- $(SLO)$/b3dtex.obj \
- $(SLO)$/b3dgeom.obj
+SLOFILES = $(SLO)$/b3dtrans.obj
.INCLUDE : target.mk
diff --git a/goodies/source/base3d/matril3d.cxx b/goodies/source/base3d/matril3d.cxx
deleted file mode 100644
index 083889f48a29..000000000000
--- a/goodies/source/base3d/matril3d.cxx
+++ /dev/null
@@ -1,139 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: matril3d.cxx,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_goodies.hxx"
-#include <goodies/matril3d.hxx>
-#include <tools/debug.hxx>
-
-/*************************************************************************
-|*
-|* Konstruktor B3dMaterial
-|*
-\************************************************************************/
-
-B3dMaterial::B3dMaterial()
-: aAmbient(COL_BLACK), // kein lokales Umgebungslicht
- aDiffuse(0x00, 0xb8, 0xff), // Blau7
- aSpecular(COL_WHITE), // Weisser Glanzpunkt
- aEmission(COL_BLACK), // Keine Selbstleuchtfarbe
- nExponent(15) // Glanzpunktbuendelung
-{
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaft setzen
-|*
-\************************************************************************/
-
-void B3dMaterial::SetMaterial(Color rNew, Base3DMaterialValue eVal)
-{
- switch(eVal)
- {
- case Base3DMaterialAmbient:
- aAmbient = rNew;
- break;
- case Base3DMaterialDiffuse:
- aDiffuse = rNew;
- break;
- case Base3DMaterialSpecular:
- aSpecular = rNew;
- break;
- case Base3DMaterialEmission:
- aEmission = rNew;
- break;
- }
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaft abfragen
-|*
-\************************************************************************/
-
-Color B3dMaterial::GetMaterial(Base3DMaterialValue eVal) const
-{
- if(eVal == Base3DMaterialAmbient)
- return aAmbient;
- if(eVal == Base3DMaterialDiffuse)
- return aDiffuse;
- if(eVal == Base3DMaterialEmission)
- return aEmission;
- return aSpecular;
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften setzen, exponent der specular-Eigenschaft
-|*
-\************************************************************************/
-
-void B3dMaterial::SetShininess(UINT16 nNew)
-{
- nExponent = nNew;
-}
-
-/*************************************************************************
-|*
-|* Materialeigenschaften abfragen, exponent der specular-Eigenschaft
-|*
-\************************************************************************/
-
-UINT16 B3dMaterial::GetShininess() const
-{
- return nExponent;
-}
-
-/*************************************************************************
-|*
-|* Vergleichsoperator
-|*
-\************************************************************************/
-
-BOOL B3dMaterial::operator==(const B3dMaterial& rMat)
-{
- if(aAmbient == rMat.aAmbient
- && aDiffuse == rMat.aDiffuse
- && aSpecular == rMat.aSpecular
- && aEmission == rMat.aEmission
- && nExponent == rMat.nExponent)
- return TRUE;
- return FALSE;
-}
-
-/*************************************************************************
-|*
-|* Bucket fuer geometrische Daten
-|*
-\************************************************************************/
-
-BASE3D_IMPL_BUCKET(B3dMaterial, Bucket)
-