/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// Create a complete tools::PolyPolygon with the plane normal for (sal_uInt32 a(0); a < aPolyPoly3D.count(); a++)
{ // Find source polygon const basegfx::B3DPolygon aPolygon(aPolyPoly3D.getB3DPolygon(a));
// Creating a new polygon for the normal
basegfx::B3DPolygon aNormals;
// Get normal (and invert)
basegfx::B3DVector aNormal(-aPolygon.getNormal());
// Fill new polygon for (sal_uInt32 b(0); b < aPolygon.count(); b++)
{
aNormals.append(aNormal);
}
// Insert new polygon into the PolyPolygon
aPolyNormals.append(aNormals);
}
// Set default normal
SetPolyNormals3D(aPolyNormals);
}
void E3dPolygonObj::CreateDefaultTexture()
{
basegfx::B2DPolyPolygon aPolyTexture; // Create a complete tools::PolyPolygon with the texture coordinates // The texture coordinates extend over X,Y and Z // on the whole extreme values in the range 0.0 .. 1.0 for (sal_uInt32 a(0); a < aPolyPoly3D.count(); a++)
{ // Find source polygon const basegfx::B3DPolygon& aPolygon(aPolyPoly3D.getB3DPolygon(a));
// Determine the total size of the object
basegfx::B3DRange aVolume(basegfx::utils::getRange(aPolygon));
// Get normal
basegfx::B3DVector aNormal(aPolygon.getNormal());
aNormal.setX(fabs(aNormal.getX()));
aNormal.setY(fabs(aNormal.getY()));
aNormal.setZ(fabs(aNormal.getZ()));
// Decide which coordinates should be used as a source for the mapping
sal_uInt16 nSourceMode = 0;
// Determine the greatest degree of freedom if (aNormal.getX() <= aNormal.getY() || aNormal.getX() <= aNormal.getZ())
{ if (aNormal.getY() > aNormal.getZ())
{ // Y is the largest, use X,Z as mapping
nSourceMode = 1;
} else
{ // Z is the largest, use X,Y as mapping
nSourceMode = 2;
}
}
// Create new polygon for texture coordinates
basegfx::B2DPolygon aTexture;
// Fill new polygon for (sal_uInt32 b(0); b < aPolygon.count(); b++)
{
basegfx::B2DPoint aTex; const basegfx::B3DPoint aCandidate(aPolygon.getB3DPoint(b));
switch (nSourceMode)
{ case 0: //Source is Y,Z if (aVolume.getHeight())
aTex.setX((aCandidate.getY() - aVolume.getMinY()) / aVolume.getHeight()); if (aVolume.getDepth())
aTex.setY((aCandidate.getZ() - aVolume.getMinZ()) / aVolume.getDepth()); break;
case 1: // Source is X,Z if (aVolume.getWidth())
aTex.setX((aCandidate.getX() - aVolume.getMinX()) / aVolume.getWidth()); if (aVolume.getDepth())
aTex.setY((aCandidate.getZ() - aVolume.getMinZ()) / aVolume.getDepth()); break;
case 2: // Source is X,Y if (aVolume.getWidth())
aTex.setX((aCandidate.getX() - aVolume.getMinX()) / aVolume.getWidth()); if (aVolume.getHeight())
aTex.setY((aCandidate.getY() - aVolume.getMinY()) / aVolume.getHeight()); break;
}
aTexture.append(aTex);
}
// Insert new polygon into the PolyPolygon
aPolyTexture.append(aTexture);
}
// Set default Texture coordinates
SetPolyTexture2D(aPolyTexture);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.