Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #pragma once
00018
00019 #include "imtl.h"
00020 #include "render.h"
00021
00022
00023
00024 typedef SFXParamDlg ToneOpParamDlg;
00025
00026
00027
00028
00029
00066 #pragma warning(push)
00067 #pragma warning(disable:4239)
00068
00069 class ToneOperator : public SpecialFX {
00070 public:
00071
00072 ToneOperator() { ClearAFlag(A_TONEOP_PROCESS_BG); }
00073
00074
00075 #pragma warning(push)
00076 #pragma warning(disable:4100)
00077 RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget,
00078 PartID& partID, RefMessage message) {return REF_SUCCEED;}
00079 SClass_ID SuperClassID() { return TONE_OPERATOR_CLASS_ID; }
00080
00081
00082
00083 IOResult Save(ISave *isave) { return SpecialFX::Save(isave); }
00084 IOResult Load(ILoad *iload) { return SpecialFX::Load(iload); }
00085
00086 virtual BOOL Active(TimeValue t) { return !TestAFlag(A_TONEOP_DISABLED); }
00108 virtual void SetActive(
00109 bool active,
00110 TimeValue t
00111 ) {
00112 if (active ^ (TestAFlag(A_TONEOP_DISABLED) == 0)) {
00113 if (active) {
00114 ClearAFlag(A_TONEOP_DISABLED);
00115 }
00116 else {
00117 SetAFlag(A_TONEOP_DISABLED);
00118 }
00119 NotifyDependents(FOREVER, (PartID)PART_ALL, REFMSG_CHANGE);
00120 }
00121 }
00122
00125 bool GetProcessBackground() { return TestAFlag(A_TONEOP_PROCESS_BG) != 0; }
00130 void SetProcessBackground(bool active) {
00131 if (active ^ (TestAFlag(A_TONEOP_PROCESS_BG) != 0)) {
00132 if (active) {
00133 SetAFlag(A_TONEOP_PROCESS_BG);
00134 }
00135 else {
00136 ClearAFlag(A_TONEOP_PROCESS_BG);
00137 }
00138 NotifyDependents(FOREVER, (PartID)PART_ALL, REFMSG_CHANGE);
00139 }
00140 }
00141
00142 bool GetIndirectOnly() { return TestAFlag(A_TONEOP_INDIRECT_ONLY) != 0; }
00143 void SetIndirectOnly(bool active) {
00144 if (active ^ (TestAFlag(A_TONEOP_INDIRECT_ONLY) != 0)) {
00145 if (active) {
00146 SetAFlag(A_TONEOP_INDIRECT_ONLY);
00147 }
00148 else {
00149 ClearAFlag(A_TONEOP_INDIRECT_ONLY);
00150 }
00151 NotifyDependents(FOREVER, (PartID)PART_ALL, REFMSG_CHANGE);
00152 }
00153 }
00154
00155
00156
00157
00172 virtual ToneOpParamDlg *CreateParamDialog(IRendParams *ip) { return NULL; }
00173
00174
00175
00176
00177
00186 virtual BOOL SetDlgThing(ToneOpParamDlg* dlg) { return FALSE; }
00187
00188
00189
00190
00191
00192
00198 virtual bool IsPhysicalSpace() const { return true; }
00199
00200
00201
00202
00203
00204
00205
00206
00219 virtual void Update(TimeValue t, Interval& valid) { }
00220
00221
00222
00223
00239 virtual bool BuildMaps(TimeValue t, RenderMapsContext& rmc)
00240 { return true; }
00241
00242
00243
00244
00245
00246 virtual void SubRenderSample(float energy[3]) { }
00247 #pragma warning(pop)
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00273 virtual void ScaledToRGB(float energy[3]) = 0;
00281 virtual float ScaledToRGB(float energy) = 0;
00282
00283
00290 virtual float GetPhysicalUnit(
00291 TimeValue t,
00292 Interval& valid = Interval(0,0)
00293 ) const = 0;
00302 virtual void SetPhysicalUnit(
00303 float value,
00304 TimeValue t
00305 ) = 0;
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00328 virtual void ScalePhysical(float energy[3]) const = 0;
00337 virtual float ScalePhysical(float energy) const = 0;
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00358 virtual void ScaleRGB(float color[3]) const = 0;
00365 virtual float ScaleRGB(float color) const = 0;
00366
00367
00368 bool CanInvert();
00369
00370
00371 void RGBToScaled(float energy[3]);
00372 float RGBToScaled(float energy);
00373 };
00374
00375
00376 #pragma warning(pop)
00377
00378
00379
00380
00381
00382
00383
00384 #define INVERTABLE_TONE_OPERATOR_INTERFACE Interface_ID(0xbe9171b, 0x71183b19)
00385
00386 class ToneOperatorInvertable : public BaseInterface {
00387 public:
00388
00389 virtual void InverseMap(float rgb[3]) = 0;
00390 virtual float InverseMap(float rgb) = 0;
00391 };
00392
00393
00394
00395 inline bool ToneOperator::CanInvert()
00396 {
00397 return GetInterface(INVERTABLE_TONE_OPERATOR_INTERFACE) != NULL;
00398 }
00399
00400
00401 inline void ToneOperator::RGBToScaled(float energy[3])
00402 {
00403 ToneOperatorInvertable* p = static_cast<ToneOperatorInvertable*>(
00404 GetInterface(INVERTABLE_TONE_OPERATOR_INTERFACE));
00405
00406 if (p != NULL)
00407 p->InverseMap(energy);
00408 }
00409
00410 inline float ToneOperator::RGBToScaled(float energy)
00411 {
00412 ToneOperatorInvertable* p = static_cast<ToneOperatorInvertable*>(
00413 GetInterface(INVERTABLE_TONE_OPERATOR_INTERFACE));
00414
00415 return p == NULL ? energy : p->InverseMap(energy);
00416 }
00417
00418
00419
00420
00421 inline bool ShadeContext::IsPhysicalSpace() const
00422 { return globContext != NULL && globContext->pToneOp != NULL
00423 && globContext->pToneOp->IsPhysicalSpace( ); }
00424
00425
00426
00427
00428
00429 inline float ShadeContext::ScaledToRGB( float energy ) const
00430 { return (globContext == NULL || globContext->pToneOp == NULL)
00431 ? energy : globContext->pToneOp->ScaledToRGB( energy ); }
00432
00433
00434
00435 inline void ShadeContext::ScaledToRGB( )
00436 { ScaledToRGB( out.c ); }
00437
00438
00439
00440
00441
00442 inline float ShadeContext::ScalePhysical(float energy) const
00443 { return (globContext == NULL || globContext->pToneOp == NULL)
00444 ? energy : globContext->pToneOp->ScalePhysical( energy ); }
00445
00446
00447
00448
00449
00450 inline float ShadeContext::ScaleRGB(float energy) const
00451 { return (globContext == NULL || globContext->pToneOp == NULL)
00452 ? energy : globContext->pToneOp->ScaleRGB( energy ); }
00453
00454
00455
00456
00457
00458
00459
00460
00461 #define TONE_OPERATOR_INTERFACE Interface_ID(0x1563269c, 0x7ec41d84)
00462
00474 class ToneOperatorInterface : public FPStaticInterface {
00475 public:
00476 typedef void (*ToneChangeCallback)(
00477 ToneOperator* newOp,
00478 ToneOperator* oldOp,
00479 void* param
00480 );
00481
00482
00485 virtual ToneOperator* GetToneOperator() const = 0;
00489 virtual void SetToneOperator(ToneOperator* op) = 0;
00490
00501 virtual void RegisterToneOperatorChangeNotification(
00502 ToneChangeCallback callback,
00503 void* param
00504 ) = 0;
00516 virtual void UnRegisterToneOperatorChangeNotification(
00517 ToneChangeCallback callback,
00518 void* param
00519 ) = 0;
00520 };
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532 #define ITONEOPERATOR_EXTENSION_INTERFACE Interface_ID(0x512b3541, 0x1c413aad)
00533
00534 class IToneOperatorExtension : public BaseInterface {
00535
00536 public:
00537
00538 enum Quantity {
00539 kQuantity_Illuminance = 0,
00540 kQuantity_Luminance = 1
00541 };
00542
00543 virtual Quantity GetUsedQuantity() const = 0;
00544 virtual void SetUsedQuantity(Quantity q) = 0;
00545
00546
00547 virtual Interface_ID GetID() { return ITONEOPERATOR_EXTENSION_INTERFACE; }
00548
00549 };
00550
00551