aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/basicfs/include/BasicFSAssetImpl.h
blob: 59de33b7ad730fa1ed3c3c6ffe71f6f15f14b442 (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
/*
 * Copyright (c) 2008-2015, 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 BASIC_FS_ASSET_IMPL_H
#define BASIC_FS_ASSET_IMPL_H

#include "Apex.h"

#include "BasicFSAsset.h"
#include "ApexSDKHelpers.h"
#include "ModuleBasicFSImpl.h"
#include "ApexAssetAuthoring.h"
#include "ApexString.h"
#include "ApexAssetTracker.h"
#include "ApexAuthorableObject.h"
#include "ApexRWLockable.h"
#include "FieldBoundaryIntl.h"

namespace nvidia
{
namespace apex
{
class RenderMeshAsset;
}
namespace basicfs
{

class BasicFSActor;

///p,q -> p cross q = n (n - must be normalized!)
PX_INLINE void BuildPlaneBasis(const PxVec3& n, PxVec3& p, PxVec3& q)
{
	float nzSqr = n.z * n.z;
	if (nzSqr > 0.5f)
	{
		// choose p in y-z plane
		const float k = PxSqrt(n.y * n.y + nzSqr);
		// k can not be zero here
		const float rk = (1 / k);
		p.x = 0;
		p.y = -n.z * rk;
		p.z = n.y * rk;
		// set q = n cross p
		q.x = k;
		q.y = -n.x * p.z;
		q.z = n.x * p.y;
	}
	else
	{
		// choose p in x-y plane
		const float k = PxSqrt(n.x * n.x + n.y * n.y);
		// k can be zero in case n is zero
		const float rk = (k > 0) ? (1 / k) : 0;
		p.x = -n.y * rk;
		p.y = n.x * rk;
		p.z = 0;
		// set q = n cross p
		q.x = -n.z * p.y;
		q.y = n.z * p.x;
		q.z = k;
	}
}

class BasicFSAssetImpl : public BasicFSAsset, public ApexResourceInterface, public ApexResource, public ApexRWLockable
{
	friend class BasicFSAssetDummyAuthoring;
public:
	APEX_RW_LOCKABLE_BOILERPLATE

	BasicFSAssetImpl(ModuleBasicFSImpl*, const char*);
	virtual ~BasicFSAssetImpl();

	/* Asset */
	const char* 			getName() const
	{
		return mName.c_str();
	}

	// TODO: implement forceLoadAssets
	uint32_t					forceLoadAssets()
	{
		return 0;
	}

	/* ApexResourceInterface, ApexResource */
	uint32_t					getListIndex() const
	{
		return m_listIndex;
	}
	void					setListIndex(class ResourceList& list, uint32_t index)
	{
		m_list = &list;
		m_listIndex = index;
	}

	/**
	* \brief Apply any changes that may been made to the NvParameterized::Interface on this asset.
	*/
	virtual void applyEditingChanges(void)
	{
		APEX_INVALID_OPERATION("Not yet implemented!");
	}

	NvParameterized::Interface* getDefaultActorDesc() = 0;
	virtual Actor* createApexActor(const NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) = 0;

	NvParameterized::Interface* getDefaultAssetPreviewDesc()
	{
		APEX_INVALID_OPERATION("Not yet implemented!");
		return NULL;
	}

	virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& /*params*/, AssetPreviewScene* /*previewScene*/)
	{
		APEX_INVALID_OPERATION("Not yet implemented!");
		return NULL;
	}

	virtual bool isValidForActorCreation(const ::NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) const
	{
		return true; // todo implement this method
	}

	virtual bool isDirty() const
	{
		return false;
	}


protected:

	ModuleBasicFSImpl* 				mModule;
	ResourceList				mFSActors;
	ApexSimpleString			mName;

	friend class ModuleBasicFSImpl;
	friend class BasicFSActor;
};

}
} // end namespace nvidia::apex

#endif // BASIC_FS_ASSET_IMPL_H