LibreOffice Module svx (master) 1
viewcontactofe3dsphere.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
22#include <svx/sphere3d.hxx>
26
27
28namespace sdr::contact
29{
31 : ViewContactOfE3d(rSphere)
32 {
33 }
34
36 {
37 }
38
40 {
42 const SfxItemSet& rItemSet = GetE3dSphereObj().GetMergedItemSet();
45
46 // get sphere center and size for geometry
47 const basegfx::B3DPoint aSpherePosition(GetE3dSphereObj().Center());
48 const basegfx::B3DVector aSphereSize(GetE3dSphereObj().Size());
49 basegfx::B3DHomMatrix aWorldTransform;
50
51 aWorldTransform.translate(-0.5, -0.5, -0.5);
52 aWorldTransform.scale(aSphereSize.getX(), aSphereSize.getY(), aSphereSize.getZ());
53 aWorldTransform.translate(aSpherePosition.getX(), aSpherePosition.getY(), aSpherePosition.getZ());
54
55 // get 3D Object Attributes
57
58 // get segment count
59 const sal_uInt32 nHorizontalSegments(GetE3dSphereObj().GetHorizontalSegments());
60 const sal_uInt32 nVerticalSegments(GetE3dSphereObj().GetVerticalSegments());
61
62 // calculate texture size, use radii for (2 * PI * r) to get a perfect
63 // mapping on the sphere
64 const basegfx::B2DVector aTextureSize(
65 M_PI * ((aSphereSize.getX() + aSphereSize.getZ()) / 2.0), // PI * d
66 M_PI_2 * aSphereSize.getY()); // half outline, (PI * d)/2 -> PI/2 * d
67
68 // create primitive and add
71 aWorldTransform, aTextureSize, aAttribute, aSdr3DObjectAttribute,
72 nHorizontalSegments, nVerticalSegments));
73 xRetval = { xReference };
74
75 return xRetval;
76 }
77
78} // end of namespace
79
80/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SphereObject with diameter r3DSize.
Definition: sphere3d.hxx:36
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1977
void translate(double fX, double fY, double fZ)
void scale(double fX, double fY, double fZ)
TYPE getX() const
TYPE getZ() const
TYPE getY() const
virtual drawinglayer::primitive3d::Primitive3DContainer createViewIndependentPrimitive3DContainer() const override
const E3dSphereObj & GetE3dSphereObj() const
attribute::SdrLineFillShadowAttribute3D createNewSdrLineFillShadowAttribute(const SfxItemSet &rSet, bool bSuppressFill)
attribute::Sdr3DObjectAttribute createNewSdr3DObjectAttribute(const SfxItemSet &rSet)
css::uno::Reference< css::graphic::XPrimitive3D > Primitive3DReference
Center