1 //
2 // Copyright 2019 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24
25 #include "../common/viewerArgsUtils.h"
26
27 #include "../../regression/common/arg_utils.h"
28 #include "../../regression/common/shape_utils.h"
29 #include "../common/objAnim.h"
30
31 #include <stdio.h>
32
33 namespace ViewerArgsUtils {
34
35 const ObjAnim *
PopulateAnimShapes(const ArgOptions & args,std::vector<ShapeDesc> * defaultShapes)36 PopulateAnimShapes(const ArgOptions &args,
37 std::vector<ShapeDesc> *defaultShapes)
38 {
39 if (args.GetObjFiles().empty())
40 return NULL;
41
42 const ObjAnim *objAnim = ObjAnim::Create(args.GetObjFiles(),
43 args.GetDefaultScheme());
44
45 if (objAnim && defaultShapes) {
46 defaultShapes->push_back(ShapeDesc(args.GetObjFiles()[0], "",
47 args.GetDefaultScheme()));
48 }
49
50 return objAnim;
51
52 }
53
54 void
PopulateShapes(const ArgOptions & args,std::vector<ShapeDesc> * defaultShapes)55 PopulateShapes(const ArgOptions &args,
56 std::vector<ShapeDesc> *defaultShapes)
57 {
58 if (defaultShapes) {
59 args.AppendObjShapes(*defaultShapes, true /* print warnings */);
60 }
61 }
62
63 void
PopulateShapesOrAnimShapes(const ArgOptions & args,std::vector<ShapeDesc> * defaultShapes,const ObjAnim ** objAnim)64 PopulateShapesOrAnimShapes(
65 const ArgOptions &args,
66 std::vector<ShapeDesc> *defaultShapes,
67 const ObjAnim **objAnim)
68 {
69 if (!defaultShapes)
70 return;
71
72 if (args.GetObjFiles().empty())
73 return;
74
75 if (args.GetObjsAreAnim()) {
76
77 if (!objAnim) {
78 printf("Warning: animations of objs are unsupported in this "
79 "viewer.\n");
80 return;
81 }
82
83 *objAnim = PopulateAnimShapes(args, defaultShapes);
84
85 } else {
86
87 PopulateShapes(args, defaultShapes);
88
89 }
90 }
91
92 }
93