Centre of Perspective view



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/10/2012 at 05:05, xxxxxxxx wrote:

    Finally got back to a bit of programming.

    I want to put something at the centre of the perspective view as a guide.

    What is the best method to use here to plot my line 
    ie how do I always guarantee the centre of the viewport when it is something that changes?

    tia



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/10/2012 at 11:05, xxxxxxxx wrote:

    Hi,
    If you mean something like crosshairs you could use the bd.GetFrame() in the Draw function to get the screen dimensions and calculate the center.
    Then you could draw there a point, a line or a circle with the corresponding 2D BaseDraw functions.
    Hope that helps.
    Phil



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 31/10/2012 at 03:25, xxxxxxxx wrote:

    thanks for hint



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/11/2012 at 01:20, xxxxxxxx wrote:

    After various tinkerings

    Do I take it that cannot be done in a simple script?

    Doing it in a tag seems cumbersome and even that doesn't seem to work in the python generator

    only sensible options appears to be to write a full blown plugin?

    Seems real overkill when I just want a user defined circle on the screen

    or have I missed something



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/11/2012 at 11:11, xxxxxxxx wrote:

    Hi.
    I'm not quite sure what you're trying to do. 
    If you put a python tag with this code on an object it will jump to the center of your camera:

    import c4d  
    from c4d import utils  
    #Welcome to the world of Python  
      
      
    def main() :  
    bd = doc.GetActiveBaseDraw()  
    cam = bd.GetSceneCamera(doc)  
    mg = cam.GetMg()  
      tm = c4d.utils.MatrixMove(c4d.Vector(0,0,10)) #Move the object a little bit in front of the camera  
    mg = mg * tm  
    op.GetObject().SetMg(mg)
    

    I tried it with a circle spline with a diameter of 0.1cm and this should do the trick, if that's what you're after. This only works if the playhead in your timeline is moving or any other event happens, not by just moving the camera.
    Phil



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/11/2012 at 15:24, xxxxxxxx wrote:

    Thanks
    Just want a variable circle that centres in the viewport. ie a drawn circle not and OM object.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/11/2012 at 01:07, xxxxxxxx wrote:

    It's easy enough to obtain a viewport, get a BaseDraw, and draw a circle on the screen. The problem you have is that it won't stay there. As soon as there's a screen update, it might disappear.

    So what you need is some way to ensure that your drawing routine is called every time there is a screen update. That's why you can't use a script, because that's only executed once. You need a plugin with a Draw() function as part of its interface. Lots of them do - ObjectData, TagData, ToolData, SceneHookData, etc.

    I'd look at a SceneHookData in the first instance, if you can do those in Python. If not, a TagData would be the next choice for me.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/11/2012 at 01:54, xxxxxxxx wrote:

    That was the problem. Trying to work out how to keep the thing visible. A tag seems really clunky - will take a look at SceneHookData.

    ta


Log in to reply