Object Hierarchy | Related C++ Class: ProxyParameter
ProxyParameter
v3.0
A Proxy parameter acts as a clone of another parameter that is elsewhere in the scene. If you look in the Scene Explorer, you can identify the proxy parameters because they appear in italics. You can create a proxy parameter by calling CustomProperty.AddProxyParameter. The proxy parameter has the same range and UI range as the original parameter. It is possible to specify a new UI range by calling EditParameterDefinition but the actual range must not be changed.
' ' Proxy Parameters are a useful way to centralize parameters from ' different objects on the same property, or even to build a simplified ' version of a property page. ' ' This example demonstrates creation of a custom property set ' that only shows a few items of the Shader that it controls, ' but maintains a pleasing layout. ' g_Logic = _ "sub Enable_OnChanged()" & vbCrLf & _ " bEnable = PPG.Enable.Value" & vbCrLf & _ " 'To disable the color control we just disable the proxy" & vbCrLf & _ " ' parameter representing the ""red"" component" & vbCrLf & _ " PPG.Ambient.Enable bEnable " & vbCrLf & _ " PPG.Diffuse.Enable bEnable " & vbCrLf & _ "end sub" & vbCrLf NewScene , false set oSphere = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" ) oSphere.AddMaterial "Phong" set oPhongShader = oSphere.Material.Shaders(0) ' This is a Boolean for enabling diffuse set oDiffuseEnable = oPhongShader.Parameters( "diffuse_inuse" ) ' These are CompoundParameters, each with R,G,B sub-parameters set oAmbientParam = oPhongShader.Parameters( "ambient" ) set oDiffuseParam = oPhongShader.Parameters( "diffuse" ) set oCustomProperty = oSphere.AddProperty("CustomProperty",false,"Proxies") ' We specify a name to avoid having a long one like "sphere_Material_Phong_diffuse_inuse" oCustomProperty.AddProxyParameter oDiffuseEnable, "Enable", "Enable" oCustomProperty.AddProxyParameter oDiffuseParam.Parameters("red"), "Diffuse", "Diffuse" oCustomProperty.AddProxyParameter oDiffuseParam.Parameters("green") oCustomProperty.AddProxyParameter oDiffuseParam.Parameters("blue") oCustomProperty.AddProxyParameter oAmbientParam.Parameters("red"), "Ambient", "Ambient" oCustomProperty.AddProxyParameter oAmbientParam.Parameters("green") oCustomProperty.AddProxyParameter oAmbientParam.Parameters("blue") ' If we inspect the object now we would see 6 separate sliders, ' each controlling a different component of the colors ' We can create a custom layout to clean up the display set oLayout = oCustomProperty.PPGLayout oLayout.AddGroup "Phong Diffuse" oLayout.AddItem "Enable" ' Just for fun, show the ambient before the diffuse, which ' is the opposite of the normal Phong Property Page oLayout.AddColor "Ambient", "Ambient", false oLayout.AddColor "Diffuse", "Diffuse", false oLayout.EndGroup oLayout.Logic = g_Logic oLayout.Language = "VBScript" ' Show both dialogs. You will see that both items ' are identical. InspectObj oCustomProperty, , , siLock InspectObj oPhongShader, , , siLock |