Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
ppematclassesbase.c
Go to the documentation of this file.
1
3{
5 protected string m_MaterialPath = "";
7
11
13
14 void PPEClassBase(string mat_path_override = "")
15 {
16 Init(mat_path_override);
20 }
21
22 protected void Init(string mat_path_override = "")
23 {
24 if (mat_path_override != "")
25 {
26 m_MaterialPath = mat_path_override;
27 }
28 else
29 {
31 }
32 m_Manager = PPEManagerStatic.GetPPEManager();
33 }
34
35 protected void CreateMaterial()
36 {
37 if (m_MaterialPath != "")
38 m_Material = GetGame().GetWorld().GetMaterial(m_MaterialPath);
39 }
40
42 {
43 return m_Material;
44 }
45
46 //do not override!
55
58
59 protected void RegisterParameterScalarBool(int idx, string parameter_name, bool default_value)
60 {
61 PPETemplateDefBool p = new PPETemplateDefBool(parameter_name,default_value);
62 PPEMatClassParameterBool parameter_data = new PPEMatClassParameterBool(GetPostProcessEffectID(),idx,this);
63 parameter_data.RegisterDefaults(p);
64 m_MaterialParamMapStructure.Set(idx, parameter_data);
65 }
66
67 protected void RegisterParameterScalarInt(int idx, string parameter_name, int default_value, int min, int max)
68 {
69 PPETemplateDefInt p = new PPETemplateDefInt(parameter_name,default_value,min,max);
70
71 PPEMatClassParameterInt parameter_data = new PPEMatClassParameterInt(GetPostProcessEffectID(),idx,this);
72 parameter_data.RegisterDefaults(p);
73 m_MaterialParamMapStructure.Set(idx, parameter_data);
74 }
75
77 protected void RegisterParameterScalarFloat(int idx, string parameter_name, float default_value, float min, float max)
78 {
79 PPETemplateDefFloat p = new PPETemplateDefFloat(parameter_name,default_value,min,max);
80
82 parameter_data.RegisterDefaults(p);
83 m_MaterialParamMapStructure.Set(idx, parameter_data);
84 }
85
87 protected void RegisterParameterScalarFloatEx(int idx, string parameter_name, float default_value, float min, float max, typename type)
88 {
89 PPETemplateDefFloat p = new PPETemplateDefFloat(parameter_name,default_value,min,max);
90
91 PPEMatClassParameterFloat parameter_data;
92 bool boo = Class.CastTo(parameter_data,type.Spawn());
93 //Print("RegisterParameterColorEx: " + boo );
94 parameter_data.RegisterDefaults(p);
95 parameter_data.SetMaterialIndex(GetPostProcessEffectID());
96 parameter_data.SetParameterIndex(idx);
97 parameter_data.SetParent(this);
98 m_MaterialParamMapStructure.Set(idx, parameter_data);
99 }
100
102 protected void RegisterParameterColor(int idx, string parameter_name, float r, float g, float b, float a)
103 {
104 PPETemplateDefColor p = new PPETemplateDefColor(parameter_name,r,g,b,a);
106 parameter_data.RegisterDefaults(p);
107 m_MaterialParamMapStructure.Set(idx, parameter_data);
108 }
109
111 protected void RegisterParameterColorEx(int idx, string parameter_name, float r, float g, float b, float a, typename type)
112 {
113 PPETemplateDefColor p = new PPETemplateDefColor(parameter_name,r,g,b,a);
114 PPEMatClassParameterColor parameter_data;
115 bool boo = Class.CastTo(parameter_data,type.Spawn());
116 //Print("RegisterParameterColorEx: " + boo );
117 parameter_data.RegisterDefaults(p);
118 parameter_data.SetMaterialIndex(GetPostProcessEffectID());
119 parameter_data.SetParameterIndex(idx);
120 parameter_data.SetParent(this);
121 m_MaterialParamMapStructure.Set(idx, parameter_data);
122 }
123
124 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>...
125 {
126 PPETemplateDefVector p = new PPETemplateDefVector(parameter_name,default_values);
127 PPEMatClassParameterVector parameter_data = new PPEMatClassParameterVector(GetPostProcessEffectID(),idx,this);
128 parameter_data.RegisterDefaults(p);
129 m_MaterialParamMapStructure.Set(idx, parameter_data);
130 }
131
132 //TEXTURE and RESOURCE types are not overridable during runtime..currently unused and unhandled
133 protected void RegisterParameterTexture(int idx, string parameter_name, string default_path)
134 {
135 PPETemplateDefTexture p = new PPETemplateDefTexture(parameter_name,default_path);
136 PPEMatClassParameterTexture parameter_data = new PPEMatClassParameterTexture(GetPostProcessEffectID(),idx,this);
137 parameter_data.RegisterDefaults(p);
138 m_MaterialParamMapStructure.Set(idx, parameter_data);
139 }
140
141 protected void RegisterParameterResource(int idx, string parameter_name, string default_path)
142 {
143 PPETemplateDefResource p = new PPETemplateDefResource(parameter_name,default_path);
144 PPEMatClassParameterResource parameter_data = new PPEMatClassParameterResource(GetPostProcessEffectID(),idx,this);
145 parameter_data.RegisterDefaults(p);
146 m_MaterialParamMapStructure.Set(idx, parameter_data);
147 }
148
149 //------------------------------------------------------------------------------------
152 {
154 bool exists = m_MaterialParamMapStructure.Find(request_data.GetParameterID(),param_data);
155 if ( !exists )
156 {
157 Error("PPEClassBase | InsertParamValueData | mat/par/req: " + GetPostProcessEffectID() + "/" + request_data.GetParameterID() + "/" + request_data.GetRequesterIDX() + " not registered in m_MaterialParamMapStructure!");
158 return;
159 }
160
161 request_data.SetDataActive(true);
162 request_data.SetUpdatingDataValues(true); //marks request data as updating
163 param_data.InsertRequestData(request_data);//<request_ID, data>
164
165 //DbgPrnt("PPEDebug | InsertParamValueData | mat/par/req: " + GetPostProcessEffectID() + "/" + request_data.GetParameterID() + "/" + request_data.GetRequesterIDX() + " | requester: " + request_data.m_Requester);
166 }
167
168 //TODO - rework
170 void RemoveRequest(int req_idx)
171 {
172 /*for (int i = 0; i < m_ActiveMaterialRequestMap.Count(); i++)
173 {
174 ActiveParameterRequestsMap dbg = m_ActiveMaterialRequestMap.Get(i);
175 //DbgPrnt("PPEDebug | dbg size: " + dbg.Count());
176
177 if ( m_ActiveMaterialRequestMap.Get(i).Contains(req_idx) )
178 {
179 m_ActiveMaterialRequestMap.Get(i).Remove(req_idx);
180
181 dbg = m_ActiveMaterialRequestMap.Get(i);
182
183 if ( !m_ActiveMaterialRequestMap.Get(i) || m_ActiveMaterialRequestMap.Get(i).Count() < 1 )
184 {
185 if (m_ParameterUpdateQueue.IsValidIndex(i))
186 {
187 DbgPrnt("PPEDebug | PPEClassBase - RemoveRequest | Removing: " + i);
188 DbgPrnt("PPEDebug | PPEClassBase - RemoveRequest | exit 4 - last request removal");
189 m_ParameterRemovalQueue.Insert(m_ParameterUpdateQueue.Get(i));
190 }
191 else
192 DbgPrnt("PPEDebug | PPEClassBase - RemoveRequest | Update queue no. " + i + " already removed!");
193 }
194 }
195 //Adds to update one more time
196 m_Manager.SetMaterialParamUpdating(GetPostProcessEffectID(),i);
197 }*/
198 }
199
201 void OnUpdate(float timeslice, int order)
202 {
203 int parameter_idx = -1;
204 //DbgPrnt("PPEDebug | PPEClassBase - OnUpdate | mat_id: " + GetPostProcessEffectID());
205
206 if ( m_ParameterUpdateQueueMap.Contains(order) )
207 {
208 //Print(m_ParameterUpdateQueueMap.Get(order));
209 for ( int i = 0; i < m_ParameterUpdateQueueMap.Get(order).Count(); i++ )
210 {
211 //DbgPrnt("PPEDebug | PPEClassBase - OnUpdate | parameter_idx: " + m_ParameterUpdateQueue.Get(i));
212 Param p_values; //TODO - move to material classes?
213 bool setting_defaults = false;
214 parameter_idx = m_ParameterUpdateQueueMap.Get(order).Get(i);
215 m_MaterialParamMapStructure.Get(parameter_idx).Update(timeslice,p_values,setting_defaults,order);
216
217 InsertUpdatedParameter(parameter_idx);
218 }
219 m_Manager.InsertUpdatedMaterial(GetPostProcessEffectID());
220
222 }
223 /*if ( !m_ParameterUpdateQueueMap.Contains(order) || m_ParameterUpdateQueueMap.Get(order).Count() < 1 )
224 m_Manager.RemoveMaterialUpdating(GetPostProcessEffectID(),order); //stops material from updating when no parameters are.*/
225 }
226
228 void SetFinalParameterValue(int parameter_idx)
229 {
230 int var_type = GetParameterCommandData(parameter_idx).GetParameterVarType();
231 Param values = GetParameterCommandData(parameter_idx).GetCurrentValues();
232
233 switch (var_type)
234 {
235 case PPEConstants.VAR_TYPE_BOOL:
236 bool value_var_bool = Param1<bool>.Cast(values).param1;
237
238 m_Material.SetParamByIndex(parameter_idx,value_var_bool);
239 //Print("DebugValues | PPEConstants.VAR_TYPE_BOOL | bool val: " + value_var_bool);
240 break;
241
242 case PPEConstants.VAR_TYPE_INT:
243 int value_var_int = Param1<int>.Cast(values).param1;
244
245 m_Material.SetParamByIndex(parameter_idx,value_var_int);
246 //Print("DebugValues | PPEConstants.VAR_TYPE_BOOL | bool val: " + value_var_bool);
247 break;
248
249 case PPEConstants.VAR_TYPE_FLOAT:
250 float value_var_float = Param1<float>.Cast(values).param1;
251
252 m_Material.SetParamByIndex(parameter_idx,value_var_float);
253 //Print("DebugValues | PPEConstants.VAR_TYPE_FLOAT | float val: " + value_var_float);
254 break;
255
256 case PPEConstants.VAR_TYPE_COLOR:
257 float color[4] = {0,0,0,0};
258 color[0] = Param4<float,float,float,float>.Cast(values).param1;
259 color[1] = Param4<float,float,float,float>.Cast(values).param2;
260 color[2] = Param4<float,float,float,float>.Cast(values).param3;
261 color[3] = Param4<float,float,float,float>.Cast(values).param4;
262
263 m_Material.SetParamByIndex(parameter_idx,color);
264 //Print("DebugValues | PPEConstants.VAR_TYPE_COLOR | color val:: " + color[0] + " " + color[1] + " " + color[2] + " " + color[3]);
265 break;
266 }
267 }
268
270 {
271 int parameter_id;
272 for (int i = 0; i < m_UpdatedParameters.Count(); i++)
273 {
274 parameter_id = m_UpdatedParameters.Get(i);
275 SetFinalParameterValue(parameter_id);
276 }
277
278 m_UpdatedParameters.Clear();
279 }
280
281 protected void InsertUpdatedParameter(int mat_id)
282 {
283 if ( m_UpdatedParameters.Find(mat_id) == -1 )
284 m_UpdatedParameters.Insert(mat_id);
285 }
286
288 void ParamUpdateRemove(int parameter_idx)
289 {
290 if ( m_ParameterRemovalQueue.Find(parameter_idx) == -1 )
291 m_ParameterRemovalQueue.Insert(parameter_idx);
292 }
293
295 void SetParameterUpdating(int order, int parameter_id)
296 {
297 if ( !m_ParameterUpdateQueueMap.Contains(order) )
298 {
300 }
301
302 if ( m_ParameterUpdateQueueMap.Get(order).Find(parameter_id) == -1 )
303 {
304 m_ParameterUpdateQueueMap.Get(order).Insert(parameter_id);
305 }
306 }
307
308 protected void ParamUpdateQueueCleanup(int order)
309 {
310 //DbgPrnt("PPEDebug | PPEClassBase - ParamUpdateQueueCleanup | mat_id: " + GetPostProcessEffectID() + " | UpdateQueue count: " + m_ParameterUpdateQueue.Count());
311 //DbgPrnt("PPEDebug | PPEClassBase - ParamUpdateQueueCleanup | mat_id: " + GetPostProcessEffectID() + " | RemovalQueue count: " + m_ParameterRemovalQueue.Count());
312 for ( int i = 0; i < m_ParameterUpdateQueueMap.Get(order).Count(); i++ )
313 {
314 if ( m_ParameterRemovalQueue.Find(m_ParameterUpdateQueueMap.Get(order).Get(i)) != -1 )
315 {
316 //DbgPrnt("PPEDebug | PPEClassBase - ParamUpdateQueueCleanup | removing update of: " + m_ParameterUpdateQueue.Get(i));
317 //m_ParameterUpdateQueue.RemoveItem(m_ParameterUpdateQueue.Get(i));
318 }
319 }
320 m_ParameterUpdateQueueMap.Get(order).Clear();
321 }
322
325
327 {
329 m_Material = null;
331 }
332
334 {
335 return m_MaterialPath;
336 }
337
340 {
341 return PostProcessEffectType.None;
342 }
343
345 /*int GetExceptionID()
346 {
347 return PPEExceptions.NONE;
348 }*/
349
351 {
352 return m_MaterialParamMapStructure.Get(parameter_idx);
353 }
354
355#ifdef DEVELOPER
356 //Debug//
357 //-----//
358 /*void DumpMap()
359 {
360 DbgPrnt("PPEClassDebug | m_ActiveMaterialRequestMap COUNT: " + m_ActiveMaterialRequestMap.Count());
361 for (int i = 0; i < m_ActiveMaterialRequestMap.Count(); i++)
362 {
363 DbgPrnt("PPEClassDebug | m_ActiveRequest#: " + i);
364 //ActiveMaterialRequests request = m_ActiveMaterialRequestMap.Get(i);
365 DbgPrnt("PPEClassDebug | request: " + request);
366 for (int j = 0; j < request.Count(); j++)
367 {
368 DbgPrnt("PPEClassDebug | request#: " + j);
369 array<bool,float,int,int> values = request.Get(j);
370 foreach (auto val : values)
371 {
372 DbgPrnt("PPEClassDebug | relative: " + val);
373 }
374 }
375 }
376 DbgPrnt("------------");
377 }*/
378#endif
379
380 void DbgPrnt(string text)
381 {
382 //Debug.Log(""+text);
383 }
384};
Super root of all classes in Enforce script.
Definition enscript.c:11
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
ref map< int, ref PPEMatClassParameterCommandData > m_MaterialParamMapStructure
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
void PPEClassBase(string mat_path_override="")
Static component of PPE manager, used to hold the instance.
Definition ppemanager.c:3
Param GetCurrentValues()
Careful, only actual values, WITHOUT string.
void InsertRequestData(PPERequestParamDataBase request_data)
Data for one material parameter, requester side.
void SetDataActive(bool state)
void SetUpdatingDataValues(bool state)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override Widget Init()
Definition dayzgame.c:127
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
Param5< string, float, float, float, float > PPETemplateDefColor
Param4< string, int, int, int > PPETemplateDefInt
Param4< string, float, float, float > PPETemplateDefFloat
Param2 PPETemplateDefBool
Param2< string, string > PPETemplateDefTexture
Param2< string, string > PPETemplateDefResource
Param2< string, ref array< float > > PPETemplateDefVector
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)