THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/09/2006 at 13:45, xxxxxxxx wrote:
Cinema 4D Version: 9+
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
A couple of questions:
1. In SeDrawParameter(), what is the DRAW_PARAMETER_ALPHA_THRESHOLD supposed to do? In the c4d_basedraw.h file, there's a comment that says it's values are from 0 to 1.0, but I don't see any difference when using LineNew() to draw lines in front of solid shaded polygons. I was hoping the lines would be lighter, sort of like they were semitransparant or something, but that doesn't seem to be what the parameter does.
2. With the LineZOffset() function, it seems that the zoom of the camera alters whether or not a line drawn with LineNew() gets drawn in front of a solid shaded polygon or not. What's the relationship with the camera and the LineZOffset() function? is there a formula to use to always calculate a value according to what the camer's zoom is?
On 19/09/2006 at 00:04, xxxxxxxx wrote:
In regards to 2., I use LineZOffset(32). It is an exaggerated value, but it appears to do the trick despite projection or camera zoom. Note that extreme zooms will cause anomalies irregardless - same goes for C4D tools from experimentation.
On 22/09/2006 at 06:40, xxxxxxxx wrote:
Thanks for the reply, Robert.
LineZOffset(32) doesn't cut it. I had to go even higher just to get the object inside the polygon object to draw its lines in front of the polygon object. But, when I zoom the camera in past a certain point and zoom the camera out past a certain point, the drawn lines disappear.
On 22/09/2006 at 14:24, xxxxxxxx wrote:
Greater than 32 - wow. What value did you find worked best?
Do you have any screenshots - and is this camera zoom or 'dolly'?
On 22/09/2006 at 17:25, xxxxxxxx wrote:
I think it's dolly and not zoom, because the zoom in the coordinates manager doesn't change, just the XYZ position changes.
Here's the result of 32:
As you can see, in the first one, it's not drawing all the joints in front, but as I pull the camera away, it draws them all in front. Then when I move the camera in close, it draws even less of them in front.
On 22/09/2006 at 21:50, xxxxxxxx wrote:
Could this be related to more 'when' you draw instead of 'where' you draw?
For instance, my tool draws the highlights only in the DRAWFLAGS_HIGHLIGHT pass - and they can be occluded in the same way you show in the images. But my visual controls are drawn irregardless of pass and always show in front of everything no matter what the dolly or zoom (except in extreme zoom out - probaby more to do with distorion) - even if behind another polygon object (just tested).
Have you tried this? (I'm going to for my highlighting - will let you know the results).
On 22/09/2006 at 22:04, xxxxxxxx wrote:
For the tool, there is definitely no occlusion occuring if the pass is ignored. These first two images are the old way (only in DRAWFLAGS_HIGHLIGHT) :
These two are the new way (ignore pass) :
Note that far away for both shows, while near fails in the old but works in the new.
On 23/09/2006 at 06:40, xxxxxxxx wrote:
Nope, ignoring the draw pass doesn't seem to make a difference.
On 23/09/2006 at 13:34, xxxxxxxx wrote:
May be you need to deactivate depth test?
Then try to do something with "SetDrawParam" or use OGL commands like "glDepthFunc( GL_ALWAYS)" (in this case don`t forget to link OGL libraries)
On 23/09/2006 at 13:48, xxxxxxxx wrote:
Of course, OGL commands are only good if the user is working in OGL and not Software mode.
And SetDrawParam() is not available pre-9 (if you are supporting earlier versions).
The problem could be that ObjectData::Draw() and ToolData::Draw() work differently (?). I don't use SetDrawParam() since I'm supporting R8. Are you returning SUPER::Draw()?
Might need to see the code for a better understanding of your process.
On 23/09/2006 at 17:09, xxxxxxxx wrote:
Jeez, I had to crank it all the way up to 950 to get it to work.
But there is still no way I can see to make the lines draw as a dotted line, so that they look semi transparent.
On 23/09/2006 at 17:21, xxxxxxxx wrote:
I was thinkin' (never good).
What draw pass are you using? The only experience I have with plugin objects is my 'bones' for IPP. Here, the only drawing is the 'origin' crosshairs which always draw in front of everything. I use DRAWPASS_HANDLES to do this. This is the method (for your perusal if it may provide something) :
Bool IPPBase::Draw(PluginObject* op, LONG drawpass, BaseDraw* bd, BaseDrawHelp* bh)
if (drawpass != DRAWPASS_HANDLES) return SUPER::Draw(op, drawpass, bd, bh);
BaseContainer* bc = op->GetDataInstance();
if (!bc) return SUPER::Draw(op, drawpass, bd, bh);
Real len = 0.05 * bc->GetReal(IPP_SCALING);
Vector ep = bc->GetVector(IPP_ENDPOINT)-bc->GetVector(IPP_ORIGIN);
Matrix mg = bh->GetMg();
// Line between Origin-EndPoint
// Origin cross-hairs
bd->Line3D(Vector(-len, 0.0, 0.0)*mg, Vector(len, 0.0, 0.0)*mg);
bd->Line3D(Vector(0.0, -len, 0.0)*mg, Vector(0.0, len, 0.0)*mg);
bd->Line3D(Vector(0.0, 0.0, -len)*mg, Vector(0.0, 0.0, len)*mg);
// EndPoint cross-hairs
bd->Line3D(Vector(ep.x-len, ep.y, ep.z)*mg, Vector(ep.x+len, ep.y, ep.z)*mg);
bd->Line3D(Vector(ep.x, ep.y-len, ep.z)*mg, Vector(ep.x, ep.y+len, ep.z)*mg);
bd->Line3D(Vector(ep.x, ep.y, ep.z-len)*mg, Vector(ep.x, ep.y, ep.z+len)*mg);
return SUPER::Draw(op, drawpass, bd, bh);
On 23/09/2006 at 17:51, xxxxxxxx wrote:
Well, I'm also using DRAWPASS_HANDLES to draw... you guessed it... "handles", so the user can edit the size of the joint envelope.
When using DRAWPASS_HANDLES, it only draws when the object is the active object. So, that's no good for drawing all the joints in the skeleton.
Same with DRAWPASS_BOX, it only draws when the object is the active object.
Using DRAWPASS_HIGHLIGHTS, it doesn't draw at all.
So all I have left is DRAWPASS_OBJECT, or let it draw without any draw pass, but then it will draw with every draw pass.
On 23/09/2006 at 18:08, xxxxxxxx wrote:
I feel your pain, Dan.
Yes, selected objects - I don't draw anything unless the 'bone' is selected. So you want to draw your objects irregardless of selection. You may need to use that extreme value for LineZOffset() - need to hear from higher authorities on this.
As for drawing semi-transparent lines, that is a good question. SetTransparency() sets transparency for polygons only - presumptiously not lines etc. DRAW_PARAMETER_ALPHA_THRESHOLD may have relevance here - but I have no experience with it.
Will have to wait for more info on this - maybe OGL is the only option and you'll only be able to support it in that situation (OGL as compared to Software mode).
Sorry that I can't be more helpful.
On 23/09/2006 at 19:41, xxxxxxxx wrote:
Well, it'll do for now. Thanks anyway.
Drawing a dotted line may even be an internal drawing function not available in the SDK.
On 26/09/2006 at 04:21, xxxxxxxx wrote:
this info is for R9.5 and i'm not sure if it will work for you, but anyways:
SetTransparency should work for lines, too. You get dottet lines by using a negative argument. SetTransparency(-128) should work fine. Other values didn't work as expected in my experiments.
If the DRAWFLAGS_INVERSE_Z flag is avaiable ( only toolplugins ? ), you can just check it and change the transparency.
If not you can do something like:
// normal pass
// dotted pass
I think with LineNew and friends you can also disable the depth test by using the NOCLIP_Z flag. Never tested it though.
Hope that helps
On 26/09/2006 at 13:37, xxxxxxxx wrote:
Thanks Michael, but it still doesn't seem to work.
Using DRAW_Z_GREATER makes the lines not draw at all, or rather makes them only draw over something that has already been drawn in the viewport. So, the only way they'll show over the geometry is if the geometry is above them in the OM so that the geometry gets drawn first.
On 27/09/2006 at 00:39, xxxxxxxx wrote:
In that case use
and draw the lines twice
// normal pass
// dotted pass
// reset parameters
this should work
On 27/09/2006 at 08:22, xxxxxxxx wrote:
Thanks Michael, but it still seems to depend on where the geometry is in the OM. Actually I am already drawing the lines twice. I'm trying to give the user an option, via a checkbox, to see the joints in front of the geometry, because as they are now, the user can only see the joints if the geometry is in XRay mode.
Geometry below the joints in the OM:
Geometry above the joints in the OM:
As you can see, it draws nicely when the geometry is above the joints in the OM, but I'd like it to draw like that no matter where the geometry is in the OM.
If I place GePrint() statements in the Draw() function, I find that the joint's Draw() function only gets called once with the flag DRAWPASS_OBJECT, unless it is the active object then it gets called three times, once with the flag DRAWPASS_OBJECT, and twice with the flag DRAWPASS_HANDLES.
DRAWPASS_BOX and DRAWPASS_HIGHLIGHTS never get passed to the joint object's Draw() function.
On 28/09/2006 at 01:57, xxxxxxxx wrote:
Aw.. damn.. you are right of couse.. what i told you can't work. It works fine for tools because they draw after objects. Even if you paint with inverted Z test, the next object will still paint above these lines.
I'm wondering how bones are implemented. They seem to have no problem.
Perhaps the only way to get your lines is to use a scenehook plugin. If you can make it draw after the objects drawpass, then you could just loop over all your bones and do the drawing as i mentioned it above.