/* -*- 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 .
*/
#include <tools/b3dtrans.hxx>
#include <osl/diagnose.h>
// Near and far clipping planes
constexpr double gfNearBound = 0.001;
constexpr double gfFarBound = 1.001;
// B3dTransformationSet -------------------------------------------------------- // Transformations for all 3D output
/// Transformations for viewport void B3dTransformationSet::CalcViewport()
{ // Parameters for projection double fLeft(mfLeftBound); double fRight(mfRightBound); double fBottom(mfBottomBound); double fTop(mfTopBound);
// Adjust projection to aspect ratio, if set if(GetRatio() != 0.0)
{ // Compute current aspect ratio of boundaries double fBoundWidth = static_cast<double>(maViewportRectangle.GetWidth() + 1); double fBoundHeight = static_cast<double>(maViewportRectangle.GetHeight() + 1); double fActRatio = 1; double fFactor;
if(fBoundWidth != 0.0)
fActRatio = fBoundHeight / fBoundWidth; // FIXME else in this case has a lot of problems, should this return.
// scale down larger part if(fActRatio > mfRatio)
{ // scale down Y
fFactor = fActRatio;
fTop *= fFactor;
fBottom *= fFactor;
} else
{ // scale down X
fFactor = 1.0 / fActRatio;
fRight *= fFactor;
fLeft *= fFactor;
}
}
// Do projection and object areas overlap?
maSetBound = maViewportRectangle;
// Reset projection with new values
basegfx::B3DHomMatrix aNewProjection;
// #i36281# // OpenGL needs a little more rough additional size to not let // the front face vanish. Changed from SMALL_DVALUE to 0.000001, // which is 1/10000th, compared with 1/tenth of a million from SMALL_DVALUE. constdouble fDistPart((gfFarBound - gfNearBound) * 0.0001);
// To avoid critical clipping, set Near & Far generously if(mbPerspective)
{
Frustum(aNewProjection, fLeft, fRight, fBottom, fTop, gfNearBound - fDistPart, gfFarBound + fDistPart);
} else
{
Ortho(aNewProjection, fLeft, fRight, fBottom, fTop, gfNearBound - fDistPart, gfFarBound + fDistPart);
}
// Set to true to guarantee loop termination
mbProjectionValid = true;
// set new projection
SetProjection(aNewProjection);
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.