DayZ 1.24
Loading...
Searching...
No Matches
PPEMatClassesBase.c
Go to the documentation of this file.
1
3{
5 protected string m_MaterialPath = "";
7
11
13
21
30
31 protected void CreateMaterial()
32 {
33 if (m_MaterialPath != "")
34 m_Material = GetGame().GetWorld().GetMaterial(m_MaterialPath);
35 }
36
38 {
39 return m_Material;
40 }
41
42 //do not override!
51
54
56 {
58 PPEMatClassParameterBool parameter_data = new PPEMatClassParameterBool(GetPostProcessEffectID(), idx, this);
59 parameter_data.RegisterDefaults(p);
61 }
62
63 protected void RegisterParameterScalarInt(int idx, string parameter_name, int default_value, int min, int max)
64 {
66
67 PPEMatClassParameterInt parameter_data = new PPEMatClassParameterInt(GetPostProcessEffectID(), idx, this);
68 parameter_data.RegisterDefaults(p);
70 }
71
81
83 protected void RegisterParameterScalarFloatEx(int idx, string parameter_name, float default_value, float min, float max, typename type)
84 {
86
88 bool boo = Class.CastTo(parameter_data, type.Spawn());
89 //Print("RegisterParameterColorEx: " + boo );
90 parameter_data.RegisterDefaults(p);
91 parameter_data.SetMaterialIndex(GetPostProcessEffectID());
92 parameter_data.SetParameterIndex(idx);
93 parameter_data.SetParent(this);
95 }
96
98 protected void RegisterParameterColor(int idx, string parameter_name, float r, float g, float b, float a)
99 {
102 parameter_data.RegisterDefaults(p);
104 }
105
107 protected void RegisterParameterColorEx(int idx, string parameter_name, float r, float g, float b, float a, typename type)
108 {
111 bool boo = Class.CastTo(parameter_data, type.Spawn());
112 //Print("RegisterParameterColorEx: " + boo );
113 parameter_data.RegisterDefaults(p);
114 parameter_data.SetMaterialIndex(GetPostProcessEffectID());
115 parameter_data.SetParameterIndex(idx);
116 parameter_data.SetParent(this);
118 }
119
120 protected void RegisterParameterVector(int idx, string parameter_name, array<float> default_values) //needs to be compatible with every type of vector (vector2 to vector4), hence array<float>...
121 {
124 parameter_data.RegisterDefaults(p);
126 }
127
128 //TEXTURE and RESOURCE types are not overridable during runtime..currently unused and unhandled
136
144
145 //------------------------------------------------------------------------------------
148 {
150 bool exists = m_MaterialParamMapStructure.Find(request_data.GetParameterID(), param_data);
151 if (!exists)
152 {
153 Error("PPEClassBase | InsertParamValueData | mat/par/req: " + GetPostProcessEffectID() + "/" + request_data.GetParameterID() + "/" + request_data.GetRequesterIDX() + " not registered in m_MaterialParamMapStructure!");
154 return;
155 }
156
157 request_data.SetDataActive(true);
158 request_data.SetUpdatingDataValues(true); //marks request data as updating
159 param_data.InsertRequestData(request_data);//<request_ID, data>
160
161 //DbgPrnt("PPEDebug | InsertParamValueData | mat/par/req: " + GetPostProcessEffectID() + "/" + request_data.GetParameterID() + "/" + request_data.GetRequesterIDX() + " | requester: " + request_data.m_Requester);
162 }
163
164 //TODO - rework
167 {
168 /*for (int i = 0; i < m_ActiveMaterialRequestMap.Count(); i++)
169 {
170 ActiveParameterRequestsMap dbg = m_ActiveMaterialRequestMap.Get(i);
171 //DbgPrnt("PPEDebug | dbg size: " + dbg.Count());
172
173 if ( m_ActiveMaterialRequestMap.Get(i).Contains(req_idx) )
174 {
175 m_ActiveMaterialRequestMap.Get(i).Remove(req_idx);
176
177 dbg = m_ActiveMaterialRequestMap.Get(i);
178
179 if ( !m_ActiveMaterialRequestMap.Get(i) || m_ActiveMaterialRequestMap.Get(i).Count() < 1 )
180 {
181 if (m_ParameterUpdateQueue.IsValidIndex(i))
182 {
183 DbgPrnt("PPEDebug | PPEClassBase - RemoveRequest | Removing: " + i);
184 DbgPrnt("PPEDebug | PPEClassBase - RemoveRequest | exit 4 - last request removal");
185 m_ParameterRemovalQueue.Insert(m_ParameterUpdateQueue.Get(i));
186 }
187 else
188 DbgPrnt("PPEDebug | PPEClassBase - RemoveRequest | Update queue no. " + i + " already removed!");
189 }
190 }
191 //Adds to update one more time
192 m_Manager.SetMaterialParamUpdating(GetPostProcessEffectID(),i);
193 }*/
194 }
195
197 void OnUpdate(float timeslice, int order)
198 {
199 int parameter_idx = -1;
200 //DbgPrnt("PPEDebug | PPEClassBase - OnUpdate | mat_id: " + GetPostProcessEffectID());
201
202 if (m_ParameterUpdateQueueMap.Contains(order))
203 {
204 //Print(m_ParameterUpdateQueueMap.Get(order));
205 for (int i = 0; i < m_ParameterUpdateQueueMap.Get(order).Count(); i++)
206 {
207 //DbgPrnt("PPEDebug | PPEClassBase - OnUpdate | parameter_idx: " + m_ParameterUpdateQueue.Get(i));
208 Param p_values; //TODO - move to material classes?
209 bool setting_defaults = false;
212
214 }
215 m_Manager.InsertUpdatedMaterial(GetPostProcessEffectID());
216
218 }
219 /*if ( !m_ParameterUpdateQueueMap.Contains(order) || m_ParameterUpdateQueueMap.Get(order).Count() < 1 )
220 m_Manager.RemoveMaterialUpdating(GetPostProcessEffectID(),order); //stops material from updating when no parameters are.*/
221 }
222
225 {
228
229 switch (var_type)
230 {
231 case PPEConstants.VAR_TYPE_BOOL:
232 bool value_var_bool = Param1<bool>.Cast(values).param1;
233
235 //Print("DebugValues | PPEConstants.VAR_TYPE_BOOL | bool val: " + value_var_bool);
236 break;
237
238 case PPEConstants.VAR_TYPE_INT:
239 int value_var_int = Param1<int>.Cast(values).param1;
240
242 //Print("DebugValues | PPEConstants.VAR_TYPE_BOOL | bool val: " + value_var_bool);
243 break;
244
245 case PPEConstants.VAR_TYPE_FLOAT:
246 float value_var_float = Param1<float>.Cast(values).param1;
247
249 //Print("DebugValues | PPEConstants.VAR_TYPE_FLOAT | float val: " + value_var_float);
250 break;
251
252 case PPEConstants.VAR_TYPE_COLOR:
253 float color[4] = {0, 0, 0, 0};
258
260 //Print("DebugValues | PPEConstants.VAR_TYPE_COLOR | color val:: " + color[0] + " " + color[1] + " " + color[2] + " " + color[3]);
261 break;
262 }
263 }
264
266 {
267 int parameter_id;
268 for (int i = 0; i < m_UpdatedParameters.Count(); i++)
269 {
272 }
273
274 m_UpdatedParameters.Clear();
275 }
276
277 protected void InsertUpdatedParameter(int mat_id)
278 {
279 if (m_UpdatedParameters.Find(mat_id) == -1)
281 }
282
289
299
300 protected void ParamUpdateQueueCleanup(int order)
301 {
302 //DbgPrnt("PPEDebug | PPEClassBase - ParamUpdateQueueCleanup | mat_id: " + GetPostProcessEffectID() + " | UpdateQueue count: " + m_ParameterUpdateQueue.Count());
303 //DbgPrnt("PPEDebug | PPEClassBase - ParamUpdateQueueCleanup | mat_id: " + GetPostProcessEffectID() + " | RemovalQueue count: " + m_ParameterRemovalQueue.Count());
304 for (int i = 0; i < m_ParameterUpdateQueueMap.Get(order).Count(); i++)
305 {
307 {
308 //DbgPrnt("PPEDebug | PPEClassBase - ParamUpdateQueueCleanup | removing update of: " + m_ParameterUpdateQueue.Get(i));
309 //m_ParameterUpdateQueue.RemoveItem(m_ParameterUpdateQueue.Get(i));
310 }
311 }
312 m_ParameterUpdateQueueMap.Get(order).Clear();
313 }
314
317
319 {
323 }
324
326 {
327 return m_MaterialPath;
328 }
329
332 {
333 return PostProcessEffectType.None;
334 }
335
337 /*int GetExceptionID()
338 {
339 return PPEExceptions.NONE;
340 }*/
341
346
347#ifdef DEVELOPER
348 //Debug//
349 //-----//
350 /*void DumpMap()
351 {
352 DbgPrnt("PPEClassDebug | m_ActiveMaterialRequestMap COUNT: " + m_ActiveMaterialRequestMap.Count());
353 for (int i = 0; i < m_ActiveMaterialRequestMap.Count(); i++)
354 {
355 DbgPrnt("PPEClassDebug | m_ActiveRequest#: " + i);
356 //ActiveMaterialRequests request = m_ActiveMaterialRequestMap.Get(i);
357 DbgPrnt("PPEClassDebug | request: " + request);
358 for (int j = 0; j < request.Count(); j++)
359 {
360 DbgPrnt("PPEClassDebug | request#: " + j);
361 array<bool,float,int,int> values = request.Get(j);
362 foreach (auto val : values)
363 {
364 DbgPrnt("PPEClassDebug | relative: " + val);
365 }
366 }
367 }
368 DbgPrnt("------------");
369 }*/
370#endif
371
372 void DbgPrnt(string text)
373 {
374 //Debug.Log(""+text);
375 }
376};
override Widget Init()
Definition DayZGame.c:120
Param2< string, ref array< float > > PPETemplateDefVector
Param4< string, float, float, float > PPETemplateDefFloat
Param2< string, string > PPETemplateDefResource
Param2< string, string > PPETemplateDefTexture
Param4< string, int, int, int > PPETemplateDefInt
Param5< string, float, float, float, float > PPETemplateDefColor
Param2 PPETemplateDefBool
void PPEManager()
Definition PPEManager.c:64
void PPEMatClassParameterColor(int mat_idx, int parameter_idx, PPEClassBase parent)
void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto void SetParamByIndex(int paramIndex, void value)
Created once, on manager init. Script-side representation of C++ material class, separate handling.
void ChangeMaterialPathUsed(string path)
ref map< int, ref array< int > > m_ParameterUpdateQueueMap
void InsertParamValueData(PPERequestParamDataBase request_data)
Distributes requester data to the material class structure and links them to appropriate parameter.
void RegisterParameterScalarFloat(int idx, string parameter_name, float default_value, float min, float max)
WARNING - min/max values are usually taken from Workbench defaults, may not be actual min/max values ...
void RegisterParameterVector(int idx, string parameter_name, array< float > default_values)
void DbgPrnt(string text)
string GetDefaultMaterialPath()
override this if you want to use different path by default; '.emat' is appended automatically
void Init(string mat_path_override="")
void SetFinalParameterValue(int parameter_idx)
Clamps the values being set to defaults, if there is no request setting non-zero values on the parame...
Material m_Material
void RegisterParameterColorEx(int idx, string parameter_name, float r, float g, float b, float a, typename type)
WARNING - min/max values are usually taken from Workbench defaults, may not be actual min/max values ...
void RegisterParameterScalarInt(int idx, string parameter_name, int default_value, int min, int max)
Material GetMaterial()
void RegisterParameterScalarBool(int idx, string parameter_name, bool default_value)
void ParamUpdateQueueCleanup(int order)
void RegisterParameterResource(int idx, string parameter_name, string default_path)
ref array< int > m_ParameterRemovalQueue
void RemoveRequest(int req_idx)
unused, see 'RemoveActiveRequestFromMaterials' for more info
void InsertUpdatedParameter(int mat_id)
void RegisterParameterScalarFloatEx(int idx, string parameter_name, float default_value, float min, float max, typename type)
WARNING - min/max values are usually taken from Workbench defaults, may not be actual min/max values ...
void RegisterMaterialParameters()
inserted into associative array by parameter int value, parameter registration order does not matter ...
string GetCurrentMaterialPath()
void OnUpdate(float timeslice, int order)
generic update method, take care when overriding!
void SetParameterUpdating(int order, int parameter_id)
Queue specific parameter of this material to update.
void CreateDataStructure()
void RegisterParameterTexture(int idx, string parameter_name, string default_path)
int GetPostProcessEffectID()
Overriden in all material classes!
void RegisterParameterColor(int idx, string parameter_name, float r, float g, float b, float a)
WARNING - min/max values are usually taken from Workbench defaults, may not be actual min/max values ...
void ParamUpdateRemove(int parameter_idx)
Queue selected parameter for removal from the update queue.
PPEManager m_Manager
PPEMatClassParameterCommandData GetParameterCommandData(int parameter_idx)
Some PP effects are handled as hard-coded exceptions, outside of material system. Default == PPEExcep...
ref array< int > m_UpdatedParameters
ref map< int, ref PPEMatClassParameterCommandData > m_MaterialParamMapStructure
void PPEClassBase(string mat_path_override="")
Static component of PPE manager, used to hold the instance.
Definition PPEManager.c:3
static PPEManager GetPPEManager()
Returns the manager instance singleton.
Definition PPEManager.c:27
Param GetCurrentValues()
Careful, only actual values, WITHOUT string.
Data for one material parameter, requester side.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
proto native CGame GetGame()
PostProcessEffectType
Post-process effect type.
Definition EnWorld.c:72
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.