blob: d8042bbf386fc6753e693e065146cee5c17f1834 (
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
|
/*
* 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 SCENE_CONTROLLER_H
#define SCENE_CONTROLLER_H
#include "SampleManager.h"
#include <map>
#include <vector>
#include <NvCloth/Factory.h>
#include "JobManager.h"
#include "ClothRenderMesh.h"
#include <cuda.h>
#include "CallbackImplementations.h"
namespace nv
{
namespace cloth
{
class Factory;
class Solver;
class Cloth;
class Fabric;
class DxContextManagerCallback;
}
}
class RenderMaterial;
class Renderable;
class DebugLineRenderBuffer;
struct ClothActor
{
Renderable* mClothRenderable;
ClothRenderMesh* mClothRenderMesh;
nv::cloth::Cloth* mCloth;
};
class Scene;
class SceneController : public ISampleController
{
public:
SceneController();
virtual ~SceneController();
virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void Animate(double dt);
void drawUI();
void drawStatsUI();
virtual void onInitialize();
virtual void onSampleStart();
virtual void onSampleStop();
virtual void onTerminate();
JobManager* getJobManager() { return &sJobManager; }
nv::cloth::Factory* getFactory() { return mFactories[mActivePlatform]; }
static JobManager sJobManager;
//////// used controllers ////////
Renderer& getRenderer() const
{
return getManager()->getRenderer();
}
CommonUIController& getCommonUIController() const
{
return getManager()->getCommonUIController();
}
RenderMaterial* getDefaultMaterial()
{
return mPhysXPrimitiveRenderMaterial;
}
RenderMaterial* getDefaultPlaneMaterial()
{
return mPhysXPlaneRenderMaterial;
}
RenderMaterial* getDefaultWeightedModelSkinMaterial()
{
return mWeightedModelSkinRenderMaterial;
}
DebugLineRenderBuffer* getDebugLineRenderBuffer()
{
return mDebugLineRenderBuffer;
}
private:
SceneController& operator= (SceneController&); // not implemented
void changeScene(int index);
//////// internal data ////////
RenderMaterial* mPhysXPrimitiveRenderMaterial;
RenderMaterial* mPhysXPlaneRenderMaterial;
RenderMaterial* mWeightedModelSkinRenderMaterial;
Renderable* mPlane;
std::vector<Renderable*> mBoxes;
DebugLineRenderBuffer* mDebugLineRenderBuffer;
float mTimeScale;
float mStartDelay;
// NvCloth
CpuDispatcher mDispatcher;
physx::PxTaskManager* mTaskManager;
nv::cloth::Factory* mFactories[3];
int mActivePlatform;
bool mCUDAInitialized;
CUcontext mCUDAContext;
bool mDXInitialized;
ID3D11Device* mDXDevice;
ID3D11DeviceContext* mDXDeviceContext;
nv::cloth::DxContextManagerCallback* mGraphicsContextManager;
Scene* mActiveScene;
int mActiveSceneIndex;
double mLeftOverTime;
bool mPaused;
int mSingleStep;
};
#endif
|