Fermat
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
pbrt_importer.h
1 /*
2  * Fermat
3  *
4  * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the NVIDIA CORPORATION nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #pragma once
30 
31 #include <pbrt_parser.h>
32 #include <cugar/linalg/vector.h>
33 #include <cugar/linalg/matrix.h>
34 #include <vector>
35 #include <stack>
36 #include <string>
37 #include <map>
38 
39 class MeshStorage;
40 struct MeshMaterial;
41 struct Camera;
42 struct DirectionalLight;
43 
44 namespace pbrt {
45 
47 {
48  FilmOptions() : gamma(2.2f), exposure(1.0f) {}
49 
50  float gamma;
51  float exposure;
52 };
53 
54 struct FermatImporter : public Importer
55 {
56  FermatImporter(const char* filename, MeshStorage* mesh, Camera* camera, std::vector<DirectionalLight>* dir_lights, std::vector<std::string>* scene_dirs);
57  ~FermatImporter();
58 
59  virtual void identity();
60  virtual void transform(const Value& floats);
61  virtual void rotate(const float angle, const float x, const float y, const float z);
62  virtual void scale(const float x, const float y, const float z);
63  virtual void translate(const float x, const float y, const float z);
64  virtual void look_at(
65  const float ex, const float ey, const float ez,
66  const float lx, const float ly, const float lz,
67  const float ux, const float uy, const float uz);
68 
69  virtual void integrator(const char* name, const ParameterList& params) {}
70  virtual void sampler(const char* name, const ParameterList& params) {}
71  virtual void pixel_filter(const char* name, const ParameterList& params) {}
72  virtual void film(const char* name, const ParameterList& params);
73  virtual void camera(const char* name, const ParameterList& params);
74 
75  virtual void world_begin();
76  virtual void world_end();
77 
78  virtual void attribute_begin();
79  virtual void attribute_end();
80 
81  virtual void transform_begin();
82  virtual void transform_end();
83 
84  virtual void texture(const char* name, const char* texel_type, const char* texture_type, const ParameterList& params);
85 
86  virtual void make_named_medium(const char* name, const ParameterList& params);
87  virtual void make_named_material(const char* name, const ParameterList& params);
88  virtual void named_material(const char* name);
89  virtual void medium_interface(const char* name1, const char* name2);
90  virtual void material(const char* type, const ParameterList& params);
91  virtual void area_light_source(const char* type, const ParameterList& params);
92  virtual void light_source(const char* type, const ParameterList& params);
93 
94  virtual void shape(const char* type, const ParameterList& params);
95 
96  void build_material(const char* type, const ParameterList& params, MeshMaterial& material);
97  void finish();
98 
99 
100  typedef std::map<std::string, uint32> texture_map_type;
101  typedef std::map<std::string, uint32> material_map_type;
102 
103  FilmOptions m_film;
104  MeshStorage* m_mesh;
105  Camera* m_camera;
106  std::vector<DirectionalLight>* m_dir_lights;
107  std::vector<std::string>& m_dirs;
108  texture_map_type m_texture_map;
109  material_map_type m_material_map;
110  std::vector<MeshMaterial> m_materials;
111  std::vector<std::string> m_material_names;
112  std::stack<cugar::Matrix4x4f> m_transform_stack;
113  std::stack<int> m_material_stack;
114  std::stack<cugar::Vector3f> m_emission_stack;
115  int m_default_material;
116 };
117 
118 } // namespace pbrt
void transform(const uint32 n, const Iterator in, const Output out, const Functor functor)
Definition: primitives_inl.h:357
Definition: pbrt_parser.h:198
CUGAR_HOST_DEVICE Matrix< T, 4, 4 > translate(const Vector< T, 3 > &vec)
Definition: matrix_inline.h:524
Definition: pbrt_importer.cpp:41
Definition: pbrt_importer.h:54
Definition: lights.h:249
Definition: MeshView.h:55
Definition: pbrt_importer.h:46
Matrix< T, 4, 4 > look_at(const Vector< T, 3 > &eye, const Vector< T, 3 > &center, const Vector< T, 3 > &up, bool flip_sign=false)
Definition: matrix_inline.h:568
Definition: MeshStorage.h:44
Definition: camera.h:46
Definition: pbrt_parser.h:186
Definition: pbrt_parser.h:74
CUGAR_HOST_DEVICE Matrix< T, 4, 4 > scale(const Vector< T, 3 > &vec)
build a 3d scaling matrix
Definition: matrix_inline.h:539