Omcolour
Attributes
-
ENGLISH NAME : X-ParticlesColorModifier
-
NAME : Omcolour
-
INCLUDE : Obase
-
PATH : res/description/omcolour.res
-
PLUGIN : X-Particles
-
MAXON online help (may not exist): OMCOLOUR
Elements
Example Code
The following code does not use the correct values when setting the data. You should check directly in C4D for the correct values that you should use in place of the ones that are shown.
This code is just to show you how to access the values for getting and setting the parameters.
Python
import c4d
from c4d import gui
def main():
obj = c4d.BaseObject(c4d.Omcolour)
doc.InsertObject(obj)
c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
#You can set parameters two different ways.
#First way
obj[c4d.XMCL_COLOUR_ENABLED] = True
obj[c4d.XMCL_COLOUR_MODE] = c4d.COLOUR_MODE_INDEP
obj[c4d.XMCL_COLOUR_OPERATION] = c4d.COLOUR_OP_SET
obj[c4d.XMCL_SHADER_SAMPLE_RANDOM] = True
obj[c4d.XMCL_COLOUR_THRESHOLD] = 0.1
obj[c4d.XMCL_COLOUR_DELTA_R] = 1
obj[c4d.XMCL_COLOUR_DELTA_G] = 1
obj[c4d.XMCL_COLOUR_DELTA_B] = 1
obj[c4d.XMCL_COLOUR_BLEND] = c4d.COLOUR_BLEND_NORMAL
obj[c4d.XMCL_COLOUR_BLEND_VALUE] = 0.1
obj[c4d.XMCL_COLOUR_GRADIENT_COMPLETE] = c4d.GRAD_COMPLETE_NONE
obj[c4d.XMCL_COLOUR_GRADIENT_SPEED_MIN] = 0.1
obj[c4d.XMCL_COLOUR_GRADIENT_SPEED_MAX] = 0.1
#Second way, using the base container.
bc = obj.GetDataInstance()
bc.SetBool(c4d.XMCL_COLOUR_ENABLED,True)
bc.SetInt32(c4d.XMCL_COLOUR_MODE,c4d.COLOUR_MODE_INDEP)
bc.SetInt32(c4d.XMCL_COLOUR_OPERATION,c4d.COLOUR_OP_SET)
bc.SetBool(c4d.XMCL_SHADER_SAMPLE_RANDOM,True)
bc.SetFloat(c4d.XMCL_COLOUR_THRESHOLD,0.1)
bc.SetInt32(c4d.XMCL_COLOUR_DELTA_R,1)
bc.SetInt32(c4d.XMCL_COLOUR_DELTA_G,1)
bc.SetInt32(c4d.XMCL_COLOUR_DELTA_B,1)
bc.SetInt32(c4d.XMCL_COLOUR_BLEND,c4d.COLOUR_BLEND_NORMAL)
bc.SetFloat(c4d.XMCL_COLOUR_BLEND_VALUE,0.1)
bc.SetInt32(c4d.XMCL_COLOUR_GRADIENT_COMPLETE,c4d.GRAD_COMPLETE_NONE)
bc.SetFloat(c4d.XMCL_COLOUR_GRADIENT_SPEED_MIN,0.1)
bc.SetFloat(c4d.XMCL_COLOUR_GRADIENT_SPEED_MAX,0.1)
if __name__=='__main__':
main()
C++
#include "c4d.h"
#include "../res/description/omcolour.h"
void SampleFunction()
{
BaseDocument *pDoc = GetActiveDocument();
BaseObject *pObject = BaseObject::Alloc(Omcolour);
pDoc->InsertObject(pObject);
pDoc->StartUndo();
pDoc->AddUndo(UNDO_NEW,pObject);
pDoc->EndUndo();
EventAdd(EVENT_FORCEREDRAW);
//You can set parameters two different ways.
//First way
//Some objects do not store all their data in the container. You need to use GetParameter()/SetParameter() instead.
DESCFLAGS_SET flags = DESCFLAGS_SET_PARAM_SET;
pObject->SetParameter(DescID(XMCL_COLOUR_ENABLED),GeData(true),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_MODE),GeData(COLOUR_MODE_INDEP),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_OPERATION),GeData(COLOUR_OP_SET),flags);
pObject->SetParameter(DescID(XMCL_SHADER_SAMPLE_RANDOM),GeData(true),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_THRESHOLD),GeData(0.1),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_DELTA_R),GeData(1),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_DELTA_G),GeData(1),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_DELTA_B),GeData(1),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_BLEND),GeData(COLOUR_BLEND_NORMAL),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_BLEND_VALUE),GeData(0.1),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_GRADIENT_COMPLETE),GeData(GRAD_COMPLETE_NONE),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_GRADIENT_SPEED_MIN),GeData(0.1),flags);
pObject->SetParameter(DescID(XMCL_COLOUR_GRADIENT_SPEED_MAX),GeData(0.1),flags);
pObject->Message(MSG_UPDATE);
//Second way, using the base container.
BaseContainer *bc = pObject->GetDataInstance();
bc->SetBool(XMCL_COLOUR_ENABLED,true);
bc->SetInt32(XMCL_COLOUR_MODE,COLOUR_MODE_INDEP);
bc->SetInt32(XMCL_COLOUR_OPERATION,COLOUR_OP_SET);
bc->SetBool(XMCL_SHADER_SAMPLE_RANDOM,true);
bc->SetFloat(XMCL_COLOUR_THRESHOLD,0.1);
bc->SetInt32(XMCL_COLOUR_DELTA_R,1);
bc->SetInt32(XMCL_COLOUR_DELTA_G,1);
bc->SetInt32(XMCL_COLOUR_DELTA_B,1);
bc->SetInt32(XMCL_COLOUR_BLEND,COLOUR_BLEND_NORMAL);
bc->SetFloat(XMCL_COLOUR_BLEND_VALUE,0.1);
bc->SetInt32(XMCL_COLOUR_GRADIENT_COMPLETE,GRAD_COMPLETE_NONE);
bc->SetFloat(XMCL_COLOUR_GRADIENT_SPEED_MIN,0.1);
bc->SetFloat(XMCL_COLOUR_GRADIENT_SPEED_MAX,0.1);
pObject->Message(MSG_UPDATE);
}
Gradients
This node has gradients. Gradients can manually be edited by calling the following code
Python
C++
#include "customgui_gradient.h"
XMCL_COLOUR_GRADIENT
GeData data;
pObject->GetParameter(DescID(XMCL_COLOUR_GRADIENT),data,DESCFLAGS_GET_PARAM_GET));
Gradient *pGradient = (Gradient*)data.GetCustomDataType(CUSTOMDATATYPE_GRADIENT);
if(pGradient)
{
//must be set before any knot is set
pGradient->SetData(GRADIENT_MODE, GeData(GRADIENTMODE_ALPHA));
GradientKnot k1, k2;
k1.col = Vector(0.0, 0.0, 1.0);
k1.pos = 0.0;
k2.col = 1.0;
k2.pos = 1.0;
pGradient->InsertKnot(k1);
pGradient->InsertKnot(k2);
}
pObject->SetParameter(DescID(XMCL_COLOUR_GRADIENT),data,DESCFLAGS_SET_PARAM_SET));