Navigation

    • Register
    • Login
        No matches found
    • Search
    1. Home
    2. rui_mac
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by rui_mac

    RE: Getting the offset of MoGraph clones

    @ferdinand, YES!!!
    That solved it. Thank you so much.
    Forgot about the effectors order inside the Matrix. I was only changing the order in the Object Manager.

    posted in General Talk •
    RE: Getting the offset of MoGraph clones

    @m_magalhaes , I tried to edit the post but it told me that I can only do it until one hour after posting 😞

    The file I include creates a Matrix with 20x20 clones and randomises their positions.
    Then, a Python effector reads the positions of all the clones and adds their indexes and distances to a list, if their distances are less than a threshold amount.
    However, the distance that is stored is always the same, as all the clones were evenly distributed and not randomly placed.
    I'm using r20.

    MoGraph Particles.c4d

    posted in General Talk •
    RE: Best way to display a bitmap in the viewport background

    @kbar, thank you for the reply.
    The problem with the Scene Hook is that it requires C++.
    I'm coding in python.

    posted in General Talk •
    Getting the offset of MoGraph clones

    I'm trying to get the position of MoGraph clones (in my case, from a Matrix object) that has a Random effector that randomises the positions of the clones.
    However, the list that I get from md.GetArray(c4d.MODATA_MATRIX) always returns the original position of the clones, not the position that is the result of the Random effector.
    I'm coding inside a Python effector (that is AFTER the Random effector, in the Object Manager).
    So, how can I get the position of the clones AFTER they are adjusted by the Random effector?
    Thank you very much in advance.

    posted in General Talk •
    Best way to display a bitmap in the viewport background

    I would like to create an Object plugin and I would like the code to be able to show a bitmap, with optional alpha (transparency) adjustment, in the background of the viewports (perspective and orthogonal views).
    What is the best way do do it?
    I don't need actual code. Just what methods to override and what must I make to be sure it displays below all viewport objects.
    Thank you very much in advance for any reply.

    Rui Batista

    posted in General Talk •
    RE: Getting the value of a gadget

    Thank you so much. That did it!!

    posted in Cinema 4D SDK •
    Getting the value of a gadget

    I have a CommandDataPlugin that creates a dialog with buttons and a checkbox.
    It is easy to get what gadget what clicked, inside the Command method.
    But how to I get the value of the checkbox?
    I need to know if it is on or off, and Command only tells me what gadget was clicked.

    posted in Cinema 4D SDK •
    RE: Exporting Polygonized scene

    You're welcome, Manuel.

    Actually, I usually prepare all the textures and mapping to be in UVW mapping, when texturing is required.
    But, mainly, what I need is exporting geometry that is animated.

    posted in Cinema 4D SDK •
    RE: Exporting Polygonized scene

    Thank you very much, Manuel.
    I will send the scene to the e-mail you provided.

    posted in Cinema 4D SDK •
    RE: Exporting Polygonized scene

    I'm trying to export a Dynamics MoGraph animation, with a Voronoi Fracture object.
    If I export as OBJ, it works fine.
    If I export as C4D, all the saved files are the same, and have no animation.

    posted in Cinema 4D SDK •
    Exporting Polygonized scene

    I have a script that exports a sequence of OBJ files out of an animated Cinema 4D scene. It works perfectly.
    I would like to be able to do the same, but export as a sequence of C4D files.
    What I need is to export a sequence of frames (the scene has animation, of course), in C4D format, but with everything polygonized.
    I'm using:

    ...
                doc.SetTime(curr_time)
                # Force the redraw of the document
                doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_NONE)
                c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
                c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW)
    
                bufferedNumber = str(frame_num)
                frame_num=frame_num+1
    
                # Export the C4D file
                file_name = os.path.join(file_path,obj_name+bufferedNumber+".c4d")
    
                poly_doc=doc.Polygonize(keepanimation = False)
    
                if poly_doc != None: c4d.documents.SaveDocument(poly_doc,file_name,c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST | c4d.SAVEDOCUMENTFLAGS_SAVECACHES,c4d.FORMAT_C4DEXPORT)
    
    

    But all the saved files are the same and I wanted each file to export as different frame, already polygonized.
    Is this possible?

    posted in Cinema 4D SDK •
    RE: Determine if a polygon is facing the camera

    Once again, thank you, Manuel.
    I had to do a few changes and it is working now.
    I even made it select the faces that are within a certain angle from the camera.
    Here is my code:

                for i,poly in enumerate(faces):
                    a,b,c,d = poly.a,poly.b,poly.c,poly.d
                    pta = points[a]*mg
                    ptb = points[b]*mg
                    ptc = points[c]*mg
                    ptd = points[d]*mg
        
                    v1 = pta-ptb
                    v2 = ptb-ptc
        
                    normal = v1.Cross(v2)
                    normal.Normalize()
        
                    if c != d:
                        center = c4d.Vector((pta.x+ptb.x+ptc.x+ptd.x)/4.0,(pta.y+ptb.y+ptc.y+ptd.y)/4.0,(pta.z+ptb.z+ptc.z+ptd.z)/4.0)
                    else:
                        center = c4d.Vector((pta.x+ptb.x+ptc.x)/3.0,(pta.y+ptb.y+ptc.y)/3.0,(pta.z+ptb.z+ptc.z)/3.0)
        
                    direction = cam_off - center
                    norm_dir = direction.GetNormalized()
                    angle = NINETY - normal.Dot(norm_dir)
        
                    if (angle > 0.0 and angle < max_ang):
                        selection.Select(i)
    
    posted in General Talk •
    RE: Determine if a polygon is facing the camera

    Thank you Manuel.
    Your code is for an object, not a face.
    So, I tried to adapt it and this is what I got (and it doesn't really work):

    def main():
        selected=doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)
    
        if selected==[]: return
        
        bd = doc.GetActiveBaseDraw()
        cam = bd.GetSceneCamera(doc)
        if cam == None: cam = bd.GetEditorCamera()
        cam_mg = cam.GetMg() # in case I need it
        cam_off = cam_mg.off # in case I need it
    
        for op in selected:
            if op.GetType() != 5100: continue
            mg = op.GetMg()
            faces = op.GetAllPolygons()
            points = op.GetAllPoints()
            
            selection = op.GetPolygonS()
            selection.DeselectAll()
            
            for i,poly in enumerate(faces):
                a,b,c,d = poly.a,poly.b,poly.c,poly.d
                pta = points[a]
                ptb = points[b]
                ptc = points[c]
                ptd = points[d]
                
                v1 = pta-ptb
                v2 = ptb-ptc
                
                normal = v1.Cross(v2)
                normal.Normalize()
                normal = normal * mg
                
                if c != d:
                    center = c4d.Vector((pta.x+ptb.x+ptc.x+ptd.x)/4.0,(pta.y+ptb.y+ptc.y+ptd.y)/4.0,(pta.z+ptb.z+ptc.z+ptd.z)/4.0)
                else:
                    center = c4d.Vector((pta.x+ptb.x+ptc.x)/3.0,(pta.y+ptb.y+ptc.y)/3.0,(pta.z+ptb.z+ptc.z)/3.0)
        
                center = center * mg
                
                is_vis = bd.BackfaceCulling(normal, center)
                
                if (is_vis == True):
                    selection.Select(i)
                    
        c4d.EventAdd()
    

    What could be wrong?

    posted in General Talk •
    Determine if a polygon is facing the camera

    How can I determine if a polygon on a polygonal object is facing the current (user or editor) camera?
    I know there is a BackfaceCulling function but it always returns me with True.

    posted in General Talk •
    RE: Undefined symbols

    Great, I will do that. 🙂

    posted in Cinema 4D SDK •
    RE: Undefined symbols

    Since it is my serial protection code, I may have to edit things a bit, to protect my secrets 😉
    I will see if I can adjust to code to provide as much information as possible, without revealing too much, as soon as I get home.

    posted in Cinema 4D SDK •
    RE: Undefined symbols

    I still get the same error, even after adding the #include "maxon/string.h"
    I also replaced the DiagnosticOutput() with ApplicationOutput(), but the error persists.

    posted in Cinema 4D SDK •
    RE: Undefined symbols

    Actually, yes.
    Would it be better to use GePrint?
    Or was it discontinued?
    What is the best way to print to the Console now, in C++?

    posted in Cinema 4D SDK •
    Undefined symbols

    I'm getting this error message:

    Undefined symbols for architecture x86_64:
    "ToString(String const&, maxon::FormatStatement const*, bool)", referenced from:
    void maxon::ToStrHlp<String>(maxon::String&, String const*, maxon::FormatStatement const*) in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    And I'm not even using the ToString in any of my code.
    Trying to recompile all my plugins to R21 is being really hard 😞

    posted in Cinema 4D SDK •
    RE: Wrong indentation of if ?!?! What is wrong?

    I set the stylecheck.level to zero and the complains about the indentation disappeared.
    I also tried that type of structure but the error still appeared, when the stylecheck.level was set to 3.
    Now I'm getting different types of errors.

    posted in Cinema 4D SDK •