/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2019, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2019 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// // UI for OdDbLight, OdDbMaterial and OdDbVisualStyle editing #include "stdafx.h" #include #include "OdaCommon.h" #include "Ge/GeScale3d.h" #include "Gi/GiWorldDraw.h" #include "DbEntity.h" #include "DbFiler.h" #include "DbCommandContext.h" #include "DbDatabase.h" #include "DbBlockTable.h" #include "DbBlockTableRecord.h" #include "DbProxyEntity.h" #include "DbUserIO.h" #include "Ed/EdCommandStack.h" #include "StaticRxObject.h" #include "SaveState.h" #include "DbLight.h" #include "DbMaterial.h" #include "DbVisualStyle.h" #include "DbDictionary.h" #include "DbXrecord.h" #include "AbstractViewPE.h" #include "ColorMapping.h" #include "DbRenderSettings.h" #include "DbAbstractViewportData.h" #include "RxRasterServices.h" #include "resource.h" #include "MaterialsEditor.h" #include "ColorPickerDlg.h" #include "VectProps.h" #include "OdaMfcApp.h" #include "DwgViewer.h" //for visual style preview #include "Db3dSolid.h" /* -------------------------------------------------------------------------------------- */ /* ExTeapot custom entity */ /* -------------------------------------------------------------------------------------- */ #define EXTEAPOT_ENABLETEXCOORDS // TeapotBody data // Vertices static const double ExTeapotBodyVertices[363 * 3] = { 0.000000, 0.000000, 0.000000, 0.385396, 0.006445, 0.163976, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.296619, 0.006445, 0.296619, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.163976, 0.006445, 0.385396, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.006445, 0.417773, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.163976, 0.006445, 0.385396, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.296619, 0.006445, 0.296619, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.385396, 0.006445, 0.163976, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.417773, 0.006445, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.385396, 0.006445, -0.163976, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.296619, 0.006445, -0.296619, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -0.163976, 0.006445, -0.385396, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.006445, -0.417773, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.163976, 0.006445, -0.385396, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.296619, 0.006445, -0.296619, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.385396, 0.006445, -0.163976, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.417773, 0.006445, 0.000000, 0.000000, 0.000000, 0.000000, 0.385396, 0.006445, 0.163976, 0.000000, 0.000000, 0.000000, 0.417773, 0.006445, 0.000000, 0.592418, 0.023438, 0.252059, 0.455953, 0.023438, 0.455953, 0.296619, 0.006445, 0.296619, 0.000000, 0.000000, 0.000000, 0.642187, 0.023438, 0.000000, 0.676200, 0.047461, 0.287706, 0.520436, 0.047461, 0.520436, 0.287706, 0.047461, 0.676200, 0.252059, 0.023438, 0.592418, 0.163976, 0.006445, 0.385396, 0.000000, 0.000000, 0.000000, 0.733008, 0.047461, 0.000000, 0.691875, 0.075000, 0.294375, 0.532500, 0.075000, 0.532500, 0.294375, 0.075000, 0.691875, 0.000000, 0.075000, 0.750000, 0.000000, 0.047461, 0.733008, 0.000000, 0.023438, 0.642187, 0.750000, 0.075000, 0.000000, -0.294375, 0.075000, 0.691875, -0.287706, 0.047461, 0.676200, -0.252059, 0.023438, 0.592418, 0.000000, 0.006445, 0.417773, 0.000000, 0.000000, 0.000000, -0.532500, 0.075000, 0.532500, -0.520436, 0.047461, 0.520436, -0.455953, 0.023438, 0.455953, -0.163976, 0.006445, 0.385396, 0.000000, 0.000000, 0.000000, -0.691875, 0.075000, 0.294375, -0.676200, 0.047461, 0.287706, -0.592418, 0.023438, 0.252059, -0.296619, 0.006445, 0.296619, 0.000000, 0.000000, 0.000000, -0.750000, 0.075000, 0.000000, -0.733008, 0.047461, 0.000000, -0.642187, 0.023438, 0.000000, -0.385396, 0.006445, 0.163976, 0.000000, 0.000000, 0.000000, -0.417773, 0.006445, 0.000000, 0.000000, 0.000000, 0.000000, -0.385396, 0.006445, -0.163976, -0.417773, 0.006445, 0.000000, -0.592418, 0.023438, -0.252059, -0.455953, 0.023438, -0.455953, -0.296619, 0.006445, -0.296619, -0.642187, 0.023438, 0.000000, -0.676200, 0.047461, -0.287706, -0.520436, 0.047461, -0.520436, -0.287706, 0.047461, -0.676200, -0.252059, 0.023438, -0.592418, -0.163976, 0.006445, -0.385396, -0.733008, 0.047461, 0.000000, -0.691875, 0.075000, -0.294375, -0.532500, 0.075000, -0.532500, -0.294375, 0.075000, -0.691875, 0.000000, 0.075000, -0.750000, 0.000000, 0.047461, -0.733008, 0.000000, 0.023438, -0.642187, -0.750000, 0.075000, 0.000000, 0.294375, 0.075000, -0.691875, 0.287706, 0.047461, -0.676200, 0.252059, 0.023438, -0.592418, 0.000000, 0.006445, -0.417773, 0.532500, 0.075000, -0.532500, 0.520436, 0.047461, -0.520436, 0.455953, 0.023438, -0.455953, 0.163976, 0.006445, -0.385396, 0.691875, 0.075000, -0.294375, 0.676200, 0.047461, -0.287706, 0.592418, 0.023438, -0.252059, 0.296619, 0.006445, -0.296619, 0.750000, 0.075000, 0.000000, 0.733008, 0.047461, 0.000000, 0.642187, 0.023438, 0.000000, 0.385396, 0.006445, -0.163976, 0.417773, 0.006445, 0.000000, -0.691875, 0.075000, 0.294375, -0.789063, 0.117773, 0.000000, -0.750000, 0.075000, 0.000000, -0.727910, 0.117773, 0.309707, -0.875000, 0.192187, 0.000000, -0.807187, 0.192187, 0.343437, -0.960938, 0.301758, 0.000000, -0.886465, 0.301758, 0.377168, -1.000000, 0.450000, 0.000000, -0.532500, 0.075000, 0.532500, -0.560234, 0.117773, 0.560234, -0.621250, 0.192187, 0.621250, -0.682266, 0.301758, 0.682266, -0.922500, 0.450000, 0.392500, -0.978516, 0.625195, 0.000000, -0.902681, 0.625195, 0.384067, -0.921875, 0.810938, 0.000000, -0.294375, 0.075000, 0.691875, -0.309707, 0.117773, 0.727910, -0.343437, 0.192187, 0.807187, -0.377168, 0.301758, 0.886465, -0.710000, 0.450000, 0.710000, -0.694746, 0.625195, 0.694746, -0.850430, 0.810938, 0.361836, -0.841797, 1.003711, 0.000000, 0.000000, 0.075000, 0.750000, 0.000000, 0.117773, 0.789063, 0.000000, 0.192187, 0.875000, 0.000000, 0.301758, 0.960938, -0.392500, 0.450000, 0.922500, -0.384067, 0.625195, 0.902681, -0.654531, 0.810938, 0.654531, 0.294375, 0.075000, 0.691875, 0.309707, 0.117773, 0.727910, 0.343437, 0.192187, 0.807187, 0.377168, 0.301758, 0.886465, 0.000000, 0.450000, 1.000000, 0.000000, 0.625195, 0.978516, -0.361836, 0.810938, 0.850430, 0.532500, 0.075000, 0.532500, 0.560234, 0.117773, 0.560234, 0.621250, 0.192187, 0.621250, 0.682266, 0.301758, 0.682266, 0.392500, 0.450000, 0.922500, 0.384067, 0.625195, 0.902681, 0.000000, 0.810938, 0.921875, 0.691875, 0.075000, 0.294375, 0.727910, 0.117773, 0.309707, 0.807187, 0.192187, 0.343437, 0.886465, 0.301758, 0.377168, 0.710000, 0.450000, 0.710000, 0.694746, 0.625195, 0.694746, 0.361836, 0.810938, 0.850430, 0.750000, 0.075000, 0.000000, 0.789063, 0.117773, 0.000000, 0.875000, 0.192187, 0.000000, 0.960938, 0.301758, 0.000000, 0.922500, 0.450000, 0.392500, 0.902681, 0.625195, 0.384067, 0.654531, 0.810938, 0.654531, 0.330405, 1.003711, 0.776558, 0.000000, 1.003711, 0.841797, 1.000000, 0.450000, 0.000000, 0.978516, 0.625195, 0.000000, 0.850430, 0.810938, 0.361836, 0.597676, 1.003711, 0.597676, 0.294375, 1.200000, 0.691875, 0.000000, 1.200000, 0.750000, -0.294375, 1.200000, 0.691875, -0.330405, 1.003711, 0.776558, 0.921875, 0.810938, 0.000000, 0.776558, 1.003711, 0.330405, 0.532500, 1.200000, 0.532500, 0.284409, 1.236914, 0.668452, 0.000000, 1.236914, 0.724609, -0.284409, 1.236914, 0.668452, 0.841797, 1.003711, 0.000000, 0.691875, 1.200000, 0.294375, 0.514473, 1.236914, 0.514473, 0.275363, 1.249219, 0.647191, 0.000000, 1.249219, 0.701563, -0.275363, 1.249219, 0.647191, 0.750000, 1.200000, 0.000000, 0.668452, 1.236914, 0.284409, 0.498109, 1.249219, 0.498109, 0.270917, 1.236914, 0.636741, 0.000000, 1.236914, 0.690234, -0.270917, 1.236914, 0.636741, 0.724609, 1.236914, 0.000000, 0.647191, 1.249219, 0.275363, 0.490066, 1.236914, 0.490066, 0.274750, 1.200000, 0.645750, 0.000000, 1.200000, 0.700000, -0.274750, 1.200000, 0.645750, 0.701563, 1.249219, 0.000000, 0.636741, 1.236914, 0.270917, 0.497000, 1.200000, 0.497000, 0.690234, 1.236914, 0.000000, 0.645750, 1.200000, 0.274750, 0.700000, 1.200000, 0.000000, -0.497000, 1.200000, 0.497000, -0.490066, 1.236914, 0.490066, -0.498109, 1.249219, 0.498109, -0.514473, 1.236914, 0.514473, -0.645750, 1.200000, 0.274750, -0.636741, 1.236914, 0.270917, -0.647191, 1.249219, 0.275363, -0.668452, 1.236914, 0.284409, -0.532500, 1.200000, 0.532500, -0.597676, 1.003711, 0.597676, -0.700000, 1.200000, 0.000000, -0.690234, 1.236914, 0.000000, -0.701563, 1.249219, 0.000000, -0.724609, 1.236914, 0.000000, -0.691875, 1.200000, 0.294375, -0.776558, 1.003711, 0.330405, -0.750000, 1.200000, 0.000000, 0.691875, 0.075000, -0.294375, 0.789063, 0.117773, 0.000000, 0.750000, 0.075000, 0.000000, 0.727910, 0.117773, -0.309707, 0.875000, 0.192187, 0.000000, 0.807187, 0.192187, -0.343437, 0.960938, 0.301758, 0.000000, 0.886465, 0.301758, -0.377168, 1.000000, 0.450000, 0.000000, 0.532500, 0.075000, -0.532500, 0.560234, 0.117773, -0.560234, 0.621250, 0.192187, -0.621250, 0.682266, 0.301758, -0.682266, 0.922500, 0.450000, -0.392500, 0.978516, 0.625195, 0.000000, 0.902681, 0.625195, -0.384067, 0.921875, 0.810938, 0.000000, 0.294375, 0.075000, -0.691875, 0.309707, 0.117773, -0.727910, 0.343437, 0.192187, -0.807187, 0.377168, 0.301758, -0.886465, 0.710000, 0.450000, -0.710000, 0.694746, 0.625195, -0.694746, 0.850430, 0.810938, -0.361836, 0.841797, 1.003711, 0.000000, 0.000000, 0.075000, -0.750000, 0.000000, 0.117773, -0.789063, 0.000000, 0.192187, -0.875000, 0.000000, 0.301758, -0.960938, 0.392500, 0.450000, -0.922500, 0.384067, 0.625195, -0.902681, 0.654531, 0.810938, -0.654531, -0.294375, 0.075000, -0.691875, -0.309707, 0.117773, -0.727910, -0.343437, 0.192187, -0.807187, -0.377168, 0.301758, -0.886465, 0.000000, 0.450000, -1.000000, 0.000000, 0.625195, -0.978516, 0.361836, 0.810938, -0.850430, -0.532500, 0.075000, -0.532500, -0.560234, 0.117773, -0.560234, -0.621250, 0.192187, -0.621250, -0.682266, 0.301758, -0.682266, -0.392500, 0.450000, -0.922500, -0.384067, 0.625195, -0.902681, 0.000000, 0.810938, -0.921875, -0.691875, 0.075000, -0.294375, -0.727910, 0.117773, -0.309707, -0.807187, 0.192187, -0.343437, -0.886465, 0.301758, -0.377168, -0.710000, 0.450000, -0.710000, -0.694746, 0.625195, -0.694746, -0.361836, 0.810938, -0.850430, -0.750000, 0.075000, 0.000000, -0.789063, 0.117773, 0.000000, -0.875000, 0.192187, 0.000000, -0.960938, 0.301758, 0.000000, -0.922500, 0.450000, -0.392500, -0.902681, 0.625195, -0.384067, -0.654531, 0.810938, -0.654531, -0.330405, 1.003711, -0.776558, 0.000000, 1.003711, -0.841797, -1.000000, 0.450000, 0.000000, -0.978516, 0.625195, 0.000000, -0.850430, 0.810938, -0.361836, -0.597676, 1.003711, -0.597676, -0.294375, 1.200000, -0.691875, 0.000000, 1.200000, -0.750000, 0.294375, 1.200000, -0.691875, 0.330405, 1.003711, -0.776558, -0.921875, 0.810938, 0.000000, -0.776558, 1.003711, -0.330405, -0.532500, 1.200000, -0.532500, -0.284706, 1.236914, -0.668452, 0.000000, 1.236914, -0.724609, 0.284409, 1.236914, -0.668452, 0.514473, 1.236914, -0.514473, -0.841797, 1.003711, 0.000000, -0.691875, 1.200000, -0.294375, -0.514736, 1.236914, -0.514473, -0.277736, 1.249219, -0.647191, 0.000000, 1.249219, -0.701563, 0.275363, 1.249219, -0.647191, 0.498109, 1.249219, -0.498109, -0.750000, 1.200000, 0.000000, -0.668551, 1.236914, -0.284409, -0.500219, 1.249219, -0.498109, -0.278926, 1.236914, -0.636741, 0.000000, 1.236914, -0.690234, 0.270917, 1.236914, -0.636741, 0.490066, 1.236914, -0.490066, -0.724609, 1.236914, 0.000000, -0.647982, 1.249219, -0.275363, -0.497186, 1.236914, -0.490066, -0.293734, 1.200000, -0.645750, 0.000000, 1.200000, -0.700000, 0.274750, 1.200000, -0.645750, 0.497000, 1.200000, -0.497000, -0.701563, 1.249219, 0.000000, -0.639411, 1.236914, -0.270917, -0.513875, 1.200000, -0.497000, -0.690234, 1.236914, 0.000000, -0.652078, 1.200000, -0.274750, -0.700000, 1.200000, 0.000000, 0.645750, 1.200000, -0.274750, 0.636741, 1.236914, -0.270917, 0.647191, 1.249219, -0.275363, 0.668452, 1.236914, -0.284409, 0.532500, 1.200000, -0.532500, 0.700000, 1.200000, 0.000000, 0.690234, 1.236914, 0.000000, 0.701563, 1.249219, 0.000000, 0.724609, 1.236914, 0.000000, 0.691875, 1.200000, -0.294375, 0.597676, 1.003711, -0.597676, 0.514473, 1.236914, -0.514473, 0.750000, 1.200000, 0.000000, 0.776558, 1.003711, -0.330405 }; // Indices static const OdInt32 ExTeapotBodyIndices[512 * 4] = { 3, 0, 1, 2, 3, 3, 4, 5, 3, 6, 7, 8, 3, 9, 10, 11, 3, 12, 13, 14, 3, 15, 16, 17, 3, 18, 19, 20, 3, 21, 22, 23, 3, 24, 25, 26, 3, 27, 28, 29, 3, 30, 31, 32, 3, 33, 34, 35, 3, 36, 37, 38, 3, 39, 40, 41, 3, 42, 43, 44, 3, 45, 46, 47, 3, 48, 49, 50, 3, 50, 51, 48, 3, 52, 48, 51, 3, 48, 52, 53, 3, 53, 54, 48, 3, 51, 50, 55, 3, 55, 56, 51, 3, 57, 51, 56, 3, 51, 57, 52, 3, 58, 52, 57, 3, 52, 58, 59, 3, 59, 53, 52, 3, 53, 59, 60, 3, 60, 61, 53, 3, 56, 55, 62, 3, 62, 63, 56, 3, 64, 56, 63, 3, 56, 64, 57, 3, 65, 57, 64, 3, 57, 65, 58, 3, 66, 58, 65, 3, 58, 66, 67, 3, 67, 59, 58, 3, 59, 67, 68, 3, 68, 60, 59, 3, 63, 62, 69, 3, 70, 67, 66, 3, 67, 70, 71, 3, 71, 68, 67, 3, 68, 71, 72, 3, 72, 73, 68, 3, 60, 68, 73, 3, 73, 74, 60, 3, 75, 71, 70, 3, 71, 75, 76, 3, 76, 72, 71, 3, 72, 76, 77, 3, 77, 78, 72, 3, 73, 72, 78, 3, 78, 79, 73, 3, 80, 76, 75, 3, 76, 80, 81, 3, 81, 77, 76, 3, 77, 81, 82, 3, 82, 83, 77, 3, 78, 77, 83, 3, 83, 84, 78, 3, 85, 81, 80, 3, 81, 85, 86, 3, 86, 82, 81, 3, 82, 86, 87, 3, 87, 88, 82, 3, 83, 82, 88, 3, 88, 89, 83, 3, 88, 87, 90, 3, 90, 91, 88, 3, 92, 49, 93, 3, 93, 94, 92, 3, 95, 92, 94, 3, 92, 95, 96, 3, 96, 54, 92, 3, 94, 93, 97, 3, 97, 98, 94, 3, 99, 94, 98, 3, 94, 99, 95, 3, 100, 95, 99, 3, 95, 100, 101, 3, 101, 96, 95, 3, 96, 101, 102, 3, 102, 61, 96, 3, 98, 97, 103, 3, 103, 104, 98, 3, 105, 98, 104, 3, 98, 105, 99, 3, 106, 99, 105, 3, 99, 106, 100, 3, 107, 100, 106, 3, 100, 107, 108, 3, 108, 101, 100, 3, 101, 108, 109, 3, 109, 102, 101, 3, 104, 103, 110, 3, 111, 108, 107, 3, 108, 111, 112, 3, 112, 109, 108, 3, 109, 112, 113, 3, 113, 114, 109, 3, 102, 109, 114, 3, 114, 74, 102, 3, 115, 112, 111, 3, 112, 115, 116, 3, 116, 113, 112, 3, 113, 116, 117, 3, 117, 118, 113, 3, 114, 113, 118, 3, 118, 79, 114, 3, 119, 116, 115, 3, 116, 119, 120, 3, 120, 117, 116, 3, 117, 120, 121, 3, 121, 122, 117, 3, 118, 117, 122, 3, 122, 84, 118, 3, 123, 120, 119, 3, 120, 123, 124, 3, 124, 121, 120, 3, 121, 124, 125, 3, 125, 126, 121, 3, 122, 121, 126, 3, 126, 89, 122, 3, 126, 125, 127, 3, 127, 91, 126, 3, 128, 129, 130, 3, 129, 128, 131, 3, 131, 132, 129, 3, 132, 131, 133, 3, 133, 134, 132, 3, 134, 133, 135, 3, 135, 136, 134, 3, 137, 131, 128, 3, 131, 137, 138, 3, 138, 133, 131, 3, 133, 138, 139, 3, 139, 135, 133, 3, 135, 139, 140, 3, 140, 141, 135, 3, 136, 135, 141, 3, 141, 142, 136, 3, 142, 141, 143, 3, 143, 144, 142, 3, 145, 138, 137, 3, 138, 145, 146, 3, 146, 139, 138, 3, 139, 146, 147, 3, 147, 140, 139, 3, 140, 147, 148, 3, 148, 149, 140, 3, 141, 140, 149, 3, 149, 143, 141, 3, 143, 149, 150, 3, 150, 151, 143, 3, 144, 143, 151, 3, 151, 152, 144, 3, 153, 146, 145, 3, 146, 153, 154, 3, 154, 147, 146, 3, 147, 154, 155, 3, 155, 148, 147, 3, 148, 155, 156, 3, 156, 157, 148, 3, 149, 148, 157, 3, 157, 150, 149, 3, 150, 157, 158, 3, 158, 159, 150, 3, 151, 150, 159, 3, 160, 154, 153, 3, 154, 160, 161, 3, 161, 155, 154, 3, 155, 161, 162, 3, 162, 156, 155, 3, 156, 162, 163, 3, 163, 164, 156, 3, 157, 156, 164, 3, 164, 158, 157, 3, 158, 164, 165, 3, 165, 166, 158, 3, 159, 158, 166, 3, 167, 161, 160, 3, 161, 167, 168, 3, 168, 162, 161, 3, 162, 168, 169, 3, 169, 163, 162, 3, 163, 169, 170, 3, 170, 171, 163, 3, 164, 163, 171, 3, 171, 165, 164, 3, 165, 171, 172, 3, 172, 173, 165, 3, 166, 165, 173, 3, 174, 168, 167, 3, 168, 174, 175, 3, 175, 169, 168, 3, 169, 175, 176, 3, 176, 170, 169, 3, 170, 176, 177, 3, 177, 178, 170, 3, 171, 170, 178, 3, 178, 172, 171, 3, 172, 178, 179, 3, 179, 180, 172, 3, 173, 172, 180, 3, 181, 175, 174, 3, 175, 181, 182, 3, 182, 176, 175, 3, 176, 182, 183, 3, 183, 177, 176, 3, 177, 183, 184, 3, 184, 185, 177, 3, 178, 177, 185, 3, 185, 179, 178, 3, 179, 185, 186, 3, 186, 187, 179, 3, 180, 179, 187, 3, 187, 188, 180, 3, 189, 180, 188, 3, 180, 189, 173, 3, 185, 184, 190, 3, 190, 186, 185, 3, 186, 190, 191, 3, 191, 192, 186, 3, 187, 186, 192, 3, 192, 193, 187, 3, 188, 187, 193, 3, 193, 194, 188, 3, 195, 188, 194, 3, 188, 195, 189, 3, 196, 189, 195, 3, 189, 196, 197, 3, 197, 173, 189, 3, 173, 197, 166, 3, 192, 191, 198, 3, 198, 199, 192, 3, 193, 192, 199, 3, 199, 200, 193, 3, 194, 193, 200, 3, 200, 201, 194, 3, 202, 194, 201, 3, 194, 202, 195, 3, 203, 195, 202, 3, 195, 203, 196, 3, 199, 198, 204, 3, 204, 205, 199, 3, 200, 199, 205, 3, 205, 206, 200, 3, 201, 200, 206, 3, 206, 207, 201, 3, 208, 201, 207, 3, 201, 208, 202, 3, 209, 202, 208, 3, 202, 209, 203, 3, 205, 204, 210, 3, 210, 211, 205, 3, 206, 205, 211, 3, 211, 212, 206, 3, 207, 206, 212, 3, 212, 213, 207, 3, 214, 207, 213, 3, 207, 214, 208, 3, 215, 208, 214, 3, 208, 215, 209, 3, 211, 210, 216, 3, 216, 217, 211, 3, 212, 211, 217, 3, 217, 218, 212, 3, 213, 212, 218, 3, 218, 219, 213, 3, 220, 213, 219, 3, 213, 220, 214, 3, 221, 214, 220, 3, 214, 221, 215, 3, 217, 216, 222, 3, 222, 223, 217, 3, 218, 217, 223, 3, 223, 224, 218, 3, 219, 218, 224, 3, 223, 222, 225, 3, 225, 226, 223, 3, 224, 223, 226, 3, 226, 225, 227, 3, 228, 215, 221, 3, 215, 228, 229, 3, 229, 209, 215, 3, 209, 229, 230, 3, 230, 203, 209, 3, 203, 230, 231, 3, 231, 196, 203, 3, 232, 229, 228, 3, 229, 232, 233, 3, 233, 230, 229, 3, 230, 233, 234, 3, 234, 231, 230, 3, 231, 234, 235, 3, 235, 236, 231, 3, 196, 231, 236, 3, 236, 197, 196, 3, 197, 236, 237, 3, 237, 166, 197, 3, 238, 233, 232, 3, 233, 238, 239, 3, 239, 234, 233, 3, 234, 239, 240, 3, 240, 235, 234, 3, 235, 240, 241, 3, 241, 242, 235, 3, 236, 235, 242, 3, 242, 237, 236, 3, 237, 242, 243, 3, 243, 159, 237, 3, 166, 237, 159, 3, 242, 241, 244, 3, 244, 243, 242, 3, 243, 244, 152, 3, 152, 151, 243, 3, 159, 243, 151, 3, 245, 246, 247, 3, 246, 245, 248, 3, 248, 249, 246, 3, 249, 248, 250, 3, 250, 251, 249, 3, 251, 250, 252, 3, 252, 253, 251, 3, 254, 248, 245, 3, 248, 254, 255, 3, 255, 250, 248, 3, 250, 255, 256, 3, 256, 252, 250, 3, 252, 256, 257, 3, 257, 258, 252, 3, 253, 252, 258, 3, 258, 259, 253, 3, 259, 258, 260, 3, 260, 261, 259, 3, 262, 255, 254, 3, 255, 262, 263, 3, 263, 256, 255, 3, 256, 263, 264, 3, 264, 257, 256, 3, 257, 264, 265, 3, 265, 266, 257, 3, 258, 257, 266, 3, 266, 260, 258, 3, 260, 266, 267, 3, 267, 268, 260, 3, 261, 260, 268, 3, 268, 269, 261, 3, 270, 263, 262, 3, 263, 270, 271, 3, 271, 264, 263, 3, 264, 271, 272, 3, 272, 265, 264, 3, 265, 272, 273, 3, 273, 274, 265, 3, 266, 265, 274, 3, 274, 267, 266, 3, 267, 274, 275, 3, 275, 276, 267, 3, 268, 267, 276, 3, 277, 271, 270, 3, 271, 277, 278, 3, 278, 272, 271, 3, 272, 278, 279, 3, 279, 273, 272, 3, 273, 279, 280, 3, 280, 281, 273, 3, 274, 273, 281, 3, 281, 275, 274, 3, 275, 281, 282, 3, 282, 283, 275, 3, 276, 275, 283, 3, 284, 278, 277, 3, 278, 284, 285, 3, 285, 279, 278, 3, 279, 285, 286, 3, 286, 280, 279, 3, 280, 286, 287, 3, 287, 288, 280, 3, 281, 280, 288, 3, 288, 282, 281, 3, 282, 288, 289, 3, 289, 290, 282, 3, 283, 282, 290, 3, 291, 285, 284, 3, 285, 291, 292, 3, 292, 286, 285, 3, 286, 292, 293, 3, 293, 287, 286, 3, 287, 293, 294, 3, 294, 295, 287, 3, 288, 287, 295, 3, 295, 289, 288, 3, 289, 295, 296, 3, 296, 297, 289, 3, 290, 289, 297, 3, 298, 292, 291, 3, 292, 298, 299, 3, 299, 293, 292, 3, 293, 299, 300, 3, 300, 294, 293, 3, 294, 300, 301, 3, 301, 302, 294, 3, 295, 294, 302, 3, 302, 296, 295, 3, 296, 302, 303, 3, 303, 304, 296, 3, 297, 296, 304, 3, 304, 305, 297, 3, 306, 297, 305, 3, 297, 306, 290, 3, 302, 301, 307, 3, 307, 303, 302, 3, 303, 307, 308, 3, 308, 309, 303, 3, 304, 303, 309, 3, 309, 310, 304, 3, 305, 304, 310, 3, 310, 311, 305, 3, 312, 305, 311, 3, 305, 312, 306, 3, 313, 306, 312, 3, 306, 313, 314, 3, 314, 290, 306, 3, 290, 314, 283, 3, 309, 308, 315, 3, 315, 316, 309, 3, 310, 309, 316, 3, 316, 317, 310, 3, 311, 310, 317, 3, 317, 318, 311, 3, 319, 311, 318, 3, 311, 319, 312, 3, 320, 312, 319, 3, 312, 320, 313, 3, 321, 313, 320, 3, 316, 315, 322, 3, 322, 323, 316, 3, 317, 316, 323, 3, 323, 324, 317, 3, 318, 317, 324, 3, 324, 325, 318, 3, 326, 318, 325, 3, 318, 326, 319, 3, 327, 319, 326, 3, 319, 327, 320, 3, 328, 320, 327, 3, 320, 328, 321, 3, 323, 322, 329, 3, 329, 330, 323, 3, 324, 323, 330, 3, 330, 331, 324, 3, 325, 324, 331, 3, 331, 332, 325, 3, 333, 325, 332, 3, 325, 333, 326, 3, 334, 326, 333, 3, 326, 334, 327, 3, 335, 327, 334, 3, 327, 335, 328, 3, 330, 329, 336, 3, 336, 337, 330, 3, 331, 330, 337, 3, 337, 338, 331, 3, 332, 331, 338, 3, 338, 339, 332, 3, 340, 332, 339, 3, 332, 340, 333, 3, 341, 333, 340, 3, 333, 341, 334, 3, 342, 334, 341, 3, 334, 342, 335, 3, 337, 336, 343, 3, 343, 344, 337, 3, 338, 337, 344, 3, 344, 345, 338, 3, 339, 338, 345, 3, 344, 343, 346, 3, 346, 347, 344, 3, 345, 344, 347, 3, 347, 346, 348, 3, 349, 335, 342, 3, 335, 349, 350, 3, 350, 328, 335, 3, 328, 350, 351, 3, 351, 321, 328, 3, 321, 351, 352, 3, 352, 353, 321, 3, 354, 350, 349, 3, 350, 354, 355, 3, 355, 351, 350, 3, 351, 355, 356, 3, 356, 352, 351, 3, 352, 356, 357, 3, 357, 358, 352, 3, 353, 352, 358, 3, 358, 359, 353, 3, 314, 353, 359, 3, 353, 314, 313, 3, 313, 360, 353, 3, 358, 357, 361, 3, 361, 362, 358, 3, 359, 358, 362, 3, 362, 276, 359, 3, 283, 359, 276, 3, 359, 283, 314, 3, 362, 361, 269, 3, 269, 268, 362, 3, 276, 362, 268 }; // Normals static const double ExTeapotBodyNormals[363 * 3] = { 0.000000, -1.000000, -0.000000, 0.038423, -0.999124, 0.016563, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, 0.028967, -0.999126, 0.030123, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, 0.015076, -0.999117, 0.039224, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.000842, -0.999117, 0.042001, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.016563, -0.999124, 0.038423, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.030123, -0.999126, 0.028967, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.039224, -0.999117, 0.015076, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.042001, -0.999117, -0.000842, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.038423, -0.999124, -0.016563, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.028967, -0.999126, -0.030123, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, -0.015076, -0.999117, -0.039224, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, 0.000842, -0.999117, -0.042001, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, 0.016563, -0.999124, -0.038423, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, 0.030123, -0.999126, -0.028967, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, 0.039224, -0.999117, -0.015076, 0.000000, -1.000000, -0.000000, 0.000000, -1.000000, -0.000000, 0.042001, -0.999117, 0.000842, 0.000000, -1.000000, -0.000000, 0.038423, -0.999124, 0.016563, 0.000000, -1.000000, -0.000000, 0.042001, -0.999117, 0.000842, 0.132609, -0.989583, 0.056043, 0.100275, -0.989643, 0.102719, 0.028967, -0.999126, 0.030123, 0.000000, -1.000000, -0.000000, 0.144219, -0.989544, 0.001769, 0.430357, -0.884825, 0.178540, 0.327021, -0.885364, 0.330436, 0.173941, -0.884904, 0.432075, 0.052771, -0.989582, 0.133947, 0.015076, -0.999117, 0.039224, 0.000000, -1.000000, -0.000000, 0.466360, -0.884592, 0.002442, 0.717727, -0.630270, 0.296021, 0.546647, -0.630850, 0.550641, 0.290730, -0.630256, 0.719898, -0.002834, -0.629277, 0.777176, -0.002442, -0.884592, 0.466360, -0.001769, -0.989544, 0.144219, 0.777176, -0.629277, 0.002834, -0.296021, -0.630270, 0.717727, -0.178540, -0.884825, 0.430357, -0.056043, -0.989583, 0.132609, -0.000842, -0.999117, 0.042001, 0.000000, -1.000000, -0.000000, -0.550641, -0.630850, 0.546647, -0.330436, -0.885364, 0.327021, -0.102719, -0.989643, 0.100275, -0.016563, -0.999124, 0.038423, 0.000000, -1.000000, -0.000000, -0.719898, -0.630256, 0.290730, -0.432075, -0.884904, 0.173941, -0.133947, -0.989582, 0.052771, -0.030123, -0.999126, 0.028967, 0.000000, -1.000000, -0.000000, -0.777176, -0.629277, -0.002834, -0.466360, -0.884592, -0.002442, -0.144219, -0.989544, -0.001769, -0.039224, -0.999117, 0.015076, 0.000000, -1.000000, -0.000000, -0.042001, -0.999117, -0.000842, 0.000000, -1.000000, -0.000000, -0.038423, -0.999124, -0.016563, -0.042001, -0.999117, -0.000842, -0.132609, -0.989583, -0.056043, -0.100275, -0.989643, -0.102719, -0.028967, -0.999126, -0.030123, -0.144219, -0.989544, -0.001769, -0.430357, -0.884825, -0.178540, -0.327021, -0.885364, -0.330436, -0.173941, -0.884904, -0.432075, -0.052771, -0.989582, -0.133947, -0.015076, -0.999117, -0.039224, -0.466360, -0.884592, -0.002442, -0.717727, -0.630270, -0.296021, -0.546647, -0.630850, -0.550641, -0.290730, -0.630256, -0.719898, 0.002834, -0.629277, -0.777176, 0.002442, -0.884592, -0.466360, 0.001769, -0.989544, -0.144219, -0.777176, -0.629277, -0.002834, 0.296021, -0.630270, -0.717727, 0.178540, -0.884825, -0.430357, 0.056043, -0.989583, -0.132609, 0.000842, -0.999117, -0.042001, 0.550641, -0.630850, -0.546647, 0.330436, -0.885364, -0.327021, 0.102719, -0.989643, -0.100275, 0.016563, -0.999124, -0.038423, 0.719898, -0.630256, -0.290730, 0.432075, -0.884904, -0.173941, 0.133947, -0.989582, -0.052771, 0.030123, -0.999126, -0.028967, 0.777176, -0.629277, 0.002834, 0.466360, -0.884592, 0.002442, 0.144219, -0.989544, 0.001769, 0.039224, -0.999117, -0.015076, 0.042001, -0.999117, 0.000842, -0.719898, -0.630256, 0.290730, -0.679500, -0.733659, -0.004828, -0.777176, -0.629277, -0.002834, -0.630137, -0.734493, 0.251887, -0.738621, -0.674098, -0.005536, -0.685269, -0.674864, 0.273797, -0.906835, -0.421465, -0.004100, -0.840707, -0.422185, 0.339075, -0.998647, -0.051997, -0.000484, -0.550641, -0.630850, 0.546647, -0.482802, -0.735046, 0.476035, -0.525184, -0.675601, 0.517442, -0.643630, -0.422882, 0.637897, -0.924585, -0.052158, 0.377388, -0.978092, 0.208155, 0.002725, -0.904304, 0.208606, 0.372448, -0.941624, 0.336635, 0.004625, -0.296021, -0.630270, 0.717727, -0.260867, -0.734536, 0.626422, -0.284064, -0.674966, 0.680976, -0.346706, -0.422165, 0.837598, -0.706482, -0.052206, 0.705803, -0.689592, 0.208974, 0.693392, -0.869697, 0.337356, 0.360304, -0.915429, 0.402438, 0.005851, -0.002834, -0.629277, 0.777176, -0.004828, -0.733659, 0.679500, -0.005536, -0.674098, 0.738621, -0.004100, -0.421465, 0.906835, -0.378291, -0.052043, 0.924222, -0.367383, 0.208618, 0.906371, -0.662301, 0.337864, 0.668735, 0.290730, -0.630256, 0.719898, 0.251887, -0.734493, 0.630137, 0.273797, -0.674864, 0.685269, 0.339075, -0.422185, 0.840707, -0.000484, -0.051997, 0.998647, 0.002725, 0.208155, 0.978092, -0.351725, 0.337320, 0.873215, 0.546647, -0.630850, 0.550641, 0.476035, -0.735046, 0.482802, 0.517442, -0.675601, 0.525184, 0.637897, -0.422882, 0.643630, 0.377388, -0.052158, 0.924585, 0.372448, 0.208606, 0.904304, 0.004625, 0.336635, 0.941624, 0.717727, -0.630270, 0.296021, 0.626422, -0.734536, 0.260867, 0.680976, -0.674966, 0.284064, 0.837598, -0.422165, 0.346706, 0.705803, -0.052206, 0.706482, 0.693392, 0.208974, 0.689592, 0.360304, 0.337356, 0.869697, 0.777176, -0.629277, 0.002834, 0.679500, -0.733659, 0.004828, 0.738621, -0.674098, 0.005536, 0.906835, -0.421465, 0.004100, 0.924222, -0.052043, 0.378291, 0.906371, 0.208618, 0.367383, 0.668735, 0.337864, 0.662301, 0.351450, 0.403277, 0.844897, 0.005851, 0.402438, 0.915429, 0.998647, -0.051997, 0.000484, 0.978092, 0.208155, -0.002725, 0.873215, 0.337320, 0.351725, 0.650935, 0.403824, 0.642814, 0.343713, 0.446390, 0.826195, 0.006127, 0.445500, 0.895261, -0.332366, 0.446280, 0.830883, -0.340612, 0.403214, 0.849354, 0.941624, 0.336635, -0.004625, 0.849354, 0.403214, 0.340612, 0.636786, 0.446962, 0.628274, 0.277308, 0.685259, 0.673440, 0.002243, 0.684558, 0.728955, -0.273137, 0.685198, 0.675204, 0.915429, 0.402438, -0.005851, 0.830883, 0.446280, 0.332366, 0.516083, 0.685982, 0.512920, 0.028087, 0.997242, 0.068699, 0.000681, 0.997288, 0.073588, -0.026891, 0.997226, 0.069413, 0.895261, 0.445500, -0.006127, 0.675204, 0.685198, 0.273137, 0.052500, 0.997290, 0.051540, -0.376868, 0.043316, -0.925253, 0.000538, 0.043140, -0.999069, 0.377870, 0.043483, -0.924837, 0.728955, 0.684558, -0.002243, 0.069413, 0.997226, 0.026891, -0.706062, 0.043366, -0.706821, -0.364647, -0.256327, -0.895170, 0.001220, -0.255752, -0.966742, 0.366927, -0.256336, -0.894235, 0.073588, 0.997288, -0.000681, -0.924837, 0.043483, -0.377870, -0.682545, -0.256729, -0.684268, -0.999069, 0.043140, -0.000538, -0.894235, -0.256336, -0.366927, -0.966742, -0.255752, -0.001220, 0.684268, -0.256729, -0.682545, 0.706821, 0.043366, -0.706062, -0.051540, 0.997290, 0.052500, -0.512920, 0.685982, 0.516083, 0.895170, -0.256327, -0.364647, 0.925253, 0.043316, -0.376868, -0.068699, 0.997242, 0.028087, -0.673440, 0.685259, 0.277308, -0.628274, 0.446962, 0.636786, -0.642814, 0.403824, 0.650935, 0.966697, -0.255740, -0.009653, 0.999169, 0.039728, -0.009059, -0.073204, 0.997317, -0.000152, -0.729084, 0.684420, 0.002551, -0.826195, 0.446390, 0.343713, -0.844897, 0.403277, 0.351450, -0.895267, 0.445487, 0.006145, 0.719898, -0.630256, -0.290730, 0.679500, -0.733659, 0.004828, 0.777176, -0.629277, 0.002834, 0.630137, -0.734493, -0.251887, 0.738621, -0.674098, 0.005536, 0.685269, -0.674864, -0.273797, 0.906835, -0.421465, 0.004100, 0.840707, -0.422185, -0.339075, 0.998647, -0.051997, 0.000484, 0.550641, -0.630850, -0.546647, 0.482802, -0.735046, -0.476035, 0.525184, -0.675601, -0.517442, 0.643630, -0.422882, -0.637897, 0.924585, -0.052158, -0.377388, 0.978092, 0.208155, -0.002725, 0.904304, 0.208606, -0.372448, 0.941624, 0.336635, -0.004625, 0.296021, -0.630270, -0.717727, 0.260867, -0.734536, -0.626422, 0.284064, -0.674966, -0.680976, 0.346706, -0.422165, -0.837598, 0.706482, -0.052206, -0.705803, 0.689592, 0.208974, -0.693392, 0.869697, 0.337356, -0.360304, 0.915429, 0.402438, -0.005851, 0.002834, -0.629277, -0.777176, 0.004828, -0.733659, -0.679500, 0.005536, -0.674098, -0.738621, 0.004100, -0.421465, -0.906835, 0.378291, -0.052043, -0.924222, 0.367383, 0.208618, -0.906371, 0.662301, 0.337864, -0.668735, -0.290730, -0.630256, -0.719898, -0.251887, -0.734493, -0.630137, -0.273797, -0.674864, -0.685269, -0.339075, -0.422185, -0.840707, 0.000484, -0.051997, -0.998647, -0.002725, 0.208155, -0.978092, 0.351725, 0.337320, -0.873215, -0.546647, -0.630850, -0.550641, -0.476035, -0.735046, -0.482802, -0.517442, -0.675601, -0.525184, -0.637897, -0.422882, -0.643630, -0.377388, -0.052158, -0.924585, -0.372448, 0.208606, -0.904304, -0.004625, 0.336635, -0.941624, -0.717727, -0.630270, -0.296021, -0.626422, -0.734536, -0.260867, -0.680976, -0.674966, -0.284064, -0.837598, -0.422165, -0.346706, -0.705803, -0.052206, -0.706482, -0.693392, 0.208974, -0.689592, -0.360304, 0.337356, -0.869697, -0.777176, -0.629277, -0.002834, -0.679500, -0.733659, -0.004828, -0.738621, -0.674098, -0.005536, -0.906835, -0.421465, -0.004100, -0.924222, -0.052043, -0.378291, -0.906371, 0.208618, -0.367383, -0.668735, 0.337864, -0.662301, -0.351450, 0.403277, -0.844897, -0.005851, 0.402438, -0.915429, -0.998647, -0.051997, -0.000484, -0.978092, 0.208155, 0.002725, -0.873215, 0.337320, -0.351725, -0.650935, 0.403824, -0.642814, -0.343653, 0.446112, -0.826370, -0.006127, 0.445500, -0.895261, 0.332366, 0.446280, -0.830883, 0.340612, 0.403214, -0.849354, -0.941624, 0.336635, 0.004625, -0.849354, 0.403214, -0.340612, -0.636916, 0.446472, -0.628491, -0.277839, 0.679586, -0.678947, -0.002240, 0.684580, -0.728934, 0.273137, 0.685198, -0.675204, 0.512920, 0.685982, -0.516083, -0.915429, 0.402438, 0.005851, -0.831010, 0.446020, -0.332400, -0.522353, 0.675688, -0.520186, -0.044855, 0.997319, -0.057814, -0.000627, 0.997392, -0.072172, 0.026891, 0.997226, -0.069413, 0.051540, 0.997290, -0.052500, -0.895267, 0.445487, 0.006145, -0.679889, 0.679941, -0.274648, -0.065495, 0.996808, -0.045663, 0.353760, -0.087981, 0.931189, -0.000646, 0.040364, 0.999185, -0.377870, 0.043483, 0.924837, -0.706821, 0.043366, 0.706062, -0.729084, 0.684420, 0.002551, -0.072569, 0.996992, -0.027228, 0.695812, -0.173404, 0.696977, 0.371495, -0.357310, 0.856926, -0.001001, -0.258014, 0.966141, -0.366927, -0.256336, 0.894235, -0.684268, -0.256729, 0.682545, -0.073204, 0.997317, -0.000152, 0.930079, -0.068165, 0.360980, 0.663802, -0.411075, 0.624808, 0.999169, 0.039728, -0.009059, 0.881702, -0.332968, 0.334266, 0.966697, -0.255740, -0.009653, -0.895170, -0.256327, 0.364647, -0.925253, 0.043316, 0.376868, 0.068699, 0.997242, -0.028087, 0.673440, 0.685259, -0.277308, 0.628274, 0.446962, -0.636786, -0.966742, -0.255752, -0.001220, -0.999069, 0.043140, -0.000538, 0.073588, 0.997288, -0.000681, 0.728955, 0.684558, -0.002243, 0.826195, 0.446390, -0.343713, 0.642814, 0.403824, -0.650935, 0.512920, 0.685982, -0.516083, 0.895261, 0.445500, -0.006127, 0.844897, 0.403277, -0.351450 }; // Texture coords #ifdef EXTEAPOT_ENABLETEXCOORDS static const double ExTeapotBodyTexCoords[363 * 2] = { 0.000000, 0.000000, 0.250000, -0.100000, 0.250000, 0.000000, 0.250000, 0.000000, 0.500000, -0.100000, 0.500000, 0.000000, 0.500000, 0.000000, 0.750000, -0.100000, 0.750000, 0.000000, 0.750000, 0.000000, 1.000000, -0.100000, 1.000000, 0.000000, 1.000000, 0.000000, 1.250000, -0.100000, 1.250000, 0.000000, 1.250000, 0.000000, 1.500000, -0.100000, 1.500000, 0.000000, 1.500000, 0.000000, 1.750000, -0.100000, 1.750000, 0.000000, 1.750000, 0.000000, 2.000000, -0.100000, 2.000000, 0.000000, 0.000000, 0.000000, 0.250000, -0.100000, 0.250000, 0.000000, 0.250000, 0.000000, 0.500000, -0.100000, 0.500000, 0.000000, 0.500000, 0.000000, 0.750000, -0.100000, 0.750000, 0.000000, 0.750000, 0.000000, 1.000000, -0.100000, 1.000000, 0.000000, 1.000000, 0.000000, 1.250000, -0.100000, 1.250000, 0.000000, 1.250000, 0.000000, 1.500000, -0.100000, 1.500000, 0.000000, 1.500000, 0.000000, 1.750000, -0.100000, 1.750000, 0.000000, 1.750000, 0.000000, 2.000000, -0.100000, 2.000000, 0.000000, 0.250000, -0.100000, 0.000000, 0.000000, 0.000000, -0.100000, 0.250000, -0.200000, 0.500000, -0.200000, 0.500000, -0.100000, 0.250000, 0.000000, 0.000000, -0.200000, 0.250000, -0.300000, 0.500000, -0.300000, 0.750000, -0.300000, 0.750000, -0.200000, 0.750000, -0.100000, 0.500000, 0.000000, 0.000000, -0.300000, 0.250000, -0.400000, 0.500000, -0.400000, 0.750000, -0.400000, 1.000000, -0.400000, 1.000000, -0.300000, 1.000000, -0.200000, 0.000000, -0.400000, 1.250000, -0.400000, 1.250000, -0.300000, 1.250000, -0.200000, 1.000000, -0.100000, 0.750000, 0.000000, 1.500000, -0.400000, 1.500000, -0.300000, 1.500000, -0.200000, 1.250000, -0.100000, 1.000000, 0.000000, 1.750000, -0.400000, 1.750000, -0.300000, 1.750000, -0.200000, 1.500000, -0.100000, 1.250000, 0.000000, 2.000000, -0.400000, 2.000000, -0.300000, 2.000000, -0.200000, 1.750000, -0.100000, 1.500000, 0.000000, 2.000000, -0.100000, 1.750000, 0.000000, 0.250000, -0.100000, 0.000000, -0.100000, 0.250000, -0.200000, 0.500000, -0.200000, 0.500000, -0.100000, 0.000000, -0.200000, 0.250000, -0.300000, 0.500000, -0.300000, 0.750000, -0.300000, 0.750000, -0.200000, 0.750000, -0.100000, 0.000000, -0.300000, 0.250000, -0.400000, 0.500000, -0.400000, 0.750000, -0.400000, 1.000000, -0.400000, 1.000000, -0.300000, 1.000000, -0.200000, 0.000000, -0.400000, 1.250000, -0.400000, 1.250000, -0.300000, 1.250000, -0.200000, 1.000000, -0.100000, 1.500000, -0.400000, 1.500000, -0.300000, 1.500000, -0.200000, 1.250000, -0.100000, 1.750000, -0.400000, 1.750000, -0.300000, 1.750000, -0.200000, 1.500000, -0.100000, 2.000000, -0.400000, 2.000000, -0.300000, 2.000000, -0.200000, 1.750000, -0.100000, 2.000000, -0.100000, 1.750000, -0.400000, 2.000000, -0.550000, 2.000000, -0.400000, 1.750000, -0.550000, 2.000000, -0.700000, 1.750000, -0.700000, 2.000000, -0.850000, 1.750000, -0.850000, 2.000000, -1.000000, 1.500000, -0.400000, 1.500000, -0.550000, 1.500000, -0.700000, 1.500000, -0.850000, 1.750000, -1.000000, 2.000000, -1.225000, 1.750000, -1.225000, 2.000000, -1.450000, 1.250000, -0.400000, 1.250000, -0.550000, 1.250000, -0.700000, 1.250000, -0.850000, 1.500000, -1.000000, 1.500000, -1.225000, 1.750000, -1.450000, 2.000000, -1.675000, 1.000000, -0.400000, 1.000000, -0.550000, 1.000000, -0.700000, 1.000000, -0.850000, 1.250000, -1.000000, 1.250000, -1.225000, 1.500000, -1.450000, 0.750000, -0.400000, 0.750000, -0.550000, 0.750000, -0.700000, 0.750000, -0.850000, 1.000000, -1.000000, 1.000000, -1.225000, 1.250000, -1.450000, 0.500000, -0.400000, 0.500000, -0.550000, 0.500000, -0.700000, 0.500000, -0.850000, 0.750000, -1.000000, 0.750000, -1.225000, 1.000000, -1.450000, 0.250000, -0.400000, 0.250000, -0.550000, 0.250000, -0.700000, 0.250000, -0.850000, 0.500000, -1.000000, 0.500000, -1.225000, 0.750000, -1.450000, 0.000000, -0.400000, 0.000000, -0.550000, 0.000000, -0.700000, 0.000000, -0.850000, 0.250000, -1.000000, 0.250000, -1.225000, 0.500000, -1.450000, 0.750000, -1.675000, 1.000000, -1.675000, 0.000000, -1.000000, 0.000000, -1.225000, 0.250000, -1.450000, 0.500000, -1.675000, 0.750000, -1.900000, 1.000000, -1.900000, 1.250000, -1.900000, 1.250000, -1.675000, 0.000000, -1.450000, 0.250000, -1.675000, 0.500000, -1.900000, 0.750000, -1.925000, 1.000000, -1.925000, 1.250000, -1.925000, 0.000000, -1.675000, 0.250000, -1.900000, 0.500000, -1.925000, 0.750000, -1.950000, 1.000000, -1.950000, 1.250000, -1.950000, 0.000000, -1.900000, 0.250000, -1.925000, 0.500000, -1.950000, 0.750000, -1.975000, 1.000000, -1.975000, 1.250000, -1.975000, 0.000000, -1.925000, 0.250000, -1.950000, 0.500000, -1.975000, 0.750000, -2.000000, 1.000000, -2.000000, 1.250000, -2.000000, 0.000000, -1.950000, 0.250000, -1.975000, 0.500000, -2.000000, 0.000000, -1.975000, 0.250000, -2.000000, 0.000000, -2.000000, 1.500000, -2.000000, 1.500000, -1.975000, 1.500000, -1.950000, 1.500000, -1.925000, 1.750000, -2.000000, 1.750000, -1.975000, 1.750000, -1.950000, 1.750000, -1.925000, 1.500000, -1.900000, 1.500000, -1.675000, 2.000000, -2.000000, 2.000000, -1.975000, 2.000000, -1.950000, 2.000000, -1.925000, 1.750000, -1.900000, 1.750000, -1.675000, 2.000000, -1.900000, 1.750000, -0.400000, 2.000000, -0.550000, 2.000000, -0.400000, 1.750000, -0.550000, 2.000000, -0.700000, 1.750000, -0.700000, 2.000000, -0.850000, 1.750000, -0.850000, 2.000000, -1.000000, 1.500000, -0.400000, 1.500000, -0.550000, 1.500000, -0.700000, 1.500000, -0.850000, 1.750000, -1.000000, 2.000000, -1.225000, 1.750000, -1.225000, 2.000000, -1.450000, 1.250000, -0.400000, 1.250000, -0.550000, 1.250000, -0.700000, 1.250000, -0.850000, 1.500000, -1.000000, 1.500000, -1.225000, 1.750000, -1.450000, 2.000000, -1.675000, 1.000000, -0.400000, 1.000000, -0.550000, 1.000000, -0.700000, 1.000000, -0.850000, 1.250000, -1.000000, 1.250000, -1.225000, 1.500000, -1.450000, 0.750000, -0.400000, 0.750000, -0.550000, 0.750000, -0.700000, 0.750000, -0.850000, 1.000000, -1.000000, 1.000000, -1.225000, 1.250000, -1.450000, 0.500000, -0.400000, 0.500000, -0.550000, 0.500000, -0.700000, 0.500000, -0.850000, 0.750000, -1.000000, 0.750000, -1.225000, 1.000000, -1.450000, 0.250000, -0.400000, 0.250000, -0.550000, 0.250000, -0.700000, 0.250000, -0.850000, 0.500000, -1.000000, 0.500000, -1.225000, 0.750000, -1.450000, 0.000000, -0.400000, 0.000000, -0.550000, 0.000000, -0.700000, 0.000000, -0.850000, 0.250000, -1.000000, 0.250000, -1.225000, 0.500000, -1.450000, 0.750000, -1.675000, 1.000000, -1.675000, 0.000000, -1.000000, 0.000000, -1.225000, 0.250000, -1.450000, 0.500000, -1.675000, 0.750000, -1.900000, 1.000000, -1.900000, 1.250000, -1.900000, 1.250000, -1.675000, 0.000000, -1.450000, 0.250000, -1.675000, 0.500000, -1.900000, 0.750000, -1.925000, 1.000000, -1.925000, 1.250000, -1.925000, 1.500000, -1.925000, 0.000000, -1.675000, 0.250000, -1.900000, 0.500000, -1.925000, 0.750000, -1.950000, 1.000000, -1.950000, 1.250000, -1.950000, 1.500000, -1.950000, 0.000000, -1.900000, 0.250000, -1.925000, 0.500000, -1.950000, 0.750000, -1.975000, 1.000000, -1.975000, 1.250000, -1.975000, 1.500000, -1.975000, 0.000000, -1.925000, 0.250000, -1.950000, 0.500000, -1.975000, 0.750000, -2.000000, 1.000000, -2.000000, 1.250000, -2.000000, 1.500000, -2.000000, 0.000000, -1.950000, 0.250000, -1.975000, 0.500000, -2.000000, 0.000000, -1.975000, 0.250000, -2.000000, 0.000000, -2.000000, 1.750000, -2.000000, 1.750000, -1.975000, 1.750000, -1.950000, 1.750000, -1.925000, 1.500000, -1.900000, 2.000000, -2.000000, 2.000000, -1.975000, 2.000000, -1.950000, 2.000000, -1.925000, 1.750000, -1.900000, 1.500000, -1.675000, 1.500000, -1.925000, 2.000000, -1.900000, 1.750000, -1.675000 }; #endif // EXTEAPOT_ENABLETEXCOORDS // TeapotHandle data // Vertices static const double ExTeapotHandleVertices[159 * 3] = { -1.431274, 1.019916, -0.084375, -1.500000, 0.900000, 0.000000, -1.453125, 1.030078, 0.000000, -1.453125, 1.030078, 0.000000, -1.295898, 1.081494, -0.084375, -1.431274, 1.019916, -0.084375, -1.295898, 1.081494, -0.084375, -1.453125, 1.030078, 0.000000, -1.312500, 1.096875, 0.000000, -1.312500, 1.096875, 0.000000, -1.071167, 1.104181, -0.084375, -1.295898, 1.081494, -0.084375, -1.071167, 1.104181, -0.084375, -1.312500, 1.096875, 0.000000, -1.078125, 1.121484, 0.000000, -1.078125, 1.121484, 0.000000, -0.757813, 1.107422, -0.084375, -1.071167, 1.104181, -0.084375, -0.757813, 1.107422, -0.084375, -1.078125, 1.121484, 0.000000, -0.750000, 1.125000, 0.000000, -1.476563, 0.900000, -0.084375, -1.383203, 0.997559, -0.112500, -1.425000, 0.900000, -0.112500, -1.383203, 0.997559, -0.112500, -1.476563, 0.900000, -0.084375, -1.431274, 1.019916, -0.084375, -1.431274, 1.019916, -0.084375, -1.259375, 1.047656, -0.112500, -1.383203, 0.997559, -0.112500, -1.259375, 1.047656, -0.112500, -1.431274, 1.019916, -0.084375, -1.295898, 1.081494, -0.084375, -1.295898, 1.081494, -0.084375, -1.055859, 1.066113, -0.112500, -1.259375, 1.047656, -0.112500, -1.055859, 1.066113, -0.112500, -1.295898, 1.081494, -0.084375, -1.071167, 1.104181, -0.084375, -1.071167, 1.104181, -0.084375, -0.775000, 1.068750, -0.112500, -1.055859, 1.066113, -0.112500, -0.775000, 1.068750, -0.112500, -1.071167, 1.104181, -0.084375, -0.757813, 1.107422, -0.084375, -1.425000, 0.900000, -0.112500, -1.335132, 0.975201, -0.084375, -1.373438, 0.900000, -0.084375, -1.335132, 0.975201, -0.084375, -1.425000, 0.900000, -0.112500, -1.383203, 0.997559, -0.112500, -1.383203, 0.997559, -0.112500, -1.222852, 1.013818, -0.084375, -1.335132, 0.975201, -0.084375, -1.222852, 1.013818, -0.084375, -1.383203, 0.997559, -0.112500, -1.259375, 1.047656, -0.112500, -1.259375, 1.047656, -0.112500, -1.040552, 1.028046, -0.084375, -1.222852, 1.013818, -0.084375, -1.040552, 1.028046, -0.084375, -1.259375, 1.047656, -0.112500, -1.055859, 1.066113, -0.112500, -1.055859, 1.066113, -0.112500, -0.792188, 1.030078, -0.084375, -1.040552, 1.028046, -0.084375, -0.792188, 1.030078, -0.084375, -1.055859, 1.066113, -0.112500, -0.775000, 1.068750, -0.112500, -1.373438, 0.900000, -0.084375, -1.313281, 0.965039, 0.000000, -1.350000, 0.900000, 0.000000, -1.313281, 0.965039, 0.000000, -1.373438, 0.900000, -0.084375, -1.335132, 0.975201, -0.084375, -1.335132, 0.975201, -0.084375, -1.206250, 0.998438, 0.000000, -1.313281, 0.965039, 0.000000, -1.206250, 0.998438, 0.000000, -1.335132, 0.975201, -0.084375, -1.222852, 1.013818, -0.084375, -1.222852, 1.013818, -0.084375, -1.033594, 1.010742, 0.000000, -1.206250, 0.998438, 0.000000, -1.033594, 1.010742, 0.000000, -1.222852, 1.013818, -0.084375, -1.040552, 1.028046, -0.084375, -1.040552, 1.028046, -0.084375, -0.800000, 1.012500, 0.000000, -1.033594, 1.010742, 0.000000, -0.800000, 1.012500, 0.000000, -1.040552, 1.028046, -0.084375, -0.792188, 1.030078, -0.084375, -0.992188, 0.426562, -0.084375, -1.160156, 0.551953, 0.000000, -1.000000, 0.450000, 0.000000, -1.165466, 0.533414, -0.084375, -1.268750, 0.675000, 0.000000, -1.283887, 0.659985, -0.084375, -1.330469, 0.798047, 0.000000, -1.351770, 0.788205, -0.084375, -1.350000, 0.900000, 0.000000, -1.373438, 0.900000, -0.084375, -0.975000, 0.375000, -0.112500, -1.177148, 0.492627, -0.112500, -1.317188, 0.626953, -0.112500, -1.398633, 0.766553, -0.112500, -1.425000, 0.900000, -0.112500, -1.445496, 0.744901, -0.084375, -1.476563, 0.900000, -0.084375, -0.957812, 0.323438, -0.084375, -1.188831, 0.451840, -0.084375, -1.350488, 0.593921, -0.084375, -1.365625, 0.578906, 0.000000, -1.466797, 0.735059, 0.000000, -1.500000, 0.900000, 0.000000, -1.431274, 1.019916, -0.084375, -0.950000, 0.300000, 0.000000, -1.194141, 0.433301, 0.000000, -1.188831, 0.451840, 0.084375, -1.350488, 0.593921, 0.084375, -1.445496, 0.744901, 0.084375, -1.476563, 0.900000, 0.084375, -1.453125, 1.030078, 0.000000, -0.957812, 0.323438, 0.084375, -0.975000, 0.375000, 0.112500, -1.177148, 0.492627, 0.112500, -1.317188, 0.626953, 0.112500, -1.398633, 0.766553, 0.112500, -1.425000, 0.900000, 0.112500, -1.431274, 1.019916, 0.084375, -1.312500, 1.096875, 0.000000, -0.992188, 0.426562, 0.084375, -1.165466, 0.533414, 0.084375, -1.283887, 0.659985, 0.084375, -1.351770, 0.788205, 0.084375, -1.373438, 0.900000, 0.084375, -1.383203, 0.997559, 0.112500, -1.295898, 1.081494, 0.084375, -1.078125, 1.121484, 0.000000, -1.000000, 0.450000, 0.000000, -1.160156, 0.551953, 0.000000, -1.268750, 0.675000, 0.000000, -1.330469, 0.798047, 0.000000, -1.350000, 0.900000, 0.000000, -1.335132, 0.975201, 0.084375, -1.259375, 1.047656, 0.112500, -1.071167, 1.104181, 0.084375, -0.750000, 1.125000, 0.000000, -0.757813, 1.107422, 0.084375, -1.055859, 1.066113, 0.112500, -0.775000, 1.068750, 0.112500, -1.313281, 0.965039, 0.000000, -1.222852, 1.013818, 0.084375, -1.206250, 0.998438, 0.000000, -1.040552, 1.028046, 0.084375, -0.792188, 1.030078, 0.084375, -1.033594, 1.010742, 0.000000, -0.800000, 1.012500, 0.000000 }; // Indices static const OdInt32 ExTeapotHandleIndices[128 * 4] = { 3, 0, 1, 2, 3, 3, 4, 5, 3, 6, 7, 8, 3, 9, 10, 11, 3, 12, 13, 14, 3, 15, 16, 17, 3, 18, 19, 20, 3, 21, 22, 23, 3, 24, 25, 26, 3, 27, 28, 29, 3, 30, 31, 32, 3, 33, 34, 35, 3, 36, 37, 38, 3, 39, 40, 41, 3, 42, 43, 44, 3, 45, 46, 47, 3, 48, 49, 50, 3, 51, 52, 53, 3, 54, 55, 56, 3, 57, 58, 59, 3, 60, 61, 62, 3, 63, 64, 65, 3, 66, 67, 68, 3, 69, 70, 71, 3, 72, 73, 74, 3, 75, 76, 77, 3, 78, 79, 80, 3, 81, 82, 83, 3, 84, 85, 86, 3, 87, 88, 89, 3, 90, 91, 92, 3, 93, 94, 95, 3, 94, 93, 96, 3, 96, 97, 94, 3, 97, 96, 98, 3, 98, 99, 97, 3, 99, 98, 100, 3, 100, 101, 99, 3, 101, 100, 102, 3, 103, 96, 93, 3, 96, 103, 104, 3, 104, 98, 96, 3, 98, 104, 105, 3, 105, 100, 98, 3, 100, 105, 106, 3, 106, 102, 100, 3, 102, 106, 107, 3, 108, 107, 106, 3, 107, 108, 109, 3, 110, 104, 103, 3, 104, 110, 111, 3, 111, 105, 104, 3, 105, 111, 112, 3, 112, 106, 105, 3, 106, 112, 108, 3, 113, 108, 112, 3, 108, 113, 114, 3, 114, 109, 108, 3, 109, 114, 115, 3, 115, 116, 109, 3, 117, 111, 110, 3, 111, 117, 118, 3, 118, 112, 111, 3, 112, 118, 113, 3, 119, 113, 118, 3, 113, 119, 120, 3, 120, 114, 113, 3, 114, 120, 121, 3, 121, 115, 114, 3, 115, 121, 122, 3, 122, 123, 115, 3, 124, 118, 117, 3, 118, 124, 119, 3, 125, 119, 124, 3, 119, 125, 126, 3, 126, 120, 119, 3, 120, 126, 127, 3, 127, 121, 120, 3, 121, 127, 128, 3, 128, 122, 121, 3, 122, 128, 129, 3, 129, 130, 122, 3, 123, 122, 130, 3, 130, 131, 123, 3, 132, 126, 125, 3, 126, 132, 133, 3, 133, 127, 126, 3, 127, 133, 134, 3, 134, 128, 127, 3, 128, 134, 135, 3, 135, 129, 128, 3, 129, 135, 136, 3, 136, 137, 129, 3, 130, 129, 137, 3, 137, 138, 130, 3, 131, 130, 138, 3, 138, 139, 131, 3, 140, 133, 132, 3, 133, 140, 141, 3, 141, 134, 133, 3, 134, 141, 142, 3, 142, 135, 134, 3, 135, 142, 143, 3, 143, 136, 135, 3, 136, 143, 144, 3, 144, 145, 136, 3, 137, 136, 145, 3, 145, 146, 137, 3, 138, 137, 146, 3, 146, 147, 138, 3, 139, 138, 147, 3, 147, 148, 139, 3, 148, 147, 149, 3, 150, 149, 147, 3, 149, 150, 151, 3, 145, 144, 152, 3, 152, 153, 145, 3, 146, 145, 153, 3, 153, 150, 146, 3, 147, 146, 150, 3, 153, 152, 154, 3, 154, 155, 153, 3, 150, 153, 155, 3, 155, 151, 150, 3, 151, 155, 156, 3, 157, 156, 155, 3, 156, 157, 158, 3, 155, 154, 157 }; // Normals static const double ExTeapotHandleNormals[159 * 3] = { -0.626659, 0.606851, -0.488907, -0.999001, 0.044619, -0.002568, -0.734172, 0.678934, -0.006396, -0.734172, 0.678934, -0.006396, -0.210750, 0.873130, -0.439578, -0.626659, 0.606851, -0.488907, -0.210750, 0.873130, -0.439578, -0.734172, 0.678934, -0.006396, -0.247915, 0.968778, -0.002907, -0.247915, 0.968778, -0.002907, -0.045501, 0.902071, -0.429183, -0.210750, 0.873130, -0.439578, -0.045501, 0.902071, -0.429183, -0.247915, 0.968778, -0.002907, -0.051279, 0.998684, 0.000004, -0.051279, 0.998684, 0.000004, -0.009743, 0.919328, -0.393370, -0.045501, 0.902071, -0.429183, -0.009743, 0.919328, -0.393370, -0.051279, 0.998684, 0.000004, -0.010565, 0.999936, -0.004023, -0.858453, 0.038722, -0.511428, -0.082373, 0.138056, -0.986993, -0.116068, 0.011951, -0.993169, -0.082373, 0.138056, -0.986993, -0.858453, 0.038722, -0.511428, -0.626659, 0.606851, -0.488907, -0.626659, 0.606851, -0.488907, 0.000902, 0.121357, -0.992608, -0.082373, 0.138056, -0.986993, 0.000902, 0.121357, -0.992608, -0.626659, 0.606851, -0.488907, -0.210750, 0.873130, -0.439578, -0.210750, 0.873130, -0.439578, 0.000846, 0.063991, -0.997950, 0.000902, 0.121357, -0.992608, 0.000846, 0.063991, -0.997950, -0.210750, 0.873130, -0.439578, -0.045501, 0.902071, -0.429183, -0.045501, 0.902071, -0.429183, -0.002232, 0.194831, -0.980834, 0.000846, 0.063991, -0.997950, -0.002232, 0.194831, -0.980834, -0.045501, 0.902071, -0.429183, -0.009743, 0.919328, -0.393370, -0.116068, 0.011951, -0.993169, 0.498677, -0.647215, -0.576571, 0.790709, -0.064356, -0.608800, 0.498677, -0.647215, -0.576571, -0.116068, 0.011951, -0.993169, -0.082373, 0.138056, -0.986993, -0.082373, 0.138056, -0.986993, 0.156413, -0.859855, -0.485988, 0.498677, -0.647215, -0.576571, 0.156413, -0.859855, -0.485988, -0.082373, 0.138056, -0.986993, 0.000902, 0.121357, -0.992608, 0.000902, 0.121357, -0.992608, 0.034693, -0.885127, -0.464054, 0.156413, -0.859855, -0.485988, 0.034693, -0.885127, -0.464054, 0.000902, 0.121357, -0.992608, 0.000846, 0.063991, -0.997950, 0.000846, 0.063991, -0.997950, 0.007370, -0.862537, -0.505941, 0.034693, -0.885127, -0.464054, 0.007370, -0.862537, -0.505941, 0.000846, 0.063991, -0.997950, -0.002232, 0.194831, -0.980834, 0.790709, -0.064356, -0.608800, 0.554299, -0.832264, 0.009487, 0.994301, -0.106502, 0.004831, 0.554299, -0.832264, 0.009487, 0.790709, -0.064356, -0.608800, 0.498677, -0.647215, -0.576571, 0.498677, -0.647215, -0.576571, 0.155479, -0.987826, 0.005168, 0.554299, -0.832264, 0.009487, 0.155479, -0.987826, 0.005168, 0.498677, -0.647215, -0.576571, 0.156413, -0.859855, -0.485988, 0.156413, -0.859855, -0.485988, 0.034265, -0.999410, 0.002213, 0.155479, -0.987826, 0.005168, 0.034265, -0.999410, 0.002213, 0.156413, -0.859855, -0.485988, 0.034693, -0.885127, -0.464054, 0.034693, -0.885127, -0.464054, 0.007796, -0.999958, -0.004858, 0.034265, -0.999410, 0.002213, 0.007796, -0.999958, -0.004858, 0.034693, -0.885127, -0.464054, 0.007370, -0.862537, -0.505941, 0.457200, 0.731205, -0.506269, 0.641597, 0.767019, 0.005833, 0.532210, 0.846550, 0.010306, 0.550987, 0.687033, -0.473709, 0.819040, 0.573692, 0.007156, 0.678318, 0.501542, -0.536973, 0.940065, 0.340967, 0.004491, 0.761591, 0.292081, -0.578504, 0.994301, -0.106502, 0.004831, 0.790709, -0.064356, -0.608800, -0.181006, -0.317794, -0.930722, -0.040773, -0.042798, -0.998251, -0.047534, -0.045581, -0.997829, -0.067901, -0.028090, -0.997297, -0.116068, 0.011951, -0.993169, -0.786864, -0.331734, -0.520382, -0.858453, 0.038722, -0.511428, -0.461411, -0.826400, -0.322742, -0.504393, -0.737391, -0.449268, -0.650444, -0.577318, -0.493586, -0.744807, -0.667258, -0.005389, -0.922677, -0.385570, -0.001807, -0.999001, 0.044619, -0.002568, -0.626659, 0.606851, -0.488907, -0.481722, -0.876322, 0.001951, -0.557163, -0.830390, -0.004747, -0.508563, -0.739128, 0.441649, -0.658289, -0.572101, 0.489240, -0.792542, -0.319726, 0.519280, -0.860032, 0.048825, 0.507899, -0.734172, 0.678934, -0.006396, -0.454022, -0.827342, 0.330710, -0.173269, -0.317004, 0.932463, -0.047036, -0.058267, 0.997192, -0.050462, -0.048304, 0.997557, -0.071663, -0.027366, 0.997053, -0.121940, 0.015266, 0.992420, -0.618725, 0.623852, 0.477481, -0.247915, 0.968778, -0.002907, 0.438986, 0.726589, 0.528544, 0.550730, 0.684269, 0.477987, 0.683859, 0.492708, 0.538122, 0.765076, 0.276669, 0.581475, 0.786638, -0.077022, 0.612592, -0.090624, 0.150578, 0.984436, -0.201901, 0.880111, 0.429698, -0.051279, 0.998684, 0.000004, 0.532210, 0.846550, 0.010306, 0.641597, 0.767019, 0.005833, 0.819040, 0.573692, 0.007156, 0.940065, 0.340967, 0.004491, 0.994301, -0.106502, 0.004831, 0.483651, -0.656558, 0.578804, -0.006691, 0.141331, 0.989940, -0.042086, 0.903258, 0.427028, -0.010565, 0.999936, -0.004023, -0.009404, 0.922549, 0.385765, -0.000158, 0.076427, 0.997075, -0.002101, 0.195821, 0.980637, 0.554299, -0.832264, 0.009487, 0.147358, -0.858914, 0.490461, 0.155479, -0.987826, 0.005168, 0.030940, -0.882808, 0.468714, 0.006811, -0.868637, 0.495402, 0.034265, -0.999410, 0.002213, 0.007796, -0.999958, -0.004858 }; // Texture coords #ifdef EXTEAPOT_ENABLETEXCOORDS static const double ExTeapotHandleTexCoords[159 * 2] = { 0.625000, -0.625000, 0.500000, -0.500000, 0.500000, -0.625000, 0.500000, -0.625000, 0.625000, -0.750000, 0.625000, -0.625000, 0.625000, -0.750000, 0.500000, -0.625000, 0.500000, -0.750000, 0.500000, -0.750000, 0.625000, -0.875000, 0.625000, -0.750000, 0.625000, -0.875000, 0.500000, -0.750000, 0.500000, -0.875000, 0.500000, -0.875000, 0.625000, -1.000000, 0.625000, -0.875000, 0.625000, -1.000000, 0.500000, -0.875000, 0.500000, -1.000000, 0.625000, -0.500000, 0.750000, -0.625000, 0.750000, -0.500000, 0.750000, -0.625000, 0.625000, -0.500000, 0.625000, -0.625000, 0.625000, -0.625000, 0.750000, -0.750000, 0.750000, -0.625000, 0.750000, -0.750000, 0.625000, -0.625000, 0.625000, -0.750000, 0.625000, -0.750000, 0.750000, -0.875000, 0.750000, -0.750000, 0.750000, -0.875000, 0.625000, -0.750000, 0.625000, -0.875000, 0.625000, -0.875000, 0.750000, -1.000000, 0.750000, -0.875000, 0.750000, -1.000000, 0.625000, -0.875000, 0.625000, -1.000000, 0.750000, -0.500000, 0.875000, -0.625000, 0.875000, -0.500000, 0.875000, -0.625000, 0.750000, -0.500000, 0.750000, -0.625000, 0.750000, -0.625000, 0.875000, -0.750000, 0.875000, -0.625000, 0.875000, -0.750000, 0.750000, -0.625000, 0.750000, -0.750000, 0.750000, -0.750000, 0.875000, -0.875000, 0.875000, -0.750000, 0.875000, -0.875000, 0.750000, -0.750000, 0.750000, -0.875000, 0.750000, -0.875000, 0.875000, -1.000000, 0.875000, -0.875000, 0.875000, -1.000000, 0.750000, -0.875000, 0.750000, -1.000000, 0.875000, -0.500000, 1.000000, -0.625000, 1.000000, -0.500000, 1.000000, -0.625000, 0.875000, -0.500000, 0.875000, -0.625000, 0.875000, -0.625000, 1.000000, -0.750000, 1.000000, -0.625000, 1.000000, -0.750000, 0.875000, -0.625000, 0.875000, -0.750000, 0.875000, -0.750000, 1.000000, -0.875000, 1.000000, -0.750000, 1.000000, -0.875000, 0.875000, -0.750000, 0.875000, -0.875000, 0.875000, -0.875000, 1.000000, -1.000000, 1.000000, -0.875000, 1.000000, -1.000000, 0.875000, -0.875000, 0.875000, -1.000000, 0.875000, 0.000000, 1.000000, -0.125000, 1.000000, 0.000000, 0.875000, -0.125000, 1.000000, -0.250000, 0.875000, -0.250000, 1.000000, -0.375000, 0.875000, -0.375000, 1.000000, -0.500000, 0.875000, -0.500000, 0.750000, 0.000000, 0.750000, -0.125000, 0.750000, -0.250000, 0.750000, -0.375000, 0.750000, -0.500000, 0.625000, -0.375000, 0.625000, -0.500000, 0.625000, 0.000000, 0.625000, -0.125000, 0.625000, -0.250000, 0.500000, -0.250000, 0.500000, -0.375000, 0.500000, -0.500000, 0.625000, -0.625000, 0.500000, 0.000000, 0.500000, -0.125000, 0.375000, -0.125000, 0.375000, -0.250000, 0.375000, -0.375000, 0.375000, -0.500000, 0.500000, -0.625000, 0.375000, 0.000000, 0.250000, 0.000000, 0.250000, -0.125000, 0.250000, -0.250000, 0.250000, -0.375000, 0.250000, -0.500000, 0.375000, -0.625000, 0.500000, -0.750000, 0.125000, 0.000000, 0.125000, -0.125000, 0.125000, -0.250000, 0.125000, -0.375000, 0.125000, -0.500000, 0.250000, -0.625000, 0.375000, -0.750000, 0.500000, -0.875000, 0.000000, 0.000000, 0.000000, -0.125000, 0.000000, -0.250000, 0.000000, -0.375000, 0.000000, -0.500000, 0.125000, -0.625000, 0.250000, -0.750000, 0.375000, -0.875000, 0.500000, -1.000000, 0.375000, -1.000000, 0.250000, -0.875000, 0.250000, -1.000000, 0.000000, -0.625000, 0.125000, -0.750000, 0.000000, -0.750000, 0.125000, -0.875000, 0.125000, -1.000000, 0.000000, -0.875000, 0.000000, -1.000000 }; #endif // EXTEAPOT_ENABLETEXCOORDS // TeapotSpout data // Vertices static const double ExTeapotSpoutVertices[149 * 3] = { 1.207031, 0.461719, 0.000000, 0.850000, 0.364453, -0.185625, 1.188721, 0.509509, -0.167607, 0.850000, 0.364453, -0.185625, 1.207031, 0.461719, 0.000000, 0.850000, 0.300000, 0.000000, 1.603125, 1.200000, -0.070313, 1.342188, 1.028320, -0.117773, 1.500000, 1.200000, -0.093750, 1.342188, 1.028320, -0.117773, 1.603125, 1.200000, -0.070313, 1.405029, 1.006165, -0.088330, 1.405029, 1.006165, -0.088330, 1.268750, 0.810938, -0.170625, 1.342188, 1.028320, -0.117773, 1.268750, 0.810938, -0.170625, 1.405029, 1.006165, -0.088330, 1.320313, 0.749707, -0.127969, 1.320313, 0.749707, -0.127969, 1.148438, 0.614648, -0.223477, 1.268750, 0.810938, -0.170625, 1.148438, 0.614648, -0.223477, 1.320313, 0.749707, -0.127969, 1.188721, 0.509509, -0.167607, 1.188721, 0.509509, -0.167607, 0.850000, 0.506250, -0.247500, 1.148438, 0.614648, -0.223477, 0.850000, 0.506250, -0.247500, 1.188721, 0.509509, -0.167607, 0.850000, 0.364453, -0.185625, 1.500000, 1.200000, -0.093750, 1.279346, 1.050476, -0.088330, 1.396875, 1.200000, -0.070313, 1.279346, 1.050476, -0.088330, 1.500000, 1.200000, -0.093750, 1.342188, 1.028320, -0.117773, 1.342188, 1.028320, -0.117773, 1.217188, 0.872168, -0.127969, 1.279346, 1.050476, -0.088330, 1.217188, 0.872168, -0.127969, 1.342188, 1.028320, -0.117773, 1.268750, 0.810938, -0.170625, 1.268750, 0.810938, -0.170625, 1.108154, 0.719788, -0.167607, 1.217188, 0.872168, -0.127969, 1.108154, 0.719788, -0.167607, 1.268750, 0.810938, -0.170625, 1.148438, 0.614648, -0.223477, 1.148438, 0.614648, -0.223477, 0.850000, 0.648047, -0.185625, 1.108154, 0.719788, -0.167607, 0.850000, 0.648047, -0.185625, 1.148438, 0.614648, -0.223477, 0.850000, 0.506250, -0.247500, 1.396875, 1.200000, -0.070313, 1.250781, 1.060547, 0.000000, 1.350000, 1.200000, 0.000000, 1.250781, 1.060547, 0.000000, 1.396875, 1.200000, -0.070313, 1.279346, 1.050476, -0.088330, 1.279346, 1.050476, -0.088330, 1.193750, 0.900000, 0.000000, 1.250781, 1.060547, 0.000000, 1.193750, 0.900000, 0.000000, 1.279346, 1.050476, -0.088330, 1.217188, 0.872168, -0.127969, 1.217188, 0.872168, -0.127969, 1.089844, 0.767578, 0.000000, 1.193750, 0.900000, 0.000000, 1.089844, 0.767578, 0.000000, 1.217188, 0.872168, -0.127969, 1.108154, 0.719788, -0.167607, 1.108154, 0.719788, -0.167607, 0.850000, 0.712500, 0.000000, 1.089844, 0.767578, 0.000000, 0.850000, 0.712500, 0.000000, 1.108154, 0.719788, -0.167607, 0.850000, 0.648047, -0.185625, 1.568750, 1.200000, 0.042188, 1.676367, 1.230322, 0.000000, 1.600000, 1.200000, 0.000000, 1.636359, 1.228880, 0.046582, 1.714063, 1.238672, 0.000000, 1.666943, 1.237024, 0.056250, 1.707227, 1.227686, 0.000000, 1.657025, 1.226656, 0.065918, 1.650000, 1.200000, 0.000000, 1.500000, 1.200000, 0.056250, 1.548340, 1.225708, 0.062109, 1.563281, 1.233398, 0.075000, 1.546582, 1.224390, 0.087891, 1.603125, 1.200000, 0.070313, 1.433594, 0.996094, 0.000000, 1.405029, 1.006165, 0.088330, 1.343750, 0.721875, 0.000000, 1.431250, 1.200000, 0.042188, 1.460321, 1.222536, 0.046582, 1.459619, 1.229773, 0.056250, 1.436139, 1.222124, 0.065918, 1.500000, 1.200000, 0.093750, 1.342188, 1.028320, 0.117773, 1.320313, 0.749707, 0.127969, 1.207031, 0.461719, 0.000000, 1.400000, 1.200000, 0.000000, 1.420313, 1.221094, 0.000000, 1.412500, 1.228125, 0.000000, 1.385937, 1.221094, 0.000000, 1.396875, 1.200000, 0.070313, 1.279346, 1.050476, 0.088330, 1.268750, 0.810938, 0.170625, 1.431250, 1.200000, -0.042188, 1.460321, 1.222536, -0.046582, 1.459619, 1.229773, -0.056250, 1.436139, 1.222124, -0.065918, 1.350000, 1.200000, 0.000000, 1.250781, 1.060547, 0.000000, 1.217188, 0.872168, 0.127969, 1.500000, 1.200000, -0.056250, 1.548340, 1.225708, -0.062109, 1.563281, 1.233398, -0.075000, 1.546582, 1.224390, -0.087891, 1.396875, 1.200000, -0.070313, 1.568750, 1.200000, -0.042188, 1.636359, 1.228880, -0.046582, 1.666943, 1.237024, -0.056250, 1.657025, 1.226656, -0.065918, 1.500000, 1.200000, -0.093750, 1.600000, 1.200000, 0.000000, 1.676367, 1.230322, 0.000000, 1.714063, 1.238672, 0.000000, 1.707227, 1.227686, 0.000000, 1.603125, 1.200000, -0.070313, 1.650000, 1.200000, 0.000000, 1.405029, 1.006165, -0.088330, 1.433594, 0.996094, 0.000000, 1.320313, 0.749707, -0.127969, 1.343750, 0.721875, 0.000000, 1.188721, 0.509509, -0.167607, 1.207031, 0.461719, 0.000000, 1.193750, 0.900000, 0.000000, 1.108154, 0.719788, 0.167607, 1.148438, 0.614648, 0.223477, 1.188721, 0.509509, 0.167607, 0.850000, 0.300000, 0.000000, 1.089844, 0.767578, 0.000000, 0.850000, 0.648047, 0.185625, 0.850000, 0.506250, 0.247500, 0.850000, 0.364453, 0.185625, 0.850000, 0.712500, 0.000000 }; // Indices static const OdInt32 ExTeapotSpoutIndices[128 * 4] = { 3, 0, 1, 2, 3, 3, 4, 5, 3, 6, 7, 8, 3, 9, 10, 11, 3, 12, 13, 14, 3, 15, 16, 17, 3, 18, 19, 20, 3, 21, 22, 23, 3, 24, 25, 26, 3, 27, 28, 29, 3, 30, 31, 32, 3, 33, 34, 35, 3, 36, 37, 38, 3, 39, 40, 41, 3, 42, 43, 44, 3, 45, 46, 47, 3, 48, 49, 50, 3, 51, 52, 53, 3, 54, 55, 56, 3, 57, 58, 59, 3, 60, 61, 62, 3, 63, 64, 65, 3, 66, 67, 68, 3, 69, 70, 71, 3, 72, 73, 74, 3, 75, 76, 77, 3, 78, 79, 80, 3, 79, 78, 81, 3, 81, 82, 79, 3, 82, 81, 83, 3, 83, 84, 82, 3, 84, 83, 85, 3, 85, 86, 84, 3, 87, 81, 78, 3, 81, 87, 88, 3, 88, 83, 81, 3, 83, 88, 89, 3, 89, 85, 83, 3, 85, 89, 90, 3, 90, 91, 85, 3, 86, 85, 91, 3, 91, 92, 86, 3, 92, 91, 93, 3, 93, 94, 92, 3, 95, 88, 87, 3, 88, 95, 96, 3, 96, 89, 88, 3, 89, 96, 97, 3, 97, 90, 89, 3, 90, 97, 98, 3, 98, 99, 90, 3, 91, 90, 99, 3, 99, 93, 91, 3, 93, 99, 100, 3, 100, 101, 93, 3, 94, 93, 101, 3, 101, 102, 94, 3, 103, 96, 95, 3, 96, 103, 104, 3, 104, 97, 96, 3, 97, 104, 105, 3, 105, 98, 97, 3, 98, 105, 106, 3, 106, 107, 98, 3, 99, 98, 107, 3, 107, 100, 99, 3, 100, 107, 108, 3, 108, 109, 100, 3, 101, 100, 109, 3, 110, 104, 103, 3, 104, 110, 111, 3, 111, 105, 104, 3, 105, 111, 112, 3, 112, 106, 105, 3, 106, 112, 113, 3, 113, 114, 106, 3, 107, 106, 114, 3, 114, 108, 107, 3, 108, 114, 115, 3, 115, 116, 108, 3, 109, 108, 116, 3, 117, 111, 110, 3, 111, 117, 118, 3, 118, 112, 111, 3, 112, 118, 119, 3, 119, 113, 112, 3, 113, 119, 120, 3, 120, 121, 113, 3, 114, 113, 121, 3, 122, 118, 117, 3, 118, 122, 123, 3, 123, 119, 118, 3, 119, 123, 124, 3, 124, 120, 119, 3, 120, 124, 125, 3, 125, 126, 120, 3, 121, 120, 126, 3, 127, 123, 122, 3, 123, 127, 128, 3, 128, 124, 123, 3, 124, 128, 129, 3, 129, 125, 124, 3, 125, 129, 130, 3, 130, 131, 125, 3, 126, 125, 131, 3, 131, 130, 132, 3, 132, 133, 131, 3, 133, 132, 134, 3, 134, 135, 133, 3, 135, 134, 136, 3, 136, 137, 135, 3, 137, 136, 138, 3, 116, 115, 139, 3, 139, 140, 116, 3, 141, 116, 140, 3, 116, 141, 109, 3, 142, 109, 141, 3, 109, 142, 101, 3, 102, 101, 142, 3, 142, 143, 102, 3, 140, 139, 144, 3, 144, 145, 140, 3, 146, 140, 145, 3, 140, 146, 141, 3, 147, 141, 146, 3, 141, 147, 142, 3, 143, 142, 147, 3, 145, 144, 148 }; // Normals static const double ExTeapotSpoutNormals[149 * 3] = { 0.626211, -0.779643, -0.004147, 0.356034, -0.756438, -0.548673, 0.557512, -0.632921, -0.537207, 0.356034, -0.756438, -0.548673, 0.626211, -0.779643, -0.004147, 0.410930, -0.911586, -0.012123, 0.548239, -0.536344, -0.641692, 0.026866, 0.175416, -0.984128, 0.076142, 0.091738, -0.992868, 0.026866, 0.175416, -0.984128, 0.548239, -0.536344, -0.641692, 0.686239, -0.341396, -0.642281, 0.686239, -0.341396, -0.642281, 0.232530, 0.131167, -0.963704, 0.026866, 0.175416, -0.984128, 0.232530, 0.131167, -0.963704, 0.686239, -0.341396, -0.642281, 0.822048, -0.288177, -0.491112, 0.822048, -0.288177, -0.491112, 0.213926, -0.012188, -0.976774, 0.232530, 0.131167, -0.963704, 0.213926, -0.012188, -0.976774, 0.822048, -0.288177, -0.491112, 0.557512, -0.632921, -0.537207, 0.557512, -0.632921, -0.537207, 0.117970, -0.104411, -0.987513, 0.213926, -0.012188, -0.976774, 0.117970, -0.104411, -0.987513, 0.557512, -0.632921, -0.537207, 0.356034, -0.756438, -0.548673, 0.076142, 0.091738, -0.992868, -0.666299, 0.452648, -0.592584, -0.430840, 0.471468, -0.769477, -0.666299, 0.452648, -0.592584, 0.076142, 0.091738, -0.992868, 0.026866, 0.175416, -0.984128, 0.026866, 0.175416, -0.984128, -0.656863, 0.491783, -0.571560, -0.666299, 0.452648, -0.592584, -0.656863, 0.491783, -0.571560, 0.026866, 0.175416, -0.984128, 0.232530, 0.131167, -0.963704, 0.232530, 0.131167, -0.963704, -0.310860, 0.703454, -0.639154, -0.656863, 0.491783, -0.571560, -0.310860, 0.703454, -0.639154, 0.232530, 0.131167, -0.963704, 0.213926, -0.012188, -0.976774, 0.213926, -0.012188, -0.976774, -0.161604, 0.712457, -0.682854, -0.310860, 0.703454, -0.639154, -0.161604, 0.712457, -0.682854, 0.213926, -0.012188, -0.976774, 0.117970, -0.104411, -0.987513, -0.430840, 0.471468, -0.769477, -0.879898, 0.475138, -0.004923, -0.765628, 0.643279, -0.002581, -0.879898, 0.475138, -0.004923, -0.430840, 0.471468, -0.769477, -0.666299, 0.452648, -0.592584, -0.666299, 0.452648, -0.592584, -0.871328, 0.490660, 0.006310, -0.879898, 0.475138, -0.004923, -0.871328, 0.490660, 0.006310, -0.666299, 0.452648, -0.592584, -0.656863, 0.491783, -0.571560, -0.656863, 0.491783, -0.571560, -0.480573, 0.876820, 0.015360, -0.871328, 0.490660, 0.006310, -0.480573, 0.876820, 0.015360, -0.656863, 0.491783, -0.571560, -0.310860, 0.703454, -0.639154, -0.310860, 0.703454, -0.639154, -0.231314, 0.972872, 0.003798, -0.480573, 0.876820, 0.015360, -0.231314, 0.972872, 0.003798, -0.310860, 0.703454, -0.639154, -0.161604, 0.712457, -0.682854, -0.256249, 0.705669, -0.660582, -0.283774, 0.958827, 0.011083, -0.371437, 0.928447, 0.004621, -0.267304, 0.900903, -0.341939, 0.296481, 0.955026, -0.004863, 0.149542, 0.965755, 0.212026, 0.568783, -0.822483, -0.002883, 0.478447, -0.609791, 0.631858, 0.634168, -0.773090, 0.012772, 0.121832, -0.001342, -0.992550, -0.081657, 0.626867, -0.774835, -0.016015, 0.989816, 0.141447, 0.074234, 0.332446, 0.940196, 0.538555, -0.566575, 0.623660, 0.850745, -0.525575, 0.001884, 0.702954, -0.330830, 0.629609, 0.920134, -0.391587, -0.003578, 0.528218, -0.565644, -0.633271, 0.333168, 0.166962, -0.927967, -0.067443, 0.992247, 0.104386, -0.272752, 0.768932, 0.578231, 0.090776, 0.041135, 0.995021, 0.054904, 0.151494, 0.986932, 0.827601, -0.293850, 0.478257, 0.626211, -0.779643, -0.004147, 0.708100, -0.704670, -0.045098, 0.921582, -0.385101, -0.048818, -0.136129, 0.990682, 0.004263, -0.449938, 0.893060, -0.000478, -0.404862, 0.488251, 0.773109, -0.648093, 0.437042, 0.623674, 0.252514, 0.126465, 0.959293, 0.542732, -0.555721, 0.629775, 0.377835, 0.126873, 0.917139, -0.070259, 0.992387, -0.101148, -0.274720, 0.771791, -0.573470, -0.765628, 0.643279, -0.002581, -0.879898, 0.475138, -0.004923, -0.642436, 0.483889, 0.594245, 0.120585, 0.010299, 0.992650, -0.069849, 0.629904, 0.773525, -0.023213, 0.988826, -0.147259, 0.056461, 0.375568, -0.925074, -0.430840, 0.471468, -0.769477, -0.249339, 0.684868, 0.684679, -0.259153, 0.900351, 0.349582, 0.131171, 0.967362, -0.216805, 0.483106, -0.561413, -0.671881, 0.076142, 0.091738, -0.992868, -0.371437, 0.928447, 0.004621, -0.283774, 0.958827, 0.011083, 0.296481, 0.955026, -0.004863, 0.568783, -0.822483, -0.002883, 0.548239, -0.536344, -0.641692, 0.634168, -0.773090, 0.012772, 0.686239, -0.341396, -0.642281, 0.850745, -0.525575, 0.001884, 0.822048, -0.288177, -0.491112, 0.920134, -0.391587, -0.003578, 0.557512, -0.632921, -0.537207, 0.626211, -0.779643, -0.004147, -0.871328, 0.490660, 0.006310, -0.295351, 0.693673, 0.656952, 0.214724, -0.021267, 0.976443, 0.557085, -0.639038, 0.530364, 0.410930, -0.911586, -0.012123, -0.480573, 0.876820, 0.015360, -0.143482, 0.713864, 0.685428, 0.127072, -0.113283, 0.985403, 0.356930, -0.767989, 0.531784, -0.231314, 0.972872, 0.003798 }; // Texture coords #ifdef EXTEAPOT_ENABLETEXCOORDS static const double ExTeapotSpoutTexCoords[149 * 2] = { 1.000000, -0.225000, 0.875000, 0.000000, 0.875000, -0.225000, 0.875000, 0.000000, 1.000000, -0.225000, 1.000000, 0.000000, 0.875000, -0.900000, 0.750000, -0.675000, 0.750000, -0.900000, 0.750000, -0.675000, 0.875000, -0.900000, 0.875000, -0.675000, 0.875000, -0.675000, 0.750000, -0.450000, 0.750000, -0.675000, 0.750000, -0.450000, 0.875000, -0.675000, 0.875000, -0.450000, 0.875000, -0.450000, 0.750000, -0.225000, 0.750000, -0.450000, 0.750000, -0.225000, 0.875000, -0.450000, 0.875000, -0.225000, 0.875000, -0.225000, 0.750000, 0.000000, 0.750000, -0.225000, 0.750000, 0.000000, 0.875000, -0.225000, 0.875000, 0.000000, 0.750000, -0.900000, 0.625000, -0.675000, 0.625000, -0.900000, 0.625000, -0.675000, 0.750000, -0.900000, 0.750000, -0.675000, 0.750000, -0.675000, 0.625000, -0.450000, 0.625000, -0.675000, 0.625000, -0.450000, 0.750000, -0.675000, 0.750000, -0.450000, 0.750000, -0.450000, 0.625000, -0.225000, 0.625000, -0.450000, 0.625000, -0.225000, 0.750000, -0.450000, 0.750000, -0.225000, 0.750000, -0.225000, 0.625000, 0.000000, 0.625000, -0.225000, 0.625000, 0.000000, 0.750000, -0.225000, 0.750000, 0.000000, 0.625000, -0.900000, 0.500000, -0.675000, 0.500000, -0.900000, 0.500000, -0.675000, 0.625000, -0.900000, 0.625000, -0.675000, 0.625000, -0.675000, 0.500000, -0.450000, 0.500000, -0.675000, 0.500000, -0.450000, 0.625000, -0.675000, 0.625000, -0.450000, 0.625000, -0.450000, 0.500000, -0.225000, 0.500000, -0.450000, 0.500000, -0.225000, 0.625000, -0.450000, 0.625000, -0.225000, 0.625000, -0.225000, 0.500000, 0.000000, 0.500000, -0.225000, 0.500000, 0.000000, 0.625000, -0.225000, 0.625000, 0.000000, 0.125000, -1.000000, 0.000000, -0.975000, 0.000000, -1.000000, 0.125000, -0.975000, 0.000000, -0.950000, 0.125000, -0.950000, 0.000000, -0.925000, 0.125000, -0.925000, 0.000000, -0.900000, 0.250000, -1.000000, 0.250000, -0.975000, 0.250000, -0.950000, 0.250000, -0.925000, 0.125000, -0.900000, 0.000000, -0.675000, 0.125000, -0.675000, 0.000000, -0.450000, 0.375000, -1.000000, 0.375000, -0.975000, 0.375000, -0.950000, 0.375000, -0.925000, 0.250000, -0.900000, 0.250000, -0.675000, 0.125000, -0.450000, 0.000000, -0.225000, 0.500000, -1.000000, 0.500000, -0.975000, 0.500000, -0.950000, 0.500000, -0.925000, 0.375000, -0.900000, 0.375000, -0.675000, 0.250000, -0.450000, 0.625000, -1.000000, 0.625000, -0.975000, 0.625000, -0.950000, 0.625000, -0.925000, 0.500000, -0.900000, 0.500000, -0.675000, 0.375000, -0.450000, 0.750000, -1.000000, 0.750000, -0.975000, 0.750000, -0.950000, 0.750000, -0.925000, 0.625000, -0.900000, 0.875000, -1.000000, 0.875000, -0.975000, 0.875000, -0.950000, 0.875000, -0.925000, 0.750000, -0.900000, 1.000000, -1.000000, 1.000000, -0.975000, 1.000000, -0.950000, 1.000000, -0.925000, 0.875000, -0.900000, 1.000000, -0.900000, 0.875000, -0.675000, 1.000000, -0.675000, 0.875000, -0.450000, 1.000000, -0.450000, 0.875000, -0.225000, 1.000000, -0.225000, 0.500000, -0.450000, 0.375000, -0.225000, 0.250000, -0.225000, 0.125000, -0.225000, 0.000000, 0.000000, 0.500000, -0.225000, 0.375000, 0.000000, 0.250000, 0.000000, 0.125000, 0.000000, 0.500000, 0.000000 }; #endif // EXTEAPOT_ENABLETEXCOORDS // TeapotLid data // Vertices static const double ExTeapotLidVertices[252 * 3] = { 0.000000, 1.575000, 0.000000, 0.170313, 1.550391, 0.000000, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, 0.157173, 1.550391, 0.067026, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, 0.121080, 1.550391, 0.121080, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, 0.067026, 1.550391, 0.157173, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, 0.000000, 1.550391, 0.170313, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.067026, 1.550391, 0.157173, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.121080, 1.550391, 0.121080, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.157173, 1.550391, 0.067026, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.170313, 1.550391, 0.000000, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.157173, 1.550391, -0.067026, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.121080, 1.550391, -0.121080, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.067026, 1.550391, -0.157173, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, 0.000000, 1.550391, -0.170313, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, 0.067026, 1.550391, -0.157173, 0.000000, 1.575000, 0.000000, 0.071000, 1.350000, -0.071000, 0.090828, 1.416797, -0.038696, 0.092250, 1.350000, -0.039250, 0.090828, 1.416797, -0.038696, 0.071000, 1.350000, -0.071000, 0.069943, 1.416797, -0.069943, 0.069943, 1.416797, -0.069943, 0.149959, 1.490625, -0.063939, 0.090828, 1.416797, -0.038696, 0.149959, 1.490625, -0.063939, 0.069943, 1.416797, -0.069943, 0.115516, 1.490625, -0.115516, 0.115516, 1.490625, -0.115516, 0.157173, 1.550391, -0.067026, 0.149959, 1.490625, -0.063939, 0.157173, 1.550391, -0.067026, 0.115516, 1.490625, -0.115516, 0.121080, 1.550391, -0.121080, 0.121080, 1.550391, -0.121080, 0.000000, 1.575000, 0.000000, 0.157173, 1.550391, -0.067026, 0.000000, 1.575000, 0.000000, 0.121080, 1.550391, -0.121080, 0.000000, 1.575000, 0.000000, 0.092250, 1.350000, -0.039250, 0.098438, 1.416797, 0.000000, 0.100000, 1.350000, 0.000000, 0.098438, 1.416797, 0.000000, 0.092250, 1.350000, -0.039250, 0.090828, 1.416797, -0.038696, 0.090828, 1.416797, -0.038696, 0.162500, 1.490625, 0.000000, 0.098438, 1.416797, 0.000000, 0.162500, 1.490625, 0.000000, 0.090828, 1.416797, -0.038696, 0.149959, 1.490625, -0.063939, 0.149959, 1.490625, -0.063939, 0.170313, 1.550391, 0.000000, 0.162500, 1.490625, 0.000000, 0.170313, 1.550391, 0.000000, 0.149959, 1.490625, -0.063939, 0.157173, 1.550391, -0.067026, 0.157173, 1.550391, -0.067026, 0.000000, 1.575000, 0.000000, 0.170313, 1.550391, 0.000000, 0.000000, 1.575000, 0.000000, 0.157173, 1.550391, -0.067026, 0.000000, 1.575000, 0.000000, 0.092250, 1.350000, 0.039250, 0.228125, 1.305469, 0.000000, 0.100000, 1.350000, 0.000000, 0.210445, 1.305469, 0.089539, 0.412500, 1.275000, 0.000000, 0.380531, 1.275000, 0.161906, 0.578125, 1.244531, 0.000000, 0.533320, 1.244531, 0.226914, 0.650000, 1.200000, 0.000000, 0.599625, 1.200000, 0.255125, 0.071000, 1.350000, 0.071000, 0.161969, 1.305469, 0.161969, 0.292875, 1.275000, 0.292875, 0.410469, 1.244531, 0.410469, 0.461500, 1.200000, 0.461500, 0.226914, 1.244531, 0.533320, 0.255125, 1.200000, 0.599625, 0.039250, 1.350000, 0.092250, 0.089539, 1.305469, 0.210445, 0.161906, 1.275000, 0.380531, 0.000000, 1.275000, 0.412500, 0.000000, 1.244531, 0.578125, 0.000000, 1.200000, 0.650000, -0.226914, 1.244531, 0.533320, -0.255125, 1.200000, 0.599625, 0.000000, 1.350000, 0.100000, 0.000000, 1.305469, 0.228125, -0.089539, 1.305469, 0.210445, -0.161906, 1.275000, 0.380531, -0.292875, 1.275000, 0.292875, -0.410469, 1.244531, 0.410469, -0.461500, 1.200000, 0.461500, -0.039250, 1.350000, 0.092250, -0.071000, 1.350000, 0.071000, -0.161969, 1.305469, 0.161969, -0.210445, 1.305469, 0.089539, -0.380531, 1.275000, 0.161906, -0.533320, 1.244531, 0.226914, -0.599625, 1.200000, 0.255125, -0.578125, 1.244531, 0.000000, -0.650000, 1.200000, 0.000000, -0.092250, 1.350000, 0.039250, -0.100000, 1.350000, 0.000000, -0.228125, 1.305469, 0.000000, -0.412500, 1.275000, 0.000000, -0.092250, 1.350000, -0.039250, -0.228125, 1.305469, 0.000000, -0.100000, 1.350000, 0.000000, -0.210445, 1.305469, -0.089539, -0.412500, 1.275000, 0.000000, -0.380531, 1.275000, -0.161906, -0.578125, 1.244531, 0.000000, -0.533320, 1.244531, -0.226914, -0.650000, 1.200000, 0.000000, -0.599625, 1.200000, -0.255125, -0.071000, 1.350000, -0.071000, -0.161969, 1.305469, -0.161969, -0.292875, 1.275000, -0.292875, -0.410469, 1.244531, -0.410469, -0.461500, 1.200000, -0.461500, -0.226914, 1.244531, -0.533320, -0.255125, 1.200000, -0.599625, -0.039250, 1.350000, -0.092250, -0.089539, 1.305469, -0.210445, -0.161906, 1.275000, -0.380531, 0.000000, 1.275000, -0.412500, 0.000000, 1.244531, -0.578125, 0.000000, 1.200000, -0.650000, 0.226914, 1.244531, -0.533320, 0.255125, 1.200000, -0.599625, 0.000000, 1.350000, -0.100000, 0.000000, 1.305469, -0.228125, 0.089539, 1.305469, -0.210445, 0.161906, 1.275000, -0.380531, 0.292875, 1.275000, -0.292875, 0.410469, 1.244531, -0.410469, 0.461500, 1.200000, -0.461500, 0.039250, 1.350000, -0.092250, 0.071000, 1.350000, -0.071000, 0.161969, 1.305469, -0.161969, 0.210445, 1.305469, -0.089539, 0.380531, 1.275000, -0.161906, 0.533320, 1.244531, -0.226914, 0.599625, 1.200000, -0.255125, 0.578125, 1.244531, 0.000000, 0.650000, 1.200000, 0.000000, 0.092250, 1.350000, -0.039250, 0.100000, 1.350000, 0.000000, 0.228125, 1.305469, 0.000000, 0.412500, 1.275000, 0.000000, 0.170313, 1.550391, 0.000000, 0.000000, 1.575000, 0.000000, 0.157173, 1.550391, 0.067026, 0.162500, 1.490625, 0.000000, 0.149959, 1.490625, 0.063939, 0.098438, 1.416797, 0.000000, 0.090828, 1.416797, 0.038696, 0.100000, 1.350000, 0.000000, 0.092250, 1.350000, 0.039250, 0.069943, 1.416797, 0.069943, 0.071000, 1.350000, 0.071000, 0.121080, 1.550391, 0.121080, 0.115516, 1.490625, 0.115516, 0.063939, 1.490625, 0.149959, 0.038696, 1.416797, 0.090828, 0.039250, 1.350000, 0.092250, 0.000000, 1.416797, 0.098438, 0.000000, 1.350000, 0.100000, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, 0.067026, 1.550391, 0.157173, 0.000000, 1.550391, 0.170313, 0.000000, 1.490625, 0.162500, -0.063939, 1.490625, 0.149959, -0.038696, 1.416797, 0.090828, -0.039250, 1.350000, 0.092250, -0.069943, 1.416797, 0.069943, -0.071000, 1.350000, 0.071000, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.067026, 1.550391, 0.157173, -0.121080, 1.550391, 0.121080, -0.115516, 1.490625, 0.115516, -0.149959, 1.490625, 0.063939, -0.090828, 1.416797, 0.038696, -0.092250, 1.350000, 0.039250, -0.098438, 1.416797, 0.000000, -0.100000, 1.350000, 0.000000, 0.000000, 1.575000, 0.000000, -0.162500, 1.490625, 0.000000, -0.170313, 1.550391, 0.000000, -0.157173, 1.550391, 0.067026, 0.000000, 1.575000, 0.000000, 0.000000, 1.575000, 0.000000, -0.170313, 1.550391, 0.000000, -0.157173, 1.550391, -0.067026, -0.162500, 1.490625, 0.000000, -0.149959, 1.490625, -0.063939, -0.098438, 1.416797, 0.000000, -0.090828, 1.416797, -0.038696, -0.100000, 1.350000, 0.000000, -0.092250, 1.350000, -0.039250, -0.069943, 1.416797, -0.069943, -0.071000, 1.350000, -0.071000, -0.121080, 1.550391, -0.121080, -0.115516, 1.490625, -0.115516, -0.063939, 1.490625, -0.149959, -0.038696, 1.416797, -0.090828, -0.039250, 1.350000, -0.092250, 0.000000, 1.416797, -0.098438, 0.000000, 1.350000, -0.100000, -0.067026, 1.550391, -0.157173, 0.000000, 1.550391, -0.170313, 0.000000, 1.490625, -0.162500, 0.063939, 1.490625, -0.149959, 0.038696, 1.416797, -0.090828, 0.039250, 1.350000, -0.092250, 0.069943, 1.416797, -0.069943, 0.071000, 1.350000, -0.071000, 0.115516, 1.490625, -0.115516, 0.121080, 1.550391, -0.121080, 0.067026, 1.550391, -0.157173 }; // Indices static const OdInt32 ExTeapotLidIndices[256 * 4] = { 3, 0, 1, 2, 3, 3, 4, 5, 3, 6, 7, 8, 3, 9, 10, 11, 3, 12, 13, 14, 3, 15, 16, 17, 3, 18, 19, 20, 3, 21, 22, 23, 3, 24, 25, 26, 3, 27, 28, 29, 3, 30, 31, 32, 3, 33, 34, 35, 3, 36, 37, 38, 3, 39, 40, 41, 3, 42, 43, 44, 3, 45, 46, 47, 3, 48, 49, 50, 3, 51, 52, 53, 3, 54, 55, 56, 3, 57, 58, 59, 3, 60, 61, 62, 3, 63, 64, 65, 3, 66, 67, 68, 3, 69, 70, 71, 3, 72, 73, 74, 3, 75, 76, 77, 3, 78, 79, 80, 3, 81, 82, 83, 3, 84, 85, 86, 3, 87, 88, 89, 3, 90, 91, 92, 3, 91, 90, 93, 3, 93, 94, 91, 3, 94, 93, 95, 3, 95, 96, 94, 3, 96, 95, 97, 3, 97, 98, 96, 3, 98, 97, 99, 3, 100, 93, 90, 3, 93, 100, 101, 3, 101, 95, 93, 3, 95, 101, 102, 3, 102, 97, 95, 3, 97, 102, 103, 3, 103, 99, 97, 3, 99, 103, 104, 3, 105, 104, 103, 3, 104, 105, 106, 3, 107, 101, 100, 3, 101, 107, 108, 3, 108, 102, 101, 3, 102, 108, 109, 3, 109, 103, 102, 3, 103, 109, 105, 3, 110, 105, 109, 3, 105, 110, 111, 3, 111, 106, 105, 3, 106, 111, 112, 3, 113, 112, 111, 3, 112, 113, 114, 3, 115, 108, 107, 3, 108, 115, 116, 3, 116, 109, 108, 3, 109, 116, 110, 3, 117, 110, 116, 3, 110, 117, 118, 3, 118, 111, 110, 3, 111, 118, 113, 3, 119, 113, 118, 3, 113, 119, 120, 3, 120, 114, 113, 3, 114, 120, 121, 3, 122, 116, 115, 3, 116, 122, 117, 3, 123, 117, 122, 3, 117, 123, 124, 3, 124, 118, 117, 3, 118, 124, 119, 3, 125, 119, 124, 3, 119, 125, 126, 3, 126, 120, 119, 3, 120, 126, 127, 3, 127, 121, 120, 3, 121, 127, 128, 3, 129, 128, 127, 3, 128, 129, 130, 3, 131, 124, 123, 3, 124, 131, 125, 3, 132, 125, 131, 3, 125, 132, 133, 3, 133, 126, 125, 3, 126, 133, 134, 3, 134, 127, 126, 3, 127, 134, 129, 3, 135, 136, 137, 3, 136, 135, 138, 3, 138, 139, 136, 3, 139, 138, 140, 3, 140, 141, 139, 3, 141, 140, 142, 3, 142, 143, 141, 3, 143, 142, 144, 3, 145, 138, 135, 3, 138, 145, 146, 3, 146, 140, 138, 3, 140, 146, 147, 3, 147, 142, 140, 3, 142, 147, 148, 3, 148, 144, 142, 3, 144, 148, 149, 3, 150, 149, 148, 3, 149, 150, 151, 3, 152, 146, 145, 3, 146, 152, 153, 3, 153, 147, 146, 3, 147, 153, 154, 3, 154, 148, 147, 3, 148, 154, 150, 3, 155, 150, 154, 3, 150, 155, 156, 3, 156, 151, 150, 3, 151, 156, 157, 3, 158, 157, 156, 3, 157, 158, 159, 3, 160, 153, 152, 3, 153, 160, 161, 3, 161, 154, 153, 3, 154, 161, 155, 3, 162, 155, 161, 3, 155, 162, 163, 3, 163, 156, 155, 3, 156, 163, 158, 3, 164, 158, 163, 3, 158, 164, 165, 3, 165, 159, 158, 3, 159, 165, 166, 3, 167, 161, 160, 3, 161, 167, 162, 3, 168, 162, 167, 3, 162, 168, 169, 3, 169, 163, 162, 3, 163, 169, 164, 3, 170, 164, 169, 3, 164, 170, 171, 3, 171, 165, 164, 3, 165, 171, 172, 3, 172, 166, 165, 3, 166, 172, 173, 3, 174, 173, 172, 3, 173, 174, 175, 3, 176, 169, 168, 3, 169, 176, 170, 3, 177, 170, 176, 3, 170, 177, 178, 3, 178, 171, 170, 3, 171, 178, 179, 3, 179, 172, 171, 3, 172, 179, 174, 3, 180, 181, 182, 3, 182, 183, 180, 3, 183, 182, 184, 3, 184, 185, 183, 3, 185, 184, 186, 3, 186, 187, 185, 3, 187, 186, 188, 3, 189, 188, 186, 3, 188, 189, 190, 3, 191, 184, 182, 3, 184, 191, 192, 3, 192, 186, 184, 3, 186, 192, 189, 3, 193, 189, 192, 3, 189, 193, 194, 3, 194, 190, 189, 3, 190, 194, 195, 3, 196, 195, 194, 3, 195, 196, 197, 3, 182, 198, 191, 3, 191, 199, 200, 3, 200, 192, 191, 3, 192, 200, 193, 3, 201, 193, 200, 3, 193, 201, 202, 3, 202, 194, 193, 3, 194, 202, 196, 3, 203, 196, 202, 3, 196, 203, 204, 3, 204, 197, 196, 3, 197, 204, 205, 3, 206, 205, 204, 3, 205, 206, 207, 3, 200, 208, 201, 3, 201, 209, 210, 3, 210, 202, 201, 3, 202, 210, 203, 3, 211, 203, 210, 3, 203, 211, 212, 3, 212, 204, 203, 3, 204, 212, 206, 3, 213, 206, 212, 3, 206, 213, 214, 3, 214, 207, 206, 3, 207, 214, 215, 3, 216, 215, 214, 3, 215, 216, 217, 3, 210, 218, 211, 3, 214, 219, 216, 3, 219, 214, 213, 3, 213, 220, 219, 3, 220, 213, 221, 3, 221, 222, 220, 3, 212, 221, 213, 3, 221, 212, 211, 3, 211, 223, 221, 3, 224, 181, 225, 3, 225, 226, 224, 3, 226, 225, 227, 3, 227, 228, 226, 3, 228, 227, 229, 3, 229, 230, 228, 3, 230, 229, 231, 3, 232, 231, 229, 3, 231, 232, 233, 3, 234, 227, 225, 3, 227, 234, 235, 3, 235, 229, 227, 3, 229, 235, 232, 3, 236, 232, 235, 3, 232, 236, 237, 3, 237, 233, 232, 3, 233, 237, 238, 3, 239, 238, 237, 3, 238, 239, 240, 3, 225, 198, 234, 3, 234, 199, 241, 3, 241, 235, 234, 3, 235, 241, 236, 3, 242, 236, 241, 3, 236, 242, 243, 3, 243, 237, 236, 3, 237, 243, 239, 3, 244, 239, 243, 3, 239, 244, 245, 3, 245, 240, 239, 3, 240, 245, 246, 3, 247, 246, 245, 3, 246, 247, 248, 3, 241, 208, 242, 3, 245, 249, 247, 3, 249, 245, 244, 3, 244, 250, 249, 3, 250, 244, 251, 3, 251, 218, 250, 3, 243, 251, 244, 3, 251, 243, 242, 3, 242, 209, 251 }; // Normals static const double ExTeapotLidNormals[252 * 3] = { 0.000000, 1.000000, -0.000000, 0.489658, 0.871914, 0.000847, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, 0.452719, 0.872174, 0.185360, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, 0.344719, 0.872647, 0.345912, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, 0.183882, 0.872007, 0.453642, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.000847, 0.871914, 0.489658, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.185360, 0.872174, 0.452719, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.345912, 0.872647, 0.344719, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.453642, 0.872007, 0.183882, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.489658, 0.871914, -0.000847, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.452719, 0.872174, -0.185360, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.344719, 0.872647, -0.345912, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.183882, 0.872007, -0.453642, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, 0.000847, 0.871914, -0.489658, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, 0.185360, 0.872174, -0.452719, 0.000000, 1.000000, -0.000000, 0.404687, 0.812671, -0.419279, 0.836436, -0.438606, -0.328633, 0.536595, 0.811852, -0.230135, 0.836436, -0.438606, -0.328633, 0.404687, 0.812671, -0.419279, 0.642806, -0.438423, -0.628160, 0.642806, -0.438423, -0.628160, 0.827200, -0.454224, -0.330788, 0.836436, -0.438606, -0.328633, 0.827200, -0.454224, -0.330788, 0.642806, -0.438423, -0.628160, 0.633568, -0.455198, -0.625609, 0.633568, -0.455198, -0.625609, 0.453642, 0.872007, -0.183882, 0.827200, -0.454224, -0.330788, 0.453642, 0.872007, -0.183882, 0.633568, -0.455198, -0.625609, 0.345912, 0.872647, -0.344719, 0.345912, 0.872647, -0.344719, 0.000000, 1.000000, -0.000000, 0.453642, 0.872007, -0.183882, 0.000000, 1.000000, -0.000000, 0.345912, 0.872647, -0.344719, 0.000000, 1.000000, -0.000000, 0.536595, 0.811852, -0.230135, 0.899515, -0.436764, 0.010523, 0.582610, 0.812681, -0.010740, 0.899515, -0.436764, 0.010523, 0.536595, 0.811852, -0.230135, 0.836436, -0.438606, -0.328633, 0.836436, -0.438606, -0.328633, 0.891518, -0.452949, 0.005752, 0.899515, -0.436764, 0.010523, 0.891518, -0.452949, 0.005752, 0.836436, -0.438606, -0.328633, 0.827200, -0.454224, -0.330788, 0.827200, -0.454224, -0.330788, 0.489658, 0.871914, 0.000847, 0.891518, -0.452949, 0.005752, 0.489658, 0.871914, 0.000847, 0.827200, -0.454224, -0.330788, 0.453642, 0.872007, -0.183882, 0.453642, 0.872007, -0.183882, 0.000000, 1.000000, -0.000000, 0.489658, 0.871914, 0.000847, 0.000000, 1.000000, -0.000000, 0.453642, 0.872007, -0.183882, 0.000000, 1.000000, -0.000000, 0.541783, 0.814041, 0.209303, 0.215445, 0.976505, -0.004631, 0.582610, 0.812681, -0.010740, 0.200657, 0.976631, 0.077004, 0.173435, 0.984840, -0.003223, 0.161453, 0.984902, 0.062462, 0.330580, 0.943771, -0.003731, 0.306956, 0.943963, 0.121294, 0.526667, 0.850059, -0.004604, 0.488250, 0.850606, 0.195145, 0.419279, 0.812671, 0.404687, 0.155096, 0.976631, 0.148784, 0.124346, 0.984965, 0.119929, 0.235371, 0.944249, 0.230204, 0.374522, 0.851020, 0.368100, 0.128206, 0.943962, 0.304137, 0.203663, 0.850660, 0.484663, 0.230135, 0.811852, 0.536595, 0.085586, 0.976587, 0.197367, 0.068360, 0.984920, 0.158930, 0.003223, 0.984840, 0.173435, 0.003731, 0.943771, 0.330580, 0.004604, 0.850059, 0.526667, -0.121294, 0.943963, 0.306956, -0.195145, 0.850606, 0.488250, 0.010740, 0.812681, 0.582610, 0.004631, 0.976505, 0.215445, -0.077004, 0.976631, 0.200657, -0.062462, 0.984902, 0.161453, -0.119929, 0.984965, 0.124346, -0.230204, 0.944249, 0.235371, -0.368100, 0.851020, 0.374522, -0.209303, 0.814041, 0.541783, -0.404687, 0.812671, 0.419279, -0.148784, 0.976631, 0.155096, -0.197367, 0.976587, 0.085586, -0.158930, 0.984920, 0.068360, -0.304137, 0.943962, 0.128206, -0.484663, 0.850660, 0.203663, -0.330580, 0.943771, 0.003731, -0.526667, 0.850059, 0.004604, -0.536595, 0.811852, 0.230135, -0.582610, 0.812681, 0.010740, -0.215445, 0.976505, 0.004631, -0.173435, 0.984840, 0.003223, -0.541783, 0.814041, -0.209303, -0.215445, 0.976505, 0.004631, -0.582610, 0.812681, 0.010740, -0.200657, 0.976631, -0.077004, -0.173435, 0.984840, 0.003223, -0.161453, 0.984902, -0.062462, -0.330580, 0.943771, 0.003731, -0.306956, 0.943963, -0.121294, -0.526667, 0.850059, 0.004604, -0.488250, 0.850606, -0.195145, -0.419279, 0.812671, -0.404687, -0.155096, 0.976631, -0.148784, -0.124346, 0.984965, -0.119929, -0.235371, 0.944249, -0.230204, -0.374522, 0.851020, -0.368100, -0.128206, 0.943962, -0.304137, -0.203663, 0.850660, -0.484663, -0.230135, 0.811852, -0.536595, -0.085586, 0.976587, -0.197367, -0.068360, 0.984920, -0.158930, -0.003223, 0.984840, -0.173435, -0.003731, 0.943771, -0.330580, -0.004604, 0.850059, -0.526667, 0.121294, 0.943963, -0.306956, 0.195145, 0.850606, -0.488250, -0.010740, 0.812681, -0.582610, -0.004631, 0.976505, -0.215445, 0.077004, 0.976631, -0.200657, 0.062462, 0.984902, -0.161453, 0.119929, 0.984965, -0.124346, 0.230204, 0.944249, -0.235371, 0.368100, 0.851020, -0.374522, 0.209303, 0.814041, -0.541783, 0.404687, 0.812671, -0.419279, 0.148784, 0.976631, -0.155096, 0.197367, 0.976587, -0.085586, 0.158930, 0.984920, -0.068360, 0.304137, 0.943962, -0.128206, 0.484663, 0.850660, -0.203663, 0.330580, 0.943771, -0.003731, 0.526667, 0.850059, -0.004604, 0.536595, 0.811852, -0.230135, 0.582610, 0.812681, -0.010740, 0.215445, 0.976505, -0.004631, 0.173435, 0.984840, -0.003223, 0.489658, 0.871914, 0.000847, 0.000000, 1.000000, -0.000000, 0.452719, 0.872174, 0.185360, 0.891518, -0.452949, 0.005752, 0.823029, -0.453842, 0.341541, 0.899515, -0.436764, 0.010523, 0.829099, -0.437190, 0.348512, 0.582610, 0.812681, -0.010740, 0.541783, 0.814041, 0.209303, 0.628160, -0.438423, 0.642806, 0.419279, 0.812671, 0.404687, 0.344719, 0.872647, 0.345912, 0.625609, -0.455198, 0.633568, 0.330788, -0.454224, 0.827200, 0.328633, -0.438606, 0.836436, 0.230135, 0.811852, 0.536595, -0.010523, -0.436764, 0.899515, 0.010740, 0.812681, 0.582610, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, 0.183882, 0.872007, 0.453642, -0.000847, 0.871914, 0.489658, -0.005752, -0.452949, 0.891518, -0.341541, -0.453842, 0.823029, -0.348512, -0.437190, 0.829099, -0.209303, 0.814041, 0.541783, -0.642806, -0.438423, 0.628160, -0.404687, 0.812671, 0.419279, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.185360, 0.872174, 0.452719, -0.345912, 0.872647, 0.344719, -0.633568, -0.455198, 0.625609, -0.827200, -0.454224, 0.330788, -0.836436, -0.438606, 0.328633, -0.536595, 0.811852, 0.230135, -0.899515, -0.436764, -0.010523, -0.582610, 0.812681, 0.010740, 0.000000, 1.000000, -0.000000, -0.891518, -0.452949, -0.005752, -0.489658, 0.871914, -0.000847, -0.453642, 0.872007, 0.183882, 0.000000, 1.000000, -0.000000, 0.000000, 1.000000, -0.000000, -0.489658, 0.871914, -0.000847, -0.452719, 0.872174, -0.185360, -0.891518, -0.452949, -0.005752, -0.823029, -0.453842, -0.341541, -0.899515, -0.436764, -0.010523, -0.829099, -0.437190, -0.348512, -0.582610, 0.812681, 0.010740, -0.541783, 0.814041, -0.209303, -0.628160, -0.438423, -0.642806, -0.419279, 0.812671, -0.404687, -0.344719, 0.872647, -0.345912, -0.625609, -0.455198, -0.633568, -0.330788, -0.454224, -0.827200, -0.328633, -0.438606, -0.836436, -0.230135, 0.811852, -0.536595, 0.010523, -0.436764, -0.899515, -0.010740, 0.812681, -0.582610, -0.183882, 0.872007, -0.453642, 0.000847, 0.871914, -0.489658, 0.005752, -0.452949, -0.891518, 0.341541, -0.453842, -0.823029, 0.348512, -0.437190, -0.829099, 0.209303, 0.814041, -0.541783, 0.642806, -0.438423, -0.628160, 0.404687, 0.812671, -0.419279, 0.633568, -0.455198, -0.625609, 0.345912, 0.872647, -0.344719, 0.185360, 0.872174, -0.452719 }; // Texture coords #ifdef EXTEAPOT_ENABLETEXCOORDS static const double ExTeapotLidTexCoords[252 * 2] = { 0.125000, -1.000000, 0.000000, -0.750000, 0.000000, -1.000000, 0.250000, -1.000000, 0.125000, -0.750000, 0.125000, -1.000000, 0.375000, -1.000000, 0.250000, -0.750000, 0.250000, -1.000000, 0.500000, -1.000000, 0.375000, -0.750000, 0.375000, -1.000000, 0.625000, -1.000000, 0.500000, -0.750000, 0.500000, -1.000000, 0.750000, -1.000000, 0.625000, -0.750000, 0.625000, -1.000000, 0.875000, -1.000000, 0.750000, -0.750000, 0.750000, -1.000000, 1.000000, -1.000000, 0.875000, -0.750000, 0.875000, -1.000000, 0.125000, -1.000000, 0.000000, -0.750000, 0.000000, -1.000000, 0.250000, -1.000000, 0.125000, -0.750000, 0.125000, -1.000000, 0.375000, -1.000000, 0.250000, -0.750000, 0.250000, -1.000000, 0.500000, -1.000000, 0.375000, -0.750000, 0.375000, -1.000000, 0.625000, -1.000000, 0.500000, -0.750000, 0.500000, -1.000000, 0.750000, -1.000000, 0.625000, -0.750000, 0.625000, -1.000000, 0.750000, 0.000000, 0.875000, -0.250000, 0.875000, 0.000000, 0.875000, -0.250000, 0.750000, 0.000000, 0.750000, -0.250000, 0.750000, -0.250000, 0.875000, -0.500000, 0.875000, -0.250000, 0.875000, -0.500000, 0.750000, -0.250000, 0.750000, -0.500000, 0.750000, -0.500000, 0.875000, -0.750000, 0.875000, -0.500000, 0.875000, -0.750000, 0.750000, -0.500000, 0.750000, -0.750000, 0.750000, -0.750000, 0.875000, -1.000000, 0.875000, -0.750000, 0.875000, -1.000000, 0.750000, -0.750000, 0.750000, -1.000000, 0.875000, 0.000000, 1.000000, -0.250000, 1.000000, 0.000000, 1.000000, -0.250000, 0.875000, 0.000000, 0.875000, -0.250000, 0.875000, -0.250000, 1.000000, -0.500000, 1.000000, -0.250000, 1.000000, -0.500000, 0.875000, -0.250000, 0.875000, -0.500000, 0.875000, -0.500000, 1.000000, -0.750000, 1.000000, -0.500000, 1.000000, -0.750000, 0.875000, -0.500000, 0.875000, -0.750000, 0.875000, -0.750000, 1.000000, -1.000000, 1.000000, -0.750000, 1.000000, -1.000000, 0.875000, -0.750000, 0.875000, -1.000000, 0.125000, -1.000000, 0.000000, -0.750000, 0.000000, -1.000000, 0.125000, -0.750000, 0.000000, -0.500000, 0.125000, -0.500000, 0.000000, -0.250000, 0.125000, -0.250000, 0.000000, 0.000000, 0.125000, 0.000000, 0.250000, -1.000000, 0.250000, -0.750000, 0.250000, -0.500000, 0.250000, -0.250000, 0.250000, 0.000000, 0.375000, -0.250000, 0.375000, 0.000000, 0.375000, -1.000000, 0.375000, -0.750000, 0.375000, -0.500000, 0.500000, -0.500000, 0.500000, -0.250000, 0.500000, 0.000000, 0.625000, -0.250000, 0.625000, 0.000000, 0.500000, -1.000000, 0.500000, -0.750000, 0.625000, -0.750000, 0.625000, -0.500000, 0.750000, -0.500000, 0.750000, -0.250000, 0.750000, 0.000000, 0.625000, -1.000000, 0.750000, -1.000000, 0.750000, -0.750000, 0.875000, -0.750000, 0.875000, -0.500000, 0.875000, -0.250000, 0.875000, 0.000000, 1.000000, -0.250000, 1.000000, 0.000000, 0.875000, -1.000000, 1.000000, -1.000000, 1.000000, -0.750000, 1.000000, -0.500000, 0.125000, -1.000000, 0.000000, -0.750000, 0.000000, -1.000000, 0.125000, -0.750000, 0.000000, -0.500000, 0.125000, -0.500000, 0.000000, -0.250000, 0.125000, -0.250000, 0.000000, 0.000000, 0.125000, 0.000000, 0.250000, -1.000000, 0.250000, -0.750000, 0.250000, -0.500000, 0.250000, -0.250000, 0.250000, 0.000000, 0.375000, -0.250000, 0.375000, 0.000000, 0.375000, -1.000000, 0.375000, -0.750000, 0.375000, -0.500000, 0.500000, -0.500000, 0.500000, -0.250000, 0.500000, 0.000000, 0.625000, -0.250000, 0.625000, 0.000000, 0.500000, -1.000000, 0.500000, -0.750000, 0.625000, -0.750000, 0.625000, -0.500000, 0.750000, -0.500000, 0.750000, -0.250000, 0.750000, 0.000000, 0.625000, -1.000000, 0.750000, -1.000000, 0.750000, -0.750000, 0.875000, -0.750000, 0.875000, -0.500000, 0.875000, -0.250000, 0.875000, 0.000000, 1.000000, -0.250000, 1.000000, 0.000000, 0.875000, -1.000000, 1.000000, -1.000000, 1.000000, -0.750000, 1.000000, -0.500000, 0.000000, -0.750000, 0.125000, -1.000000, 0.125000, -0.750000, 0.000000, -0.500000, 0.125000, -0.500000, 0.000000, -0.250000, 0.125000, -0.250000, 0.000000, 0.000000, 0.125000, 0.000000, 0.250000, -0.250000, 0.250000, 0.000000, 0.250000, -0.750000, 0.250000, -0.500000, 0.375000, -0.500000, 0.375000, -0.250000, 0.375000, 0.000000, 0.500000, -0.250000, 0.500000, 0.000000, 0.250000, -1.000000, 0.375000, -1.000000, 0.375000, -0.750000, 0.500000, -0.750000, 0.500000, -0.500000, 0.625000, -0.500000, 0.625000, -0.250000, 0.625000, 0.000000, 0.750000, -0.250000, 0.750000, 0.000000, 0.500000, -1.000000, 0.625000, -1.000000, 0.625000, -0.750000, 0.750000, -0.750000, 0.750000, -0.500000, 0.875000, -0.500000, 0.875000, -0.250000, 0.875000, 0.000000, 1.000000, -0.250000, 1.000000, 0.000000, 0.750000, -1.000000, 1.000000, -0.500000, 1.000000, -0.750000, 0.875000, -0.750000, 1.000000, -1.000000, 0.875000, -1.000000, 0.000000, -0.750000, 0.125000, -0.750000, 0.000000, -0.500000, 0.125000, -0.500000, 0.000000, -0.250000, 0.125000, -0.250000, 0.000000, 0.000000, 0.125000, 0.000000, 0.250000, -0.250000, 0.250000, 0.000000, 0.250000, -0.750000, 0.250000, -0.500000, 0.375000, -0.500000, 0.375000, -0.250000, 0.375000, 0.000000, 0.500000, -0.250000, 0.500000, 0.000000, 0.375000, -0.750000, 0.500000, -0.750000, 0.500000, -0.500000, 0.625000, -0.500000, 0.625000, -0.250000, 0.625000, 0.000000, 0.750000, -0.250000, 0.750000, 0.000000, 0.750000, -0.500000, 0.750000, -0.750000, 0.625000, -0.750000 }; #endif // EXTEAPOT_ENABLETEXCOORDS class ExTeapot : public OdDbEntity { static const int lastKnownVersion; OdGePoint3d m_position; bool m_bDrawBody; bool m_bDrawHandle; bool m_bDrawSpout; bool m_bDrawLid; bool m_bDrawTexCoords; bool m_bInvertTexCoords; OdGeScale3d m_scale; OdGeVector3d m_rotate; public: ODDB_DECLARE_MEMBERS(ExTeapot); ExTeapot() : m_bDrawBody(true) , m_bDrawHandle(true) , m_bDrawSpout(true) , m_bDrawLid(true) , m_bDrawTexCoords(true) , m_bInvertTexCoords(true) { } ~ExTeapot() { } static int getVersion() { return lastKnownVersion; } OdGePoint3d position() const { assertReadEnabled(); return m_position; } void setPosition(const OdGePoint3d pos) { assertWriteEnabled(); m_position = pos; } bool drawBody() const { assertReadEnabled(); return m_bDrawBody; } void setDrawBody(bool bDraw) { assertWriteEnabled(); m_bDrawBody = bDraw; } bool drawHandle() const { assertReadEnabled(); return m_bDrawHandle; } void setDrawHandle(bool bDraw) { assertWriteEnabled(); m_bDrawHandle = bDraw; } bool drawSpout() const { assertReadEnabled(); return m_bDrawSpout; } void setDrawSpout(bool bDraw) { assertWriteEnabled(); m_bDrawSpout = bDraw; } bool drawLid() const { assertReadEnabled(); return m_bDrawLid; } void setDrawLid(bool bDraw) { assertWriteEnabled(); m_bDrawLid = bDraw; } bool drawTexCoords() const { assertReadEnabled(); return m_bDrawTexCoords; } void setDrawTexCoords(bool bDraw) { assertWriteEnabled(); m_bDrawTexCoords = bDraw; } bool invertTexCoords() const { assertReadEnabled(); return m_bInvertTexCoords; } void setInvertTexCoords(bool bInv) { assertWriteEnabled(); m_bInvertTexCoords = bInv; } OdGeScale3d scale() const { assertReadEnabled(); return m_scale; } void setScale(const OdGeScale3d scale) { assertWriteEnabled(); m_scale = scale; } OdGeVector3d rotate() const { assertReadEnabled(); return m_rotate; } void setRotate(const OdGeVector3d &rot) { assertWriteEnabled(); m_rotate = rot; } OdGeMatrix3d getTransform() const { assertReadEnabled(); return OdGeMatrix3d::translation(m_position.asVector()) * OdGeMatrix3d::rotation(m_rotate.x, OdGeVector3d::kXAxis) * OdGeMatrix3d::rotation(m_rotate.y, OdGeVector3d::kYAxis) * OdGeMatrix3d::rotation(m_rotate.z, OdGeVector3d::kZAxis) * OdGeMatrix3d::scaling(m_scale); } void setTransform(const OdGeMatrix3d &tm) { assertWriteEnabled(); OdGeVector3d xAxis, yAxis, zAxis; OdGePoint3d origin; tm.getCoordSystem(origin, xAxis, yAxis, zAxis); m_position = origin; m_scale.set(xAxis.normalizeGetLength(), yAxis.normalizeGetLength(), zAxis.normalizeGetLength()); m_rotate.set(OD_ATAN2(yAxis.z, zAxis.z), -OD_ASIN(xAxis.z), OD_ATAN2(xAxis.y, xAxis.x)); } OdResult subTransformBy(const OdGeMatrix3d& xform) { setTransform(xform * getTransform()); return eOk; } void makeCompatibleCoords(OdUInt32 numCoords, const double *pInCoords, OdGePoint3dArray &outCoords) const { outCoords.resize(numCoords); OdGePoint3d *pOut = outCoords.asArrayPtr(); if (m_bInvertTexCoords) { for (OdUInt32 nCoord = 0; nCoord < numCoords; nCoord++, pInCoords += 2, pOut++) pOut->set(pInCoords[0], 1.0 - pInCoords[1], 0.0); } else { for (OdUInt32 nCoord = 0; nCoord < numCoords; nCoord++, pInCoords += 2, pOut++) pOut->set(pInCoords[0], pInCoords[1], 0.0); } } bool subWorldDraw(OdGiWorldDraw* pWd) const { if (!m_bDrawBody && !m_bDrawHandle && !m_bDrawSpout && !m_bDrawLid) return true; OdGeMatrix3d tx = getTransform() * OdGeMatrix3d::rotation(OdaToRadian(90.0), OdGeVector3d::kXAxis) * OdGeMatrix3d::rotation(OdaToRadian(90.0), OdGeVector3d::kYAxis); pWd->geometry().pushModelTransform(tx); if (m_bDrawBody) { OdGiVertexData vData; vData.setNormals((const OdGeVector3d*)ExTeapotBodyNormals); #ifdef EXTEAPOT_ENABLETEXCOORDS OdGePoint3dArray mapCoords; if (m_bDrawTexCoords) { makeCompatibleCoords(sizeof(ExTeapotBodyTexCoords) / sizeof(double) / 2, ExTeapotBodyTexCoords, mapCoords); vData.setMappingCoords(OdGiVertexData::kAllChannels, mapCoords.getPtr()); } #endif pWd->geometry().shell(sizeof(ExTeapotBodyVertices) / sizeof(double) / 3, (const OdGePoint3d*)ExTeapotBodyVertices, sizeof(ExTeapotBodyIndices) / sizeof(OdInt32), ExTeapotBodyIndices, 0, 0, &vData); } if (m_bDrawHandle) { OdGiVertexData vData; vData.setNormals((const OdGeVector3d*)ExTeapotHandleNormals); #ifdef EXTEAPOT_ENABLETEXCOORDS OdGePoint3dArray mapCoords; if (m_bDrawTexCoords) { makeCompatibleCoords(sizeof(ExTeapotHandleTexCoords) / sizeof(double) / 2, ExTeapotHandleTexCoords, mapCoords); vData.setMappingCoords(OdGiVertexData::kAllChannels, mapCoords.getPtr()); } #endif pWd->geometry().shell(sizeof(ExTeapotHandleVertices) / sizeof(double) / 3, (const OdGePoint3d*)ExTeapotHandleVertices, sizeof(ExTeapotHandleIndices) / sizeof(OdInt32), ExTeapotHandleIndices, 0, 0, &vData); } if (m_bDrawSpout) { OdGiVertexData vData; vData.setNormals((const OdGeVector3d*)ExTeapotSpoutNormals); #ifdef EXTEAPOT_ENABLETEXCOORDS OdGePoint3dArray mapCoords; if (m_bDrawTexCoords) { makeCompatibleCoords(sizeof(ExTeapotSpoutTexCoords) / sizeof(double) / 2, ExTeapotSpoutTexCoords, mapCoords); vData.setMappingCoords(OdGiVertexData::kAllChannels, mapCoords.getPtr()); } #endif pWd->geometry().shell(sizeof(ExTeapotSpoutVertices) / sizeof(double) / 3, (const OdGePoint3d*)ExTeapotSpoutVertices, sizeof(ExTeapotSpoutIndices) / sizeof(OdInt32), ExTeapotSpoutIndices, 0, 0, &vData); } if (m_bDrawLid) { OdGiVertexData vData; vData.setNormals((const OdGeVector3d*)ExTeapotLidNormals); #ifdef EXTEAPOT_ENABLETEXCOORDS OdGePoint3dArray mapCoords; if (m_bDrawTexCoords) { makeCompatibleCoords(sizeof(ExTeapotLidTexCoords) / sizeof(double) / 2, ExTeapotLidTexCoords, mapCoords); vData.setMappingCoords(OdGiVertexData::kAllChannels, mapCoords.getPtr()); } #endif pWd->geometry().shell(sizeof(ExTeapotLidVertices) / sizeof(double) / 3, (const OdGePoint3d*)ExTeapotLidVertices, sizeof(ExTeapotLidIndices) / sizeof(OdInt32), ExTeapotLidIndices, 0, 0, &vData); } pWd->geometry().popModelTransform(); return true; } OdResult dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbEntity::dwgInFields(pFiler); if (res != eOk) return res; int nVersion = pFiler->rdInt16(); if (nVersion > getVersion()) return eMakeMeProxy; m_position = pFiler->rdPoint3d(); m_bDrawBody = pFiler->rdBool(); m_bDrawHandle = pFiler->rdBool(); m_bDrawSpout = pFiler->rdBool(); m_bDrawLid = pFiler->rdBool(); m_bDrawTexCoords = pFiler->rdBool(); m_bInvertTexCoords = pFiler->rdBool(); m_scale = pFiler->rdScale3d(); m_rotate = pFiler->rdVector3d(); return eOk; } void dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbEntity::dwgOutFields(pFiler); pFiler->wrInt16((OdInt16)getVersion()); pFiler->wrPoint3d(m_position); pFiler->wrBool(m_bDrawBody); pFiler->wrBool(m_bDrawHandle); pFiler->wrBool(m_bDrawSpout); pFiler->wrBool(m_bDrawLid); pFiler->wrBool(m_bDrawTexCoords); pFiler->wrBool(m_bInvertTexCoords); pFiler->wrScale3d(m_scale); pFiler->wrVector3d(m_rotate); } OdResult dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbEntity::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(desc()->name())) return eBadDxfSequence; int nVersion = pFiler->nextRb()->getInt16(); if (nVersion > getVersion()) return eMakeMeProxy; m_position = pFiler->nextRb()->getPoint3d(); m_bDrawBody = pFiler->nextRb()->getBool(); m_bDrawHandle = pFiler->nextRb()->getBool(); m_bDrawSpout = pFiler->nextRb()->getBool(); m_bDrawLid = pFiler->nextRb()->getBool(); m_bDrawTexCoords = pFiler->nextRb()->getBool(); m_bInvertTexCoords = pFiler->nextRb()->getBool(); m_scale.sx = pFiler->nextRb()->getDouble(); m_scale.sy = pFiler->nextRb()->getDouble(); m_scale.sz = pFiler->nextRb()->getDouble(); m_rotate.x = (pFiler->nextRb(), pFiler->rdAngle()); m_rotate.y = (pFiler->nextRb(), pFiler->rdAngle()); m_rotate.z = (pFiler->nextRb(), pFiler->rdAngle()); return eOk; } void dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbEntity::dxfOutFields(pFiler); pFiler->wrSubclassMarker(desc()->name()); pFiler->wrInt16(70, (OdInt16)getVersion()); pFiler->wrPoint3d(10, m_position); pFiler->wrBool(290, m_bDrawBody); pFiler->wrBool(291, m_bDrawHandle); pFiler->wrBool(292, m_bDrawSpout); pFiler->wrBool(293, m_bDrawLid); pFiler->wrBool(294, m_bDrawTexCoords); pFiler->wrBool(295, m_bInvertTexCoords); pFiler->wrDouble(40, m_scale.sx); pFiler->wrDouble(41, m_scale.sy); pFiler->wrDouble(42, m_scale.sz); pFiler->wrAngle(50, m_rotate.x); pFiler->wrAngle(51, m_rotate.y); pFiler->wrAngle(53, m_rotate.z); } }; const int ExTeapot::lastKnownVersion = 1; ODRX_DXF_DEFINE_MEMBERS(ExTeapot, OdDbEntity, DBOBJECT_CONSTR, OdDb::vAC24, OdDb::kMRelease0, OdDbProxyEntity::kAllAllowedBits, ExTeapot, OdaMfcApp|Description: Teigha Run-time Extension Example) class OdExTeapotCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExTeapot"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdDbBlockTableRecordPtr pBTR = pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite); OdSmartPtr pTeapot = ExTeapot::createObject(); pTeapot->setDatabaseDefaults(pDb); pTeapot->setPosition(pIO->getPoint(OD_T("\nSpecify center of teapot: "))); pTeapot->setScale(OdGeScale3d(pIO->getDist(OD_T("\nSpecify scale of teapot: ")))); pTeapot->setRotate(OdGeVector3d(0.0, 0.0, pIO->getAngle(OD_T("\nSpecify rotation angle around z-axis: ")))); pBTR->appendOdDbEntity(pTeapot); } }; static OdStaticRxObject g_OdExTeapotCmd; #ifdef _DEBUG // This is test for DGN-specific functionality (bug #7074) #include "Ge/GeEllipArc3d.h" class ExDgnSpecTObj : public OdDbEntity { public: enum Type { kTypeCircle = 0, kTypeEllipseSector, kTypeEllipseChord, kTypeEllipseSimple, kTypeCircArcSector, kTypeCircArcChord, kTypeCircArcSimple, kTypeEllipArcSector, kTypeEllipArcChord, kTypeEllipArcSimple, kTypePolygon, kTypeShell }; private: static const int lastKnownVersion; OdGePoint3d m_position; double m_radius; Type m_type; bool m_fillAlways; bool m_cFill; public: ODDB_DECLARE_MEMBERS(ExDgnSpecTObj); ExDgnSpecTObj() : m_radius(1.0) , m_type(kTypeCircle) , m_fillAlways(false) , m_cFill(false) { } ~ExDgnSpecTObj() { } static int getVersion() { return lastKnownVersion; } OdGePoint3d position() const { assertReadEnabled(); return m_position; } void setPosition(const OdGePoint3d pos) { assertWriteEnabled(); m_position = pos; } double radius() const { assertReadEnabled(); return m_radius; } void setRadius(double rad) { assertWriteEnabled(); m_radius = rad; } Type type() const { assertReadEnabled(); return m_type; } void setType(Type type) { assertWriteEnabled(); m_type = type; } bool fillAlways() const { assertReadEnabled(); return m_fillAlways; } void setFillAlways(bool fill) { assertWriteEnabled(); m_fillAlways = fill; } bool contourFill() const { assertReadEnabled(); return m_cFill; } void setContourFill(bool fill) { assertWriteEnabled(); m_cFill = fill; } OdResult subTransformBy(const OdGeMatrix3d& xform) { m_position.transformBy(xform); m_radius *= odmax(OdGeScale3d().extractScale(xform).sx, odmax(OdGeScale3d().extractScale(xform).sy, OdGeScale3d().extractScale(xform).sz)); return eOk; } bool subWorldDraw(OdGiWorldDraw* pWd) const { const double startAng = OdaToRadian(184.0), endAng = OdaToRadian(281.0); pWd->subEntityTraits().setFillType((m_fillAlways) ? kOdGiFillAlways : kOdGiFillNever); if (m_cFill) { pWd->subEntityTraits().setDrawFlags(OdGiSubEntityTraits::kDrawContourFill); pWd->subEntityTraits().setSecondaryTrueColor(OdCmEntityColor(0, 255, 0)); } switch (m_type) { case kTypeCircle: pWd->geometry().circle(m_position, m_radius, OdGeVector3d::kZAxis); break; case kTypeEllipseSector: pWd->geometry().ellipArc(OdGeEllipArc3d(m_position, OdGeVector3d(0.5, 0.5, 0.0).normal(), OdGeVector3d(-0.5, 0.5, 0.0).normal(), m_radius * 1.5, m_radius * 0.5), 0, kOdGiArcSector); break; case kTypeEllipseChord: pWd->geometry().ellipArc(OdGeEllipArc3d(m_position, OdGeVector3d(0.5, 0.5, 0.0).normal(), OdGeVector3d(-0.5, 0.5, 0.0).normal(), m_radius * 1.5, m_radius * 0.5), 0, kOdGiArcChord); break; case kTypeEllipseSimple: pWd->geometry().ellipArc(OdGeEllipArc3d(m_position, OdGeVector3d(0.5, 0.5, 0.0).normal(), OdGeVector3d(-0.5, 0.5, 0.0).normal(), m_radius * 1.5, m_radius * 0.5), 0, kOdGiArcSimple); break; case kTypeCircArcSector: pWd->geometry().circularArc(m_position, m_radius, OdGeVector3d::kZAxis, OdGeVector3d::kYAxis, endAng - startAng, kOdGiArcSector); break; case kTypeCircArcChord: pWd->geometry().circularArc(m_position, m_radius, OdGeVector3d::kZAxis, OdGeVector3d::kYAxis, endAng - startAng, kOdGiArcChord); break; case kTypeCircArcSimple: pWd->geometry().circularArc(m_position, m_radius, OdGeVector3d::kZAxis, OdGeVector3d::kYAxis, endAng - startAng, kOdGiArcSimple); break; case kTypeEllipArcSector: pWd->geometry().ellipArc(OdGeEllipArc3d(m_position, OdGeVector3d(0.5, 0.5, 0.0).normal(), OdGeVector3d(-0.5, 0.5, 0.0).normal(), m_radius * 1.5, m_radius * 0.5, startAng, endAng), 0, kOdGiArcSector); break; case kTypeEllipArcChord: pWd->geometry().ellipArc(OdGeEllipArc3d(m_position, OdGeVector3d(0.5, 0.5, 0.0).normal(), OdGeVector3d(-0.5, 0.5, 0.0).normal(), m_radius * 1.5, m_radius * 0.5, startAng, endAng), 0, kOdGiArcChord); break; case kTypeEllipArcSimple: pWd->geometry().ellipArc(OdGeEllipArc3d(m_position, OdGeVector3d(0.5, 0.5, 0.0).normal(), OdGeVector3d(-0.5, 0.5, 0.0).normal(), m_radius * 1.5, m_radius * 0.5, startAng, endAng), 0, kOdGiArcSimple); break; case kTypePolygon: { OdGePoint3d pt[4] = { m_position - OdGeVector3d::kYAxis * m_radius, m_position + OdGeVector3d::kXAxis * m_radius, m_position + OdGeVector3d::kYAxis * m_radius, m_position - OdGeVector3d::kXAxis * m_radius }; pWd->geometry().polygon(4, pt); OdGePoint3d pt2[3] = { m_position - OdGeVector3d::kYAxis * (m_radius * 0.5), m_position + OdGeVector3d::kXAxis * (m_radius * 0.5), m_position + OdGeVector3d::kYAxis * (m_radius * 0.5) }; pWd->geometry().polygon(3, pt2); } break; case kTypeShell: { OdGePoint3d pt[4] = { m_position - OdGeVector3d::kYAxis * m_radius, m_position + OdGeVector3d::kXAxis * m_radius, m_position + OdGeVector3d::kYAxis * m_radius, m_position - OdGeVector3d::kXAxis * m_radius }; const OdInt32 faces[5] = { 4, 0, 1, 2, 3 }; pWd->geometry().shell(4, pt, 5, faces); OdGePoint3d pt2[3] = { m_position - OdGeVector3d::kYAxis * (m_radius * 0.5), m_position + OdGeVector3d::kXAxis * (m_radius * 0.5), m_position + OdGeVector3d::kYAxis * (m_radius * 0.5) }; const OdInt32 faces2[4] = { 3, 0, 1, 2 }; pWd->geometry().shell(3, pt2, 4, faces2); } break; } return true; } OdResult dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbEntity::dwgInFields(pFiler); if (res != eOk) return res; int nVersion = pFiler->rdInt16(); if (nVersion > getVersion()) return eMakeMeProxy; m_position = pFiler->rdPoint3d(); m_radius = pFiler->rdDouble(); m_type = (Type)pFiler->rdInt16(); m_fillAlways = pFiler->rdBool(); m_cFill = pFiler->rdBool(); return eOk; } void dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbEntity::dwgOutFields(pFiler); pFiler->wrInt16((OdInt16)getVersion()); pFiler->wrPoint3d(m_position); pFiler->wrDouble(m_radius); pFiler->wrInt16((OdInt16)m_type); pFiler->wrBool(m_fillAlways); pFiler->wrBool(m_cFill); } OdResult dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbEntity::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(desc()->name())) return eBadDxfSequence; int nVersion = pFiler->nextRb()->getInt16(); if (nVersion > getVersion()) return eMakeMeProxy; m_position = pFiler->nextRb()->getPoint3d(); m_radius = pFiler->nextRb()->getDouble(); m_type = (Type)pFiler->nextRb()->getInt16(); m_fillAlways = pFiler->nextRb()->getBool(); m_cFill = pFiler->nextRb()->getBool(); return eOk; } void dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbEntity::dxfOutFields(pFiler); pFiler->wrSubclassMarker(desc()->name()); pFiler->wrInt16(70, (OdInt16)getVersion()); pFiler->wrPoint3d(10, m_position); pFiler->wrDouble(40, m_radius); pFiler->wrInt16(71, (OdInt16)m_type); pFiler->wrBool(290, m_fillAlways); pFiler->wrBool(291, m_cFill); } }; const int ExDgnSpecTObj::lastKnownVersion = 1; ODRX_DXF_DEFINE_MEMBERS(ExDgnSpecTObj, OdDbEntity, DBOBJECT_CONSTR, OdDb::vAC24, OdDb::kMRelease0, OdDbProxyEntity::kAllAllowedBits, ExDgnSpecTObj, OdaMfcApp|Description: Teigha Run-time Extension Example) class OdExDgnSpecTObjCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExDgnSpecTObj"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdDbBlockTableRecordPtr pBTR = pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite); // Populate ExDgnSpecTObj-objects double yOffset = 0.0, xOffset; for (int y = 0; y < 4; y++) { xOffset = 0.0; bool bFlag1 = false, bFlag2 = false; switch (y) { case 1: bFlag1 = true; break; case 2: bFlag2 = true; break; case 3: bFlag1 = bFlag2 = true; break; } for (int x = 0; x <= (int)ExDgnSpecTObj::kTypeShell; x++) { OdSmartPtr pObj = ExDgnSpecTObj::createObject(); pObj->setDatabaseDefaults(pDb); pObj->setPosition(OdGePoint3d(xOffset, yOffset, 0.0)); pObj->setRadius(1.0); pObj->setType((ExDgnSpecTObj::Type)x); pObj->setFillAlways(bFlag1); pObj->setContourFill(bFlag2); pBTR->appendOdDbEntity(pObj); xOffset += 3.0; } yOffset += 3.0; } } }; static OdStaticRxObject g_OdExDgnSpecTObjCmd; #endif // #3764-related class OdExScaledArrayCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExScaledArray"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdDbBlockTableRecordPtr pBTR = pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite); OdDbSelectionSetPtr pSSet = pIO->select(OD_T("Select objects:")); if (pSSet->numEntities() > 0) { bool bMult = (0 == pIO->getKeyword(OD_T("Specify scale method [Diff/Mult]:"), OD_T("Mult Diff"))); double dFactor = pIO->getDist(OD_T("Specify scale factor:")); int nCount = pIO->getInt(OD_T("Set count of iterations:")); OdDbSelectionSetIteratorPtr pIter = pSSet->newIterator(); for (; !pIter->done(); pIter->next()) { OdRxObjectPtr pObj = pIter->objectId().safeOpenObject(); OdGeExtents3d ext; OdDbEntity::cast(pObj)->getGeomExtents(ext); double inFac = 1.0; for (int i = 0; i < nCount; i++) { OdRxObjectPtr pCopy = pObj->clone(); OdDbEntityPtr pEnt = pCopy; pBTR->appendOdDbEntity(pEnt); if (bMult) inFac *= dFactor; else inFac += dFactor; pEnt->transformBy(OdGeMatrix3d::scaling(inFac, ext.center())); } } } } }; static OdStaticRxObject g_OdExScaledArrayCmd; class OdExEraseByClassNameCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExEraseByClassName"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdString className = pIO->getString(OD_T("Enter class name:")); OdRxObjectPtr pClassObj = ::odrxClassDictionary()->getAt(className); OdRxClass *pClass = OdRxClass::cast(pClassObj).get(); if (!pClass) { pIO->putString(OD_T("No class found.")); return; } OdDbEntityPtrArray pEnts; OdDbBlockTableRecordPtr pBTR = pDb->getActiveLayoutBTRId().openObject(); OdDbObjectIteratorPtr pIt = pBTR->newIterator(); while (!pIt->done()) { OdDbEntityPtr pEnt = pIt->entity(); if (pEnt->isKindOf(pClass)) pEnts.push_back(pEnt); pIt->step(); } if (pEnts.isEmpty()) { pIO->putString(OD_T("No objects found.")); return; } for (OdUInt32 nEnt = 0; nEnt < pEnts.size(); nEnt++) { pEnts[nEnt]->upgradeOpen(); pEnts[nEnt]->erase(); } pIO->putString(OdString().format(OD_T("%u objects erased."), pEnts.size())); } }; static OdStaticRxObject g_OdExEraseByClassNameCmd; class OdExCopyEntToBlockCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExCopyEntToBlock"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdDbSelectionSetPtr pSSet = pIO->select(OD_T("Select objects:")); if (pSSet->numEntities() > 0) { OdString blockName = pIO->getString(OD_T("Enter block name:")); OdDbBlockTableRecordPtr pBTR = OdDbBlockTable::cast(pDb->getBlockTableId().safeOpenObject())->getAt(blockName).openObject(OdDb::kForWrite); if (pBTR.isNull()) { pIO->putString(OD_T("Block not found.")); return; } OdDbSelectionSetIteratorPtr pIter = pSSet->newIterator(); for (; !pIter->done(); pIter->next()) { OdDbEntityPtr pEnt = pIter->objectId().safeOpenObject(); pBTR->appendOdDbEntity(OdDbEntity::cast(pEnt->clone())); } } } }; static OdStaticRxObject g_OdExCopyEntToBlockCmd; class OdExGLES2CompositeMfCmd : public OdEdCommand { protected: bool m_bEnabled; public: OdExGLES2CompositeMfCmd() : m_bEnabled(false) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2CompositeMf"); } bool setting() const { return m_bEnabled; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); m_bEnabled = (0 == pDbCmdCtx->userIO()->getKeyword(OdString().format(OD_T("Enable GLES2 Composite Metafiles Mode (Cur: %ls)[Yes No]?"), (m_bEnabled) ? OD_T("Yes") : OD_T("No")).c_str(), OD_T("Yes No"), (m_bEnabled) ? 0 : 1)); } }; static OdStaticRxObject g_OdExGLES2CompositeMfCmd; class OdExGLES2VisualStylesCmd : public OdEdCommand { protected: bool m_bEnabled; public: OdExGLES2VisualStylesCmd() : m_bEnabled(true) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2VisualStyles"); } bool setting() const { return m_bEnabled; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); m_bEnabled = (0 == pDbCmdCtx->userIO()->getKeyword(OdString().format(OD_T("Enable GLES2 Visual Styles Usage Mode (Cur: %ls)[Yes No]?"), (m_bEnabled) ? OD_T("Yes") : OD_T("No")).c_str(), OD_T("Yes No"), (m_bEnabled) ? 0 : 1)); } }; static OdStaticRxObject g_OdExGLES2VisualStylesCmd; class OdExGLES2OverlaysCmd : public OdEdCommand { protected: bool m_bEnabled; public: OdExGLES2OverlaysCmd() : m_bEnabled(true) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2Overlays"); } bool setting() const { return m_bEnabled; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); m_bEnabled = (0 == pDbCmdCtx->userIO()->getKeyword(OdString().format(OD_T("Enable GLES2 Overlays Usage Mode (Cur: %ls)[Yes No]?"), (m_bEnabled) ? OD_T("Yes") : OD_T("No")).c_str(), OD_T("Yes No"), (m_bEnabled) ? 0 : 1)); } }; static OdStaticRxObject g_OdExGLES2OverlaysCmd; class OdExGLES2OITCmd : public OdEdCommand { protected: bool m_bEnabled; public: OdExGLES2OITCmd() : m_bEnabled(true) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2OIT"); } bool setting() const { return m_bEnabled; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); m_bEnabled = (0 == pDbCmdCtx->userIO()->getKeyword(OdString().format(OD_T("Enable GLES2 Order Independent Transparency (Cur: %ls)[Yes No]?"), (m_bEnabled) ? OD_T("Yes") : OD_T("No")).c_str(), OD_T("Yes No"), (m_bEnabled) ? 0 : 1)); { // Try to apply setting immediately OdDbObjectPtr pVp = pDb->activeViewportId().openObject(); OdDbAbstractViewportDataPtr pVpData(pVp); OdGsView *pView = pVpData->gsView(pVp); if (pView && pView->device() && !pView->device()->properties().isNull() && pView->device()->properties()->has(OD_T("BlendingMode"))) { const OdUInt32 uNewSetting = (setting()) ? 3 : 0; pView->device()->properties()->putAt(OD_T("BlendingMode"), OdRxVariantValue(uNewSetting)); pView->device()->invalidate(); } } } }; static OdStaticRxObject g_OdExGLES2OITCmd; #include "Tr/sg/TrRndSgSettingsUI.h" // Invoke vectorizer properties dialog as a base for our needs class CSceneGraphOptionsEditDlg : public CDialog { protected: OdTrRndSgSceneGraphSettingsUI *m_pOptions; StaticExtBar m_extBar; enum { IDD = IDD_RENDER_VECTPROPS }; CButton m_BitmapDevice; public: CSceneGraphOptionsEditDlg(OdTrRndSgSceneGraphSettingsUI &options, CWnd* pParent = NULL) : CDialog(IDD, pParent) , m_pOptions(&options) { } protected: virtual BOOL OnInitDialog() { CDialog::OnInitDialog(); SetWindowText(_T("Scene Graph Options")); m_extBar.resetCallback(m_pOptions); ExtBar::WinSysHandle sysHandle = { GetSafeHwnd(), NULL }; m_extBar.create(&sysHandle); ExtBar::Rect placeholderSize; ::GetWindowRect(::GetDlgItem(GetSafeHwnd(), IDC_VECTPROPS_LIST), &placeholderSize); ScreenToClient(&placeholderSize); m_extBar.resize(placeholderSize); GetDlgItem(IDC_VECTPROPS_LIST)->ShowWindow(SW_HIDE); { // Create cancel button CRect rect, winRect; WINDOWINFO winInfo; GetDlgItem(IDOK)->GetWindowRect(&rect); ScreenToClient(&rect); GetDlgItem(IDOK)->GetWindowInfo(&winInfo); GetClientRect(&winRect); rect.SetRect(winRect.right - rect.right, rect.top, (winRect.right - rect.right) + (rect.right - rect.left), rect.bottom); m_BitmapDevice.Create(_T("&Cancel"), winInfo.dwStyle & ~BS_DEFPUSHBUTTON, rect, this, IDCANCEL); m_BitmapDevice.SetFont(GetFont(), FALSE); } return TRUE; } void OnOK() { m_pOptions->closeExtBar(m_extBar.extBar(), 1); CDialog::OnOK(); } DECLARE_MESSAGE_MAP() protected: afx_msg void OnBitmapDeviceButtonClicked() { EndDialog(IDCANCEL); } afx_msg void OnDestroy() { m_extBar.destroy(); } }; BEGIN_MESSAGE_MAP(CSceneGraphOptionsEditDlg, CDialog) ON_BN_CLICKED(IDC_BUTTON2, &CSceneGraphOptionsEditDlg::OnBitmapDeviceButtonClicked) ON_WM_DESTROY() END_MESSAGE_MAP() class OdExGLES2SceneGraphCmd : public OdEdCommand { protected: OdTrRndSgSceneGraphSettingsUI m_options; bool m_bEnabled; public: OdExGLES2SceneGraphCmd() : m_bEnabled(true) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2SceneGraph"); } bool setting() const { return m_bEnabled; } OdIntPtr options() const { return reinterpret_cast(&m_options); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); int nKeyword = pDbCmdCtx->userIO()->getKeyword(OdString().format(OD_T("Enable GLES2 Scene Graph Usage Mode (Cur: %ls)[Yes No Options]?"), (m_bEnabled) ? OD_T("Yes") : OD_T("No")).c_str(), OD_T("Yes No Options"), (m_bEnabled) ? 0 : 1); if (nKeyword <= 1) m_bEnabled = (0 == nKeyword); else { CSceneGraphOptionsEditDlg sgOptionsEdit(m_options); if (sgOptionsEdit.DoModal()) { // Try to apply setting immediately OdDbObjectPtr pVp = pDb->activeViewportId().openObject(); OdDbAbstractViewportDataPtr pVpData(pVp); OdGsView *pView = pVpData->gsView(pVp); if (pView && pView->device() && !pView->device()->properties().isNull() && pView->device()->properties()->has(OD_T("SceneGraphOptions"))) { pView->device()->properties()->putAt(OD_T("SceneGraphOptions"), OdRxVariantValue(options())); pView->device()->invalidate(); } } } } }; static OdStaticRxObject g_OdExGLES2SceneGraphCmd; class OdExGLES2ExtendedMaterialsCmd : public OdEdCommand { protected: bool m_bEnabled; public: OdExGLES2ExtendedMaterialsCmd() : m_bEnabled(true) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2ExtendedMaterials"); } bool setting() const { return m_bEnabled; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); m_bEnabled = (0 == pDbCmdCtx->userIO()->getKeyword(OdString().format(OD_T("Enable GLES2 Extended Materials Usage (Cur: %ls)[Yes No]?"), (m_bEnabled) ? OD_T("Yes") : OD_T("No")).c_str(), OD_T("Yes No"), (m_bEnabled) ? 0 : 1)); } }; static OdStaticRxObject g_OdExGLES2ExtendedMaterialsCmd; // Invoke vectorizer properties dialog as a base for our needs class CAntiAliasingEditDlg : public CDialog, protected ExtBar::Callback { protected: OdGsDevice *m_pDevice; CDialog *&m_pDownPtr; StaticExtBar m_extBar; CButton m_BitmapDevice; public: enum { IDD = IDD_RENDER_VECTPROPS }; CAntiAliasingEditDlg(OdGsDevice *pDevice, CDialog *&pDownPtr, CWnd* pParent = NULL) : CDialog(IDD, pParent) , m_pDevice(pDevice) , m_pDownPtr(pDownPtr) { } protected: virtual BOOL OnInitDialog() { CDialog::OnInitDialog(); SetWindowText(_T("Anti Aliasing Levels Control")); m_extBar.resetCallback(this); ExtBar::WinSysHandle sysHandle = { GetSafeHwnd(), NULL }; m_extBar.create(&sysHandle); ExtBar::Rect placeholderSize; ::GetWindowRect(::GetDlgItem(GetSafeHwnd(), IDC_VECTPROPS_LIST), &placeholderSize); ScreenToClient(&placeholderSize); m_extBar.resize(placeholderSize); GetDlgItem(IDC_VECTPROPS_LIST)->ShowWindow(SW_HIDE); { // Create cancel button CRect rect, winRect; WINDOWINFO winInfo; GetDlgItem(IDOK)->GetWindowRect(&rect); ScreenToClient(&rect); GetDlgItem(IDOK)->GetWindowInfo(&winInfo); GetClientRect(&winRect); rect.SetRect(winRect.right - rect.right, rect.top, (winRect.right - rect.right) + (rect.right - rect.left), rect.bottom); m_BitmapDevice.Create(_T("&Cancel"), winInfo.dwStyle & ~BS_DEFPUSHBUTTON, rect, this, IDCANCEL); m_BitmapDevice.SetFont(GetFont(), FALSE); } return TRUE; } void OnOK() { //CDialog::OnOK(); DestroyWindow(); } void OnCancel() { DestroyWindow(); } DECLARE_MESSAGE_MAP() protected: afx_msg void OnBitmapDeviceButtonClicked() { EndDialog(IDCANCEL); } afx_msg void OnDestroy() { m_extBar.destroy(); m_pDownPtr = NULL; delete this; } virtual void fillExtBar(ExtBar *pExtBar) { double aaLevel = 0.0, aaLevelExt = 1.0; if (m_pDevice && !m_pDevice->properties().isNull()) { OdRxDictionaryPtr pProps = m_pDevice->properties(); if (pProps->has(OD_T("AntiAliasLevel"))) aaLevel = OdRxVariantValue(pProps->getAt(OD_T("AntiAliasLevel")))->getDouble(); if (pProps->has(OD_T("AntiAliasLevelExt"))) aaLevelExt = OdRxVariantValue(pProps->getAt(OD_T("AntiAliasLevelExt")))->getDouble(); } pExtBar->createText(100, NULL, ExtBar::k6d8)->setText(OD_T("Anti-Aliasing Level:")); pExtBar->createRangeBox(101, NULL, ExtBar::k2d8, false, true)->setFP(aaLevel, 0.0, 100.0, 0.01); pExtBar->createText(200, NULL, ExtBar::k6d8)->setText(OD_T("Anti-Aliasing Level Multiplier:")); pExtBar->createRangeBox(201, NULL, ExtBar::k2d8, false, true)->setFP(aaLevelExt, 0.0, 10.0, 0.01); } virtual void elementChanged(ExtBar::Element *pElem) { switch (pElem->elementId()) { case 101: { OdRxDictionaryPtr pProps = m_pDevice->properties(); if (!pProps.isNull() && pProps->has(OD_T("AntiAliasLevel"))) pProps->putAt(OD_T("AntiAliasLevel"), OdRxVariantValue(ExtBar::RangeElement::cast(pElem)->getPosFP())); } break; case 201: { OdRxDictionaryPtr pProps = m_pDevice->properties(); if (!pProps.isNull() && pProps->has(OD_T("AntiAliasLevelExt"))) pProps->putAt(OD_T("AntiAliasLevelExt"), OdRxVariantValue(ExtBar::RangeElement::cast(pElem)->getPosFP())); } break; } m_pDevice->invalidate(); ::SendMessage((HWND)OdRxVariantValue(m_pDevice->properties()->getAt(OD_T("WindowHWND")))->getIntPtr(), WM_PAINT, 0, 0); } }; BEGIN_MESSAGE_MAP(CAntiAliasingEditDlg, CDialog) ON_BN_CLICKED(IDC_BUTTON2, &CAntiAliasingEditDlg::OnBitmapDeviceButtonClicked) ON_WM_DESTROY() END_MESSAGE_MAP() class OdExGLES2AntiAliasCmd : public OdEdCommand { protected: CDialog *m_pDialog; public: OdExGLES2AntiAliasCmd() : m_pDialog(NULL) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2AntiAlias"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdDbObjectPtr pVp = pDb->activeViewportId().openObject(); OdDbAbstractViewportDataPtr pVpData(pVp); OdGsView *pView = pVpData->gsView(pVp); if (!pView) { pIO->putString(OD_T("Active view not found.")); return; } if (m_pDialog) { pIO->putString(OD_T("Dialog already active.")); return; } CAntiAliasingEditDlg *pDialog = new CAntiAliasingEditDlg(pView->device(), m_pDialog); pDialog->Create(CAntiAliasingEditDlg::IDD, CWnd::FromHandle((HWND)OdRxVariantValue(pView->device()->properties()->getAt(OD_T("WindowHWND")))->getIntPtr())); pDialog->ShowWindow(SW_SHOW); m_pDialog = pDialog; } }; static OdStaticRxObject g_OdExGLES2AntiAliasCmd; class OdExGLES2XmlDebugCmd : public OdEdCommand { protected: OdString m_outputFileName; public: OdExGLES2XmlDebugCmd() { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGLES2XmlDebug"); } const OdString &value() const { return m_outputFileName; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); m_outputFileName = pIO->getFilePath(L"Select Xml file to save", OdEd::kGfpForSave | OdEd::kGfpOverwritePrompt, L"Select file to save", L"xml", L"", "Xml files (*.xml)|*.xml"); } }; static OdStaticRxObject g_OdExGLES2XmlDebugCmd; void odExGLES2ConfigureDevice(OdRxDictionary *pProperties) { { // Enable composite metafiles onto renderer side if(pProperties->has(OD_T("UseCompositeMetafiles"))) // Check if property is supported pProperties->putAt(OD_T("UseCompositeMetafiles"), OdRxVariantValue(g_OdExGLES2CompositeMfCmd.setting())); if(pProperties->has(OD_T("RenderSettingsDlg")) && g_OdExGLES2CompositeMfCmd.setting()) // Check if property is supported pProperties->putAt(OD_T("RenderSettingsDlg"), OdRxVariantValue((OdIntPtr)AfxGetMainWnd()->GetSafeHwnd())); } { // Enable visual styles onto renderer side if (pProperties->has(OD_T("UseVisualStyles"))) // Check if property is supported pProperties->putAt(OD_T("UseVisualStyles"), OdRxVariantValue(g_OdExGLES2VisualStylesCmd.setting())); } { // Enable overlay buffers onto renderer side if (pProperties->has(OD_T("UseOverlays"))) // Check if property is supported pProperties->putAt(OD_T("UseOverlays"), OdRxVariantValue(g_OdExGLES2OverlaysCmd.setting())); } { // Enable scene graph usage onto renderer side if (pProperties->has(OD_T("UseSceneGraph"))) // Check if property is supported pProperties->putAt(OD_T("UseSceneGraph"), OdRxVariantValue(g_OdExGLES2SceneGraphCmd.setting())); if (pProperties->has(OD_T("SceneGraphOptions"))) // Check if property is supported pProperties->putAt(OD_T("SceneGraphOptions"), OdRxVariantValue(g_OdExGLES2SceneGraphCmd.options())); } { // Enable extended materials usage onto renderer side if (pProperties->has(OD_T("UseExtendedMaterials"))) // Check if property is supported pProperties->putAt(OD_T("UseExtendedMaterials"), OdRxVariantValue(g_OdExGLES2ExtendedMaterialsCmd.setting())); } if (!g_OdExGLES2OITCmd.setting() && pProperties->has(OD_T("BlendingMode"))) // Disable Order Independent Transparency if this is required pProperties->putAt(OD_T("BlendingMode"), OdRxVariantValue(OdUInt32(0))); { // Enable debug Xml output if (pProperties->has(OD_T("XmlOutput"))) // Check if property is supported pProperties->putAt(OD_T("XmlOutput"), OdRxVariantValue(g_OdExGLES2XmlDebugCmd.value())); } } class OdExSaveGsStateCmd : public OdEdCommand { public: OdExSaveGsStateCmd() { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExSaveGsState"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); CMDIChildWnd *pChild = ((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive(); if (pChild) { CView *pView = pChild->GetActiveView(); if (pView && pView->IsKindOf(RUNTIME_CLASS(CDwgViewer))) { CDwgViewer *pViewer = static_cast(pView); if (!pViewer->getDevice()->supportLayoutGsStateSaving()) { pIO->putString(OD_T("Vectorization device doesn't support Gs state saving.")); return; } OdString filePath = pIO->getFilePath(L"Select file to save", OdEd::kGfpForSave | OdEd::kGfpOverwritePrompt, L"Select file to save", L"tgss", L"", "TGSS files (*.tgss)|*.tgss"); if (filePath.isEmpty()) { pIO->putString(OD_T("No file selected.")); return; } OdStreamBufPtr pFile = ::odrxSystemServices()->createFile(filePath, Oda::kFileWrite, Oda::kShareDenyWrite, Oda::kCreateAlways); if (pFile.isNull()) { pIO->putString(OD_T("Failed to create file.")); return; } if (!pViewer->getDevice()->storeLayoutGsState(pFile)) { pIO->putString(OD_T("Failed to save file.")); return; } pIO->putString(OD_T("File saved.")); } else { pIO->putString(OD_T("Failed to detect Gs device.")); } } else { pIO->putString(OD_T("Failed to detect MDI child window.")); } } }; static OdStaticRxObject g_OdExSaveGsStateCmd; class OdExLoadGsStateCmd : public OdEdCommand { protected: bool m_bEnabled; OdString m_fileName; public: OdExLoadGsStateCmd() : m_bEnabled(false) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExLoadGsState"); } bool setting() const { return m_bEnabled; } const OdString &fileName() const { return m_fileName; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); m_bEnabled = (0 == pDbCmdCtx->userIO()->getKeyword(OdString().format(OD_T("Enable Gs State Loading (Cur: %ls)[Yes No]?"), (m_bEnabled) ? OD_T("Yes") : OD_T("No")).c_str(), OD_T("Yes No"), (m_bEnabled) ? 0 : 1)); if (m_bEnabled) m_fileName = pIO->getFilePath(L"Select file to load", OdEd::kGfpForOpen, L"Select file to load", L"tgss", L"", "TGSS files (*.tgss)|*.tgss"); else m_fileName.empty(); } }; static OdStaticRxObject g_OdExLoadGsStateCmd; const OdString &odExLoadGsStateSetting() { return (g_OdExLoadGsStateCmd.setting()) ? g_OdExLoadGsStateCmd.fileName() : OdString::kEmpty; } class OdExSetSnapshotDirectoryCmd : public OdEdCommand { protected: OdString m_ssDirectory; int m_counter; public: OdExSetSnapshotDirectoryCmd() : m_counter(0) { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExSetSnapshotDirectory"); } const OdString &fileName() const { return m_ssDirectory; } int &counter() { return m_counter; } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdString filePath = pIO->getFilePath(L"Select snapshot file to save", OdEd::kGfpForSave | OdEd::kGfpOverwritePrompt, L"Select bitmap file to save", L"bmp", L"", "BMP files (*.bmp)|*.bmp|PNG files (*.png)|*.png|JPEG files (*.jpg)|*.jpg||"); if (filePath.isEmpty()) pIO->putString(OD_T("No file selected.")); else { m_ssDirectory = filePath; pIO->putString(OdString().format(OD_T("File selected: %ls"), filePath.c_str())); m_counter = 0; } } }; static OdStaticRxObject g_OdExSetSnapshotDirectoryCmd; class OdExTakeSnapshotCmd : public OdEdCommand { public: OdExTakeSnapshotCmd() { } const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExTakeSnapshot"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdDbObjectPtr pVp = pDb->activeViewportId().openObject(); OdDbAbstractViewportDataPtr pVpData(pVp); OdGsView *pView = pVpData->gsView(pVp); if (!pView) { pIO->putString(OD_T("Graphics System not found.")); return; } OdGsDevice *pDevice = pView->device(); OdGsDCRect snapshotRegion; pDevice->getSize(snapshotRegion); OdGiRasterImagePtr pSnapshot; pDevice->getSnapShot(pSnapshot, snapshotRegion); if (pSnapshot.isNull()) { pIO->putString(OD_T("Looks like active vectorization module doesn't support snapshots.")); return; } if (g_OdExSetSnapshotDirectoryCmd.fileName().isEmpty()) g_OdExSetSnapshotDirectoryCmd.execute(pCmdCtx); if (g_OdExSetSnapshotDirectoryCmd.fileName().isEmpty()) { pIO->putString(OD_T("No output file specified.")); return; } OdString fileName = g_OdExSetSnapshotDirectoryCmd.fileName(); { OdString extension; int nPos = fileName.reverseFind(OdChar('.'), fileName.getLength()); if (nPos >= 0) extension = fileName.right(fileName.getLength() - nPos); fileName = fileName.left(nPos); fileName = OdString().format(OD_T("%ls%04d%ls"), fileName.c_str(), g_OdExSetSnapshotDirectoryCmd.counter()++, extension.c_str()); } OdRxRasterServicesPtr pRasSvcs = odrxDynamicLinker()->loadApp(RX_RASTER_SERVICES_APPNAME); if (pRasSvcs.isNull()) { pIO->putString(OD_T("Raster Services module not found.")); return; } if (!pRasSvcs->saveRasterImage(pSnapshot, fileName)) pIO->putString(OdString().format(OD_T("Snapshot saving error: %ls"), fileName.c_str())); else pIO->putString(OdString().format(OD_T("Snapshot saved: %ls"), fileName.c_str())); } }; static OdStaticRxObject g_OdExTakeSnapshotCmd; class ExSectionTrackingObj : public OdDbEntity { protected: mutable OdGePoint3d m_position; mutable OdGeVector3d m_normal; mutable OdGeVector3d m_rtUrVec; mutable OdGeVector3d m_rtXVec; bool m_bStyle1, m_bStyle2; public: ODDB_DECLARE_MEMBERS(ExSectionTrackingObj); ExSectionTrackingObj() : m_normal(OdGeVector3d::kZAxis), m_rtUrVec(OdGeVector3d::kYAxis), m_rtXVec(OdGeVector3d::kXAxis) , m_bStyle1(false), m_bStyle2(false) { } ~ExSectionTrackingObj() { } const OdGePoint3d &position() const { assertReadEnabled(); return m_position; } void setPosition(const OdGePoint3d &pos) { assertWriteEnabled(); m_position = pos; updateSection(); } const OdGeVector3d &normal() const { assertReadEnabled(); return m_normal; } void setNormal(const OdGeVector3d &norm) { assertWriteEnabled(); m_normal = norm; updateSection(); } const OdUInt32 style() const { assertReadEnabled(); return ((m_bStyle1) ? 1u : 0u) | ((m_bStyle2) ? 2u : 0u); } void setStyle(OdUInt32 nStyle) { assertWriteEnabled(); m_bStyle1 = nStyle > 0; m_bStyle2 = nStyle > 1; updateSection(); } OdResult subTransformBy(const OdGeMatrix3d& xform) { m_position.transformBy(xform); m_normal.transformBy(xform); m_rtUrVec.transformBy(xform); m_rtXVec.transformBy(xform); updateSection(); return eOk; } OdResult subGetGripPoints(OdGePoint3dArray& gripPoints) const { gripPoints.push_back(m_position); gripPoints.push_back(m_position + m_rtXVec); gripPoints.push_back(m_position + m_rtUrVec); return eOk; } OdResult subMoveGripPointsAt(const OdIntArray& indices, const OdGeVector3d& offset) { assertWriteEnabled(); switch (indices.getAt(0)) { case 0: subTransformBy(OdGeMatrix3d::translation(offset)); break; case 1: { OdGsView *pView = getGsView(); if (!pView) return eNoDocument; const OdGeVector3d proj = offset.orthoProject((pView->position() - pView->target()).normal()); const double dot = proj.dotProduct(m_normal); subTransformBy(OdGeMatrix3d::rotation(dot / m_rtXVec.length(), m_rtUrVec, m_position)); } break; case 2: { OdGsView *pView = getGsView(); if (!pView) return eNoDocument; const OdGeVector3d proj = offset.orthoProject((pView->position() - pView->target()).normal()); const double dot = -proj.dotProduct(m_normal); subTransformBy(OdGeMatrix3d::rotation(dot / m_rtUrVec.length(), m_rtXVec, m_position)); } break; } return eOk; } bool subWorldDraw(OdGiWorldDraw* /*pWd*/) const { return false; } void subViewportDraw(OdGiViewportDraw *pVd) const { pVd->subEntityTraits().setFillType(kOdGiFillAlways); OdGePoint2d llCrn, urCrn; pVd->viewport().getViewportDcCorners(llCrn, urCrn); const double dScale = llCrn.distanceTo(urCrn) * 0.5; const double dScaleHalf = dScale * 0.5; pVd->subEntityTraits().setTrueColor(OdCmEntityColor(192, 192, 192)); pVd->subEntityTraits().setTransparency(OdCmTransparency((OdUInt8)128)); const OdGeVector3d urVec = m_normal.perpVector(); const OdGeVector3d xVec = m_normal.crossProduct(urVec); const OdGePoint3d polyPts[5] = { m_position - urVec * dScaleHalf - xVec * dScaleHalf, m_position - urVec * dScaleHalf + xVec * dScaleHalf, m_position + urVec * dScaleHalf + xVec * dScaleHalf, m_position + urVec * dScaleHalf - xVec * dScaleHalf, m_position - urVec * dScaleHalf - xVec * dScaleHalf }; pVd->geometry().polygon(4, polyPts); pVd->subEntityTraits().setTransparency(OdCmTransparency()); pVd->geometry().polyline(5, polyPts); pVd->subEntityTraits().setColor(1); OdGePoint3d plPts[2] = { m_position + xVec * dScale, m_position }; pVd->geometry().polyline(2, plPts); pVd->subEntityTraits().setColor(3); *plPts = m_position + urVec * dScale; pVd->geometry().polyline(2, plPts); pVd->subEntityTraits().setColor(5); *plPts = m_position + m_normal * dScale; pVd->geometry().polyline(2, plPts); // Update runtime data m_rtUrVec = urVec * dScaleHalf; m_rtXVec = xVec * dScaleHalf; } OdResult dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbEntity::dwgInFields(pFiler); if (res != eOk) return res; m_position = pFiler->rdPoint3d(); m_normal = pFiler->rdVector3d(); m_rtUrVec = pFiler->rdVector3d(); m_rtXVec = pFiler->rdVector3d(); m_bStyle1 = pFiler->rdBool(); m_bStyle2 = pFiler->rdBool(); return eOk; } void dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbEntity::dwgOutFields(pFiler); pFiler->wrPoint3d(m_position); pFiler->wrVector3d(m_normal); pFiler->wrVector3d(m_rtUrVec); pFiler->wrVector3d(m_rtXVec); pFiler->wrBool(m_bStyle1); pFiler->wrBool(m_bStyle2); } OdResult dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbEntity::dxfInFields(pFiler); if (res != eOk) return res; if (!pFiler->atSubclassData(desc()->name())) return eBadDxfSequence; m_position = pFiler->nextRb()->getPoint3d(); m_normal = pFiler->nextRb()->getVector3d(); m_bStyle1 = pFiler->nextRb()->getBool(); m_bStyle2 = pFiler->nextRb()->getBool(); return eOk; } void dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbEntity::dxfOutFields(pFiler); pFiler->wrSubclassMarker(desc()->name()); pFiler->wrPoint3d(10, m_position); pFiler->wrVector3d(210, m_normal); pFiler->wrBool(290, m_bStyle1); pFiler->wrBool(291, m_bStyle2); } virtual bool sectionAttached() const { return false; } protected: virtual void eraseSection() {} OdResult subErase(bool erasing) { OdResult rs = OdDbEntity::subErase(erasing); if (erasing) { eraseSection(); } else updateSection(); return rs; } virtual void updateSection() {} OdGsView *getGsView() const { if (database()) { OdDbObjectPtr pVp = database()->activeViewportId().openObject(); if (!pVp.isNull()) { OdDbAbstractViewportDataPtr pVpPE(pVp); if (!pVpPE.isNull()) return pVpPE->gsView(pVp); } } return NULL; } }; ODRX_DXF_DEFINE_MEMBERS(ExSectionTrackingObj, OdDbEntity, DBOBJECT_CONSTR, OdDb::vAC24, OdDb::kMRelease0, OdDbProxyEntity::kAllAllowedBits, ExSectionTrackingObj, OdaMfcApp|Description: Teigha Run-time Extension Example) #include "../../Extensions/ExRender/ExHardwareSections.h" class ExHardwareSectionObj : public ExSectionTrackingObj { public: ODDB_DECLARE_MEMBERS(ExHardwareSectionObj); ExHardwareSectionObj() : ExSectionTrackingObj() { } ~ExHardwareSectionObj() { } virtual bool sectionAttached() const { OdGsView *pView; OdHardwareSectionsInterface *pSec = hwSectionsIface(pView); return pSec && pSec->numSectionPlanes(pView); } protected: virtual void eraseSection() { OdGsView *pView; OdHardwareSectionsInterface *pSec = hwSectionsIface(pView); if (pSec) { pSec->clearSectionPlanes(pView); } } virtual void updateSection() { OdGsView *pView; OdHardwareSectionsInterface *pSec = hwSectionsIface(pView); if (pSec) { if (pSec->numSectionPlanes(pView)) pSec->clearSectionPlanes(pView); pSec->addSectionPlane(pView, OdHardwareSectionsInterface::SectionDef(m_position, m_normal)); //pSec->addSectionPlane(pView, OdHardwareSectionsInterface::SectionDef(m_position, m_normal.rotateBy(OdaPI2, OdGeVector3d::kZAxis))); // State pSec->setEnableSectionsFill(pView, m_bStyle1); if (m_bStyle1) { pSec->setSectionsFillColor(pView, ODRGBA(255, 0, 0, (m_bStyle2) ? 128 : 255)); if (m_bStyle2) { pSec->setEnableSectionsFillPattern(pView, true); pSec->setSectionsFillPattern(pView, OdPs::kFsSlantRight); pSec->setSectionsFillPatternColor(pView, ODRGBA(0, 0, 255, 255)); } } } } OdHardwareSectionsInterface *hwSectionsIface(OdGsView *&pGsView) const { pGsView = getGsView(); if (pGsView) { if (pGsView->device() && !pGsView->device()->properties().isNull() && pGsView->device()->properties()->has(OD_T("HardwareSections"))) return static_cast(pGsView->device()->properties()->getAt(OD_T("HardwareSections")).get()); } return NULL; } }; ODRX_DXF_DEFINE_MEMBERS(ExHardwareSectionObj, OdDbEntity, DBOBJECT_CONSTR, OdDb::vAC24, OdDb::kMRelease0, OdDbProxyEntity::kAllAllowedBits, ExHardwareSectionObj, OdaMfcApp|Description: Teigha Run-time Extension Example) class OdExHardwareSectionCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExHardwareSection"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdSmartPtr pObj = ExHardwareSectionObj::createObject(); pObj->setDatabaseDefaults(pDb); if (!pObj->sectionAttached()) { pObj->setPosition(pIO->getPoint(OD_T("Specify plane position"))); pObj->setStyle(pIO->getInt(OD_T("Specify section style"))); OdDbBlockTableRecordPtr pBTR = pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite); pBTR->appendOdDbEntity(pObj); } else pIO->putString(OD_T("Section already attached.")); } }; static OdStaticRxObject g_OdExHardwareSectionCmd; class ExGhostSectionObj : public ExSectionTrackingObj { public: ODDB_DECLARE_MEMBERS(ExGhostSectionObj); ExGhostSectionObj() : ExSectionTrackingObj() { } ~ExGhostSectionObj() { } virtual bool sectionAttached() const { OdGsView *pView = getGsView(); return pView && pView->viewport3dClipping(); } protected: virtual void eraseSection() { OdGsView *pView = getGsView(); if (pView) { pView->setViewport3dClipping(NULL); } } virtual void updateSection() { OdGsView *pView = getGsView(); if (pView) { // Setup traits resolver for section geometry OdGiSectionGeometryOutputPtr pTraitsSets = OdGiSectionGeometryOutput::createObject(); pTraitsSets->setTraitsOverrideFlags(OdGiSubEntityTraitsChangedFlags::kColorChanged | OdGiSubEntityTraitsChangedFlags::kMaterialChanged); pTraitsSets->traitsOverrides().setColor(1); pTraitsSets->setSectionToleranceOverride(1.0e-2); // Setup traits resolver for ghost geometry OdGiCuttedGeometryOutputPtr pTraitsCutSets = OdGiCuttedGeometryOutput::createObject(); pTraitsCutSets->setTraitsOverrideFlags(OdGiSubEntityTraitsChangedFlags::kColorChanged | OdGiSubEntityTraitsChangedFlags::kMaterialChanged); pTraitsCutSets->traitsOverrides().setColor(OdCmEntityColor::kACIBlue); pTraitsCutSets->setNonSectionableGeometryClipping(false); // Setup clipping planes OdGiPlanarClipBoundary::ClipPlaneArray clipPlanes; clipPlanes.push_back(OdGiPlanarClipBoundary::ClipPlane(m_position, m_normal)); OdGiPlanarClipBoundary bnd; bnd.setClipPlanes(clipPlanes); //bnd.setSectionGeometryOutput(pTraitsSets); bnd.setCuttedGeometryOutput(pTraitsCutSets); // Setup viewport clipping OdGiClipBoundary emptyBoundary; ::odgiEmptyClipBoundary(emptyBoundary); pView->setViewport3dClipping(&emptyBoundary, &bnd); // Invalidate sectionable objects cache if (gsNode()) gsNode()->model()->invalidate(pView); } } }; ODRX_DXF_DEFINE_MEMBERS(ExGhostSectionObj, OdDbEntity, DBOBJECT_CONSTR, OdDb::vAC24, OdDb::kMRelease0, OdDbProxyEntity::kAllAllowedBits, ExGhostSectionObj, OdaMfcApp|Description: Teigha Run-time Extension Example) class OdExGhostSectionCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExGhostSection"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdSmartPtr pObj = ExGhostSectionObj::createObject(); pObj->setDatabaseDefaults(pDb); if (!pObj->sectionAttached()) { pObj->setPosition(pIO->getPoint(OD_T("Specify plane position"))); pObj->setStyle(pIO->getInt(OD_T("Specify section style"))); OdDbBlockTableRecordPtr pBTR = pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite); pBTR->appendOdDbEntity(pObj); } else pIO->putString(OD_T("Section already attached.")); } }; static OdStaticRxObject g_OdExGhostSectionCmd; class ExModelMovementObj : public ExSectionTrackingObj { public: ODDB_DECLARE_MEMBERS(ExModelMovementObj); ExModelMovementObj() : ExSectionTrackingObj() { } ~ExModelMovementObj() { } virtual bool sectionAttached() const { OdGsView *pView = getGsView(); if (pView) { OdGsModelArray models = pView->getModelList(); return !models.isEmpty() && !models.first()->transform().isEqualTo(OdGeMatrix3d::kIdentity); } return false; } protected: virtual void eraseSection() { OdGsView *pView = getGsView(); if (pView) { OdGsModelArray models = pView->getModelList(); if (!models.isEmpty()) models.first()->setTransform(OdGeMatrix3d::kIdentity); } } virtual void updateSection() { OdGsView *pView = getGsView(); if (pView) { OdGsModelArray models = pView->getModelList(); if (!models.isEmpty()) models.first()->setTransform(OdGeMatrix3d().setCoordSystem(m_position, m_rtXVec.normal(), m_rtUrVec.normal(), m_normal)); } } void subViewportDraw(OdGiViewportDraw *pVd) const { OdSaveState _pos(m_position); OdSaveState _norm(m_normal); OdGeVector3d m_rtVals[2] = { m_rtXVec, m_rtUrVec }; if (gsNode()) { m_position = OdGePoint3d::kOrigin; m_normal = OdGeVector3d::kZAxis; m_rtXVec = OdGeVector3d::kXAxis * m_rtXVec.length(); m_rtUrVec = OdGeVector3d::kYAxis * m_rtUrVec.length(); } ExSectionTrackingObj::subViewportDraw(pVd); m_rtXVec = m_rtVals[0] * (m_rtXVec.length() / m_rtVals[0].length()); m_rtUrVec = m_rtVals[1] * (m_rtUrVec.length() / m_rtVals[1].length()); } }; ODRX_DXF_DEFINE_MEMBERS(ExModelMovementObj, OdDbEntity, DBOBJECT_CONSTR, OdDb::vAC24, OdDb::kMRelease0, OdDbProxyEntity::kAllAllowedBits, ExModelMovementObj, OdaMfcApp|Description: Teigha Run-time Extension Example) class OdExModelMovementCmd : public OdEdCommand { public: const OdString groupName() const { return OD_T("ODAMFCAPP"); } const OdString globalName() const { return OD_T("ExModelMovement"); } void execute(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); OdSmartPtr pObj = ExModelMovementObj::createObject(); pObj->setDatabaseDefaults(pDb); if (!pObj->sectionAttached()) { pObj->setPosition(OdGePoint3d::kOrigin); OdDbBlockTableRecordPtr pBTR = pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite); pBTR->appendOdDbEntity(pObj); } else pIO->putString(OD_T("Object already attached.")); } }; static OdStaticRxObject g_OdExModelMovementCmd; void rxInitMaterialsEditorObjects() { odedRegCmds()->addCommand(&g_OdExTeapotCmd); ExTeapot::rxInit(); #ifdef _DEBUG odedRegCmds()->addCommand(&g_OdExDgnSpecTObjCmd); ExDgnSpecTObj::rxInit(); #endif odedRegCmds()->addCommand(&g_OdExScaledArrayCmd); odedRegCmds()->addCommand(&g_OdExEraseByClassNameCmd); odedRegCmds()->addCommand(&g_OdExCopyEntToBlockCmd); odedRegCmds()->addCommand(&g_OdExGLES2CompositeMfCmd); odedRegCmds()->addCommand(&g_OdExGLES2VisualStylesCmd); odedRegCmds()->addCommand(&g_OdExGLES2OverlaysCmd); odedRegCmds()->addCommand(&g_OdExGLES2OITCmd); odedRegCmds()->addCommand(&g_OdExGLES2SceneGraphCmd); odedRegCmds()->addCommand(&g_OdExGLES2ExtendedMaterialsCmd); odedRegCmds()->addCommand(&g_OdExGLES2AntiAliasCmd); odedRegCmds()->addCommand(&g_OdExGLES2XmlDebugCmd); odedRegCmds()->addCommand(&g_OdExSaveGsStateCmd); odedRegCmds()->addCommand(&g_OdExLoadGsStateCmd); odedRegCmds()->addCommand(&g_OdExSetSnapshotDirectoryCmd); odedRegCmds()->addCommand(&g_OdExTakeSnapshotCmd); odedRegCmds()->addCommand(&g_OdExHardwareSectionCmd); odedRegCmds()->addCommand(&g_OdExGhostSectionCmd); odedRegCmds()->addCommand(&g_OdExModelMovementCmd); ExSectionTrackingObj::rxInit(); ExHardwareSectionObj::rxInit(); ExGhostSectionObj::rxInit(); ExModelMovementObj::rxInit(); } void rxUninitMaterialsEditorObjects() { ExModelMovementObj::rxUninit(); ExGhostSectionObj::rxUninit(); ExHardwareSectionObj::rxUninit(); ExSectionTrackingObj::rxUninit(); odedRegCmds()->removeCmd(&g_OdExModelMovementCmd); odedRegCmds()->removeCmd(&g_OdExGhostSectionCmd); odedRegCmds()->removeCmd(&g_OdExHardwareSectionCmd); odedRegCmds()->removeCmd(&g_OdExTakeSnapshotCmd); odedRegCmds()->removeCmd(&g_OdExSetSnapshotDirectoryCmd); odedRegCmds()->removeCmd(&g_OdExLoadGsStateCmd); odedRegCmds()->removeCmd(&g_OdExSaveGsStateCmd); odedRegCmds()->removeCmd(&g_OdExGLES2XmlDebugCmd); odedRegCmds()->removeCmd(&g_OdExGLES2AntiAliasCmd); odedRegCmds()->removeCmd(&g_OdExGLES2ExtendedMaterialsCmd); odedRegCmds()->removeCmd(&g_OdExGLES2SceneGraphCmd); odedRegCmds()->removeCmd(&g_OdExGLES2OITCmd); odedRegCmds()->removeCmd(&g_OdExGLES2OverlaysCmd); odedRegCmds()->removeCmd(&g_OdExGLES2VisualStylesCmd); odedRegCmds()->removeCmd(&g_OdExGLES2CompositeMfCmd); odedRegCmds()->removeCmd(&g_OdExCopyEntToBlockCmd); odedRegCmds()->removeCmd(&g_OdExEraseByClassNameCmd); odedRegCmds()->removeCmd(&g_OdExScaledArrayCmd); #ifdef _DEBUG ExDgnSpecTObj::rxUninit(); odedRegCmds()->removeCmd(&g_OdExDgnSpecTObjCmd); #endif ExTeapot::rxUninit(); odedRegCmds()->removeCmd(&g_OdExTeapotCmd); } // CCmEntityColorPreview IMPLEMENT_DYNAMIC(CCmEntityColorPreview, CStatic) CCmEntityColorPreview::CCmEntityColorPreview() { } CCmEntityColorPreview::~CCmEntityColorPreview() { } BEGIN_MESSAGE_MAP(CCmEntityColorPreview, CStatic) ON_WM_CREATE() ON_WM_DESTROY() ON_WM_PAINT() END_MESSAGE_MAP() // CCmEntityColorPreview message handlers int CCmEntityColorPreview::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CStatic::OnCreate(lpCreateStruct) == -1) return -1; // . . . return 0; } void CCmEntityColorPreview::OnDestroy() { CStatic::OnDestroy(); } void CCmEntityColorPreview::SetColor(const OdCmEntityColor &color) { m_color = color; if (color.isByBlock()) SetWindowText(_T("ByBlock")); else if (color.isByLayer()) SetWindowText(_T("ByLayer")); else if (color.isNone()) SetWindowText(_T("ByEntity")); Invalidate(); } inline ODCOLORREF lookupRGBHelper(const OdCmEntityColor &entColor) { OdUInt32 bgr = OdCmEntityColor::lookUpRGB((OdUInt8)entColor.colorIndex()); return ODRGB((bgr >> 16) & 0xFF, (bgr >> 8) & 0xFF, bgr & 0xFF); } COLORREF CCmEntityColorPreview::GetCref() { COLORREF color = ::GetSysColor(COLOR_BTNFACE); if (m_color.isByACI() || m_color.isByDgnIndex()) color = ::lookupRGBHelper(m_color); else if (m_color.isByColor()) color = RGB(m_color.red(), m_color.green(), m_color.blue()); return color; } void CCmEntityColorPreview::OnPaint() { if (m_color.isByBlock() || m_color.isByLayer() || m_color.isNone()) CStatic::OnPaint(); else { CPaintDC dc(this); CRect cliArea; GetClientRect(&cliArea); dc.FillSolidRect(&cliArea, GetCref()); } } ///////////////////////////////////////////////////////////////////////////// // CDbLightsDlg dialog CDbLightsDlg::CDbLightsDlg(OdDbDatabase* pDb, CWnd* pParent /*=NULL*/) : CDialog(CDbLightsDlg::IDD, pParent) , m_pDb(pDb) , m_nItem(0) { //{{AFX_DATA_INIT(CDbLightsDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CDbLightsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDbLightsDlg) DDX_Control(pDX, IDC_LIGHTS_LIST, m_LightsList); DDX_Control(pDX, IDC_SCOLOR, m_Color); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDbLightsDlg, CDialog) //{{AFX_MSG_MAP(CDbLightsDlg) //}}AFX_MSG_MAP ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIGHTS_LIST, &CDbLightsDlg::OnLvnItemchangedLightsList) ON_BN_CLICKED(IDC_CBON, &CDbLightsDlg::OnBnClickedCbon) ON_BN_CLICKED(IDC_CBTARGETED, &CDbLightsDlg::OnBnClickedCbtargeted) ON_BN_CLICKED(IDC_BHIGHLIGHT, &CDbLightsDlg::OnBnClickedBhighlight) ON_EN_KILLFOCUS(IDC_EINTENSITY, &CDbLightsDlg::OnEnChangeEintensity) ON_BN_CLICKED(IDC_BCOLOR, &CDbLightsDlg::OnBnClickedBcolor) ON_EN_KILLFOCUS(IDC_EHOTSPOT, &CDbLightsDlg::OnEnChangeEhotspot) ON_EN_KILLFOCUS(IDC_EFALLOFF, &CDbLightsDlg::OnEnChangeEfalloff) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDbLightsDlg message handlers BOOL CDbLightsDlg::OnInitDialog() { CDialog::OnInitDialog(); if (m_pDb) { RECT rect; m_LightsList.GetClientRect(&rect); m_LightsList.InsertColumn(0, _T("Type") , LVCFMT_LEFT, (rect.right - rect.left) / 2); m_LightsList.InsertColumn(1, _T("Light Name"), LVCFMT_LEFT, (rect.right - rect.left) / 2); OdDbBlockTableRecordPtr pBTR = OdDbBlockTableRecord::cast(m_pDb->getActiveLayoutBTRId().openObject()); OdDbObjectIteratorPtr pIt = pBTR->newIterator(); int nItem = 0; while (!pIt->done()) { OdDbLightPtr pLight = OdDbLight::cast(pIt->entity()); if (!pLight.isNull()) { CString lightType; switch (pLight->drawableType()) { case OdGiDrawable::kPointLight: lightType = _T("Point"); break; case OdGiDrawable::kDistantLight: lightType = _T("Distant"); break; case OdGiDrawable::kSpotLight: lightType = _T("Spot"); break; case OdGiDrawable::kWebLight: lightType = _T("Web"); break; default: lightType = _T("Unknown"); } m_LightsList.InsertItem(nItem, lightType); m_LightsList.SetItemText(nItem, 1, pLight->name().c_str()); m_LightsList.SetItemData(nItem, (DWORD_PTR)pLight->id()); nItem++; } pIt->step(); } } UpdateProperties(-1); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDbLightsDlg::UpdateProperties(int nItem) { if (nItem == -1) { GetDlgItem(IDC_CBON)->EnableWindow(FALSE); GetDlgItem(IDC_CBTARGETED)->EnableWindow(FALSE); GetDlgItem(IDC_BHIGHLIGHT)->EnableWindow(FALSE); GetDlgItem(IDC_EINTENSITY)->EnableWindow(FALSE); GetDlgItem(IDC_BCOLOR)->EnableWindow(FALSE); GetDlgItem(IDC_EHOTSPOT)->EnableWindow(FALSE); GetDlgItem(IDC_EFALLOFF)->EnableWindow(FALSE); } else { GetDlgItem(IDC_CBON)->EnableWindow(TRUE); GetDlgItem(IDC_CBTARGETED)->EnableWindow(TRUE); GetDlgItem(IDC_BHIGHLIGHT)->EnableWindow(TRUE); GetDlgItem(IDC_EINTENSITY)->EnableWindow(TRUE); GetDlgItem(IDC_BCOLOR)->EnableWindow(TRUE); GetDlgItem(IDC_EHOTSPOT)->EnableWindow(TRUE); GetDlgItem(IDC_EFALLOFF)->EnableWindow(TRUE); OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(); SetDlgItemText(IDC_SPOSITION, OdString().format(OD_T("{ %.2f; %.2f; %.2f }"), pLight->position().x, pLight->position().y, pLight->position().z).c_str()); SetDlgItemText(IDC_STARGET, OdString().format(OD_T("{ %.2f; %.2f; %.2f }"), pLight->targetLocation().x, pLight->targetLocation().y, pLight->targetLocation().z).c_str()); CheckDlgButton(IDC_CBON, (pLight->isOn()) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CBTARGETED, (pLight->hasTarget()) ? BST_CHECKED : BST_UNCHECKED); SetDlgItemText(IDC_EINTENSITY, OdString().format(OD_T("%f"), pLight->intensity()).c_str()); { OdCmEntityColor toColor; toColor.setColor(pLight->lightColor().color()); m_Color.SetColor(toColor); } if (pLight->drawableType() == OdGiDrawable::kSpotLight) { SetDlgItemInt(IDC_EHOTSPOT, (UINT)OdaToDegree(pLight->hotspotAngle())); SetDlgItemInt(IDC_EFALLOFF, (UINT)OdaToDegree(pLight->falloffAngle())); } else { GetDlgItem(IDC_EHOTSPOT)->EnableWindow(FALSE); GetDlgItem(IDC_EFALLOFF)->EnableWindow(FALSE); } } m_nItem = nItem; } void CDbLightsDlg::OnLvnItemchangedLightsList(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR); if ((pNMLV->uChanged & LVIF_STATE) && (pNMLV->uNewState & LVNI_SELECTED)) UpdateProperties(pNMLV->iItem); // TODO: Add your control notification handler code here *pResult = 0; } void CDbLightsDlg::OnBnClickedCbon() { OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(m_nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(OdDb::kForWrite); pLight->setOn(IsDlgButtonChecked(IDC_CBON) == BST_CHECKED); } void CDbLightsDlg::OnBnClickedCbtargeted() { OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(m_nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(OdDb::kForWrite); pLight->setHasTarget(IsDlgButtonChecked(IDC_CBTARGETED) == BST_CHECKED); } void CDbLightsDlg::OnBnClickedBhighlight() { OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(m_nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(); pLight->highlight(); } void CDbLightsDlg::OnEnChangeEintensity() { CString intensity; GetDlgItemText(IDC_EINTENSITY, intensity); double dStr = odStrToD(intensity.GetBuffer()); if (dStr == 0.0) return; OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(m_nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(OdDb::kForWrite); pLight->setIntensity(dStr); SetDlgItemText(IDC_EINTENSITY, OdString().format(OD_T("%f"), pLight->intensity()).c_str()); } void CDbLightsDlg::OnBnClickedBcolor() { CColorPickerDlg dlg; dlg.SetColor(m_Color.GetCref()); if (dlg.DoModal() == IDOK) { COLORREF color = dlg.GetColor(); OdCmEntityColor cmColor(GetRValue(color), GetGValue(color), GetBValue(color)); m_Color.SetColor(cmColor); OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(m_nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(OdDb::kForWrite); OdCmColor cmColor2; cmColor2.setColor(cmColor.color()); pLight->setLightColor(cmColor2); } } void CDbLightsDlg::OnEnChangeEhotspot() { OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(m_nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(OdDb::kForWrite); pLight->setHotspotAndFalloff(OdaToRadian((double)GetDlgItemInt(IDC_EHOTSPOT)), pLight->falloffAngle()); SetDlgItemInt(IDC_EHOTSPOT, (UINT)OdaToDegree(pLight->hotspotAngle())); SetDlgItemInt(IDC_EFALLOFF, (UINT)OdaToDegree(pLight->falloffAngle())); } void CDbLightsDlg::OnEnChangeEfalloff() { OdDbStub *pLightId = (OdDbStub*)m_LightsList.GetItemData(m_nItem); OdDbLightPtr pLight = OdDbObjectId(pLightId).openObject(OdDb::kForWrite); pLight->setHotspotAndFalloff(pLight->hotspotAngle(), OdaToRadian((double)GetDlgItemInt(IDC_EFALLOFF))); SetDlgItemInt(IDC_EHOTSPOT, (UINT)OdaToDegree(pLight->hotspotAngle())); SetDlgItemInt(IDC_EFALLOFF, (UINT)OdaToDegree(pLight->falloffAngle())); } // CMaterialPreview IMPLEMENT_DYNAMIC(CMaterialPreview, CStatic) CMaterialPreview::CMaterialPreview(OdDbDatabase *pHostDb) : m_pHostDb(pHostDb) , m_hDc(NULL) , m_devName(OdWinOpenGLModuleName) , m_bDiagBkgnd(false) { } CMaterialPreview::~CMaterialPreview() { } BEGIN_MESSAGE_MAP(CMaterialPreview, CStatic) ON_WM_CREATE() ON_WM_DESTROY() ON_WM_PAINT() END_MESSAGE_MAP() // CMaterialPreview message handlers int CMaterialPreview::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CStatic::OnCreate(lpCreateStruct) == -1) return -1; return 0; } void CMaterialPreview::OnDestroy() { if (m_hDc) ReleaseDC(m_hDc); CStatic::OnDestroy(); } OdString CMaterialPreview::findFile(const OdString& file, OdDbBaseDatabase* pDb, OdDbBaseHostAppServices::FindFileHint hint) { return theApp.findFile(file, m_pHostDb, hint); } void CMaterialPreview::PreparePreviewDatabase() { m_pDb = createDatabase(); { // Create preview material OdDbMaterialPtr pMtl = OdDbMaterial::createObject(); pMtl->setName(OD_T("PreviewMaterial")); OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().openObject(OdDb::kForWrite))->setAt(OD_T("PreviewMaterial"), pMtl); } { // Create preview entity OdSmartPtr pTeapot = ExTeapot::createObject(); pTeapot->setDatabaseDefaults(m_pDb); pTeapot->setScale(OdGeScale3d(1.0)); pTeapot->setPosition(OdGePoint3d::kOrigin - OdGeVector3d::kZAxis * 0.5); pTeapot->setRotate(OdGeVector3d(-OdaPI / 4, 0.0, -OdaPI / 4)); pTeapot->setMaterial(OD_T("PreviewMaterial")); OdDbBlockTableRecord::cast(m_pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite))->appendOdDbEntity(pTeapot); } { // Prepare view settings OdDbObjectPtr pView = m_pDb->activeViewportId().openObject(OdDb::kForWrite); OdAbstractViewPEPtr pSet(pView); pSet->setRenderMode(pView, OdDb::kGouraudShaded); pSet->setView(pView, OdGePoint3d::kOrigin, OdGeVector3d::kYAxis * 5.0, OdGeVector3d::kZAxis, 2.5, 2.5, false); } } const OdGiContextForDbDatabase* CMaterialPreview::giContext() { if (m_pCtx.isNull()) { m_pCtx = OdGiContextForDbDatabase::createObject(); m_pCtx->enableGsModel(true); m_pCtx->setPaletteBackground(ODRGB(0, 0, 0)); m_pCtx->setDatabase(m_pDb); } return m_pCtx.get(); } void CMaterialPreview::PreparePreviewDevice() { m_pDevice.release(); CRect rc; GetClientRect(&rc); try { OdGsModulePtr pGs = ::odrxDynamicLinker()->loadModule(m_devName.GetBuffer(), false); OdGsDevicePtr pDevice = pGs->createDevice(); OdRxDictionaryPtr pProperties = pDevice->properties(); if(pProperties.get()) { if(pProperties->has(OD_T("WindowHWND"))) // Check if property is supported pProperties->putAt(OD_T("WindowHWND"), OdRxVariantValue((OdIntPtr)GetSafeHwnd())); // hWnd necessary for DirectX device if (!m_hDc) m_hDc = GetDC(); if(pProperties->has(OD_T("WindowHDC"))) // Check if property is supported pProperties->putAt(OD_T("WindowHDC"), OdRxVariantValue((OdIntPtr)m_hDc->GetSafeHdc())); // hWindowDC necessary for Bitmap device if(pProperties->has(OD_T("UseVisualStyles"))) // Check if property is supported pProperties->putAt(OD_T("UseVisualStyles"), OdRxVariantValue(false)); } if (m_pCtx.isNull()) { m_pCtx = OdGiContextForDbDatabase::createObject(); m_pCtx->enableGsModel(true); m_pCtx->setPaletteBackground(ODRGB(0, 0, 0)); m_pCtx->setDatabase(m_pDb); } m_pDevice = OdDbGsManager::setupActiveLayoutViews(pDevice, m_pCtx); m_pDevice->setLogicalPalette(::odcmAcadDarkPalette(), 256); m_pDevice->setBackgroundColor(ODRGB(0, 0, 0)); OdGsDCRect gsRect(rc.left, rc.right, rc.bottom, rc.top); m_pDevice->onSize(gsRect); if (m_bDiagBkgnd) SetDiagnosticBackground(true); Invalidate(); } catch(const OdError& /*e*/) { m_pDevice.release(); MessageBox(_T("Requested device couldn't be created."), _T("Graphic System Initialization Error"), MB_ICONSTOP); } } void CMaterialPreview::SetMaterial(const OdDbObjectId &mtlId) { if (m_pDb.isNull()) PreparePreviewDatabase(); OdDbMaterialPtr pMtl = mtlId.openObject()->clone(); pMtl->setDescription(pMtl->name()); pMtl->setName(OD_T("PreviewMaterial")); OdDbMaterialPtr pMtlTo = OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().openObject())->getAt(OD_T("PreviewMaterial"), OdDb::kForWrite); pMtlTo->handOverTo(pMtl); if (m_pDevice.isNull()) PreparePreviewDevice(); UpdatePreview(); } OdDbObjectId CMaterialPreview::GetMaterial() { return OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().openObject())->getAt(OD_T("PreviewMaterial")); } void CMaterialPreview::ResetDevice(const CString &devName, bool bMaterial) { if (m_pDevice.isNull() || devName != m_devName) { m_devName = devName; if (bMaterial) PreparePreviewDevice(); } } bool CMaterialPreview::SetDiagnosticBackground(bool bSet) { bool bPrevSet = m_bDiagBkgnd; m_bDiagBkgnd = bSet; if (!m_pDevice.isNull()) { OdDbRenderSettingsPtr pSets = oddbGetActiveRenderSettingsObject(m_pDb, OdDb::kForWrite, true); pSets->setDiagnosticBackgroundEnabled(bSet); UpdatePreview(); } return bPrevSet; } void CMaterialPreview::UpdatePreview() { if (!m_pDevice.isNull()) { OdGsLayoutHelper::cast(m_pDevice)->gsModel()->invalidate(OdGsModel::kInvalidateAll); m_pDevice->invalidate(); Invalidate(); } } void CMaterialPreview::OnPaint() { CPaintDC dc(this); if (m_pDevice.isNull()) { CRect cliArea; GetClientRect(&cliArea); dc.FillSolidRect(&cliArea, ::GetSysColor(COLOR_BTNFACE)); } else { m_pDevice->update(); } } ///////////////////////////////////////////////////////////////////////////// // CDbMaterialsDlg dialog //Common tools //Tab Control BEGIN_MESSAGE_MAP(OdTabCtrl, CTabCtrl) ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnSelChange) END_MESSAGE_MAP() OdTabCtrl::OdTabCtrl() : CTabCtrl() { m_curPage = 0; } void OdTabCtrl::addTabPage( const OdString& caption, CDialog* pDlg ) { if( !pDlg ) return; TC_ITEM tabCtrlItem; tabCtrlItem.mask = TCIF_TEXT; OdString str = caption; tabCtrlItem.pszText = str.getBuffer( caption.getLength() ); InsertItem( m_pages.size(), &tabCtrlItem ); m_pages.push_back( pDlg ); adjustTabPageSize( pDlg, m_pages.size() == 1 ); SetCurSel( 0 ); } void OdTabCtrl::adjustTabPageSize( CDialog* pDlg, bool bMakeVisible ) { CRect tabRect, itemRect; GetClientRect(&tabRect); GetItemRect(0, &itemRect); OdUInt32 nX, nY, nXc, nYc; nX=itemRect.left; nY=itemRect.bottom+1; nXc=tabRect.right-itemRect.left-1; nYc=tabRect.bottom-nY-1; pDlg->SetWindowPos( &wndTop, nX, nY, nXc, nYc, ( bMakeVisible ) ? SWP_SHOWWINDOW : SWP_HIDEWINDOW ); } void OdTabCtrl::showTab( OdUInt32 nTab ) { for( OdUInt32 i = 0; i < m_pages.size(); ++i ) { m_pages[ i ]->ShowWindow( ( i == nTab ) ? SW_SHOW : SW_HIDE ); } } void OdTabCtrl::OnSelChange(NMHDR* /*pNMHDR*/, LRESULT* pResult) { *pResult = 0; if (m_curPage == GetCurSel()) return; m_curPage = GetCurSel(); showTab( m_curPage ); } //Layout manager OdDialogLayoutManager::OdDialogLayoutManager() { m_pWnd = NULL; m_nWidth = 10; m_nHeight = 10; m_nOffset = 2; m_nCols = 0; m_nRows = 0; } void OdDialogLayoutManager::initBySize( CWnd* pWnd, OdUInt32 width, OdUInt32 height, OdUInt32 offset ) { m_pWnd = pWnd; m_nWidth = width; m_nHeight = height; m_nOffset = offset; CRect wndRect; m_pWnd->GetClientRect( &wndRect ); OdUInt32 w = m_nWidth + m_nOffset; m_nCols = wndRect.Width() / w; OdUInt32 h = m_nHeight + m_nOffset; m_nRows = wndRect.Height() / h; } bool OdDialogLayoutManager::placeItem( CRect* pRect, OdUInt32 nRow, OdUInt32 nCol, OdUInt32 numRow, OdUInt32 numCol ) { bool bRet = true; if( nRow >= numRows() || nCol >= numCols() ) bRet = false; if( nRow + numRow >= numRows() || nCol + numCol >= numCols() ) bRet = false; OdUInt32 w = m_nWidth + m_nOffset; OdUInt32 startX = m_nOffset + w * nCol; OdUInt32 h = m_nHeight + m_nOffset; OdUInt32 startY = m_nOffset + h * nRow; pRect->SetRect( startX + (m_nOffset / 2), startY + (m_nOffset / 2), startX + w * numCol - + (m_nOffset / 2), startY + h * numRow - + (m_nOffset / 2) ); return bRet; } //Tab page base class OdTabPage::OdTabPage( CWnd* pParent ) : CDialog( OdTabPage::IDD, pParent ) { } OdTabPage::~OdTabPage() { clearItems(); } void OdTabPage::registerItem( CWnd* pItem, bool bSetFont ) { m_items.push_back( pItem ); if( bSetFont ) { pItem->SetFont( GetFont(), TRUE ); } } void OdTabPage::clearItems() { for( OdUInt32 i = 0; i < m_items.size(); ++i ) { if( m_items[ i ]->m_hWnd ) { m_items[ i ]->DestroyWindow(); } delete m_items[ i ]; } m_items.clear(); } int OdTabPage::processScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar ) { int minpos, maxpos; CSliderCtrl *pSlider = reinterpret_cast(pScrollBar); pSlider->GetRange(minpos, maxpos); int curpos = pSlider->GetPos(); switch (nSBCode) { case SB_LEFT: curpos = minpos; break; case SB_RIGHT: curpos = maxpos; break; case SB_ENDSCROLL: break; case SB_LINELEFT: if (curpos > minpos) curpos--; break; case SB_LINERIGHT: if (curpos < maxpos) curpos++; break; case SB_PAGELEFT: { if (curpos > minpos) curpos = odmax(minpos, curpos - 10); } break; case SB_PAGERIGHT: { SCROLLINFO info; pScrollBar->GetScrollInfo(&info, SIF_ALL); if (curpos < maxpos) curpos = odmin(maxpos, curpos + 10); } break; case SB_THUMBPOSITION: curpos = nPos; break; case SB_THUMBTRACK: curpos = nPos; break; } return curpos; } //Tab pages BEGIN_MESSAGE_MAP(OdTabPage_Common, CDialog) ON_BN_CLICKED(OdTabPage_Common::DOUBLESIDED_CHECK, OnDoubleSidedClicked) END_MESSAGE_MAP() OdTabPage_Common::OdTabPage_Common( CWnd* pParent ) : OdTabPage( pParent ) { } void OdTabPage_Common::setupPage() { OdDialogLayoutManager manager; manager.initBySize( this ); CStatic* sName = new CStatic; CRect rc; manager.placeItem( &rc, 0, 0, 1, 4 ); sName->Create( L"Name:", WS_CHILD | WS_VISIBLE, rc, this ); registerItem( sName ); m_nameWnd = new CStatic(); manager.placeItem( &rc, 0, 5, 1, 17 ); m_nameWnd->Create( L"", WS_CHILD | WS_VISIBLE | SS_SUNKEN, rc, this, 0 ); registerItem( m_nameWnd ); CStatic* sDescr = new CStatic; manager.placeItem( &rc, 1, 0, 1, 4 ); sDescr->Create( L"Description:", WS_CHILD | WS_VISIBLE, rc, this ); registerItem( sDescr ); m_descrWnd = new CStatic(); manager.placeItem( &rc, 1, 5, 1, 17 ); m_descrWnd->Create( L"", WS_CHILD | WS_VISIBLE | SS_SUNKEN, rc, this, 0 ); registerItem( m_descrWnd ); m_checkBtn = new CButton; manager.placeItem( &rc, 2, 0, 1, 4 ); m_checkBtn->Create( L"2-Sided", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, rc, this, DOUBLESIDED_CHECK ); registerItem( m_checkBtn ); } void OdTabPage_Common::enablePage( BOOL bEnable ) { m_nameWnd->EnableWindow( bEnable ); m_descrWnd->EnableWindow( bEnable ); m_checkBtn->EnableWindow( bEnable ); } bool OdTabPage_Common::getDoubleSided() { return m_checkBtn->GetCheck() == BST_CHECKED; } void OdTabPage_Common::setDoubleSided( bool b ) { m_checkBtn->SetCheck( b ? BST_CHECKED : BST_UNCHECKED ); } void OdTabPage_Common::setName( const OdString& str ) { OdString s = str; m_nameWnd->SetWindowText( s.getBuffer( s.getLength() ) ); } void OdTabPage_Common::setDescription( const OdString& str ) { OdString s = str; m_descrWnd->SetWindowText( s.getBuffer( s.getLength() ) ); } void OdTabPage_Common::OnDoubleSidedClicked() { PostMessage( OdTabPage::MESSAGE_ID, MAKEWPARAM( DOUBLESIDED_CHECK, BN_CLICKED ), 0 ); } OdTabPage_Channel::OdTabPage_Channel( CWnd* pParent ) : OdTabPage( pParent ) { m_elements = 0; m_nSliders = 0; m_colorDescr.m_caption = OdString::kEmpty; m_colorDescr.m_message = 0; m_colorDescr.m_pCaptionWnd = NULL; m_colorDescr.m_ownWnd = NULL; m_colorDescr.m_extWnd = NULL; m_colorDescr.m_curPos = 0; m_texturePreviewDescr.m_caption = OdString::kEmpty; m_texturePreviewDescr.m_message = 0; m_texturePreviewDescr.m_pCaptionWnd = NULL; m_texturePreviewDescr.m_ownWnd = NULL; m_texturePreviewDescr.m_extWnd = NULL; m_texturePreviewDescr.m_curPos = 0; } BEGIN_MESSAGE_MAP(OdTabPage_Channel, CDialog) ON_WM_HSCROLL() ON_BN_CLICKED(OdTabPage_Channel::kMessageColorButtonPressed, &OdTabPage_Channel::OnColorButtonClicked) ON_BN_CLICKED(OdTabPage_Channel::kMessagePreviewButtonPressed, &OdTabPage_Channel::OnPreviewButtonClicked) ON_BN_CLICKED(OdTabPage_Channel::kMessageCheckboxPressed, &OdTabPage_Channel::OnCheckboxClicked) END_MESSAGE_MAP() void OdTabPage_Channel::initPage( OdUInt8 elements, OdUInt8 nSliders ) { m_elements = elements; m_nSliders = nSliders; if( hasSlider() ) { m_sliders.resize( m_nSliders ); for( OdUInt8 i = 0; i < m_nSliders; ++i ) { m_sliders[ i ].m_caption = OdString::kEmpty; m_sliders[ i ].m_message = 0; m_sliders[ i ].m_pCaptionWnd = NULL; m_sliders[ i ].m_ownWnd = NULL; m_sliders[ i ].m_extWnd = NULL; m_sliders[ i ].m_curPos = 0; } } } void OdTabPage_Channel::setupSliderElement( const OdString& str, OdUInt16 message, OdUInt8 index ) { if( !hasSlider() || index >= numSliders() ) return; m_sliders[ index ].m_caption = str; m_sliders[ index ].m_message = message; } void OdTabPage_Channel::setupPage() { OdDialogLayoutManager manager; manager.initBySize( this ); CRect rc; OdUInt32 nRow = 0; if( hasColor() ) { CStatic* s = new CStatic; manager.placeItem( &rc, nRow, 0, 1, 4 ); s->Create( m_colorDescr.m_caption.c_str(), WS_CHILD | WS_VISIBLE, rc, this ); registerItem( s ); m_colorDescr.m_pCaptionWnd = s; CCmEntityColorPreview* pColorPrev = new CCmEntityColorPreview; manager.placeItem( &rc, nRow, 5, 1, 6 ); pColorPrev->Create( L"", WS_CHILD | WS_VISIBLE | SS_SUNKEN, rc, this ); pColorPrev->SetWindowPos( NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_SHOWWINDOW ); registerItem( pColorPrev ); m_colorDescr.m_extWnd = pColorPrev; CButton* pBtn = new CButton; manager.placeItem( &rc, nRow, 11, 1, 2 ); pBtn->Create( L"...", WS_CHILD | WS_VISIBLE, rc, this, kMessageColorButtonPressed ); registerItem( pBtn ); m_colorDescr.m_ownWnd = pBtn; nRow++; } if( hasSlider() ) { for( OdUInt8 i = 0; i < numSliders(); ++i ) { CStatic *s1 = new CStatic; manager.placeItem( &rc, nRow, 0, 1, 4 ); s1->Create( m_sliders[ i ].m_caption.c_str(), WS_CHILD | WS_VISIBLE, rc, this ); registerItem( s1 ); m_sliders[ i ].m_pCaptionWnd = s1; CSliderCtrl* pSlider = new CSliderCtrl; manager.placeItem( &rc, nRow, 5, 1, 8 ); pSlider->Create( TBS_BOTH | TBS_NOTICKS | WS_CHILD | WS_VISIBLE, rc, this, m_sliders[ i ].m_message ); pSlider->SetRange( 0, 100 ); registerItem( pSlider ); m_sliders[ i ].m_ownWnd = pSlider; nRow++; } } if( hasPreview() ) { CStatic* s2 = new CStatic; manager.placeItem( &rc, 0, 13, 1, 3 ); s2->Create( OD_T("Texture:"), WS_CHILD | WS_VISIBLE, rc, this ); registerItem( s2 ); CStatic* nameWnd = new CStatic(); manager.placeItem( &rc, 0, 16, 1, 6 ); nameWnd->Create( L"", WS_CHILD | WS_VISIBLE | SS_SUNKEN, rc, this, 0 ); registerItem( nameWnd ); m_texturePreviewDescr.m_pCaptionWnd = nameWnd; CPreviewGiRasterImage* pImg = new CPreviewGiRasterImage; manager.placeItem( &rc, 1, 13, 6, 9 ); pImg->Create( L"", WS_CHILD | WS_VISIBLE | SS_SUNKEN, rc, this ); registerItem( pImg ); m_texturePreviewDescr.m_extWnd = pImg; CButton* pBtn = new CButton; manager.placeItem( &rc, 7, 14, 1, 7 ); pBtn->Create( L"...", WS_CHILD | WS_VISIBLE, rc, this, kMessagePreviewButtonPressed ); registerItem( pBtn ); m_texturePreviewDescr.m_ownWnd = pBtn; pBtn->EnableWindow( FALSE ); } if( hasCheckbox() ) { CButton* pBtn = new CButton; manager.placeItem( &rc, nRow, 0, 1, 4 ); pBtn->Create( m_checkboxDescr.m_caption.c_str(), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, rc, this, kMessageCheckboxPressed ); registerItem( pBtn ); m_checkboxDescr.m_ownWnd = pBtn; } } void OdTabPage_Channel::enablePage( BOOL bEnable ) { if( hasColor() ) { m_colorDescr.m_extWnd->EnableWindow( bEnable ); m_colorDescr.m_ownWnd->EnableWindow( bEnable ); } if( hasSlider() ) { for( OdUInt8 i = 0; i < numSliders(); ++i ) { m_sliders[ i ].m_ownWnd->EnableWindow( bEnable ); } } if( hasPreview() ) { m_texturePreviewDescr.m_ownWnd->EnableWindow( bEnable ); } if( hasCheckbox() ) { m_checkboxDescr.m_ownWnd->EnableWindow( bEnable ); } } void OdTabPage_Channel::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int curpos = processScroll( nSBCode, nPos, pScrollBar ); if( hasSlider() && nSBCode != SB_ENDSCROLL ) { for( OdUInt8 i = 0; i < numSliders(); ++i ) { if( m_sliders[ i ].m_ownWnd->m_hWnd == pScrollBar->m_hWnd ) { m_sliders[ i ].m_curPos = curpos; PostMessage( OdTabPage::MESSAGE_ID, MAKEWPARAM( m_sliders[ i ].m_message, BN_CLICKED ), 0 ); break; } } } CDialog::OnHScroll(nSBCode, nPos, pScrollBar); } void OdTabPage_Channel::OnColorButtonClicked() { if( !hasColor() ) return; PostMessage( OdTabPage::MESSAGE_ID, MAKEWPARAM( m_colorDescr.m_message, BN_CLICKED ), 0 ); } void OdTabPage_Channel::OnPreviewButtonClicked() { if( !hasPreview() ) return; PostMessage( OdTabPage::MESSAGE_ID, MAKEWPARAM( m_texturePreviewDescr.m_message, BN_CLICKED ), 0 ); } void OdTabPage_Channel::OnCheckboxClicked() { if( !hasCheckbox() ) return; PostMessage( OdTabPage::MESSAGE_ID, MAKEWPARAM( m_checkboxDescr.m_message, BN_CLICKED ), 0 ); } COLORREF OdTabPage_Channel::getColor() { if( !hasColor() ) return 0; CCmEntityColorPreview* pClr = (CCmEntityColorPreview*)m_colorDescr.m_extWnd; return pClr->GetCref(); } void OdTabPage_Channel::setColor( const OdCmEntityColor& cl ) { if( !hasColor() ) return; CCmEntityColorPreview* pClr = (CCmEntityColorPreview*)m_colorDescr.m_extWnd; pClr->SetColor( cl ); } void OdTabPage_Channel::setSliderValue( int value, OdUInt8 index ) { if( !hasSlider() || index >= numSliders() ) return; CSliderCtrl* pSlider = (CSliderCtrl*)(m_sliders[ index ].m_ownWnd); pSlider->SetPos( value ); m_sliders[ index ].m_curPos = value; } int OdTabPage_Channel::getSliderValue( OdUInt8 index ) { if( !hasSlider() || index >= numSliders() ) return 0; return m_sliders[ index ].m_curPos; } void OdTabPage_Channel::setTexturePreview( OdGiMaterialMap& matMap, const OdGiContext* pCtx ) { if( !hasPreview() ) return; CPreviewGiRasterImage* pImgWnd = (CPreviewGiRasterImage*)(m_texturePreviewDescr.m_extWnd); pImgWnd->SetImage( NULL ); if( matMap.source() == OdGiMaterialMap::kFile && !matMap.sourceFileName().isEmpty() || matMap.source() == OdGiMaterialMap::kProcedural && !matMap.texture().isNull() ) { if( matMap.source() == OdGiMaterialMap::kProcedural ) m_texturePreviewDescr.m_pCaptionWnd->SetWindowText( matMap.texture()->isA()->name() ); else m_texturePreviewDescr.m_pCaptionWnd->SetWindowText( matMap.sourceFileName() ); OdGiMaterialTextureEntryPtr pEntry = OdGiMaterialTextureEntry::createObject(); OdGiMaterialTextureData::DevDataVariant devData; if( matMap.source() == OdGiMaterialMap::kProcedural ) pEntry->setGiMaterialTexture( devData, OdGiMaterialTextureData::defaultTextureDataImplementationDesc(), *pCtx, matMap.texture() ); else pEntry->setGiMaterialTexture( devData, OdGiMaterialTextureData::defaultTextureDataImplementationDesc(), *pCtx, matMap.sourceFileName() ); OdGiMaterialTextureDataPtr pTexData = pEntry->textureData(); if( !pTexData.isNull() ) { OdUInt32 w, h; OdGiPixelBGRA32Array pixels; pTexData->textureData( pixels, w, h ); OdGiImageBGRA32 img( w, h, pixels.asArrayPtr() ); m_pCachedImage = OdGiRasterImageBGRA32Copy::createObject( &img ); if( !m_pCachedImage.isNull() ) { pImgWnd->SetImage( m_pCachedImage ); } } } else { m_texturePreviewDescr.m_pCaptionWnd->SetWindowText( L"None" ); pImgWnd->SetImage( NULL ); } } void OdTabPage_Channel::setCheckboxChecked( bool b ) { if( !hasCheckbox() ) return; CButton* pCheck = (CButton*)( m_checkboxDescr.m_ownWnd ); pCheck->SetCheck( b ? BST_CHECKED : BST_UNCHECKED ); } bool OdTabPage_Channel::isCheckboxChecked() { if( !hasCheckbox() ) return false; CButton* pCheck = (CButton*)( m_checkboxDescr.m_ownWnd ); return pCheck->GetCheck() == BST_CHECKED; } CTextureOptionsDialog::CTextureOptionsDialog( const OdGiMaterialMap& matMap, const OdGiContext* pCtx, CWnd* pParent ) : CDialog( CTextureOptionsDialog::IDD, pParent ) { m_map = matMap; m_pCtx = pCtx; m_bHasChanges = false; } BEGIN_MESSAGE_MAP(CTextureOptionsDialog, CDialog) ON_BN_CLICKED(IDC_TRANSFORM_APPLY_BTN, &CTextureOptionsDialog::OnBnClickedApplyTransform) ON_BN_CLICKED(IDC_TEXTURE_PATH_BTN, &CTextureOptionsDialog::OnTexturePathClicked) ON_CBN_SELCHANGE(IDC_COMBO_H_TILING,&CTextureOptionsDialog::OnCbnSelchangeComboHTiling) ON_CBN_SELCHANGE(IDC_COMBO_V_TILING,&CTextureOptionsDialog::OnCbnSelchangeComboVTiling) END_MESSAGE_MAP() BOOL CTextureOptionsDialog::OnInitDialog() { CDialog::OnInitDialog(); m_imgPreview.SubclassDlgItem( IDC_TEXTURE_PREVIEW, this ); fillMatrix(); CComboBox* cb = (CComboBox*)GetDlgItem( IDC_COMBO_H_TILING ); cb->AddString( L"InheritTiling" ); cb->AddString( L"Tile" ); cb->AddString( L"Crop" ); cb->AddString( L"Clamp" ); cb->AddString( L"Mirror" ); cb->SetCurSel( (int)(m_map.mapper().uTiling()) ); cb = (CComboBox*)GetDlgItem( IDC_COMBO_V_TILING ); cb->AddString( L"InheritTiling" ); cb->AddString( L"Tile" ); cb->AddString( L"Crop" ); cb->AddString( L"Clamp" ); cb->AddString( L"Mirror" ); cb->SetCurSel( (int)(m_map.mapper().vTiling()) ); BOOL b = updatePreview(); enableItems( b ); return TRUE; } void CTextureOptionsDialog::SetDlgItemFloat(int nId, double nVal) { SetDlgItemText(nId, OdString().format(OD_T("%.2f"), nVal).c_str()); } double CTextureOptionsDialog::GetDlgItemFloat(int nId) { CString cs; GetDlgItemText(nId, cs); return odStrToF(cs); } void CTextureOptionsDialog::fillMatrix() { OdGeMatrix3d m = m_map.mapper().transform(); SetDlgItemFloat( IDC_EDIT_TR00, m.entry[0][0] ); SetDlgItemFloat( IDC_EDIT_TR01, m.entry[0][1] ); SetDlgItemFloat( IDC_EDIT_TR02, m.entry[0][2] ); SetDlgItemFloat( IDC_EDIT_TR03, m.entry[0][3] ); SetDlgItemFloat( IDC_EDIT_TR10, m.entry[1][0] ); SetDlgItemFloat( IDC_EDIT_TR11, m.entry[1][1] ); SetDlgItemFloat( IDC_EDIT_TR12, m.entry[1][2] ); SetDlgItemFloat( IDC_EDIT_TR13, m.entry[1][3] ); SetDlgItemFloat( IDC_EDIT_TR20, m.entry[2][0] ); SetDlgItemFloat( IDC_EDIT_TR21, m.entry[2][1] ); SetDlgItemFloat( IDC_EDIT_TR22, m.entry[2][2] ); SetDlgItemFloat( IDC_EDIT_TR23, m.entry[2][3] ); SetDlgItemFloat( IDC_EDIT_TR30, m.entry[3][0] ); SetDlgItemFloat( IDC_EDIT_TR31, m.entry[3][1] ); SetDlgItemFloat( IDC_EDIT_TR32, m.entry[3][2] ); SetDlgItemFloat( IDC_EDIT_TR33, m.entry[3][3] ); } OdGeMatrix3d CTextureOptionsDialog::readMatrix() { OdGeMatrix3d m; m.entry[0][0] = GetDlgItemFloat( IDC_EDIT_TR00 ); m.entry[0][1] = GetDlgItemFloat( IDC_EDIT_TR01 ); m.entry[0][2] = GetDlgItemFloat( IDC_EDIT_TR02 ); m.entry[0][3] = GetDlgItemFloat( IDC_EDIT_TR03 ); m.entry[1][0] = GetDlgItemFloat( IDC_EDIT_TR10 ); m.entry[1][1] = GetDlgItemFloat( IDC_EDIT_TR11 ); m.entry[1][2] = GetDlgItemFloat( IDC_EDIT_TR12 ); m.entry[1][3] = GetDlgItemFloat( IDC_EDIT_TR13 ); m.entry[2][0] = GetDlgItemFloat( IDC_EDIT_TR20 ); m.entry[2][1] = GetDlgItemFloat( IDC_EDIT_TR21 ); m.entry[2][2] = GetDlgItemFloat( IDC_EDIT_TR22 ); m.entry[2][3] = GetDlgItemFloat( IDC_EDIT_TR23 ); m.entry[3][0] = GetDlgItemFloat( IDC_EDIT_TR30 ); m.entry[3][1] = GetDlgItemFloat( IDC_EDIT_TR31 ); m.entry[3][2] = GetDlgItemFloat( IDC_EDIT_TR32 ); m.entry[3][3] = GetDlgItemFloat( IDC_EDIT_TR33 ); return m; } void CTextureOptionsDialog::OnBnClickedApplyTransform() { m_bHasChanges = true; OdGeMatrix3d m = readMatrix(); m_map.mapper().setTransform( m ); } void CTextureOptionsDialog::OnCbnSelchangeComboHTiling() { CComboBox* cb = (CComboBox*)GetDlgItem( IDC_COMBO_H_TILING ); OdGiMapper::Tiling t = ( OdGiMapper::Tiling )( cb->GetCurSel() ); if( t != m_map.mapper().uTiling() ) { m_bHasChanges = true; m_map.mapper().setUTiling( t ); } } void CTextureOptionsDialog::OnCbnSelchangeComboVTiling() { CComboBox* cb = (CComboBox*)GetDlgItem( IDC_COMBO_V_TILING ); OdGiMapper::Tiling t = ( OdGiMapper::Tiling )( cb->GetCurSel() ); if( t != m_map.mapper().vTiling() ) { m_bHasChanges = true; m_map.mapper().setVTiling( t ); } } BOOL CTextureOptionsDialog::updatePreview() { m_imgPreview.SetImage( NULL ); if( m_map.source() == OdGiMaterialMap::kFile && !m_map.sourceFileName().isEmpty() || m_map.source() == OdGiMaterialMap::kProcedural && !m_map.texture().isNull() ) { if( m_map.source() == OdGiMaterialMap::kProcedural ) { SetDlgItemText( IDC_TEXTURE_PATH, m_map.texture()->isA()->name() ); } else { SetDlgItemText( IDC_TEXTURE_PATH, m_map.sourceFileName() ); } OdGiMaterialTextureEntryPtr pEntry = OdGiMaterialTextureEntry::createObject(); OdGiMaterialTextureData::DevDataVariant devData; if( m_map.source() == OdGiMaterialMap::kProcedural ) pEntry->setGiMaterialTexture( devData, OdGiMaterialTextureData::defaultTextureDataImplementationDesc(), *m_pCtx, m_map.texture() ); else pEntry->setGiMaterialTexture( devData, OdGiMaterialTextureData::defaultTextureDataImplementationDesc(), *m_pCtx, m_map.sourceFileName() ); OdGiMaterialTextureDataPtr pTexData = pEntry->textureData(); if( !pTexData.isNull() ) { OdUInt32 w, h; OdGiPixelBGRA32Array pixels; pTexData->textureData( pixels, w, h ); OdGiImageBGRA32 img( w, h, pixels.asArrayPtr() ); m_pImage = OdGiRasterImageBGRA32Copy::createObject( &img ); if( !m_pImage.isNull() && w > 0 && h > 0 ) { m_imgPreview.SetImage( m_pImage ); } return TRUE; } } else { SetDlgItemText( IDC_TEXTURE_PATH, L"None" ); } return FALSE; } void CTextureOptionsDialog::enableItems( BOOL bEnable ) { GetDlgItem( IDC_EDIT_TR00 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR01 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR02 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR03 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR10 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR11 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR12 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR13 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR20 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR21 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR22 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR23 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR30 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR31 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR32 )->EnableWindow( bEnable ); GetDlgItem( IDC_EDIT_TR33 )->EnableWindow( bEnable ); GetDlgItem( IDC_TRANSFORM_APPLY_BTN )->EnableWindow( bEnable ); GetDlgItem( IDC_COMBO_H_TILING )->EnableWindow( bEnable ); GetDlgItem( IDC_COMBO_V_TILING )->EnableWindow( bEnable ); } void CTextureOptionsDialog::OnTexturePathClicked() { CString csImagePath; GetDlgItemText(IDC_TEXTURE_PATH, csImagePath); CFileDialog openFile(true, _T("png"), csImagePath, OFN_PATHMUSTEXIST, _T("Windows Bitmap (*.bmp)|*.bmp|") _T("JPEG Images (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|TARGA Images (*.tga)|*.tga|All Files (*.*)|*.*||"), this); if (openFile.DoModal() == IDOK) { //SetDlgItemText(IDC_TEXTURE_PATH, openFile.GetPathName()); //UpdateEnvImage(); csImagePath = openFile.GetPathName(); m_map.setSource( OdGiMaterialMap::kFile ); m_map.setSourceFileName( csImagePath.GetBuffer() ); csImagePath.ReleaseBuffer(); BOOL b = updatePreview(); enableItems( b ); m_bHasChanges = true; } } //Material editor CDbMaterialsDlg::CDbMaterialsDlg(OdDbDatabase* pDb, CWnd* pParent /*=NULL*/) : CDialog(CDbMaterialsDlg::IDD, pParent) , m_Material(pDb) , m_pDb(pDb) , m_bChanged(false) { //{{AFX_DATA_INIT(CDbMaterialsDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CDbMaterialsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDbMaterialsDlg) DDX_Control(pDX, IDC_LBMATERIALS, m_MaterialsList); DDX_Control(pDX, IDC_SPREVIEW, m_Material); DDX_Control(pDX, IDC_CBDEVICE, m_Device); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDbMaterialsDlg, CDialog) //{{AFX_MSG_MAP(CDbMaterialsDlg) //}}AFX_MSG_MAP ON_LBN_SELCHANGE(IDC_LBMATERIALS, &CDbMaterialsDlg::OnLbnSelchangeLbmaterials) ON_CBN_SELCHANGE(IDC_CBDEVICE, &CDbMaterialsDlg::OnCbnSelchangeCbdevice) ON_BN_CLICKED(IDC_CBDIAGBKGND, &CDbMaterialsDlg::OnBnClickedCbdiagbkgnd) ON_BN_CLICKED(IDC_BFBX, &CDbMaterialsDlg::OnBnClickedExtractFbx) ON_WM_HSCROLL() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDbMaterialsDlg message handlers BOOL CDbMaterialsDlg::OnInitDialog() { CDialog::OnInitDialog(); if (m_pDb) { OdDbDictionaryPtr pMtls = OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().safeOpenObject()); OdDbDictionaryIteratorPtr pIt = pMtls->newIterator(); while (!pIt->done()) { m_MaterialsList.AddString(pIt->name().c_str()); pIt->next(); } } CRect rc; rc.SetRect( 7, 270, 7+450, 270 + 165 ); m_tabCtrl.Create( TCS_TABS | WS_VISIBLE | WS_CHILD, rc, this, TabCtrlIDD ); m_tabCtrl.SetFont( GetFont(), TRUE ); m_commonPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_commonPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Common"), &m_commonPage ); m_commonPage.setupPage(); m_ambientPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_ambientPage.initPage( OdTabPage_Channel::kElementColor ); m_ambientPage.setupColorElement( OdString( OD_T("Ambient color:") ), MESSAGE_AMBIENTCOLOR_BTN ); m_ambientPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Ambient"), &m_ambientPage ); m_ambientPage.setupPage(); m_diffusePage.Create( OdTabPage::IDD, &m_tabCtrl ); m_diffusePage.initPage( OdTabPage_Channel::kElementAll ); m_diffusePage.setupColorElement( OdString( OD_T("Diffuse color:") ), MESSAGE_DIFFUSECOLOR_BTN ); m_diffusePage.setupSliderElement( OdString( OD_T("Blend factor:") ), MESSAGE_DIFFUSE_BLEND ); m_diffusePage.setupTexturePreview( MESSAGE_DIFFUSE_PREVIEW ); m_diffusePage.setupCheckbox( OdString( OD_T("Enabled") ), MESSAGE_DIFFUSE_CHECK ); m_diffusePage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Diffuse"), &m_diffusePage ); m_diffusePage.setupPage(); m_specularPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_specularPage.initPage( OdTabPage_Channel::kElementAll, 2 ); m_specularPage.setupColorElement( OdString( OD_T("Specular color:") ), MESSAGE_SPECULARCOLOR_BTN ); m_specularPage.setupSliderElement( OdString( OD_T("Gloss:") ), MESSAGE_SPECULARCOLOR_GLOSS ); m_specularPage.setupSliderElement( OdString( OD_T("Blend factor:") ), MESSAGE_SPECULAR_BLEND, 1 ); m_specularPage.setupTexturePreview( MESSAGE_SPECULAR_PREVIEW ); m_specularPage.setupCheckbox( OdString( OD_T("Enabled") ), MESSAGE_SPECULAR_CHECK ); m_specularPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Specular"), &m_specularPage ); m_specularPage.setupPage(); m_opacityPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_opacityPage.initPage( OdTabPage_Channel::kElementSliderPreviewCheckbox, 3 ); m_opacityPage.setupSliderElement( OdString( OD_T("Opacity:") ), MESSAGE_OPACITY_OPACITY ); m_opacityPage.setupSliderElement( OdString( OD_T("Blend factor:") ), MESSAGE_OPACITY_BLEND, 1 ); m_opacityPage.setupSliderElement( OdString( OD_T("Translucence:") ), MESSAGE_OPACITY_TRANSLUCENCE, 2 ); m_opacityPage.setupTexturePreview( MESSAGE_OPACITY_PREVIEW ); m_opacityPage.setupCheckbox( OdString( OD_T("Enabled") ), MESSAGE_OPACITY_CHECK ); m_opacityPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Opacity"), &m_opacityPage ); m_opacityPage.setupPage(); m_reflectionPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_reflectionPage.initPage( OdTabPage_Channel::kElementSliderPreviewCheckbox, 2 ); m_reflectionPage.setupSliderElement( OdString( OD_T("Reflectivity:") ), MESSAGE_REFLECTION_REFLECTIVITY ); m_reflectionPage.setupSliderElement( OdString( OD_T("Blend factor:") ), MESSAGE_REFLECTION_BLEND, 1 ); m_reflectionPage.setupTexturePreview( MESSAGE_REFLECTION_PREVIEW ); m_reflectionPage.setupCheckbox( OdString( OD_T("Enabled") ), MESSAGE_REFLECTION_CHECK ); m_reflectionPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Reflection"), &m_reflectionPage ); m_reflectionPage.setupPage(); m_refractionPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_refractionPage.initPage( OdTabPage_Channel::kElementSliderPreviewCheckbox, 2 ); m_refractionPage.setupSliderElement( OdString( OD_T("Index:") ), MESSAGE_REFRACTION_INDEX ); m_refractionPage.setupSliderElement( OdString( OD_T("Blend factor:") ), MESSAGE_REFRACTION_BLEND, 1 ); m_refractionPage.setupTexturePreview( MESSAGE_REFRACTION_PREVIEW ); m_refractionPage.setupCheckbox( OdString( OD_T("Enabled") ), MESSAGE_REFRACTION_CHECK ); m_refractionPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Refraction"), &m_refractionPage ); m_refractionPage.setupPage(); m_bumpPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_bumpPage.initPage( OdTabPage_Channel::kElementSliderPreviewCheckbox, 2 ); m_bumpPage.setupSliderElement( OdString( OD_T("Bump scale:") ), MESSAGE_BUMP_SCALE ); m_bumpPage.setupSliderElement( OdString( OD_T("Blend factor:") ), MESSAGE_BUMP_BLEND, 1 ); m_bumpPage.setupTexturePreview( MESSAGE_BUMP_PREVIEW ); m_bumpPage.setupCheckbox( OdString( OD_T("Enabled") ), MESSAGE_BUMP_CHECK ); m_bumpPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Bump"), &m_bumpPage ); m_bumpPage.setupPage(); m_normalMapPage.Create( OdTabPage::IDD, &m_tabCtrl ); m_normalMapPage.initPage( OdTabPage_Channel::kElementSliderPreviewCheckbox, 2 ); m_normalMapPage.setupSliderElement( OdString( OD_T("Strength:") ), MESSAGE_NORMALMAP_STRENGTH ); m_normalMapPage.setupSliderElement( OdString( OD_T("Blend factor:") ), MESSAGE_NORMALMAP_BLEND, 1 ); m_normalMapPage.setupTexturePreview( MESSAGE_NORMALMAP_PREVIEW ); m_normalMapPage.setupCheckbox( OdString( OD_T("Enabled") ), MESSAGE_NORMALMAP_CHECK ); m_normalMapPage.SetFont( GetFont(), TRUE ); m_tabCtrl.addTabPage( OD_T("Normal map"), &m_normalMapPage ); m_normalMapPage.setupPage(); m_Device.AddString(OdWinOpenGLModuleName); m_Device.AddString(OdWinDirectXModuleName); m_Device.AddString(OdWinGLES2ModuleName); m_Device.AddString(_T("WinOpenRL.txv")); m_Device.SelectString(0, OdWinOpenGLModuleName); UpdateMaterial(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } BOOL CDbMaterialsDlg::PreTranslateMessage( MSG* pMsg ) { if( pMsg->message == OdTabPage::MESSAGE_ID ) { UINT low = LOWORD( pMsg->wParam );//& 0xFFFF; switch( low ) { case MESSAGE_AMBIENTCOLOR_BTN: OnBnClickedBambient(); break; case MESSAGE_DIFFUSECOLOR_BTN: OnBnClickedBdiffuse(); break; case MESSAGE_SPECULARCOLOR_BTN: OnBnClickedBspecular(); break; case OdTabPage_Common::DOUBLESIDED_CHECK: OnBnClickedCheck2(); break; case MESSAGE_SPECULARCOLOR_GLOSS: case MESSAGE_OPACITY_OPACITY: case MESSAGE_REFLECTION_REFLECTIVITY: case MESSAGE_DIFFUSE_BLEND: case MESSAGE_SPECULAR_BLEND: case MESSAGE_OPACITY_BLEND: case MESSAGE_REFLECTION_BLEND: case MESSAGE_OPACITY_TRANSLUCENCE: case MESSAGE_REFRACTION_INDEX: case MESSAGE_REFRACTION_BLEND: case MESSAGE_BUMP_SCALE: case MESSAGE_BUMP_BLEND: case MESSAGE_NORMALMAP_STRENGTH: case MESSAGE_NORMALMAP_BLEND: OnSliderChanged( low ); break; case MESSAGE_DIFFUSE_PREVIEW: case MESSAGE_SPECULAR_PREVIEW: case MESSAGE_OPACITY_PREVIEW: case MESSAGE_REFLECTION_PREVIEW: case MESSAGE_REFRACTION_PREVIEW: case MESSAGE_BUMP_PREVIEW: case MESSAGE_NORMALMAP_PREVIEW: OnPreviewClicked( low ); break; case MESSAGE_DIFFUSE_CHECK: case MESSAGE_SPECULAR_CHECK: case MESSAGE_OPACITY_CHECK: case MESSAGE_REFLECTION_CHECK: case MESSAGE_REFRACTION_CHECK: case MESSAGE_BUMP_CHECK: case MESSAGE_NORMALMAP_CHECK: OnEnableCheckboxClicked( low ); break; } return 1; } return CDialog::PreTranslateMessage( pMsg ); } void CDbMaterialsDlg::CheckChanges() { if (m_bChanged) { if (MessageBox(_T("Material was changed.\nWould you like to apply changes in database?"), _T("Material Modified"), MB_ICONQUESTION | MB_YESNO) == IDYES) { OdDbMaterialPtr pMtlFrom = m_Material.GetMaterial().openObject()->clone(); OdDbMaterialPtr pMtlTo = OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().openObject())->getAt(pMtlFrom->description(), OdDb::kForWrite); pMtlFrom->setName(pMtlTo->name()); pMtlFrom->setDescription(pMtlTo->description()); pMtlTo->handOverTo(pMtlFrom); } m_bChanged = false; } } void CDbMaterialsDlg::UpdateMaterial() { int nItem = m_MaterialsList.GetCurSel(); if (nItem == -1) { m_commonPage.enablePage( FALSE ); m_ambientPage.enablePage( FALSE ); m_diffusePage.enablePage( FALSE ); m_specularPage.enablePage( FALSE ); m_opacityPage.enablePage( FALSE ); m_reflectionPage.enablePage( FALSE ); m_refractionPage.enablePage( FALSE ); m_bumpPage.enablePage( FALSE ); m_normalMapPage.enablePage( FALSE ); GetDlgItem(IDC_BFBX)->EnableWindow(FALSE); } else { CheckChanges(); m_commonPage.enablePage( TRUE ); m_ambientPage.enablePage( TRUE ); m_diffusePage.enablePage( TRUE ); m_specularPage.enablePage( TRUE ); m_opacityPage.enablePage( TRUE ); m_reflectionPage.enablePage( TRUE ); m_refractionPage.enablePage( TRUE ); m_bumpPage.enablePage( TRUE ); m_normalMapPage.enablePage( TRUE ); // init preview CString mtlName; m_MaterialsList.GetText(nItem, mtlName); OdDbMaterialPtr pMtl = OdDbMaterial::cast(OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().openObject())->getAt(mtlName.GetBuffer(), OdDb::kForRead)); m_Material.SetMaterial(pMtl->id()); // init properties { // ambient color OdGiMaterialColor ambColor; pMtl->ambient(ambColor); m_ambientPage.setColor( ambColor.color() ); } { // 2-sided m_commonPage.setDoubleSided( pMtl->twoSided() ); } { // diffuse color OdGiMaterialColor difColor; OdGiMaterialMap difMap; pMtl->diffuse(difColor, difMap); m_diffusePage.setColor( difColor.color() ); m_diffusePage.setSliderValue( (int)( difMap.blendFactor() * 100 ) ); m_diffusePage.setTexturePreview( difMap, m_Material.giContext() ); m_diffusePage.setCheckboxChecked( (pMtl->channelFlags() & OdGiMaterialTraits::kUseDiffuse) != 0 ); } { // specular color OdGiMaterialColor specColor; OdGiMaterialMap specMap; double glossFac; pMtl->specular(specColor, specMap, glossFac); m_specularPage.setColor( specColor.color() ); m_specularPage.setSliderValue( (int)(glossFac * 100) ); m_specularPage.setSliderValue( (int)( specMap.blendFactor() * 100 ), 1 ); m_specularPage.setTexturePreview( specMap, m_Material.giContext() ); m_specularPage.setCheckboxChecked( (pMtl->channelFlags() & OdGiMaterialTraits::kUseSpecular) != 0 ); } { // opacity OdGiMaterialMap opacityMap; double opacityPerc; pMtl->opacity(opacityPerc, opacityMap); m_opacityPage.setSliderValue( (int)(opacityPerc * 100) ); m_opacityPage.setSliderValue( (int)( opacityMap.blendFactor() * 100 ), 1 ); m_opacityPage.setSliderValue( (int)( pMtl->translucence() * 100 ), 2 ); m_opacityPage.setTexturePreview( opacityMap, m_Material.giContext() ); m_opacityPage.setCheckboxChecked( (pMtl->channelFlags() & OdGiMaterialTraits::kUseOpacity) != 0 ); } { // reflection OdGiMaterialMap reflMap; pMtl->reflection( reflMap ); m_reflectionPage.setTexturePreview( reflMap, m_Material.giContext() ); m_reflectionPage.setSliderValue( (int)( pMtl->reflectivity() * 100 ) ); m_reflectionPage.setSliderValue( (int)(reflMap.blendFactor() * 100 ), 1 ); m_reflectionPage.setCheckboxChecked( (pMtl->channelFlags() & OdGiMaterialTraits::kUseReflection) != 0 ); } { //refraction OdGiMaterialMap refrMap; double refrIndex; pMtl->refraction( refrIndex, refrMap ); m_refractionPage.setTexturePreview( refrMap, m_Material.giContext() ); m_refractionPage.setSliderValue( (int)( refrIndex * 100 ) ); m_refractionPage.setSliderValue( (int)( refrMap.blendFactor() * 100 ), 1 ); m_refractionPage.setCheckboxChecked( (pMtl->channelFlags() & OdGiMaterialTraits::kUseRefraction) != 0 ); } { //bump OdGiMaterialMap bumpMap; pMtl->bump( bumpMap ); m_bumpPage.setTexturePreview( bumpMap, m_Material.giContext() ); m_bumpPage.setSliderValue( 50 ); m_bumpPage.setSliderValue( (int)( bumpMap.blendFactor() * 100 ), 1 ); m_bumpPage.setCheckboxChecked( (pMtl->channelFlags() & OdGiMaterialTraits::kUseBump) != 0 ); } { //normal map OdGiMaterialMap normalMap; double d; OdGiMaterialTraits::NormalMapMethod method; pMtl->normalMap( normalMap, method, d ); m_normalMapPage.setTexturePreview( normalMap, m_Material.giContext() ); m_normalMapPage.setSliderValue( (int)( d * 100 ) ); m_normalMapPage.setSliderValue( (int)( normalMap.blendFactor() * 100 ), 1 ); m_normalMapPage.setCheckboxChecked( (pMtl->channelFlags() & OdGiMaterialTraits::kUseNormalMap) != 0 ); } { // name and desc m_commonPage.setName( pMtl->name() ); m_commonPage.setDescription( pMtl->description() ); } { // check that material contains FBX Asset OdDbDictionaryPtr pXDic = OdDbDictionary::cast(pMtl->extensionDictionary().openObject()); OdDbXrecordPtr pAsset; if (!pXDic.isNull()) pAsset = OdDbXrecord::cast(pXDic->getAt(OD_T("FBXASSET")).openObject()); GetDlgItem(IDC_BFBX)->EnableWindow((pAsset.isNull()) ? FALSE : TRUE); } } } void CDbMaterialsDlg::OnLbnSelchangeLbmaterials() { UpdateMaterial(); } void CDbMaterialsDlg::OnCbnSelchangeCbdevice() { CString nDevName; m_Device.GetLBText(m_Device.GetCurSel(), nDevName); m_Material.ResetDevice(nDevName, m_MaterialsList.GetCurSel() != -1); } void CDbMaterialsDlg::OnBnClickedCbdiagbkgnd() { m_Material.SetDiagnosticBackground(IsDlgButtonChecked(IDC_CBDIAGBKGND) == BST_CHECKED); } void CDbMaterialsDlg::OnBnClickedBambient() { CColorPickerDlg dlg; dlg.SetColor( m_ambientPage.getColor() ); if (dlg.DoModal() == IDOK) { COLORREF color = dlg.GetColor(); OdCmEntityColor cmColor(GetRValue(color), GetGValue(color), GetBValue(color)); m_ambientPage.setColor( cmColor ); OdDbMaterialPtr pMtl = m_Material.GetMaterial().openObject(OdDb::kForWrite); OdGiMaterialColor ambColor; ambColor.setColor(cmColor); ambColor.setMethod(OdGiMaterialColor::kOverride); pMtl->setAmbient(ambColor); m_Material.UpdatePreview(); m_bChanged = true; } } void CDbMaterialsDlg::OnBnClickedBdiffuse() { CColorPickerDlg dlg; dlg.SetColor( m_diffusePage.getColor() ); if (dlg.DoModal() == IDOK) { COLORREF color = dlg.GetColor(); OdCmEntityColor cmColor(GetRValue(color), GetGValue(color), GetBValue(color)); m_diffusePage.setColor( cmColor ); OdDbMaterialPtr pMtl = m_Material.GetMaterial().openObject(OdDb::kForWrite); OdGiMaterialColor difColor; OdGiMaterialMap difMap; pMtl->diffuse(difColor, difMap); difColor.setColor(cmColor); difColor.setMethod(OdGiMaterialColor::kOverride); pMtl->setDiffuse(difColor, difMap); m_Material.UpdatePreview(); m_bChanged = true; } } void CDbMaterialsDlg::OnBnClickedBspecular() { CColorPickerDlg dlg; dlg.SetColor( m_specularPage.getColor() ); if (dlg.DoModal() == IDOK) { COLORREF color = dlg.GetColor(); OdCmEntityColor cmColor(GetRValue(color), GetGValue(color), GetBValue(color)); m_specularPage.setColor( cmColor ); OdDbMaterialPtr pMtl = m_Material.GetMaterial().openObject(OdDb::kForWrite); OdGiMaterialColor specColor; OdGiMaterialMap specMap; double glossFac; pMtl->specular(specColor, specMap, glossFac); specColor.setColor(cmColor); specColor.setMethod(OdGiMaterialColor::kOverride); pMtl->setSpecular(specColor, specMap, glossFac); m_Material.UpdatePreview(); m_bChanged = true; } } void CDbMaterialsDlg::OnSliderChanged( OdUInt32 id ) { OdDbMaterialPtr pMtl = m_Material.GetMaterial().openObject(OdDb::kForWrite); switch( id ) { case MESSAGE_SPECULARCOLOR_GLOSS: case MESSAGE_SPECULAR_BLEND: { int index = ( id == MESSAGE_SPECULARCOLOR_GLOSS ) ? 0 : 1; double newVal = (double)m_specularPage.getSliderValue( index ) / 100.0; OdGiMaterialColor specColor; OdGiMaterialMap specMap; double glossFac; pMtl->specular(specColor, specMap, glossFac); if( id == MESSAGE_SPECULARCOLOR_GLOSS ) glossFac = newVal; else if( id == MESSAGE_SPECULAR_BLEND ) specMap.setBlendFactor( newVal ); pMtl->setSpecular(specColor, specMap, glossFac); } break; case MESSAGE_OPACITY_OPACITY: case MESSAGE_OPACITY_BLEND: { int index = ( id == MESSAGE_OPACITY_OPACITY ) ? 0 : 1; double newVal = (double)m_opacityPage.getSliderValue( index ) / 100.0; OdGiMaterialMap opacityMap; double opacityPerc; pMtl->opacity(opacityPerc, opacityMap); if( id == MESSAGE_OPACITY_OPACITY ) opacityPerc = newVal; else if( id == MESSAGE_OPACITY_BLEND ) opacityMap.setBlendFactor( newVal ); pMtl->setOpacity(opacityPerc, opacityMap); } break; case MESSAGE_REFLECTION_REFLECTIVITY: case MESSAGE_REFLECTION_BLEND: { int index = ( id == MESSAGE_REFLECTION_REFLECTIVITY ) ? 0 : 1; double newVal = (double)m_reflectionPage.getSliderValue( index ) / 100.0; if( id == MESSAGE_REFLECTION_BLEND ) { OdGiMaterialMap reflMap; pMtl->reflection( reflMap ); reflMap.setBlendFactor( newVal ); pMtl->setReflection( reflMap ); } else if( id == MESSAGE_REFLECTION_REFLECTIVITY ) { pMtl->setReflectivity( newVal ); } } break; case MESSAGE_DIFFUSE_BLEND: { double newVal = (double)m_diffusePage.getSliderValue() / 100.0; OdGiMaterialColor difColor; OdGiMaterialMap difMap; pMtl->diffuse( difColor, difMap ); difMap.setBlendFactor( newVal ); pMtl->setDiffuse( difColor, difMap ); } break; case MESSAGE_OPACITY_TRANSLUCENCE: { double newVal = (double)m_opacityPage.getSliderValue( 2 ) / 100.0; pMtl->setTranslucence( newVal ); } break; case MESSAGE_REFRACTION_INDEX: case MESSAGE_REFRACTION_BLEND: { int index = ( id == MESSAGE_REFRACTION_INDEX ) ? 0 : 1; double newVal = (double)m_refractionPage.getSliderValue( index ) / 100.0; OdGiMaterialMap refrMap; double refrIndex; pMtl->refraction( refrIndex, refrMap ); if( id == MESSAGE_REFRACTION_INDEX ) refrIndex = newVal; else if( id == MESSAGE_REFRACTION_BLEND ) refrMap.setBlendFactor( newVal ); pMtl->setRefraction( refrIndex, refrMap ); } break; case MESSAGE_BUMP_SCALE: case MESSAGE_BUMP_BLEND: { int index = ( id == MESSAGE_BUMP_SCALE ) ? 0 : 1; double newVal = (double)m_bumpPage.getSliderValue( index ) / 100.0; OdGiMaterialMap bumpMap; pMtl->bump( bumpMap ); if( id == MESSAGE_BUMP_SCALE ) { ODA_FAIL(); //unsupported now } else if( id == MESSAGE_BUMP_BLEND ) bumpMap.setBlendFactor( newVal ); pMtl->setBump( bumpMap ); } break; case MESSAGE_NORMALMAP_STRENGTH: case MESSAGE_NORMALMAP_BLEND: { int index = ( id == MESSAGE_NORMALMAP_STRENGTH ) ? 0 : 1; double newVal = (double)m_normalMapPage.getSliderValue( index ) / 100.0; OdGiMaterialMap normMap; double strength; OdGiMaterialTraits::NormalMapMethod method; pMtl->normalMap( normMap, method, strength ); if( id == MESSAGE_NORMALMAP_STRENGTH ) { strength = newVal; } else if( id == MESSAGE_NORMALMAP_BLEND ) normMap.setBlendFactor( newVal ); pMtl->setNormalMap( normMap, method, strength ); } break; default: ODA_FAIL(); break; } m_Material.UpdatePreview(); m_bChanged = true; } void CDbMaterialsDlg::OnEnableCheckboxClicked( OdUInt32 id ) { OdDbMaterialPtr pMtl = m_Material.GetMaterial().openObject(OdDb::kForWrite); OdUInt32 flags = (OdUInt32)(pMtl->channelFlags()); switch( id ) { case MESSAGE_DIFFUSE_CHECK: SETBIT( flags, OdGiMaterialTraits::kUseDiffuse, m_diffusePage.isCheckboxChecked() ); break; case MESSAGE_SPECULAR_CHECK: SETBIT( flags, OdGiMaterialTraits::kUseSpecular, m_specularPage.isCheckboxChecked() ); break; case MESSAGE_OPACITY_CHECK: SETBIT( flags, OdGiMaterialTraits::kUseOpacity, m_opacityPage.isCheckboxChecked() ); break; case MESSAGE_REFLECTION_CHECK: SETBIT( flags, OdGiMaterialTraits::kUseReflection, m_reflectionPage.isCheckboxChecked() ); break; case MESSAGE_REFRACTION_CHECK: SETBIT( flags, OdGiMaterialTraits::kUseRefraction, m_refractionPage.isCheckboxChecked() ); break; case MESSAGE_BUMP_CHECK: SETBIT( flags, OdGiMaterialTraits::kUseBump, m_bumpPage.isCheckboxChecked() ); break; case MESSAGE_NORMALMAP_CHECK: SETBIT( flags, OdGiMaterialTraits::kUseNormalMap, m_normalMapPage.isCheckboxChecked() ); break; default: ODA_FAIL(); break; } pMtl->setChannelFlags( (OdGiMaterialTraits::ChannelFlags)flags ); m_Material.UpdatePreview(); m_bChanged = true; } void CDbMaterialsDlg::OnBnClickedCheck2() { OdDbMaterialPtr pMtl = m_Material.GetMaterial().openObject(OdDb::kForWrite); pMtl->setTwoSided(m_commonPage.getDoubleSided()); m_Material.UpdatePreview(); m_bChanged = true; } void CDbMaterialsDlg::OnPreviewClicked( OdUInt32 id ) { OdDbMaterialPtr pMtl = m_Material.GetMaterial().openObject(OdDb::kForWrite); OdGiMaterialMap matMap; OdGiMaterialColor cl; double d; OdGiMaterialTraits::NormalMapMethod method; switch( id ) { case MESSAGE_DIFFUSE_PREVIEW: pMtl->diffuse(cl, matMap); break; case MESSAGE_SPECULAR_PREVIEW: pMtl->specular( cl, matMap, d ); break; case MESSAGE_OPACITY_PREVIEW: pMtl->opacity( d, matMap ); break; case MESSAGE_REFLECTION_PREVIEW: pMtl->reflection( matMap ); break; case MESSAGE_REFRACTION_PREVIEW: pMtl->refraction( d, matMap ); break; case MESSAGE_BUMP_PREVIEW: pMtl->bump( matMap ); break; case MESSAGE_NORMALMAP_PREVIEW: pMtl->normalMap( matMap, method, d ); break; default: { ODA_FAIL(); return; } } CTextureOptionsDialog dlg( matMap, m_Material.giContext() ); if( dlg.DoModal() == IDOK && dlg.hasChanges() ) { switch( id ) { case MESSAGE_DIFFUSE_PREVIEW: pMtl->setDiffuse( cl, dlg.getMap() ); m_diffusePage.setTexturePreview( dlg.getMap(), m_Material.giContext() ); break; case MESSAGE_SPECULAR_PREVIEW: pMtl->setSpecular( cl, dlg.getMap(), d ); m_specularPage.setTexturePreview( dlg.getMap(), m_Material.giContext() ); break; case MESSAGE_OPACITY_PREVIEW: pMtl->setOpacity( d, dlg.getMap() ); m_opacityPage.setTexturePreview( dlg.getMap(), m_Material.giContext() ); break; case MESSAGE_REFLECTION_PREVIEW: pMtl->setReflection( dlg.getMap() ); m_reflectionPage.setTexturePreview( dlg.getMap(), m_Material.giContext() ); break; case MESSAGE_REFRACTION_PREVIEW: pMtl->setRefraction( d, dlg.getMap() ); m_refractionPage.setTexturePreview( dlg.getMap(), m_Material.giContext() ); break; case MESSAGE_BUMP_PREVIEW: pMtl->setBump( dlg.getMap() ); m_bumpPage.setTexturePreview( dlg.getMap(), m_Material.giContext() ); break; case MESSAGE_NORMALMAP_PREVIEW: pMtl->setNormalMap( dlg.getMap(), method, d ); m_normalMapPage.setTexturePreview( dlg.getMap(), m_Material.giContext() ); break; default: { ODA_FAIL(); return; } } m_Material.UpdatePreview(); m_bChanged = true; } } void CDbMaterialsDlg::OnBnClickedExtractFbx() { CFileDialog saveFile(false, _T("fbx"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("FBX Asset (*.fbx)|*.fbx|All Files (*.*)|*.*||"), this); if (saveFile.DoModal() == IDOK) { OdDbMaterialPtr pMtlClone = m_Material.GetMaterial().openObject(); OdDbMaterialPtr pMtl = OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().openObject())->getAt(pMtlClone->description(), OdDb::kForRead); OdDbDictionaryPtr pXDic = OdDbDictionary::cast(pMtl->extensionDictionary().openObject()); OdDbXrecordPtr pAsset; if (!pXDic.isNull()) pAsset = OdDbXrecord::cast(pXDic->getAt(OD_T("FBXASSET")).openObject()); if (pAsset.isNull()) { MessageBox(_T("Can't access material Xrecord."), _T("FBX Asset extracting error"), MB_ICONSTOP); return; } OdStreamBufPtr pFile = ::odrxSystemServices()->createFile((LPCTSTR)saveFile.GetPathName(), Oda::kFileWrite, Oda::kShareDenyWrite, Oda::kCreateAlways); if (pFile.isNull()) { MessageBox(_T("Can't open output file for writing."), _T("FBX Asset extracting error"), MB_ICONSTOP); return; } bool bImported = false; OdDbXrecordIteratorPtr pXrecIt = pAsset->newIterator(); while (!pXrecIt->done()) { if (pXrecIt->curRestype() == OdResBuf::kDxfBinaryChunk) { OdResBufPtr pRb = pXrecIt->getCurResbuf(); pFile->putBytes(pRb->getBinaryChunk().getPtr(), pRb->getBinaryChunk().size()); bImported = true; } // Ignore GUID and so on pXrecIt->next(); } ODA_ASSERT(pXrecIt->done()); if (!bImported) MessageBox(_T("Nothing was extracted from Xrecord."), _T("FBX Asset extracting error"), MB_ICONSTOP); } } void CDbMaterialsDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { CDialog::OnHScroll(nSBCode, nPos, pScrollBar); } void CDbMaterialsDlg::OnOK() { CheckChanges(); CDialog::OnOK(); } ///////////////////////////////////////////////////////////////////////////// // COdCmEntityColorDlg dialog COdCmEntityColorDlg::COdCmEntityColorDlg(const OdCmEntityColor &crColor, CWnd* pParent /*=NULL*/) : CDialog(COdCmEntityColorDlg::IDD, pParent) , m_crColor(crColor) { } COdCmEntityColorDlg::~COdCmEntityColorDlg() { } void COdCmEntityColorDlg::SetColor(const OdCmEntityColor &crColor, bool invalidate) { m_crColor = crColor; if (!invalidate) return; m_cByColorPreview.SetColor(crColor); // Please don't ask why I don't utilize "official" MFC mechanism for working with radio buttons here. I know how it works :) m_bByLayer.SetCheck(BST_UNCHECKED); m_bByBlock.SetCheck(BST_UNCHECKED); m_bByColor.SetCheck(BST_UNCHECKED); m_bByACI.SetCheck(BST_UNCHECKED); m_bByPen.SetCheck(BST_UNCHECKED); m_bForeground.SetCheck(BST_UNCHECKED); m_bByDgnIndex.SetCheck(BST_UNCHECKED); m_bNone.SetCheck(BST_UNCHECKED); switch (crColor.colorMethod()) { case OdCmEntityColor::kByLayer: m_bByLayer.SetCheck(BST_CHECKED); break; case OdCmEntityColor::kByBlock: m_bByBlock.SetCheck(BST_CHECKED); break; case OdCmEntityColor::kByColor: m_bByColor.SetCheck(BST_CHECKED); break; case OdCmEntityColor::kByACI: m_bByACI.SetCheck(BST_CHECKED); break; case OdCmEntityColor::kByPen: m_bByPen.SetCheck(BST_CHECKED); break; case OdCmEntityColor::kForeground: m_bForeground.SetCheck(BST_CHECKED); break; case OdCmEntityColor::kByDgnIndex: m_bByDgnIndex.SetCheck(BST_CHECKED); break; case OdCmEntityColor::kNone: m_bNone.SetCheck(BST_CHECKED); break; } m_bChooseByColorColor.EnableWindow((crColor.isByColor()) ? TRUE : FALSE); m_cbByACIColor.EnableWindow((crColor.isByACI()) ? TRUE : FALSE); if (crColor.isByACI()) m_cbByACIColor.SetCurSel(crColor.colorIndex()); } OdCmEntityColor COdCmEntityColorDlg::GetColor() const { return m_crColor; } void COdCmEntityColorDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_RBBYLAYER, m_bByLayer); DDX_Control(pDX, IDC_RBBYBLOCK, m_bByBlock); DDX_Control(pDX, IDC_RBBYCOLOR, m_bByColor); DDX_Control(pDX, IDC_RBBYACI, m_bByACI); DDX_Control(pDX, IDC_RBBYPEN, m_bByPen); DDX_Control(pDX, IDC_RBFOREGROUND, m_bForeground); DDX_Control(pDX, IDC_RBBYDGNINDEX, m_bByDgnIndex); DDX_Control(pDX, IDC_RBNONE, m_bNone); DDX_Control(pDX, IDC_GRADCOLOR_SELECTED, m_cByColorPreview); DDX_Control(pDX, IDC_GRADCOLOR_CHOOSE, m_bChooseByColorColor); DDX_Control(pDX, IDC_PS_FORMVIEW_COMBO_COLOR, m_cbByACIColor); } BEGIN_MESSAGE_MAP(COdCmEntityColorDlg, CDialog) ON_WM_DESTROY() ON_CBN_SELCHANGE(IDC_PS_FORMVIEW_COMBO_COLOR, OnSelchangeComboColor) ON_BN_CLICKED(IDC_RBBYLAYER, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_RBBYBLOCK, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_RBBYCOLOR, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_RBBYACI, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_RBBYPEN, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_RBFOREGROUND, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_RBBYDGNINDEX, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_RBNONE, OnBnClickedColorMethod) ON_BN_CLICKED(IDC_GRADCOLOR_CHOOSE, OnBnClickedSelColor) END_MESSAGE_MAP() // CColorPickerDlg message handlers BOOL COdCmEntityColorDlg::OnInitDialog() { CDialog::OnInitDialog(); { CBitmapColorInfo *pBitmapColorInfo = new CBitmapColorInfo(MAKEINTRESOURCE(IDB_SELECT_TRUE_COLOR), _T("template")); CBitmap *bitmapSrc = &(pBitmapColorInfo->m_bitmap); m_aByACIColors.reserve(256); for (OdUInt32 nColor = 0; nColor < 256; nColor++) { OdCmEntityColor entClr; entClr.setColorIndex((OdInt16)nColor); m_aByACIColors.push_back(new CBitmapColorInfo(bitmapSrc, ::lookupRGBHelper(entClr), OdString().format(OD_T("%u"), (unsigned)nColor).c_str())); m_cbByACIColor.AddBitmap(&m_aByACIColors.last()->m_bitmap, m_aByACIColors.last()->m_name); } delete pBitmapColorInfo; } SetColor(m_crColor, true); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void COdCmEntityColorDlg::OnDestroy() { for (OdUInt32 nColor = 0; nColor < m_aByACIColors.size(); nColor++) delete m_aByACIColors[nColor]; CDialog::OnDestroy(); } void COdCmEntityColorDlg::OnBnClickedColorMethod() { OdCmEntityColor::ColorMethod cMethod = m_crColor.colorMethod(); if (IsDlgButtonChecked(m_bByLayer.GetDlgCtrlID()) && !m_crColor.isByLayer()) cMethod = OdCmEntityColor::kByLayer; if (IsDlgButtonChecked(m_bByBlock.GetDlgCtrlID()) && !m_crColor.isByBlock()) cMethod = OdCmEntityColor::kByBlock; if (IsDlgButtonChecked(m_bByColor.GetDlgCtrlID()) && !m_crColor.isByColor()) cMethod = OdCmEntityColor::kByColor; if (IsDlgButtonChecked(m_bForeground.GetDlgCtrlID()) && !m_crColor.isForeground()) cMethod = OdCmEntityColor::kForeground; if (IsDlgButtonChecked(m_bByACI.GetDlgCtrlID()) && !m_crColor.isByACI()) cMethod = OdCmEntityColor::kByACI; if (IsDlgButtonChecked(m_bByPen.GetDlgCtrlID()) && !(m_crColor.colorMethod() == OdCmEntityColor::kByPen)) cMethod = OdCmEntityColor::kByPen; if (IsDlgButtonChecked(m_bByDgnIndex.GetDlgCtrlID()) && !m_crColor.isByDgnIndex()) cMethod = OdCmEntityColor::kByDgnIndex; if (IsDlgButtonChecked(m_bNone.GetDlgCtrlID()) && !m_crColor.isNone()) cMethod = OdCmEntityColor::kNone; if (cMethod != m_crColor.colorMethod()) { // Make some minor user-friendly handling here to apply conversions between ACI and True Color if (m_crColor.isByACI() && (cMethod == OdCmEntityColor::kByColor)) { ODCOLORREF cr = ::lookupRGBHelper(m_crColor); m_crColor.setRGB(ODGETRED(cr), ODGETGREEN(cr), ODGETBLUE(cr)); } else if (m_crColor.isByColor() && (cMethod == OdCmEntityColor::kByACI)) m_crColor.setColorIndex((OdInt16)OdCmEntityColor::lookUpACI(m_crColor.red(), m_crColor.green(), m_crColor.blue())); else m_crColor.setColorMethod(cMethod); } SetColor(m_crColor, true); } void COdCmEntityColorDlg::OnSelchangeComboColor() { m_crColor.setColorIndex((OdInt16)m_cbByACIColor.GetCurSel()); SetColor(m_crColor, true); } void COdCmEntityColorDlg::OnBnClickedSelColor() { CColorPickerDlg dlg; dlg.SetColor(ODRGB(m_crColor.red(), m_crColor.green(), m_crColor.blue())); if (dlg.DoModal() == IDOK) { COLORREF color = dlg.GetColor(); m_crColor.setRGB(ODGETRED(color), ODGETGREEN(color), ODGETBLUE(color)); SetColor(m_crColor, true); } } // CVisualStylesPreview IMPLEMENT_DYNAMIC(CVisualStylesPreview, CStatic) CVisualStylesPreview::CVisualStylesPreview(OdDbDatabase *pHostDb) : m_pHostDb(pHostDb) , m_hDc(NULL) { } CVisualStylesPreview::~CVisualStylesPreview() { } BEGIN_MESSAGE_MAP(CVisualStylesPreview, CStatic) ON_WM_CREATE() ON_WM_DESTROY() ON_WM_PAINT() END_MESSAGE_MAP() // CVisualStylesPreview message handlers int CVisualStylesPreview::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CStatic::OnCreate(lpCreateStruct) == -1) return -1; return 0; } void CVisualStylesPreview::OnDestroy() { if (m_hDc) ReleaseDC(m_hDc); CStatic::OnDestroy(); } OdString CVisualStylesPreview::findFile(const OdString& file, OdDbBaseDatabase* pDb, OdDbBaseHostAppServices::FindFileHint hint) { return theApp.findFile(file, m_pHostDb, hint); } void CVisualStylesPreview::PreparePreviewDatabase() { m_pDb = createDatabase(); { // Create preview material OdDbMaterialPtr pMtl = OdDbMaterial::createObject(); pMtl->setName(OD_T("PreviewMaterial")); OdDbDictionary::cast(m_pDb->getMaterialDictionaryId().openObject(OdDb::kForWrite))->setAt(OD_T("PreviewMaterial"), pMtl); } { // Create preview entities //1. Create red box at first OdDb3dSolidPtr pSolid = OdDb3dSolid::createObject(); pSolid->setDatabaseDefaults(m_pDb); pSolid->createBox(1., 1.1, 1.5); OdCmColor color; color.setRGB(255, 0, 0); pSolid->setColor(color); pSolid->transformBy( OdGeMatrix3d::rotation(-OdaPI / 4, OdGeVector3d::kXAxis) * OdGeMatrix3d::rotation(-OdaPI / 4, OdGeVector3d::kZAxis)); pSolid->transformBy(OdGeMatrix3d::translation(OdGeVector3d(-0.4,0.0,0.0))); OdDbBlockTableRecord::cast(m_pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite))->appendOdDbEntity(pSolid); //2. Create blue cone OdDb3dSolidPtr pCone = OdDb3dSolid::createObject(); pCone->setDatabaseDefaults(m_pDb); pCone->createFrustum(2.0,0.65,0.65,0.0); OdCmColor color1; color1.setRGB(0, 0, 255); pCone->setColor(color1); pCone->transformBy( OdGeMatrix3d::rotation(-OdaPI / 4, OdGeVector3d::kXAxis) /*Not use rotation over z xais because there is a problem with edge for cone*/ /** OdGeMatrix3d::rotation(-OdaPI / 4, OdGeVector3d::kZAxis)*/); pCone->transformBy(OdGeMatrix3d::translation(OdGeVector3d(0.5,0.,0.2))); OdDbBlockTableRecord::cast(m_pDb->getActiveLayoutBTRId().openObject(OdDb::kForWrite))->appendOdDbEntity(pCone); } { //Create preview visual style OdDbVisualStylePtr pVstl = OdDbVisualStyle::createObject(); pVstl->setDescription(L"PreviewVisualStyle"); OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().openObject(OdDb::kForWrite))->setAt(OD_T("PreviewVisualStyle"), pVstl); // Prepare view settings OdDbObjectPtr pView = m_pDb->activeViewportId().openObject(OdDb::kForWrite); OdAbstractViewPEPtr pSet(pView); pSet->setView(pView, OdGePoint3d::kOrigin, OdGeVector3d::kYAxis, OdGeVector3d::kZAxis, 2.5, 2.5, false); } } void CVisualStylesPreview::PreparePreviewDevice() { m_pDevice.release(); CRect rc; GetClientRect(&rc); try { CString devName = OdWinGLES2ModuleName; OdGsModulePtr pGs = ::odrxDynamicLinker()->loadModule(devName.GetBuffer(), false); OdGsDevicePtr pDevice = pGs->createDevice(); OdRxDictionaryPtr pProperties = pDevice->properties(); if(pProperties.get()) { if(pProperties->has(OD_T("WindowHWND"))) // Check if property is supported pProperties->putAt(OD_T("WindowHWND"), OdRxVariantValue((OdIntPtr)GetSafeHwnd())); // hWnd necessary for DirectX device if (!m_hDc) m_hDc = GetDC(); if(pProperties->has(OD_T("WindowHDC"))) // Check if property is supported pProperties->putAt(OD_T("WindowHDC"), OdRxVariantValue((OdIntPtr)m_hDc->GetSafeHdc())); // hWindowDC necessary for Bitmap device if(pProperties->has(OD_T("UseVisualStyles"))) // Check if property is supported pProperties->putAt(OD_T("UseVisualStyles"), OdRxVariantValue(true)); if(pProperties->has(OD_T("UseCompositeMetafiles"))) // Check if property is supported pProperties->putAt(OD_T("UseCompositeMetafiles"), OdRxVariantValue(true)); // Enable scene graph usage onto renderer side if (pProperties->has(OD_T("UseSceneGraph"))) // Check if property is supported pProperties->putAt(OD_T("UseSceneGraph"), OdRxVariantValue(g_OdExGLES2SceneGraphCmd.setting())); if (pProperties->has(OD_T("SceneGraphOptions"))) // Check if property is supported pProperties->putAt(OD_T("SceneGraphOptions"), OdRxVariantValue(g_OdExGLES2SceneGraphCmd.options())); } if (m_pCtx.isNull()) { m_pCtx = OdGiContextForDbDatabase::createObject(); m_pCtx->enableGsModel(true); m_pCtx->setPaletteBackground(ODRGB(0, 0, 0)); m_pCtx->setDatabase(m_pDb); } m_pDevice = OdDbGsManager::setupActiveLayoutViews(pDevice, m_pCtx); m_pDevice->setLogicalPalette(::odcmAcadDarkPalette(), 256); m_pDevice->setBackgroundColor(ODRGB(0, 0, 0)); OdGsDCRect gsRect(rc.left, rc.right, rc.bottom, rc.top); m_pDevice->onSize(gsRect); Invalidate(); } catch(const OdError& /*e*/) { m_pDevice.release(); MessageBox(_T("Requested device couldn't be created."), _T("Graphic System Initialization Error"), MB_ICONSTOP); } } void CVisualStylesPreview::SetVisualStyle(const OdDbObjectId &vslId) { if (m_pDb.isNull()) PreparePreviewDatabase(); { OdDbVisualStylePtr pVstl = vslId.openObject()->clone(); pVstl->setDescription(OD_T("PreviewVisualStyle")); OdDbVisualStylePtr pVstlTo = OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().openObject())->getAt(OD_T("PreviewVisualStyle"), OdDb::kForWrite); pVstlTo->handOverTo(pVstl); if (m_pDevice.isNull()) PreparePreviewDevice(); } OdDbVisualStylePtr pVstlToRead = OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().openObject())->getAt(OD_T("PreviewVisualStyle"), OdDb::kForRead); OdDbObjectPtr pVp = m_pDb->activeViewportId().openObject(); OdDbAbstractViewportDataPtr pVdata(pVp); pVdata->setVisualStyle(pVp, pVstlToRead->id()); UpdatePreview(); } OdDbObjectId CVisualStylesPreview::GetVisualStyle() { return OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().openObject())->getAt(OD_T("PreviewVisualStyle")); } void CVisualStylesPreview::UpdatePreview() { if (!m_pDevice.isNull()) { OdRxDictionaryPtr pProperties = m_pDevice->properties(); if (pProperties.isNull() || !pProperties->has(OD_T("UseCompositeMetafiles")) || !OdRxVariantValue(pProperties->getAt(OD_T("UseCompositeMetafiles")))->getBool()) { if (OdGsLayoutHelper::cast(m_pDevice)->gsModel()) OdGsLayoutHelper::cast(m_pDevice)->gsModel()->invalidate(OdGsModel::kInvalidateAll); } m_pDevice->invalidate(); Invalidate(); } } void CVisualStylesPreview::OnPaint() { CPaintDC dc(this); if (m_pDevice.isNull()) { CRect cliArea; GetClientRect(&cliArea); dc.FillSolidRect(&cliArea, ::GetSysColor(COLOR_BTNFACE)); } else { m_pDevice->update(); } } ///////////////////////////////////////////////////////////////////////////// // CVisualStylePropertyEditDlg dialog class CVisualStylePropertyEditDlg : protected CDialog { // Construction public: CVisualStylePropertyEditDlg(CWnd* pParent = NULL) // standard constructor : CDialog(CVisualStylePropertyEditDlg::IDD, pParent) , m_bFlags(false), m_nVals(0), m_nInitialState(0) { //{{AFX_DATA_INIT(CVisualStylePropertyEditDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // Dialog Data //{{AFX_DATA(CVisualStylePropertyEditDlg) enum { IDD = IDD_VS_FLAGSEDITOR }; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CVisualStylePropertyEditDlg) protected: virtual void DoDataExchange(CDataExchange* pDX) // DDX/DDV support { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CVisualStylePropertyEditDlg) //}}AFX_DATA_MAP } //}}AFX_VIRTUAL public: bool DoFlags(const OdChar *pPropName, const OdChar **pFlagNames, const OdUInt32 *pFlags, OdUInt32 nFlags, OdUInt32 &flagsVal) { m_bFlags = true; m_nVals = nFlags; m_nInitialState = flagsVal; m_pValNames = pFlagNames; m_pVals = pFlags; m_pPropName = pPropName; if (DoModal() == IDOK) { flagsVal = m_nInitialState; return true; } return false; } bool DoEnum(const OdChar *pPropName, const OdChar **pEnumNames, const OdUInt32 *pVals, OdUInt32 nEnum, OdUInt32 &enumVal) { m_bFlags = false; m_nVals = nEnum; m_nInitialState = enumVal; m_pValNames = pEnumNames; m_pVals = pVals; m_pPropName = pPropName; if (DoModal() == IDOK) { enumVal = m_nInitialState; return true; } return false; } // Implementation protected: // Generated message map functions //{{AFX_MSG(CVisualStylePropertyEditDlg) virtual BOOL OnInitDialog() { CDialog::OnInitDialog(); // Get characteristics of first RB and remove it CRect firstRect; GetDlgItem(IDC_RBPLACEHOLDER)->GetWindowRect(&firstRect); ScreenToClient(&firstRect); GetDlgItem(IDC_RBPLACEHOLDER)->ShowWindow(SW_HIDE); // Get characteristics of second CB and remove it CRect secondRect; GetDlgItem(IDC_CBPLACEHOLDER)->GetWindowRect(&secondRect); ScreenToClient(&secondRect); GetDlgItem(IDC_CBPLACEHOLDER)->ShowWindow(SW_HIDE); // Set property name SetDlgItemText(IDC_SPROPNAME, m_pPropName); // Create new windows for (OdUInt32 nWin = 0; nWin < m_nVals; nWin++) { CWnd *pBaseWnd = GetDlgItem((!m_bFlags) ? IDC_RBPLACEHOLDER : IDC_CBPLACEHOLDER); OdChar className[64]; ::GetClassName(pBaseWnd->GetSafeHwnd(), className, sizeof(className) / sizeof(OdChar)); HWND newItem = ::CreateWindowEx(::GetWindowLong(pBaseWnd->GetSafeHwnd(), GWL_EXSTYLE), className, m_pValNames[nWin], ::GetWindowLong(pBaseWnd->GetSafeHwnd(), GWL_STYLE) | WS_VISIBLE, firstRect.left, firstRect.top + (secondRect.top - firstRect.top) * nWin, firstRect.right - firstRect.left, firstRect.bottom - firstRect.top, GetSafeHwnd(), (HMENU)(OdIntPtr)(IDC_CBPLACEHOLDER + nWin + 1), AfxGetInstanceHandle(), NULL); SetWindowFont(newItem, (HFONT)GetWindowFont(pBaseWnd->GetSafeHwnd()), FALSE); if ((m_bFlags && GETBIT(m_nInitialState, m_pVals[nWin])) || (!m_bFlags && (m_nInitialState == m_pVals[nWin]))) CheckDlgButton(IDC_CBPLACEHOLDER + nWin + 1, BST_CHECKED); } // Resize dialog box CRect cliRect; GetWindowRect(&cliRect); GetParent()->ScreenToClient(&cliRect); const long diff = ((secondRect.top - firstRect.top) * m_nVals) - ((secondRect.top - firstRect.top) * 2); cliRect.bottom += diff; SetWindowPos(NULL, cliRect.left, cliRect.top, cliRect.Width(), cliRect.Height(), SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER); // Move buttons GetDlgItem(IDOK)->GetWindowRect(&firstRect); ScreenToClient(&firstRect); firstRect.top += diff; firstRect.bottom += diff; GetDlgItem(IDOK)->MoveWindow(&firstRect, FALSE); GetDlgItem(IDCANCEL)->GetWindowRect(&firstRect); ScreenToClient(&firstRect); firstRect.top += diff; firstRect.bottom += diff; GetDlgItem(IDCANCEL)->MoveWindow(&firstRect, FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //}}AFX_MSG DECLARE_MESSAGE_MAP() private: bool m_bFlags; OdUInt32 m_nVals, m_nInitialState; const OdChar **m_pValNames; const OdUInt32 *m_pVals; const OdChar *m_pPropName; void OnOK() { m_nInitialState = 0; for (OdUInt32 nWin = 0; nWin < m_nVals; nWin++) { if (IsDlgButtonChecked(IDC_CBPLACEHOLDER + nWin + 1) != BST_UNCHECKED) m_nInitialState |= m_pVals[nWin]; } CDialog::OnOK(); } }; BEGIN_MESSAGE_MAP(CVisualStylePropertyEditDlg, CDialog) //{{AFX_MSG_MAP(CVisualStylePropertyEditDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDbVisualStylesDlg dialog CDbVisualStylesDlg::CDbVisualStylesDlg(OdDbDatabase* pDb, CWnd* pParent /*=NULL*/) : CDialog(CDbVisualStylesDlg::IDD, pParent) , m_VisualStyle(pDb) , m_pDb(pDb) { //{{AFX_DATA_INIT(CDbVisualStylesDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CDbVisualStylesDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDbVisualStylesDlg) DDX_Control(pDX, IDC_LBVISUALSTYLES, m_VisualStylesList); DDX_Control(pDX, IDC_SPREVIEW, m_VisualStyle); DDX_Control(pDX, IDC_VSPROPS_LIST, m_PropsList); DDX_Control(pDX, IDC_CBSHOWINTERNAL, m_ShowInternalStyles); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDbVisualStylesDlg, CDialog) //{{AFX_MSG_MAP(CDbVisualStylesDlg) //}}AFX_MSG_MAP ON_LBN_SELCHANGE(IDC_LBVISUALSTYLES, &CDbVisualStylesDlg::OnLbnSelchangeLbvisualstyles) ON_LBN_DBLCLK(IDC_LBVISUALSTYLES, &CDbVisualStylesDlg::OnDblclkLbvisualstyles) ON_NOTIFY(NM_CLICK, IDC_VSPROPS_LIST, OnClickListPropsList) ON_BN_CLICKED(IDC_CBSHOWINTERNAL, OnShowInternalChanged) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDbVisualStylesDlg message handlers BOOL CDbVisualStylesDlg::OnInitDialog() { CDialog::OnInitDialog(); if (m_pDb) { OdDbObjectPtr pVp = m_pDb->activeViewportId().openObject(); OdDbAbstractViewportDataPtr pVdata(pVp); OdDbObjectId curVsId = pVdata->visualStyle(pVp); int curVsIndex = -1; OdDbDictionaryPtr pVSs = OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().safeOpenObject()); const bool bShowInternal = m_ShowInternalStyles.GetCheck() == BST_CHECKED; OdDbDictionaryIteratorPtr pIt = pVSs->newIterator(); while (!pIt->done()) { OdDbVisualStylePtr pVS = OdDbVisualStyle::cast(pIt->object()); if (!pVS.isNull() && (!pVS->isInternalUseOnly() || bShowInternal)) { if (pIt->objectId() == curVsId) curVsIndex = m_VisualStylesList.GetCount(); m_VisualStylesList.AddString(pIt->name().c_str()); } pIt->next(); } if (curVsIndex >= 0) m_VisualStylesList.SetCurSel(curVsIndex); } RECT rect; m_PropsList.GetClientRect(&rect); const int widthSeg = (rect.right - rect.left) / 6; m_PropsList.InsertColumn(0, _T("Name"), LVCFMT_LEFT, widthSeg * 2); m_PropsList.InsertColumn(1, _T("Type"), LVCFMT_LEFT, widthSeg); m_PropsList.InsertColumn(2, _T("Operation"), LVCFMT_LEFT, widthSeg); m_PropsList.InsertColumn(3, _T("Value"), LVCFMT_LEFT, (rect.right - rect.left) - widthSeg * 4); UpdateVisualStyle(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDbVisualStylesDlg::OnShowInternalChanged() { int nItem = m_VisualStylesList.GetCurSel(), curVsIndex = -1; OdString selItemName; if (nItem != -1) { CString vsName; m_VisualStylesList.GetText(nItem, vsName); selItemName = vsName.GetBuffer(); } m_VisualStylesList.ResetContent(); OdDbDictionaryPtr pVSs = OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().safeOpenObject()); const bool bShowInternal = m_ShowInternalStyles.GetCheck() == BST_CHECKED; OdDbDictionaryIteratorPtr pIt = pVSs->newIterator(); while (!pIt->done()) { OdDbVisualStylePtr pVS = OdDbVisualStyle::cast(pIt->object()); if (!pVS.isNull() && (!pVS->isInternalUseOnly() || bShowInternal)) { if (pIt->name() == selItemName) curVsIndex = m_VisualStylesList.GetCount(); m_VisualStylesList.AddString(pIt->name().c_str()); } pIt->next(); } if (curVsIndex >= 0) m_VisualStylesList.SetCurSel(curVsIndex); } static const TCHAR* g_VisualStylePropName[OdGiVisualStyleProperties::kPropertyCount + 1] = { _T("kFaceLightingModel"), _T("kFaceLightingQuality"), _T("kFaceColorMode"), _T("kFaceModifiers"), _T("kFaceOpacity"), _T("kFaceSpecular"), _T("kFaceMonoColor"), _T("kEdgeModel"), _T("kEdgeStyles"), _T("kEdgeIntersectionColor"), _T("kEdgeObscuredColor"), _T("kEdgeObscuredLinePattern"), _T("kEdgeIntersectionLinePattern"), _T("kEdgeCreaseAngle"), _T("kEdgeModifiers"), _T("kEdgeColor"), _T("kEdgeOpacity"), _T("kEdgeWidth"), _T("kEdgeOverhang"), _T("kEdgeJitterAmount"), _T("kEdgeSilhouetteColor"), _T("kEdgeSilhouetteWidth"), _T("kEdgeHaloGap"), _T("kEdgeIsolines"), _T("kEdgeHidePrecision"), _T("kDisplayStyles"), _T("kDisplayBrightness"), _T("kDisplayShadowType"), _T("kUseDrawOrder"), _T("kViewportTransparency"), _T("kLightingEnabled"), _T("kPosterizeEffect"), _T("kMonoEffect"), _T("kBlurEffect"), _T("kPencilEffect"), _T("kBloomEffect"), _T("kPastelEffect"), _T("kBlurAmount"), _T("kPencilAngle"), _T("kPencilScale"), _T("kPencilPattern"), _T("kPencilColor"), _T("kBloomThreshold"), _T("kBloomRadius"), _T("kTintColor"), _T("kFaceAdjustment"), _T("kPostContrast"), _T("kPostBrightness"), _T("kPostPower"), _T("kTintEffect"), _T("kBloomIntensity"), _T("kColor"), _T("kTransparency"), _T("kEdgeWiggleAmount"), _T("kEdgeTexturePath"), _T("kDepthOfField"), _T("kFocusDistance"), _T("kFocusWidth"), /* if new property will be added, add it here */ _T("unknown (new?)") }; static const struct GVSFlagsDef { OdGiVisualStyleProperties::Property m_prop; const OdInt32 m_nFlag; const OdChar *m_pFlagName; } g_VisualStyleFlagsDef[] = { { OdGiVisualStyleProperties::kFaceModifiers, OdGiVisualStyleProperties::kFaceOpacityFlag , _T("kFaceOpacityFlag") }, { OdGiVisualStyleProperties::kFaceModifiers, OdGiVisualStyleProperties::kSpecularFlag , _T("kSpecularFlag") }, { OdGiVisualStyleProperties::kFaceModifiers, OdGiVisualStyleProperties::kNoFaceModifiers , _T("kNoFaceModifiers") }, { OdGiVisualStyleProperties::kEdgeStyles , OdGiVisualStyleProperties::kVisibleFlag , _T("kVisibleFlag") }, { OdGiVisualStyleProperties::kEdgeStyles , OdGiVisualStyleProperties::kSilhouetteFlag , _T("kSilhouetteFlag") }, { OdGiVisualStyleProperties::kEdgeStyles , OdGiVisualStyleProperties::kObscuredFlag , _T("kObscuredFlag") }, { OdGiVisualStyleProperties::kEdgeStyles , OdGiVisualStyleProperties::kIntersectionFlag, _T("kIntersectionFlag") }, { OdGiVisualStyleProperties::kEdgeStyles , OdGiVisualStyleProperties::kNoEdgeStyle , _T("kNoEdgeStyle") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeOverhangFlag, _T("kEdgeOverhangFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeJitterFlag , _T("kEdgeJitterFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeWidthFlag , _T("kEdgeWidthFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeColorFlag , _T("kEdgeColorFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeHaloGapFlag , _T("kEdgeHaloGapFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kAlwaysOnTopFlag , _T("kAlwaysOnTopFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeOpacityFlag , _T("kEdgeOpacityFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeWiggleFlag , _T("kEdgeWiggleFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kEdgeTextureFlag , _T("kEdgeTextureFlag") }, { OdGiVisualStyleProperties::kEdgeModifiers, OdGiVisualStyleProperties::kNoEdgeModifiers , _T("kNoEdgeModifiers") }, { OdGiVisualStyleProperties::kDisplayStyles, OdGiVisualStyleProperties::kBackgroundsFlag , _T("kBackgroundsFlag") }, { OdGiVisualStyleProperties::kDisplayStyles, OdGiVisualStyleProperties::kLightingFlag , _T("kLightingFlag") }, { OdGiVisualStyleProperties::kDisplayStyles, OdGiVisualStyleProperties::kMaterialsFlag , _T("kMaterialsFlag") }, { OdGiVisualStyleProperties::kDisplayStyles, OdGiVisualStyleProperties::kTexturesFlag , _T("kTexturesFlag") }, { OdGiVisualStyleProperties::kDisplayStyles, OdGiVisualStyleProperties::kNoDisplayStyle , _T("kNoDisplayStyle") } }, g_VisualStyleEnumsDef[] = { { OdGiVisualStyleProperties::kFaceLightingModel , OdGiVisualStyleProperties::kInvisible , _T("kInvisible") }, { OdGiVisualStyleProperties::kFaceLightingModel , OdGiVisualStyleProperties::kConstant , _T("kConstant") }, { OdGiVisualStyleProperties::kFaceLightingModel , OdGiVisualStyleProperties::kPhong , _T("kPhong") }, { OdGiVisualStyleProperties::kFaceLightingModel , OdGiVisualStyleProperties::kGooch , _T("kGooch") }, { OdGiVisualStyleProperties::kFaceLightingModel , OdGiVisualStyleProperties::kZebra , _T("kZebra") }, { OdGiVisualStyleProperties::kFaceLightingQuality , OdGiVisualStyleProperties::kNoLighting , _T("kNoLighting") }, { OdGiVisualStyleProperties::kFaceLightingQuality , OdGiVisualStyleProperties::kPerFaceLighting , _T("kPerFaceLighting") }, { OdGiVisualStyleProperties::kFaceLightingQuality , OdGiVisualStyleProperties::kPerVertexLighting , _T("kPerVertexLighting") }, { OdGiVisualStyleProperties::kFaceLightingQuality , OdGiVisualStyleProperties::kPerPixelLighting , _T("kPerPixelLighting") }, { OdGiVisualStyleProperties::kFaceColorMode , OdGiVisualStyleProperties::kNoColorMode , _T("kNoColorMode") }, { OdGiVisualStyleProperties::kFaceColorMode , OdGiVisualStyleProperties::kObjectColor , _T("kObjectColor") }, { OdGiVisualStyleProperties::kFaceColorMode , OdGiVisualStyleProperties::kBackgroundColor , _T("kBackgroundColor") }, { OdGiVisualStyleProperties::kFaceColorMode , OdGiVisualStyleProperties::kMono , _T("kMono") }, { OdGiVisualStyleProperties::kFaceColorMode , OdGiVisualStyleProperties::kTint , _T("kTint") }, { OdGiVisualStyleProperties::kFaceColorMode , OdGiVisualStyleProperties::kDesaturate , _T("kDesaturate") }, { OdGiVisualStyleProperties::kEdgeModel , OdGiVisualStyleProperties::kNoEdges , _T("kNoEdges") }, { OdGiVisualStyleProperties::kEdgeModel , OdGiVisualStyleProperties::kIsolines , _T("kIsolines") }, { OdGiVisualStyleProperties::kEdgeModel , OdGiVisualStyleProperties::kFacetEdges , _T("kFacetEdges") }, { OdGiVisualStyleProperties::kEdgeJitterAmount , OdGiVisualStyleProperties::kJitterLow , _T("kJitterLow") }, { OdGiVisualStyleProperties::kEdgeJitterAmount , OdGiVisualStyleProperties::kJitterMedium , _T("kJitterMedium") }, { OdGiVisualStyleProperties::kEdgeJitterAmount , OdGiVisualStyleProperties::kJitterHigh , _T("kJitterHigh") }, { OdGiVisualStyleProperties::kEdgeWiggleAmount , OdGiVisualStyleProperties::kWiggleLow , _T("kWiggleLow") }, { OdGiVisualStyleProperties::kEdgeWiggleAmount , OdGiVisualStyleProperties::kWiggleMedium , _T("kWiggleMedium") }, { OdGiVisualStyleProperties::kEdgeWiggleAmount , OdGiVisualStyleProperties::kWiggleHigh , _T("kWiggleHigh") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kSolid , _T("kSolid") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kDashedLine , _T("kDashedLine") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kDotted , _T("kDotted") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kShortDash , _T("kShortDash") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kMediumDash , _T("kMediumDash") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kLongDash , _T("kLongDash") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kDoubleShortDash , _T("kDoubleShortDash") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kDoubleMediumDash , _T("kDoubleMediumDash") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kDoubleLongDash , _T("kDoubleLongDash") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kMediumLongDash , _T("kMediumLongDash") }, { OdGiVisualStyleProperties::kEdgeObscuredLinePattern , OdGiVisualStyleProperties::kSparseDot , _T("kSparseDot") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kSolid , _T("kSolid") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kDashedLine , _T("kDashedLine") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kDotted , _T("kDotted") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kShortDash , _T("kShortDash") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kMediumDash , _T("kMediumDash") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kLongDash , _T("kLongDash") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kDoubleShortDash , _T("kDoubleShortDash") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kDoubleMediumDash , _T("kDoubleMediumDash") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kDoubleLongDash , _T("kDoubleLongDash") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kMediumLongDash , _T("kMediumLongDash") }, { OdGiVisualStyleProperties::kEdgeIntersectionLinePattern, OdGiVisualStyleProperties::kSparseDot , _T("kSparseDot") }, { OdGiVisualStyleProperties::kDisplayShadowType , OdGiVisualStyleProperties::kShadowsNone , _T("kShadowsNone") }, { OdGiVisualStyleProperties::kDisplayShadowType , OdGiVisualStyleProperties::kShadowsGroundPlane , _T("kShadowsGroundPlane") }, { OdGiVisualStyleProperties::kDisplayShadowType , OdGiVisualStyleProperties::kShadowsFull , _T("kShadowsFull") }, { OdGiVisualStyleProperties::kDisplayShadowType , OdGiVisualStyleProperties::kShadowsFullAndGround, _T("kShadowsFullAndGround") } }; static const TCHAR *odGiVariantTypeToText(const OdGiVariant *pVal) { switch (pVal->type()) { case OdGiVariant::kUndefined: return _T("kUndefined"); case OdGiVariant::kBoolean: return _T("kBoolean"); case OdGiVariant::kInt: return _T("kInt"); case OdGiVariant::kDouble: return _T("kDouble"); case OdGiVariant::kColor: return _T("kColor"); case OdGiVariant::kString: return _T("kString"); case OdGiVariant::kTable: return _T("kTable"); } return _T("error"); } static const TCHAR *visualStyleOperationToText(OdGiVisualStyleOperations::Operation op) { switch (op) { case OdGiVisualStyleOperations::kInherit: return _T("kInherit"); case OdGiVisualStyleOperations::kSet: return _T("kSet"); case OdGiVisualStyleOperations::kDisable: return _T("kDisable"); case OdGiVisualStyleOperations::kEnable: return _T("kEnable"); default: return _T("kInvalid"); } } static void odGiVariantToText(OdGiVisualStyleProperties::Property nProp, const OdGiVariant *pVal, OdString &out) { switch (pVal->type()) { case OdGiVariant::kBoolean: if (pVal->asBoolean()) out = OD_T("true"); else out = OD_T("false"); break; case OdGiVariant::kInt: { out.format(OD_T("%d"), (int)pVal->asInt()); // Search in enums... probably this is enum variable. { const OdUInt32 nEnums = sizeof(g_VisualStyleEnumsDef) / sizeof(GVSFlagsDef); for (OdUInt32 nEnum = 0; nEnum < nEnums; nEnum++) { if ((g_VisualStyleEnumsDef[nEnum].m_prop == nProp) && (g_VisualStyleEnumsDef[nEnum].m_nFlag == pVal->asInt())) { out += OD_T(" (enum:"); out += g_VisualStyleEnumsDef[nEnum].m_pFlagName; out += OD_T(")"); break; } } } // Search in flags... probably this is flags variable. { const OdUInt32 nFlags = sizeof(g_VisualStyleFlagsDef) / sizeof(GVSFlagsDef); for (OdUInt32 nFlag = 0; nFlag < nFlags; nFlag++) { if (g_VisualStyleFlagsDef[nFlag].m_prop == nProp) { OdInt32 pFlag = pVal->asInt(); out += OD_T(" (flags:"); do { if (GETBIT(pFlag, g_VisualStyleFlagsDef[nFlag].m_nFlag)) { out += g_VisualStyleFlagsDef[nFlag].m_pFlagName; pFlag &= ~g_VisualStyleFlagsDef[nFlag].m_nFlag; if (pFlag) out += OD_T("|"); } nFlag++; } while (g_VisualStyleFlagsDef[nFlag].m_nFlag); if (pFlag == pVal->asInt()) out += g_VisualStyleFlagsDef[nFlag].m_pFlagName; out += OD_T(")"); } } } } break; case OdGiVariant::kDouble: out.format(OD_T("%f"), pVal->asDouble()); break; case OdGiVariant::kColor: { const OdCmEntityColor &color = pVal->asColor(); switch (color.colorMethod()) { case OdCmEntityColor::kByLayer: out = OD_T("ByLayer"); break; case OdCmEntityColor::kByBlock: out = OD_T("ByBlock"); break; case OdCmEntityColor::kByColor: out.format(OD_T("ByColor (r:%u,g:%u,b:%u)"), (unsigned)color.red(), (unsigned)color.green(), (unsigned)color.blue()); break; case OdCmEntityColor::kByACI: out.format(OD_T("ByACI (id:%u)"), (unsigned)color.colorIndex()); break; case OdCmEntityColor::kByPen: out.format(OD_T("ByPen (id:%u)"), (unsigned)color.colorIndex()); break; case OdCmEntityColor::kForeground: out = OD_T("Foreground"); break; case OdCmEntityColor::kByDgnIndex: out.format(OD_T("ByDgnIndex (id:%u)"), (unsigned)color.colorIndex()); break; case OdCmEntityColor::kNone: out = OD_T("ByEntity"); break; default: out = OD_T("unknown"); } } break; case OdGiVariant::kString: out = pVal->asString(); break; default: out = OD_T("error type"); } } void CDbVisualStylesDlg::UpdateVisualStyle() { int nItem = m_VisualStylesList.GetCurSel(); int nTopIndex = m_PropsList.GetTopIndex(); m_PropsList.DeleteAllItems(); if (nItem != -1) { CString vsName; m_VisualStylesList.GetText(nItem, vsName); OdDbVisualStylePtr pVS = OdDbVisualStyle::cast(OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().openObject())->getAt(vsName.GetBuffer(), OdDb::kForRead)); //FAE: add preview support m_VisualStyle.SetVisualStyle(pVS->id()); for (OdUInt32 nProp = 0; nProp < OdGiVisualStyleProperties::kPropertyCount; nProp++) { OdGiVisualStyleOperations::Operation op; OdGiVariantPtr pVal = pVS->trait((OdGiVisualStyleProperties::Property)nProp, &op); OdString val; ::odGiVariantToText((OdGiVisualStyleProperties::Property)nProp, pVal, val); m_PropsList.InsertItem((int)nProp, g_VisualStylePropName[nProp]); m_PropsList.SetItemText((int)nProp, 1, ::odGiVariantTypeToText(pVal)); m_PropsList.SetItemText((int)nProp, 2, ::visualStyleOperationToText(op)); m_PropsList.SetItemText((int)nProp, 3, val.c_str()); } if (nTopIndex) { m_PropsList.EnsureVisible(m_PropsList.GetItemCount() - 1, TRUE); m_PropsList.EnsureVisible(nTopIndex, TRUE); } } } void CDbVisualStylesDlg::OnLbnSelchangeLbvisualstyles() { UpdateVisualStyle(); } // From OdaLayerPropManagerDlg.cpp bool hittestSubitem(CListCtrl& listLayersList, int columns_count, const CPoint& pt, int &index, int &labelIndex); void CDbVisualStylesDlg::OnClickListPropsList(NMHDR* /*pNMHDR*/, LRESULT* pResult) { DWORD pos = GetMessagePos(); CPoint pt(GET_X_LPARAM(pos), GET_Y_LPARAM(pos)); m_PropsList.ScreenToClient(&pt); int index, labelIndex; if (hittestSubitem(m_PropsList, 4, pt, index, labelIndex) && (labelIndex >= 2)) { CString vsName; m_VisualStylesList.GetText(m_VisualStylesList.GetCurSel(), vsName); OdDbVisualStylePtr pVS = OdDbVisualStyle::cast(OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().openObject())->getAt(vsName.GetBuffer(), OdDb::kForRead)); OdGiVisualStyleOperations::Operation op; OdGiVariantPtr pVal = pVS->trait((OdGiVisualStyleProperties::Property)index, &op); if (labelIndex == 2) { // operation bool val(op == OdGiVisualStyleOperations::kSet); const bool prevVal(val); if (CSimpleInputDlg().DoInput(_T("Input Operation Value"), _T("Enter \"false\" for \"kInherit\" operation, or \"true\" for \"kSet\" mode:"), &val)) { if (val != prevVal) { op = (val) ? OdGiVisualStyleOperations::kSet : OdGiVisualStyleOperations::kInherit; pVS->upgradeOpen(); pVS->setTrait((OdGiVisualStyleProperties::Property)index, pVal.get(), op); m_PropsList.SetItemText(index, 2, ::visualStyleOperationToText(op)); //FAE: support preview m_VisualStyle.SetVisualStyle(pVS->id()); } } } else { // value bool bChanged = false; switch (pVal->type()) { case OdGiVariant::kBoolean: { bool val(pVal->asBoolean()); const bool prevVal(val); if (CSimpleInputDlg().DoInput(_T("Input Property Value"), _T("Enter new boolean value:"), &val)) { if (val != prevVal) pVal->set(val), bChanged = true; } } break; case OdGiVariant::kInt: { OdInt32 val(pVal->asInt()); const OdInt32 prevVal(val); // Search in enums... probably this is enum variable. OdVector > valNames; OdVector > valVals; { const OdUInt32 nEnums = sizeof(g_VisualStyleEnumsDef) / sizeof(GVSFlagsDef); for (OdUInt32 nEnum = 0; nEnum < nEnums; nEnum++) { if ((g_VisualStyleEnumsDef[nEnum].m_prop == (OdGiVisualStyleProperties::Property)index)) { //if (g_VisualStyleEnumsDef[nEnum].m_nFlag) // enum can have zeroes { valNames.push_back(g_VisualStyleEnumsDef[nEnum].m_pFlagName); valVals.push_back(OdUInt32(g_VisualStyleEnumsDef[nEnum].m_nFlag)); } } } if (!valNames.isEmpty()) { if (CVisualStylePropertyEditDlg().DoEnum(g_VisualStylePropName[index], valNames.asArrayPtr(), valVals.asArrayPtr(), valVals.size(), *(OdUInt32*)&val)) { if (val != prevVal) pVal->set(val), bChanged = true; } } } // Search in flags... probably this is flags variable. if (valNames.isEmpty()) { const OdUInt32 nFlags = sizeof(g_VisualStyleFlagsDef) / sizeof(GVSFlagsDef); for (OdUInt32 nFlag = 0; nFlag < nFlags; nFlag++) { if (g_VisualStyleFlagsDef[nFlag].m_prop == (OdGiVisualStyleProperties::Property)index) { if (g_VisualStyleFlagsDef[nFlag].m_nFlag) { valNames.push_back(g_VisualStyleFlagsDef[nFlag].m_pFlagName); valVals.push_back(OdUInt32(g_VisualStyleFlagsDef[nFlag].m_nFlag)); } } } if (!valNames.isEmpty()) { if (CVisualStylePropertyEditDlg().DoFlags(g_VisualStylePropName[index], valNames.asArrayPtr(), valVals.asArrayPtr(), valVals.size(), *(OdUInt32*)&val)) { if (val != prevVal) pVal->set(val), bChanged = true; } } } if (valNames.isEmpty()) { if (CSimpleInputDlg().DoInput(_T("Input Property Value"), _T("Enter new integer value:"), &val)) { if (val != prevVal) pVal->set(val), bChanged = true; } } } break; case OdGiVariant::kDouble: { double val(pVal->asDouble()); const double prevVal(val); if (CSimpleInputDlg().DoInput(_T("Input Property Value"), _T("Enter new floating point value:"), &val)) { if (val != prevVal) pVal->set(val), bChanged = true; } } break; case OdGiVariant::kColor: { OdCmEntityColor val(pVal->asColor()); const OdCmEntityColor prevVal(val); COdCmEntityColorDlg colorDlg(val); if (colorDlg.DoModal() == IDOK) { val = colorDlg.GetColor(); if (val != prevVal) pVal->set(val), bChanged = true; } } break; case OdGiVariant::kString: { OdString val(pVal->asString()); const OdString prevVal(val); if (CSimpleInputDlg().DoInput(_T("Input Property Value"), _T("Enter new string value:"), &val)) { if (val != prevVal) pVal->set(val), bChanged = true; } } break; default: break; } if (bChanged) { try { pVS->upgradeOpen(); pVS->setTrait((OdGiVisualStyleProperties::Property)index, pVal.get(), op); pVal = pVS->trait((OdGiVisualStyleProperties::Property)index); // Get back to be sure that it is modified OdString val; ::odGiVariantToText((OdGiVisualStyleProperties::Property)index, pVal, val); m_PropsList.SetItemText(index, 3, val.c_str()); //FAE: support preview m_VisualStyle.SetVisualStyle(pVS->id()); } catch (...) { MessageBox(_T("Value isn't modified."), OD_T("Value Editor"), MB_ICONWARNING); } } } } *pResult = 0; } void CDbVisualStylesDlg::OnDblclkLbvisualstyles() { int nItem = m_VisualStylesList.GetCurSel(); OdDbObjectPtr pVp = m_pDb->activeViewportId().openObject(OdDb::kForWrite); OdDbAbstractViewportDataPtr pVdata(pVp); if (nItem != -1 && !pVdata.isNull() && pVdata->gsView(pVp)) { CString vsName; m_VisualStylesList.GetText(nItem, vsName); OdDbVisualStylePtr pVS = OdDbVisualStyle::cast(OdDbDictionary::cast(m_pDb->getVisualStyleDictionaryId().openObject())->getAt(vsName.GetBuffer(), OdDb::kForRead)); OdDb::RenderMode nearestMode = OdDb::k2DOptimized; if (!pVS->trait(OdGiVisualStyleProperties::kUseDrawOrder)->asBoolean()) { if (pVS->trait(OdGiVisualStyleProperties::kFaceLightingModel)->asInt() == OdGiVisualStyleProperties::kInvisible) nearestMode = OdDb::kWireframe; else if (pVS->trait(OdGiVisualStyleProperties::kFaceLightingModel)->asInt() == OdGiVisualStyleProperties::kConstant) nearestMode = OdDb::kHiddenLine; else { if (pVS->trait(OdGiVisualStyleProperties::kEdgeModel)->asInt() != OdGiVisualStyleProperties::kNoEdges) nearestMode = (pVS->trait(OdGiVisualStyleProperties::kFaceLightingQuality)->asInt() == OdGiVisualStyleProperties::kPerFaceLighting) ? OdDb::kFlatShadedWithWireframe : OdDb::kGouraudShadedWithWireframe; else nearestMode = (pVS->trait(OdGiVisualStyleProperties::kFaceLightingQuality)->asInt() == OdGiVisualStyleProperties::kPerFaceLighting) ? OdDb::kFlatShaded : OdDb::kGouraudShaded; } } pVdata->setRenderMode(pVp, nearestMode); pVdata->setVisualStyle(pVp, pVS->id()); EndDialog(IDYES); } } void CDbVisualStylesDlg::OnOK() { CDialog::OnOK(); } ///////////////////////////////////////////////////////////////////////////// // CDbRenderEnvironmentDlg dialog CDbRenderEnvironmentDlg::CDbRenderEnvironmentDlg(OdDbDatabase* pDb, CWnd* pParent /*=NULL*/) : CDialog(CDbRenderEnvironmentDlg::IDD, pParent) , m_pDb(pDb) { //{{AFX_DATA_INIT(CDbRenderEnvironmentDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CDbRenderEnvironmentDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDbRenderEnvironmentDlg) DDX_Control(pDX, IDC_SENVIMAGEPREVIEW, m_ctrlImagePreview); DDX_Control(pDX, IDC_SENVFOGCOLOR, m_ctrlFogColor); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDbRenderEnvironmentDlg, CDialog) //{{AFX_MSG_MAP(CDbRenderEnvironmentDlg) //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BROWSE, &CDbRenderEnvironmentDlg::OnBnClickedEnvImageBrowse) ON_BN_CLICKED(IDC_BENVFOGCOLOR, &CDbRenderEnvironmentDlg::OnBnClickedEnvFogColor) ON_BN_CLICKED(IDC_BENVFOGDISTNEAR, &CDbRenderEnvironmentDlg::OnBnClickedEnvFogNearDist) ON_BN_CLICKED(IDC_BENVFOGDISTFAR, &CDbRenderEnvironmentDlg::OnBnClickedEnvFogFarDist) ON_BN_CLICKED(IDC_BENVFOGDENSNEAR, &CDbRenderEnvironmentDlg::OnBnClickedEnvFogNearDens) ON_BN_CLICKED(IDC_BENVFOGDENSFAR, &CDbRenderEnvironmentDlg::OnBnClickedEnvFogFarDens) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDbRenderEnvironmentDlg message handlers BOOL CDbRenderEnvironmentDlg::OnInitDialog() { CDialog::OnInitDialog(); if (m_pDb) { OdDbRenderEnvironmentPtr pEnv = ::oddbGetRenderEnvironmentObject(m_pDb, OdDb::kForRead, false); if (!pEnv.isNull()) { // Environment image CheckDlgButton(IDC_CBENABLEENVIMAGE, (pEnv->environmentImageEnabled()) ? BST_CHECKED : BST_UNCHECKED); SetDlgItemText(IDC_SENVIMAGEFILE, pEnv->environmentImageFileName().c_str()); UpdateEnvImage(); // Fog CheckDlgButton(IDC_CBENABLEENVFOG, (pEnv->fogEnabled()) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CBENABLEENVFOGBACKGROUND, (pEnv->fogBackgroundEnabled()) ? BST_CHECKED : BST_UNCHECKED); m_ctrlFogColor.SetColor(pEnv->fogColor()); { double distNear = 0.0, distFar = 0.0; pEnv->distances(distNear, distFar); SetDlgItemFloat(IDC_SENVFOGDISTNEAR, distNear); SetDlgItemFloat(IDC_SENVFOGDISTFAR, distFar); } { double densNear = 0.0, densFar = 0.0; pEnv->fogDensity(densNear, densFar); SetDlgItemFloat(IDC_SENVFOGDENSNEAR, densNear); SetDlgItemFloat(IDC_SENVFOGDENSFAR, densFar); } } } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDbRenderEnvironmentDlg::SetDlgItemFloat(int nId, double nVal) { SetDlgItemText(nId, OdString().format(OD_T("%.2f"), nVal).c_str()); } double CDbRenderEnvironmentDlg::GetDlgItemFloat(int nId) { CString cs; GetDlgItemText(nId, cs); return odStrToF(cs); } void CDbRenderEnvironmentDlg::UpdateEnvImage() { OdRxRasterServicesPtr pRasSvcs = odrxDynamicLinker()->loadApp(RX_RASTER_SERVICES_APPNAME); if (!pRasSvcs.isNull()) { CString cs; GetDlgItemText(IDC_SENVIMAGEFILE, cs); m_ctrlImagePreview.SetImage(pRasSvcs->loadRasterImage(OdString((LPCTSTR)cs))); } if (m_ctrlImagePreview.GetImage()) SetDlgItemText(IDC_SENVIMAGESTATUS, _T("Resolved")); else SetDlgItemText(IDC_SENVIMAGESTATUS, _T("Not found")); } void CDbRenderEnvironmentDlg::OnOK() { if (m_pDb) { OdDbRenderEnvironmentPtr pEnv = ::oddbGetRenderEnvironmentObject(m_pDb, OdDb::kForWrite, true); // Environment image pEnv->setEnvironmentImageEnabled(IsDlgButtonChecked(IDC_CBENABLEENVIMAGE) == BST_CHECKED); CString csEnvImage; GetDlgItemText(IDC_SENVIMAGEFILE, csEnvImage); pEnv->setEnvironmentImageFileName(OdString((LPCTSTR)csEnvImage)); // Fog pEnv->setFogEnabled(IsDlgButtonChecked(IDC_CBENABLEENVFOG) == BST_CHECKED); pEnv->setFogBackgroundEnabled(IsDlgButtonChecked(IDC_CBENABLEENVFOGBACKGROUND) == BST_CHECKED); pEnv->setFogColor(m_ctrlFogColor.GetColor()); pEnv->setDistances(GetDlgItemFloat(IDC_SENVFOGDISTNEAR), GetDlgItemFloat(IDC_SENVFOGDISTFAR)); pEnv->setFogDensity(GetDlgItemFloat(IDC_SENVFOGDENSNEAR), GetDlgItemFloat(IDC_SENVFOGDENSFAR)); } CDialog::OnOK(); } void CDbRenderEnvironmentDlg::OnBnClickedEnvImageBrowse() { CString csEnvImage; GetDlgItemText(IDC_SENVIMAGEFILE, csEnvImage); CFileDialog openFile(true, _T("png"), csEnvImage, OFN_PATHMUSTEXIST, _T("Windows Bitmap (*.bmp)|*.bmp|") _T("JPEG Images (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|TARGA Images (*.tga)|*.tga|All Files (*.*)|*.*||"), this); if (openFile.DoModal() == IDOK) { SetDlgItemText(IDC_SENVIMAGEFILE, openFile.GetPathName()); UpdateEnvImage(); } } void CDbRenderEnvironmentDlg::OnBnClickedEnvFogColor() { COdCmEntityColorDlg colorDlg(m_ctrlFogColor.GetColor()); if (colorDlg.DoModal() == IDOK) m_ctrlFogColor.SetColor(colorDlg.GetColor()); } void CDbRenderEnvironmentDlg::OnBnClickedEnvFogNearDist() { double val(GetDlgItemFloat(IDC_SENVFOGDISTNEAR)); if (CSimpleInputDlg().DoInput(_T("Near Fog Distance"), _T("Enter floating point value in 0-100 range:"), &val, 0.0, GetDlgItemFloat(IDC_SENVFOGDISTFAR))) SetDlgItemFloat(IDC_SENVFOGDISTNEAR, val); } void CDbRenderEnvironmentDlg::OnBnClickedEnvFogFarDist() { double val(GetDlgItemFloat(IDC_SENVFOGDISTFAR)); if (CSimpleInputDlg().DoInput(_T("Far Fog Distance"), _T("Enter floating point value in 0-100 range:"), &val, GetDlgItemFloat(IDC_SENVFOGDISTNEAR), 100.0)) SetDlgItemFloat(IDC_SENVFOGDISTFAR, val); } void CDbRenderEnvironmentDlg::OnBnClickedEnvFogNearDens() { double val(GetDlgItemFloat(IDC_SENVFOGDENSNEAR)); if (CSimpleInputDlg().DoInput(_T("Near Fog Density"), _T("Enter floating point value in 0-100 range:"), &val, 0.0, GetDlgItemFloat(IDC_SENVFOGDENSFAR))) SetDlgItemFloat(IDC_SENVFOGDENSNEAR, val); } void CDbRenderEnvironmentDlg::OnBnClickedEnvFogFarDens() { double val(GetDlgItemFloat(IDC_SENVFOGDENSFAR)); if (CSimpleInputDlg().DoInput(_T("Far Fog Density"), _T("Enter floating point value in 0-100 range:"), &val, GetDlgItemFloat(IDC_SENVFOGDENSNEAR), 100.0)) SetDlgItemFloat(IDC_SENVFOGDENSFAR, val); } //