AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
PovExporter.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXIO_POV_EXPORTER_H
18#define AGXIO_POV_EXPORTER_H
19
20#include <agx/config.h>
22#include <stdexcept>
23#include <agx/AffineMatrix4x4.h>
24#include <agx/RigidBody.h>
25#include <agxCollide/Geometry.h>
26#include <agx/Constraint.h>
27#include <agxSDK/Assembly.h>
28#include <sstream>
29namespace agxSDK
30{
31 class Simulation;
32}
33
34namespace agx {
35 class PropertyContainer;
36 class Material;
37 class ContactMaterial;
38}
39
40namespace agxCollide {
41 class Shape;
42}
43
44namespace agxIO
45{
50 {
51 public:
53
65 bool write( const agx::String& filename, agxSDK::Simulation *simulation,
66 agx::Vec3 from, agx::Vec3 at,
67 agx::Vec3 up, double fovy, double aspectRatio );
68
80 bool write( std::ostream& outStream, agxSDK::Simulation *simulation,
81 agx::Vec3 from, agx::Vec3 at,
82 agx::Vec3 up, double fovy, double aspectRatio );
83
85
86 static void setFocalSettings( agx::Real distance, agx::Real aperture, int blur_samples, agx::Real variance );
87 static void setEnableFocalBlur( bool enable );
88
89 protected:
90
93 {
94 agx::String out;
95 out.resize(in.size());
96
97 for(size_t i=0; i < in.size(); i++)
98 {
99 if (isalnum(static_cast<unsigned char>(in[i])))
100 out[i] = in[i];
101 else
102 out[i] = '_';
103 }
104 return "pov_"+out;
105 }
106
107
109// bool exportConstraints();
112 bool exportGeometries( const agx::String& parentMaterial );
113 bool exportShape( const agx::AffineMatrix4x4& t, const agxCollide::Shape *shape, const agx::String& parentMaterial );
114 bool exportGeometry( agxCollide::Geometry *geometry, const agx::String& parentMaterial);
116
120
122#ifdef GET_NAME
123#undef GET_NAME
124#endif
125#define GET_NAME(TYPE, NAME) \
126 typedef agx::HashTable<const TYPE *, agx::String> NameTable ##NAME; \
127 typedef agx::HashSet<agx::String> UniqueNameTable ##NAME; \
128 NameTable ##NAME m_exportedName ##NAME; \
129 UniqueNameTable ##NAME m_uniqueNames ##NAME; \
130 \
131 inline agx::String getName( const TYPE *item ) \
132 { \
133 agx::String name = item->getName(); \
134 NameTable ##NAME::const_iterator nameIt = m_exportedName ##NAME.find(item); \
135 if (nameIt != m_exportedName ##NAME.end()) \
136 return cleanupString(nameIt->second); /* use the associated name */ \
137 if (name.empty()) { \
138 std::stringstream str; \
139 str << #NAME << "_" << item->getIndex(); \
140 name = str.str(); \
141 m_exportedName ##NAME.insert(item, name); \
142 m_uniqueNames ##NAME.insert(name); \
143 return cleanupString(name); \
144 } \
145 else { /* Not empty, but is it unique? */ \
146 UniqueNameTable ##NAME::const_iterator it = m_uniqueNames ##NAME.find(name); \
147 if (it == m_uniqueNames ##NAME.end() ) \
148 { \
149 m_uniqueNames ##NAME.insert(name); \
150 m_exportedName ##NAME.insert(item, name); \
151 return cleanupString(name); \
152 } \
153 \
154 std::stringstream str; \
155 str << name << "_" << item->getIndex(); /* Create a new unique name and use that for this item */ \
156 name = str.str(); \
157 m_exportedName ##NAME.insert(item, name); \
158 m_uniqueNames ##NAME.insert(name); \
159 } \
160 return cleanupString(name); \
161 }
162
163 GET_NAME(agx::RigidBody, Bodies)
164 GET_NAME(agxCollide::Geometry, Geometries)
165 GET_NAME(agxSDK::Assembly, Assemblies)
166
167 #undef GET_NAME
168
172
174
175 std::ostream *m_outStream;
176
181 static int m_blurSamples;
182 static bool m_focalBlurEnable;
183 };
184
185}
186#endif
#define GET_NAME(TYPE, NAME)
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
Base class for a shape.
Definition Shape.h:54
Class for exporting a simulation into AGX .pov format.
Definition PovExporter.h:50
static void setFocalSettings(agx::Real distance, agx::Real aperture, int blur_samples, agx::Real variance)
GeometryPtrHashSet m_geometryHasMaterial
std::ostream * m_outStream
static agx::Real m_aperture
bool exportRigidBody(agx::RigidBody *body)
static agx::Real m_variance
static int m_blurSamples
agxSDK::Simulation * m_simulation
static void setEnableFocalBlur(bool enable)
AssemblyPtrHashSet m_exportedAssemblies
agx::HashSet< agxSDK::Assembly * > AssemblyPtrHashSet
agx::HashSet< agxCollide::Geometry * > GeometryPtrHashSet
static bool m_focalBlurEnable
agx::HashSet< agx::RigidBody * > RigidBodyPtrHashSet
RigidBodyPtrHashSet m_exportedBodies
bool exportShape(const agx::AffineMatrix4x4 &t, const agxCollide::Shape *shape, const agx::String &parentMaterial)
bool exportGeometries(const agx::String &parentMaterial)
bool write(const agx::String &filename, agxSDK::Simulation *simulation, agx::Vec3 from, agx::Vec3 at, agx::Vec3 up, double fovy, double aspectRatio)
Write a simulation into the Pov-ray file format for rendering.
static agx::Real m_focalDistance
agx::String cleanupString(const agx::String &in)
Translate any non-alphanumeric letters into '_'.
Definition PovExporter.h:92
bool exportAssembly(agxSDK::Assembly *assembly)
bool write(std::ostream &outStream, agxSDK::Simulation *simulation, agx::Vec3 from, agx::Vec3 at, agx::Vec3 up, double fovy, double aspectRatio)
Write a simulation in .pov format to a stream.
GeometryPtrHashSet m_exportedGeometries
bool exportGeometry(agxCollide::Geometry *geometry, const agx::String &parentMaterial)
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Definition Assembly.h:68
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Inheritance with partial specialization due to bug with ref_ptr containers.
The rigid body class, combining a geometric model and a frame of reference.
Definition RigidBody.h:52
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxIO namespace contains classes for reading, writing and finding files.
Definition Material.h:42
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition Real.h:42