protected BaseObject allocBonesCurveY(string mainname, BaseObject parent, long counter = 0, double3 vec = new double3())
        {
            int bone = (int)counter;
            BaseObject myJoint = null;
            double x = vec.x;
            double y = vec.y;
            if (x < 0)
            {
                x *= -1;
            }
            while (bone > 0)
            {
                vec.y += x / bone;
                if (vec.y > x)
                {
                    vec.y = x;
                }
                myJoint = this.allocJoint(mainname, parent, vec);
                this.wtag.AddJoint(myJoint);
                vec.x += vec.y;
                if (vec.x > 0)
                {
                    vec.x = 0;
                }

                parent = myJoint;
                bone--;
            }
            return myJoint;
        }
        protected BaseObject allocBonesCurveY(string mainname, BaseObject parent, long counter = 0, Vector3D vec = new Vector3D())
        {
            int bone = (int)counter;
            BaseObject myJoint = null;
            double x = vec.X;
            double y = vec.Y;
            if (x < 0)
            {
                x *= -1;
            }
            while (bone > 0)
            {
                vec.Y += x / bone;
                if (vec.Y > x)
                {
                    vec.Y = x;
                }
                myJoint = this.allocJoint(mainname, parent, vec);
                this.wtag.AddJoint(myJoint);
                vec.X += vec.Y;
                if (vec.X > 0)
                {
                    vec.X = 0;
                }

                parent = myJoint;
                bone--;
            }
            return myJoint;
        }
Exemplo n.º 3
0
        static Vector3D GetRTHandle(BaseObject op, int id)
        {
	        BaseContainer data = GetDataInstance(op);
	        double rad	  = data.GetReal(CIRCLEOBJECT_RAD);
	        int plane  = data.GetLong(C4dApi.PRIM_PLANE);
	        return SwapPoint(new Vector3D(rad,0.0,0.0),plane);
        }
        protected bool allocBonesInBones(string mainname, string bonename, BaseObject parent, double3 vec = new double3(), double3 vecMulti = new double3(), double3 vecBone = new double3(), double3 vecBoneMulti = new double3(), long counter = 0)
        {
            int KnochenLinks;
            int bone = (int)counter;

            if (bone != 0)
            {
                while (bone != 0)
                {
                    BaseObject jointBone = this.allocJoint(mainname + "_" + bone, parent, new double3(vec.x += vecMulti.x, vec.y += vecMulti.y, vec.z += vecMulti.z));
                    //BaseObject jointBone = this.allocJoint(mainname +"_"+ bone, parent, new double3(vec.x, vec.y, vec.z + bone_z));
                    this.wtag.AddJoint(jointBone);

                    if (bone == 1)
                    {
                        KnochenLinks = 2;
                    }
                    else
                    {
                        KnochenLinks = 3;
                    }

                    while (KnochenLinks != 0)
                    {
                        jointBone = this.allocJoint(bonename + "_" + KnochenLinks, jointBone, new double3(vecBone.x += vecBoneMulti.x, vecBone.y += vecBoneMulti.y, vecBone.z += vecBoneMulti.z));
                        this.wtag.AddJoint(jointBone);
                        KnochenLinks--;
                    }
                    bone--;
                }
            }
            return true;
        }
Exemplo n.º 5
0
        protected bool allocBonesInBones(string mainname, string bonename, BaseObject parent, Vector3D vec = new Vector3D(), Vector3D vecMulti = new Vector3D(), Vector3D vecBone = new Vector3D(), Vector3D vecBoneMulti = new Vector3D(), long counter = 0)
        {
            int KnochenLinks;
            int bone = (int)counter;

            if (bone != 0)
            {
                while (bone != 0)
                {
                    BaseObject jointBone = this.allocJoint(mainname + "_" + bone, parent, new Vector3D(vec.X += vecMulti.X, vec.Y += vecMulti.Y, vec.Z += vecMulti.Z));
                    //BaseObject jointBone = this.allocJoint(mainname +"_"+ bone, parent, new Vector3D(vec.X, vec.Y, vec.Z + bone_z));
                    this.wtag.AddJoint(jointBone);

                    if (bone == 1)
                    {
                        KnochenLinks = 2;
                    }
                    else
                    {
                        KnochenLinks = 3;
                    }

                    while (KnochenLinks != 0)
                    {
                        jointBone = this.allocJoint(bonename + "_" + KnochenLinks, jointBone, new Vector3D(vecBone.X += vecBoneMulti.X, vecBone.Y += vecBoneMulti.Y, vecBone.Z += vecBoneMulti.Z));
                        this.wtag.AddJoint(jointBone);
                        KnochenLinks--;
                    }
                    bone--;
                }
            }
            return true;
        }
 public override int DetectHandle(BaseObject op, BaseDraw bd, int x, int y, QUALIFIER qualifier)
 {
     if (0 != (qualifier & QUALIFIER.QUALIFIER_CTRL))
         return -1;
     double4x4 mg = op.GetMg();
     if (bd.PointInRange(mg * GetRTHandle(op,0),x,y))
         return 0; // OK
     return -1; // Not OK
 }
        private List<SceneObjectContainer> FuseefyOb(BaseObject ob)
        {
            if (ob == null)
                return null;

            List<SceneObjectContainer> ret = new List<SceneObjectContainer>();
            do
            {
                SceneObjectContainer soc = new SceneObjectContainer();

                double4x4 mtxD = ob.GetMl();
                soc.Transform = (float4x4) mtxD;
                PolygonObject polyOb = ob as PolygonObject;
                if (polyOb != null)
                {
                    /*double3  padr = ToPoly(op)->GetPointR();
                    CPolygon vadr = ToPoly(op)->GetPolygonR();*/
                    int nPolys = polyOb.GetPolygonCount();
                    ushort nNewVerts = 0;
                    List<float3> verts = new List<float3>();
                    List<ushort> tris = new List<ushort>();

                    for (int i = 0; i < nPolys; i++)
                    {
                        CPolygon poly = polyOb.GetPolygonAt(i);
                        double3 a = polyOb.GetPointAt(poly.a);
                        double3 b = polyOb.GetPointAt(poly.b);
                        double3 c = polyOb.GetPointAt(poly.c);
                        double3 d = polyOb.GetPointAt(poly.d);

                        verts.Add((float3)a);
                        verts.Add((float3)b);
                        verts.Add((float3)c);

                        tris.AddRange(new ushort[] {nNewVerts, (ushort)(nNewVerts+1), (ushort)(nNewVerts+2)});

                        if (c != d)
                        {
                            // The Polyogon is not only a triangle, but a quad. Add the second triangle.
                            verts.Add((float3)d);
                            tris.AddRange(new ushort[] { nNewVerts, (ushort)(nNewVerts + 2), (ushort)(nNewVerts + 3) });
                            nNewVerts += 1;
                        }
                        nNewVerts += 3;
                    }
                    soc.Mesh = new MeshContainer()
                    {
                        Vertices = verts.ToArray(),
                        Triangles = tris.ToArray(),
                    };
                }
                soc.Children = FuseefyOb(ob.GetDown());
                ret.Add(soc);
                ob = ob.GetNext();
            } while (ob != null);
            return ret;
        }
Exemplo n.º 8
0
 /**
  * Anlegen eines Joint Objekts
  * @param string Name des Joint Objekts
  * @param BaseObject Parent Joint, falls dieser gekuppelt werden soll
  * @param Vector3D Vektor in die der Joint zeigen soll
  * @return BaseObject Joint Objekt zurückgeben
  */
 protected BaseObject allocJoint(string name, BaseObject parentJoint = null, Vector3D vec = new Vector3D())
 {
     BaseObject myJoint = BaseObject.Alloc(C4dApi.Ojoint); // Speicher reservieren für den Joint
     myJoint.SetName(name); // Joint mit einem Namen versehen
     if (parentJoint == null)
     {
         parentJoint = this.myMesh;
     }
     this.doc.InsertObject(myJoint, parentJoint, null); // Kuppeln der Joints
     myJoint.SetAbsPos(vec); // Richtung vorgeben
     return myJoint;
 }
Exemplo n.º 9
0
  public virtual void GetModelingAxis(BaseObject op, BaseDocument doc, ref Fusee.Math.Core.Matrix4D /* Matrix*&_cstype */ axis) {
    double[] adbl_axis;
    unsafe {adbl_axis = Fusee.Math.ArrayConversion.Convert.Matrix4DToArrayDoubleC4DLayout(axis);    fixed (double *pdbl_axis = adbl_axis) {
    /* Matrix*&_csin_pre */
    try {
      C4dApiPINVOKE.ObjectData_GetModelingAxis(swigCPtr, BaseObject.getCPtr(op), BaseDocument.getCPtr(doc), (IntPtr) pdbl_axis /* Matrix*&_csin */);
    } finally {
        axis = Fusee.Math.ArrayConversion.Convert.ArrayDoubleC4DLayoutToMatrix4D(pdbl_axis);
        /* Matrix*&_csin_post */
    }
} } /* Matrix*&_csin_terminator */
  }
Exemplo n.º 10
0
  public virtual bool Do(SWIGTYPE_p_void data, BaseObject op, ref Fusee.Math.Core.Matrix4D /* constMatrix&_cstype */ mg, bool controlobject) {
    double[] adbl_mg;
    unsafe {adbl_mg = Fusee.Math.ArrayConversion.Convert.Matrix4DToArrayDoubleC4DLayout(mg);    fixed (double *pdbl_mg = adbl_mg) {
    /* constMatrix&_csin_pre */
    try {
      bool ret = C4dApiPINVOKE.Hierarchy_Do(swigCPtr, SWIGTYPE_p_void.getCPtr(data), BaseObject.getCPtr(op), (IntPtr) pdbl_mg /* constMatrix&_csin */, controlobject);
      return ret;
    } finally {
        // NOP mg = Fusee.Math.ArrayConversion.Convert.ArrayDoubleC4DLayoutToMatrix4D(pdbl_mg);
        /* constMatrix&_csin_post */
    }
} } /* constMatrix&_csin_terminator */
  }
        public override DRAWRESULT Draw(BaseObject op, DRAWPASS type, BaseDraw bd, BaseDrawHelp bh)
        {
            if (type!=DRAWPASS.DRAWPASS_HANDLES)
                return DRAWRESULT.DRAWRESULT_SKIP;

            int hitid = op.GetHighlightHandle(bd);

            double4x4 m = bh.GetMg();

            if (hitid==0)
                bd.SetPen(C4dApi.GetViewColor(C4dApi.VIEWCOLOR_SELECTION_PREVIEW));
            else
                bd.SetPen(C4dApi.GetViewColor(C4dApi.VIEWCOLOR_ACTIVEPOINT));

            // double3 zeroPos = new double3(0, 0, 0);
            bd.SetMatrix_Matrix(op, ref m);
            bd.DrawHandle(GetRTHandle(op, 0), DRAWHANDLE.DRAWHANDLE_BIG,0);
            bd.DrawLine(GetRTHandle(op, 0), new double3(0, 0, 0),0);

            return DRAWRESULT.DRAWRESULT_OK;
        }
Exemplo n.º 12
0
 protected BaseObject allocMirrorJoint(string name, BaseObject parentJoint, BaseObject mirrorJoint)
 {
     double3 vecparent = mirrorJoint.GetAbsPos();
     BaseObject myJoint = this.allocJoint(name, parentJoint, new double3(vecparent.x * -1, vecparent.y, vecparent.z));
     return myJoint;
 }
Exemplo n.º 13
0
        protected BaseObject[] allocBonesSwing(string mainname, BaseObject parent, long counter = 0, double3 vec = new double3())
        {
            int bone = (int)counter;
            bone -= 2;

            /*
             * Vor Swing joint
             */
            BaseObject myJoint = this.allocJoint(mainname, parent, new double3(vec.x, 0, 0));
            parent = myJoint;
            this.wtag.AddJoint(myJoint);

            /*
             * Swing einbauen
             */
            double temp = bone;
            bool change = false;
            while (bone > 0)
            {
                if (temp / 2 > bone && change == false)
                {
                    vec.y = 0;
                    change = true;
                }
                BaseObject jointBone = this.allocJoint(mainname + "_" + bone, parent, new double3(vec.x, vec.y, vec.z));
                this.wtag.AddJoint(jointBone);
                parent = jointBone;
                bone--;
            }

            // Nach Swing Joint
            BaseObject myJoint1 = this.allocJoint(mainname, parent, new double3(vec.x, 0, 0));
            this.wtag.AddJoint(myJoint1);
            // Array als rückgabe vorbereiten
            BaseObject[] arrJoint = { myJoint, myJoint1 };
            return arrJoint;
        }
        private void AddFeet(BaseObject parentJoint, BaseObject mirrorJoint = null)
        {
            this.feet = this.b.GetLong(SKELETT_FUESSE);
            this.toes = this.b.GetLong(SKELETT_ZEHEN);
            this.legs = this.b.GetLong(SKELETT_BEINE);
            //this.tail = this.b.GetLong(SKELETT_SCHWANZ); (Animal Klasse)

            if (this.legs > 0)
            {
                BaseObject jointL_Leg = this.allocJoint("L_Leg", parentJoint, new double3(0, -100, 0));
                BaseObject jointL_Cnemials = this.allocJoint("L_Cnemials", jointL_Leg, new double3(0, -100, 0));
                BaseObject jointL_Foot = null;

                this.wtag.AddJoint(jointL_Leg);
                this.wtag.AddJoint(jointL_Cnemials);

                if (this.feet > 0)
                {
                    jointL_Foot = this.allocJoint("L_Foot", jointL_Cnemials, new double3(0, 0, -50));

                    if (this.toes > 0)
                    {
                        this.allocBonesInBones("L_Feet", "L_FeetBone", jointL_Foot, new double3(15, 0, -25), new double3(-5, 0, 0), new double3(0, 0, -5), new double3(0, 0, 0), this.toes);
                    }
                    this.wtag.AddJoint(jointL_Foot);
                }

                if (this.legs == 2)
                {
                    BaseObject jointR_Leg = this.allocMirrorJoint("R_Leg", mirrorJoint, jointL_Leg);
                    BaseObject jointR_Cnemials = this.allocMirrorJoint("R_Cnemials", jointR_Leg, jointL_Cnemials);
                    BaseObject jointR_Foot = null;

                    this.wtag.AddJoint(jointR_Leg);
                    this.wtag.AddJoint(jointR_Cnemials);

                    if (this.feet == 2)
                    {
                        jointR_Foot = this.allocMirrorJoint("R_Foot", jointR_Cnemials, jointL_Foot);
                        this.wtag.AddJoint(jointR_Foot);

                        if (this.toes > 0)
                        {
                            this.allocBonesInBones("R_Feet", "R_FeetBone", jointR_Foot, new double3(15, 0, -25), new double3(-5, 0, 0), new double3(0, 0, -5), new double3(0, 0, 0), this.toes);
                        }
                    }
                }
            }
        }
        private void AddArms(BaseObject parentJoint, BaseObject mirrorJoint = null)
        {
            this.arms = this.b.GetLong(SKELETT_ARME);
            this.hands = this.b.GetLong(SKELETT_HAND);
            this.finger = this.b.GetLong(SKELETT_FINGER);

            if (this.arms > 0)
            {
                BaseObject jointL_Upperam = this.allocJoint("L_Upperarm", parentJoint, new double3(75, 0, 0));
                BaseObject jointL_Forearm = this.allocJoint("L_Forearm", jointL_Upperam, new double3(75, 0, 0));
                BaseObject jointL_Hand = null;

                this.wtag.AddJoint(jointL_Upperam);
                this.wtag.AddJoint(jointL_Forearm);

                if (this.hands > 0)
                {
                    jointL_Hand = this.allocJoint("L_Hand", jointL_Forearm, new double3(25, 0, 0));

                    if (this.finger > 0)
                    {
                        this.allocBonesInBones("L_Finger", "L_FingerBone", jointL_Hand, new double3(25, 0, 10), new double3(0, 0, -5), new double3(5, 0, 0), new double3(0, 0, 0), this.finger);
                    }
                    this.wtag.AddJoint(jointL_Hand);
                }

                if (this.arms == 2)
                {
                    BaseObject jointR_Upperarm = this.allocMirrorJoint("R_Upperarm", mirrorJoint, jointL_Upperam);
                    BaseObject jointR_Forearm = this.allocMirrorJoint("R_Forearm", jointR_Upperarm, jointL_Forearm);

                    this.wtag.AddJoint(jointR_Upperarm);
                    this.wtag.AddJoint(jointR_Forearm);

                    if (this.hands == 2)
                    {
                        BaseObject jointR_Hand = this.allocMirrorJoint("R_Hand", jointR_Forearm, jointL_Hand);
                        this.wtag.AddJoint(jointR_Hand);

                        if (this.finger > 0)
                        {
                            this.allocBonesInBones("R_Finger", "R_FingerBone", jointR_Hand, new double3(-25, 0, 10), new double3(0, 0, -5), new double3(-5, 0, 0), new double3(0, 0, 0), this.finger);
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
 private void setJointWeight(int tagPos, BaseObject op2,PointObject pObj)
 { 
     BaseTag t = op2.GetTag(C4dApi.Tpointselection,tagPos);
     SelectionTag st = (SelectionTag) op2.GetTag(C4dApi.Tpolygonselection);
     BaseSelect SelectedPoints = st.GetBaseSelect();
     if (t.GetName() == null)
     { }
     else
     {
         string selectioname = t.GetName();
         for (int j = 0; j < this.wtagGlob.GetJointCount(); j++)
         {
             if (selectioname == this.wtagGlob.GetName())
             {
                 for (int i = 0; i < pObj.GetPointCount(); i++)
                 {
                     if (SelectedPoints.IsSelected(i))
                     {
                         this.wtagGlob.SetWeight(1, i, 0.04);
                         setJointWeight(tagPos + 1, op2, pObj);
                         //C4dApi.GePrint("Der Punkt mit dem Index " + i + " ist selektiert");
                     }
                 }
             }
         }
     }
    
 }
Exemplo n.º 17
0
 public void SetOrigin(BaseObject origin) {
   C4dApiPINVOKE.BaseObject_SetOrigin(swigCPtr, BaseObject.getCPtr(origin));
 }
Exemplo n.º 18
0
 public bool Record(BaseObject op, bool always) {
   bool ret = C4dApiPINVOKE.StickTextureTag_Record(swigCPtr, BaseObject.getCPtr(op), always);
   return ret;
 }
Exemplo n.º 19
0
 public int FindJoint(BaseObject op, BaseDocument doc) {
   int ret = C4dApiPINVOKE.CAWeightTag_FindJoint(swigCPtr, BaseObject.getCPtr(op), BaseDocument.getCPtr(doc));
   return ret;
 }
Exemplo n.º 20
0
 public void RemoveJoint(BaseObject op) {
   C4dApiPINVOKE.CAWeightTag_RemoveJoint(swigCPtr, BaseObject.getCPtr(op));
 }
Exemplo n.º 21
0
 public int AddJoint(BaseObject op) {
   int ret = C4dApiPINVOKE.CAWeightTag_AddJoint(swigCPtr, BaseObject.getCPtr(op));
   return ret;
 }
Exemplo n.º 22
0
 internal static HandleRef getCPtr(BaseObject obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Exemplo n.º 23
0
 public void AddDependence(HierarchyHelp hh, BaseObject op) {
   C4dApiPINVOKE.BaseObject_AddDependence(swigCPtr, HierarchyHelp.getCPtr(hh), BaseObject.getCPtr(op));
 }
Exemplo n.º 24
0
 public BaseObject GetHierarchyClone(HierarchyHelp hh, BaseObject op, HIERARCHYCLONEFLAGS flags, SWIGTYPE_p_Bool dirty, AliasTrans trans) {
   IntPtr cPtr = C4dApiPINVOKE.BaseObject_GetHierarchyClone(swigCPtr, HierarchyHelp.getCPtr(hh), BaseObject.getCPtr(op), (int)flags, SWIGTYPE_p_Bool.getCPtr(dirty), AliasTrans.getCPtr(trans));
   BaseObject ret = (cPtr == IntPtr.Zero) ? null : new BaseObject(cPtr, false);
   return ret;
 }
Exemplo n.º 25
0
 public bool CopyTagsTo(BaseObject dest, int visible, int variable, int hierarchical, AliasTrans trans) {
   bool ret = C4dApiPINVOKE.BaseObject_CopyTagsTo(swigCPtr, BaseObject.getCPtr(dest), visible, variable, hierarchical, AliasTrans.getCPtr(trans));
   return ret;
 }
Exemplo n.º 26
0
 public void SetSceneCamera(BaseObject op, bool animate) {
   C4dApiPINVOKE.BaseDraw_SetSceneCamera__SWIG_0(swigCPtr, BaseObject.getCPtr(op), animate);
 }
Exemplo n.º 27
0
 protected BaseObject allocMirrorJoint(string name, BaseObject parentJoint, BaseObject mirrorJoint)
 {
     Vector3D vecparent = mirrorJoint.GetAbsPos();
     BaseObject myJoint = this.allocJoint(name, parentJoint, new Vector3D(vecparent.X * -1, vecparent.Y, vecparent.Z));
     return myJoint;
 }
Exemplo n.º 28
0
 public void SetSceneCamera(BaseObject op) {
   C4dApiPINVOKE.BaseDraw_SetSceneCamera__SWIG_1(swigCPtr, BaseObject.getCPtr(op));
 }
Exemplo n.º 29
0
 public bool SearchHierarchy(BaseObject op) {
   bool ret = C4dApiPINVOKE.BaseObject_SearchHierarchy(swigCPtr, BaseObject.getCPtr(op));
   return ret;
 }
Exemplo n.º 30
0
   } /* </Matrix_csout> */ 

  public void CopyMatrixTo(BaseObject dst) {
    C4dApiPINVOKE.BaseObject_CopyMatrixTo(swigCPtr, BaseObject.getCPtr(dst));
  }