aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/include/Module.h
blob: e02280b30942cb408258f98bcdaf91fe19a6e290 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
 * Copyright (c) 2008-2017, NVIDIA CORPORATION.  All rights reserved.
 *
 * NVIDIA CORPORATION and its licensors retain all intellectual property
 * and proprietary rights in and to this software, related documentation
 * and any modifications thereto.  Any use, reproduction, disclosure or
 * distribution of this software and related documentation without an express
 * license agreement from NVIDIA CORPORATION is strictly prohibited.
 */


#ifndef MODULE_H
#define MODULE_H

/*!
\file
\brief APEX Module API
*/

#include "ApexInterface.h"
#include "ApexSDK.h"
#include "foundation/PxSimpleTypes.h"

namespace nvidia
{
namespace apex
{

PX_PUSH_PACK_DEFAULT

class RenderableIterator;

/**
\brief Render lock modes.  These are used per-module to determine how render locking is done.
*/
struct RenderLockMode
{
	/**
	\brief Enum of render lock modes
	*/
	enum Enum
	{
		/**
		\brief	Disables render locking in the module scene.
		*/
		NO_RENDER_LOCK					= 0,

		/**
		\brief	Locks all apex actors in the module scene individually.
		*/
		PER_ACTOR_RENDER_LOCK			= 1,

		/**
		\brief	Locks an entire module scene with one lock.
		*/
		PER_MODULE_SCENE_RENDER_LOCK	= 2,
	};
};

/**
\brief A structure that holds two templated values, a min and a max
*/
template <typename T>
struct Range
{
	Range() {};
	/**
	\brief Constructor, sets min amd max values
	*/
	Range(T inMin, T inMax) : minimum(inMin), maximum(inMax) {};

	/**
	\brief operator ==
	*/
	bool operator== (const Range& r) const
	{
		return minimum == r.minimum && maximum == r.maximum;
	}

	/**
	\brief Minimal value
	*/
	T minimum;
	/**
	\brief Maximal value
	*/
	T maximum;
};



/**
\brief base class of all APEX modules

It describes the LODParameters and weights defined by the module.
*/
class Module : public ApexInterface
{
public:
	/**
	\brief Initialize the module
	\param[in] desc use Module::getDefaultModuleDesc() to get the descriptor necessary for initializing the module
	*/
	virtual void init(::NvParameterized::Interface& desc) = 0;

	/**
	\brief Returns the name of the module
	*/
	virtual const char* getName() const = 0;

	/**
	\brief Returns the unique ID of the module
	*/
	virtual AuthObjTypeID getModuleID() const = 0;

	/**
	\brief Returns the NvParameterized interface that contains module initialization parameters
	\note The module itself owns this object, so there's no need for the application to destroy it
	*/
	virtual ::NvParameterized::Interface* getDefaultModuleDesc()
	{
		return NULL;
	}

	/**
	\brief Allocate a renderable iterator

	Returns an Renderable iterator instance for the specified Scene.  The iterator
	will return pointers to renderables in this scene that were generated by this module. This
	is the preferred method for rendering IOFX actors.
	*/
	virtual RenderableIterator* createRenderableIterator(const Scene&) = 0;

	/**
	\brief Choose the locking mode for the module scene.  See RenderLockMode.

	Returns true if successful.
	*/
	virtual bool setRenderLockMode(RenderLockMode::Enum, Scene&) { return false; }

	/**
	\brief Returns the current render lock mode for the module scene.
	*/
	virtual RenderLockMode::Enum getRenderLockMode(const Scene&) const { return RenderLockMode::NO_RENDER_LOCK; }

	/**
	\brief Sets a render lock for the module scene.  Used when the SDK render lock mode is RenderLockMode::PER_MODULE_SCENE_RENDER_LOCK.  See ApexSDK::setRenderLockMode().
	
	Returns true iff successful.
	*/
	virtual	bool lockModuleSceneRenderLock(Scene&) { return false; }

	/**
	\brief Releases the render lock for the module scene.  See lockModuleSceneRenderLock().

	Returns true iff successful.
	*/
	virtual	bool unlockModuleSceneRenderLock(Scene&) { return false; }
};

PX_POP_PACK

}
} // end namespace nvidia::apex

#endif // MODULE_H