Can an expression draw a light source?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/09/2007 at 13:31, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10.111
Platform: Windows ;
Language(s) : C++ ;---------
Hi,in my plugin I have an expression tag that takes control over the DOF parameters of a camera. Now I want to visualize the DOF in the editor, so the user doesn't have to render to get an impression of the result.
Visualizing the DOF can be done well with a light source. But can I draw a light source with my expression? Of course, I could link a light source from the scene into my tag, but it would be much more elegant to create an own 'internal' light source.
Thanks for any help & tipps!
Best regards,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/09/2007 at 15:52, xxxxxxxx wrote:
Doing an actual editor representation would require OpenGL - not even sure if it is possible to add to or override C4D's handling of the editor display (say, if you wanted to display displacement in the editor. I've never seen it done and one would think that a very useful plugin). And this would preclude Software display support.
From there, you could go the route specified or do your own little 'preview window' (ala Cineview for instance). It is certainly possible to do basic display drawing into the editor viewport(s). TagData has a Draw() method - which is exactly what you're looking for!
For instance, you could use a series of transparent spheres to denote the drop-off of the DOF effect. Or you could use a series of lines to demarkate regions. But as for simulating a light - we're back to OpenGL. The light you see in the editor display is 'Powered by OpenGL (tm)(r)(c)' or that supported by C4D's Software equivalent. So, you'll either need to go the more schematic Draw() route or use a light. The disadvantage with using a light is that you must remember that OpenGL can only display so many depending upon the graphics card and drivers. The usual limit is 8 - with more lights, their displayed effect in the editor is ignored.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/09/2007 at 13:11, xxxxxxxx wrote:
On the user meeting in cologne, Bobtronic told me about the possibility of using the DrawObject() method of the BaseDraw class, which is passed to the Draw() method of my expression.
I will try that.
What you told me in your post is interesting, but I think developing 'outside' the SDK could be bad, regarding the compatibility to MAC systems. Also, I have not enough experience to program with OpenGL yet
Greetings,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/09/2007 at 10:42, xxxxxxxx wrote:
OK, I am back at this problem...
The Draw() method can handle a BaseObject, so (at least I think so) also a lightsource. But now I come to a much more basic problem: How do I create a lightsource object in my code?
I suspect the RayLight has something to do with it, but how do I use it?
I just want to create a point light, give it some parameters (global position, brightness, color, clipping) and draw it in the editor.
Thank you again for any help or tips!
Best regards & Greetings,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/09/2007 at 11:00, xxxxxxxx wrote:
Do you want to create a light object or emulate a light source? It is easy to create a light object, configure it, and add it to the scene - but that might not be what you are going for.
You could draw an emulated light into the editor - but you are still limited to the available BaseDraw draw methods. To actually show the light interaction with other objects is another story, as noted previously.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/09/2007 at 11:04, xxxxxxxx wrote:
Hm, where's the difference?
I want my expression to draw a lightsource in the editor, but not to show this lightsource as an object in the object manager. It should only be available to and controlled by the expression tag, since the light is just for visualization purposes, and not part of the scene to be rendered.
Greetings,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/09/2007 at 12:02, xxxxxxxx wrote:
That's the difference!
A Cinema 4D Light object has all of the power of the light code behind it. And to benefit from it you have to create one and add it to the scene - as you are aware, one cannot even extend existing types like Olight with plugins and one cannot get the light effect if not attached to a scene.
Most other 'light' based code in the SDK is for rendering (internal/external/materials). Whether there is code to do this in the editor preview is not known to me - but I suspect it is not possible.
The BaseDraw::SimpleShade() method is only for applying basic lighting/shading to a polygon object being drawn into the editor display (using DrawPolygonObject() for instance).
Don't confuse 'draw an emulated light into the editor' with actual lighting. Here I am saying that you could draw a polygon object and lines to show where the light is, where it points, and maybe its direction/scope/strength - schematically.
To show the light's actual effect in the editor, you'll need a way to draw into the editor. There are two ways: OpenGL and Draw() method. It may be possible to the Draw() method to 'highlight' each polygon of the target objects using transparency and Polygon3D(). This would be a crude way to show the lighting on other objects.
The only other possibility is a bit more esoteric. Here you would use a shader or material on the other objects to 'allow' and show the pseudo light source lighting. At least with a shader or material you have a way to do more complex drawing into the editor.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/09/2007 at 00:42, xxxxxxxx wrote:
The problem is that the light added by Draw() is not included in your scene and therefore will not light your objects. When we were talking about this on the usermeeting in Cologne I hadn't thought about this. I think you have to come up with something different. What exactly do you want to achieve?
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/09/2007 at 01:05, xxxxxxxx wrote:
Hi Matthias,
I also noticed that I can't light the scene that way.
Therefore, I solved the problem differently now:I create a lightsource (null object alloc) in the scene, and store the link in a hidden ID in my .h description (.h file). When deleting the tag or closing the scene, I use the Free() function of the TagData class to remove the lightsource. Works fine.
The only thing I need to do now is to hide the lightsource object in the object manager. I didn't find a possibility for that yet, but I was told that it's possible.
+ + +
What I want to achieve: Visualizing the Depth Of Field in the Editor, without the need to render it first. You can try that yourself: Add a spotlight and make it a child of the scene camera. Make local position and rotation = (0,0,0). Then activate the clipping in the lightsources attributes and set e.g. NearStart to 200.0, NearEnd to 300.0, RearStart to 400.0 and RearEnd to 500.0. Now you have a range of light in front of your camera. If the Start and End values are calculated according to the depth settings of the camera, this makes for a fine visualization of the DOF. Very intuitive.
Greetings,
Frank