AGX Dynamics 2.42.2.1
Loading...
Searching...
No Matches
RaytraceHandles.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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#pragma once
18
19#include <agxCollide/Shape.h>
20
21namespace agxCollide
22{
23 class MeshData;
24}
25
26namespace agxSensor
27{
28 class RtInstanceData;
29
30 struct RtSceneHandle;
31 struct RtScene;
32 struct RtShape;
33 struct RtShapeInstanceHandle;
34 struct RtMaterialHandle;
35
36 using RtSceneHandleRef = std::shared_ptr<RtSceneHandle>;
37 using RtSceneRef = std::shared_ptr<RtScene>;
38
39 using RtShapeRef = std::shared_ptr<RtShape>;
40 using RtShapeInstanceHandleRef = std::shared_ptr<RtShapeInstanceHandle>;
41 using RtMaterialHandleRef = std::shared_ptr<RtMaterialHandle>;
42
47 {
48 enum class Type
49 {
50 UNKNOWN,
51 OPAQUE_LAMBERTIAN,
52 OPAQUE_GGX_AND_OREN_NAYAR,
53 OPAQUE_BRDF_EXPLICIT,
54 AMBIENT_ATMOSPHERE,
55 NUM_TYPES
56 };
57 };
58
64 {
72
83
90 template<RtMaterialHandle::Type Type>
91 RtMaterialInstance as() const;
92
98 bool is( RtMaterialHandle::Type inType ) const;
99
105 template<RtMaterialHandle::Type Type>
106 bool is() const;
107
112 bool operator== ( const RtMaterialInstance& other ) const;
113
117 bool operator!= ( const RtMaterialInstance& other ) const;
118
119 RtMaterialHandleRef handle{ nullptr };
120 RtMaterialHandle::Type type{ RtMaterialHandle::Type::UNKNOWN };
121 };
122
124 {
125 return is( inType ) ?
126 *this :
127 // Invalid material of given inType.
128 RtMaterialInstance{ nullptr, inType };
129 }
130
131 template<RtMaterialHandle::Type Type>
133 {
134 return this->as( Type );
135 }
136
138 {
139 return this->type == inType;
140 }
141
142 template<RtMaterialHandle::Type Type>
143 inline bool RtMaterialInstance::is() const
144 {
145 return this->is( Type );
146 }
147
148 inline bool RtMaterialInstance::operator== ( const RtMaterialInstance& other ) const
149 {
150 return handle == other.handle && type == other.type;
151 }
152
153 inline bool RtMaterialInstance::operator!= ( const RtMaterialInstance& other ) const
154 {
155 return !( *this == other );
156 }
157
163 {
169 };
170
175 {
180
185 void setMaterial( RtMaterialInstance newMaterial );
186
187 RtSceneHandleRef handle{ nullptr };
188 RtMaterialInstance material{ nullptr };
189 };
190
196 {
203 static RtShapeRef create( const agx::Vec3Vector& vertices, const agx::UInt32Vector& indices );
204
212 static RtShapeRef create( const agx::Vec3Vector& vertices, const agx::UInt32Vector& indices, const agx::Vec3Vector& normals );
213
220
228
235 static RtShapeRef create( const agxCollide::Shape* shape );
236
242 static RtShapeRef create( const agxCollide::RenderData* renderData );
243
249 void setVertices( const agx::Vec3Vector& vertices );
250 };
253
258 {
264 void setTransform( const agx::AffineMatrix4x4& agxTransform,
265 agx::Vec3 scale = agx::Vec3( 1 ) );
266
272
278 void setMaterial( RtMaterialInstance materialInstance );
279 };
280
286 {
287 };
288}
#define AGXSENSOR_EXPORT
Stores triangle mesh data as triangle lists, i.e.
Definition: MeshData.h:39
Class for storing rendering information for a Shape.
Definition: RenderData.h:39
Base class for a shape.
Definition: Shape.h:58
Type
Define the type of a Shape.
Definition: Shape.h:62
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...
std::shared_ptr< RtShape > RtShapeRef
RtShapeRef RtShapeHandleRef
std::shared_ptr< RtShapeInstanceHandle > RtShapeInstanceHandleRef
RtEntityId
Entity id > 0 to access user data given raytrace results including ENTITY_ID_I32.
std::shared_ptr< RtSceneHandle > RtSceneHandleRef
std::shared_ptr< RtScene > RtSceneRef
std::shared_ptr< RtMaterialHandle > RtMaterialHandleRef
Material handle of implicit type in the raytrace environment.
Material instance in the raytrace environment, containing handle and type.
bool operator!=(const RtMaterialInstance &other) const
bool is() const
Check if this material instance is of the given type.
RtMaterialInstance as() const
"Cast" this material instance the given template parameter Type.
bool operator==(const RtMaterialInstance &other) const
static RtMaterialInstance create(RtMaterialHandle::Type type)
Create a new handle and instance in of a material of the given type in the raytrace environment.
RtMaterialHandle::Type type
A node performs a single operation, e.g., raycast, gaussian blur, merging etc.
A scene constitutes the raytrace environment and contains a number of raytrace instances.
static RtSceneHandleRef create()
Create an empty raytracing environment scene.
Raytrace scene with handle and ambient/atmospheric material.
static RtSceneRef create()
Create a new scene with default ambient/atmospheric material.
void setMaterial(RtMaterialInstance newMaterial)
Assign ambient/atmosphere material.
Handle to an instance in the raytrace environment.
void setEntityId(RtEntityId id)
Assign id of this instance.
void setTransform(const agx::AffineMatrix4x4 &agxTransform, agx::Vec3 scale=agx::Vec3(1))
Update transform and/or scale of this instance.
void setMaterial(RtMaterialInstance materialInstance)
Assign material to this instance.
Handle and interface for shapes in the raytrace environment (alias RtShapeHandle).
void setVertices(const agx::Vec3Vector &vertices)
Update vertex positions of this mesh.
static RtShapeRef create(const agxCollide::MeshData *data)
Create mesh handle given collision mesh data.
static RtShapeRef create(const agxCollide::Shape *shape)
Create mesh handle given shape instance.
static RtShapeRef create(const agxCollide::RenderData *renderData)
Create mesh handle given the triangles in the given render data instance.
static RtShapeRef create(agxCollide::Shape::Type shapeType)
Create mesh handle given shape type.
static RtShapeRef create(const agx::Vec3Vector &vertices, const agx::UInt32Vector &indices, const agx::Vec3Vector &normals)
Create mesh handle given vertices and indices.
static RtShapeRef create(const agx::Vec3Vector &vertices, const agx::UInt32Vector &indices)
Create mesh handle given vertices and indices.