THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/02/2010 at 10:07, xxxxxxxx wrote:
Cinema 4D Version: 10
Platform: Windows ;
Language(s) : C++ ;
I know there is a target tag which allows me to point to an object. Is there a similar way to simply point to the origin of the world coordinate frame? Can I use the origin as a target somehow?
There is the simple workaround to place a null object in the origin, but just wanted to check whether there is a "cleaner" solution without adding another object.
On 26/02/2010 at 10:15, xxxxxxxx wrote:
Maybe create a Vector at (0,0,0) and point to that?
What type of plugin are you making? An object?
On 26/02/2010 at 10:25, xxxxxxxx wrote:
My plugin creates an infinite light source and places it in the scene, then I want to make it point to the origin of the scene ...
How do you want to point to a vector?
I am looking at the lookatcamera example, but I want to avoid creating a new plugin just for that. Was really hoping there is a simpler solution.
On 26/02/2010 at 10:26, xxxxxxxx wrote:
Is there an Xpresso equivalent to Vector2HPB?
On 26/02/2010 at 11:00, xxxxxxxx wrote:
I actually managed to do it now with an XPRESSO tag and using the C.O.F.F.E.E. VectorToHPB function.
Would still be interested in other solutions though!
On 01/03/2010 at 06:30, xxxxxxxx wrote:
What kind of plugin is creating the light object, a CommandData plugin?
More specifically at which point in your plugin do you want to orient the light object?
On 02/03/2010 at 02:41, xxxxxxxx wrote:
my plugin is creating a realistic scene. Through a CommandData plugin, I add the Sun, i.e. an infinite light object at a specified position. After insertion, this light object shall point from its position always to the center of the scene (world origin).
Currently, i am creating the object in a C4D file by hand, including all parameter settings, etc.,Then I simply put it into the scene through a MergeDocument() call. This call is done by a CommandData plugin (see above).
What I have done at the moment is to use an infinite light with a Xpresso tag, where the position of the object feeds back into the rotation through a VectorToHPB COFFEE block.
As I said, don't know if that is a very elegant solution. Would be happy on your feedback.
On 02/03/2010 at 03:12, xxxxxxxx wrote:
Why don't you create the objects yourself within your plugin, it's not that difficult.
Here is an example which does exactly this, including pointing the light source towards the world origin. Read the code comments for a more detailed explaination.
Bool MenuTest::Execute(BaseDocument *doc)
StopAllThreads(); //stop all threads before modifying the document
BaseObject *light = NULL;
light = BaseObject::Alloc(Olight); //create a light object
if (!light) return FALSE;
Vector pos = Vector(234.0,634.0,534.0); //just some random postion of the light
light->SetPos(pos); //set the postion
Vector hpb = VectorToHPB(-!pos); //the normalized and inverted postion vector used as direction vector
hpb.z = 0.0; //banking angle set to zero
light->SetRot(hpb); //set the rotation
light->SetParameter(DescLevel(LIGHT_TYPE), GeData(LIGHT_TYPE_DISTANT), 0); //set the light type to distant light
light->SetParameter(DescLevel(LIGHT_SHADOWTYPE), GeData(LIGHT_SHADOWTYPE_HARD), 0); //set the shadow type to hard raytraced
doc->StartUndo(); //start adding undos
doc->InsertObject(light, NULL, NULL, FALSE); //insert the light object into the document
doc->AddUndo(UNDO_NEW, light); //add an undo for the insertion
doc->EndUndo(); //end adding undos
doc->Message(MSG_UPDATE); //inform the document of changes
EventAdd(); //refresh the managers (OM etc.)
On 02/03/2010 at 04:14, xxxxxxxx wrote:
Thanks for the example, Matthias.
I decided to do it in an extra C4D scene because this gives me the opportunity to insert not only the light, but also a glowing sphere to represent the Sun when looking at it. This way, I can set all properties in the file and change them, without having to modify my plugin as such.
Also, I want to later move the light object in the scene (during the "day"), but do not want to have to change the rotation every time. So when having the object with a tag that makes it point to the origin, it points there regardless of how and where I move it in the scene.