LibreOffice Module svx (master) 1
sdrattributecreator3d.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
21#include <svx/svx3ditems.hxx>
22#include <svl/itemset.hxx>
23#include <com/sun/star/drawing/NormalsKind.hpp>
24#include <com/sun/star/drawing/TextureProjectionMode.hpp>
25#include <com/sun/star/drawing/TextureKind2.hpp>
26#include <com/sun/star/drawing/TextureMode.hpp>
27#include <svx/xflclit.hxx>
30
31
33{
35 {
36 // get NormalsKind
37 css::drawing::NormalsKind aNormalsKind(css::drawing::NormalsKind_SPECIFIC);
38 const sal_uInt16 nNormalsValue(rSet.Get(SDRATTR_3DOBJ_NORMALS_KIND).GetValue());
39
40 if(1 == nNormalsValue)
41 {
42 aNormalsKind = css::drawing::NormalsKind_FLAT;
43 }
44 else if(2 == nNormalsValue)
45 {
46 aNormalsKind = css::drawing::NormalsKind_SPHERE;
47 }
48
49 // get NormalsInvert flag
50 const bool bInvertNormals(rSet.Get(SDRATTR_3DOBJ_NORMALS_INVERT).GetValue());
51
52 // get TextureProjectionX
53 css::drawing::TextureProjectionMode aTextureProjectionX(css::drawing::TextureProjectionMode_OBJECTSPECIFIC);
54 const sal_uInt16 nTextureValueX(rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X).GetValue());
55
56 if(1 == nTextureValueX)
57 {
58 aTextureProjectionX = css::drawing::TextureProjectionMode_PARALLEL;
59 }
60 else if(2 == nTextureValueX)
61 {
62 aTextureProjectionX = css::drawing::TextureProjectionMode_SPHERE;
63 }
64
65 // get TextureProjectionY
66 css::drawing::TextureProjectionMode aTextureProjectionY(css::drawing::TextureProjectionMode_OBJECTSPECIFIC);
67 const sal_uInt16 nTextureValueY(rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y).GetValue());
68
69 if(1 == nTextureValueY)
70 {
71 aTextureProjectionY = css::drawing::TextureProjectionMode_PARALLEL;
72 }
73 else if(2 == nTextureValueY)
74 {
75 aTextureProjectionY = css::drawing::TextureProjectionMode_SPHERE;
76 }
77
78 // get DoubleSided flag
79 const bool bDoubleSided(rSet.Get(SDRATTR_3DOBJ_DOUBLE_SIDED).GetValue());
80
81 // get Shadow3D flag
82 const bool bShadow3D(rSet.Get(SDRATTR_3DOBJ_SHADOW_3D).GetValue());
83
84 // get TextureFilter flag
85 const bool bTextureFilter(rSet.Get(SDRATTR_3DOBJ_TEXTURE_FILTER).GetValue());
86
87 // get texture kind
88 // TextureKind: 1 == Base3DTextureLuminance, 2 == Base3DTextureIntensity, 3 == Base3DTextureColor
89 css::drawing::TextureKind2 aTextureKind(css::drawing::TextureKind2_LUMINANCE);
90 const sal_uInt16 nTextureKind(rSet.Get(SDRATTR_3DOBJ_TEXTURE_KIND).GetValue());
91
92 if(2 == nTextureKind)
93 {
94 aTextureKind = css::drawing::TextureKind2_INTENSITY;
95 }
96 else if(3 == nTextureKind)
97 {
98 aTextureKind = css::drawing::TextureKind2_COLOR;
99 }
100
101 // get texture mode
102 // TextureMode: 1 == Base3DTextureReplace, 2 == Base3DTextureModulate, 3 == Base3DTextureBlend
103 css::drawing::TextureMode aTextureMode(css::drawing::TextureMode_REPLACE);
104 const sal_uInt16 nTextureMode(rSet.Get(SDRATTR_3DOBJ_TEXTURE_MODE).GetValue());
105
106 if(2 == nTextureMode)
107 {
108 aTextureMode = css::drawing::TextureMode_MODULATE;
109 }
110 else if(3 == nTextureMode)
111 {
112 aTextureMode = css::drawing::TextureMode_BLEND;
113 }
114
115 // get object color
116 const ::basegfx::BColor aObjectColor(rSet.Get(XATTR_FILLCOLOR).GetColorValue().getBColor());
117
118 // get specular color
119 const ::basegfx::BColor aSpecular(rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR).GetValue().getBColor());
120
121 // get emissive color
122 const ::basegfx::BColor aEmission(rSet.Get(SDRATTR_3DOBJ_MAT_EMISSION).GetValue().getBColor());
123
124 // get specular intensity
125 sal_uInt16 nSpecularIntensity(rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY).GetValue());
126
127 if(nSpecularIntensity > 128)
128 {
129 nSpecularIntensity = 128;
130 }
131
132 // get reduced line geometry
133 const bool bReducedLineGeometry(rSet.Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY).GetValue());
134
135 // prepare material
136 attribute::MaterialAttribute3D aMaterial(aObjectColor, aSpecular, aEmission, nSpecularIntensity);
137
139 aNormalsKind, aTextureProjectionX, aTextureProjectionY,
140 aTextureKind, aTextureMode, aMaterial,
141 bInvertNormals, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry);
142 }
143} // end of namespace
144
145/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
attribute::Sdr3DObjectAttribute createNewSdr3DObjectAttribute(const SfxItemSet &rSet)
static SfxItemSet & rSet
constexpr TypedWhichId< Svx3DNormalsKindItem > SDRATTR_3DOBJ_NORMALS_KIND(SDRATTR_3DOBJ_FIRST+7)
constexpr TypedWhichId< Svx3DTextureModeItem > SDRATTR_3DOBJ_TEXTURE_MODE(SDRATTR_3DOBJ_FIRST+17)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DOBJ_TEXTURE_FILTER(SDRATTR_3DOBJ_FIRST+18)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DOBJ_DOUBLE_SIDED(SDRATTR_3DOBJ_FIRST+6)
constexpr TypedWhichId< Svx3DTextureKindItem > SDRATTR_3DOBJ_TEXTURE_KIND(SDRATTR_3DOBJ_FIRST+16)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DOBJ_MAT_SPECULAR(SDRATTR_3DOBJ_FIRST+14)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DOBJ_SHADOW_3D(SDRATTR_3DOBJ_FIRST+11)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DOBJ_NORMALS_INVERT(SDRATTR_3DOBJ_FIRST+8)
constexpr TypedWhichId< Svx3DReducedLineGeometryItem > SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY(SDRATTR_3DOBJ_FIRST+24)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DOBJ_MAT_EMISSION(SDRATTR_3DOBJ_FIRST+13)
constexpr TypedWhichId< Svx3DTextureProjectionYItem > SDRATTR_3DOBJ_TEXTURE_PROJ_Y(SDRATTR_3DOBJ_FIRST+10)
constexpr TypedWhichId< Svx3DTextureProjectionXItem > SDRATTR_3DOBJ_TEXTURE_PROJ_X(SDRATTR_3DOBJ_FIRST+9)
constexpr TypedWhichId< SfxUInt16Item > SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY(SDRATTR_3DOBJ_FIRST+15)
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)