public CharakterHuman(GeListNode node, DescriptionCommand desc) { this.b = GetDataInstance(node); this.button = desc.id.GetAt(0).id; this.doc = C4dApi.GetActiveDocument();//Speichern aller Elemente im Dokument in die Variable doc this.myMesh = b.GetObjectLink(SKELETT_OBJ_AUSWAHL, doc); //selektiertes Object in die Variable ObjSe speichern this.mcd = new ModelingCommandData(this.doc, this.myMesh, this.myMesh.GetDataInstance(), MODELINGCOMMANDMODE.MODELINGCOMMANDMODE_ALL, MODELINGCOMMANDFLAGS.MODELINGCOMMANDFLAGS_CREATEUNDO, null, null); /** * Bisheriges speichern und in die Szene zeichnen */ C4dApi.EventAdd(); /** * Wichtungstag definieren */ this.wtag = CAWeightTag.Alloc(); //TODO - Geaendert von DS //this.wtagBaseTag = BaseTag.Alloc(C4dApi.Tweights); /** * Wichtungstag in das BaseObject einbauen */ this.myMesh.InsertTag(this.wtag); /** * Standard BaseObject vom Typ Joint erstellen, diese sind bei Menschen immer aktiv */ BaseObject jointSpine = this.allocJoint("Spine"); BaseObject jointAbs = this.allocJoint("Abs", jointSpine, new double3(0, 100, 0)); BaseObject jointChest = this.allocJoint("Chest", jointAbs, new double3(0, 50, 0)); BaseObject jointNeck = this.allocJoint("Neck", jointChest, new double3(0, 25, 0)); BaseObject jointHead = this.allocJoint("Head", jointNeck, new double3(0, 50, 0)); BaseObject jointL_Hip = this.allocJoint("L_Hip", jointSpine, new double3(25, 0, 0)); BaseObject jointL_Shoulder = this.allocJoint("L_Shoulder", jointChest, new double3(25, 0, 0)); /** * Spiegelung */ BaseObject jointR_Hip = this.allocMirrorJoint("R_Hip", jointSpine, jointL_Hip); BaseObject jointR_Shoulder = this.allocMirrorJoint("R_Shoulder", jointChest, jointL_Shoulder); /*********** * Übergabe an den Wichtungstag ***********/ /** * Arme hinzufügen */ this.AddArms(jointL_Shoulder, jointR_Shoulder); /** * Füße hinzufügen */ this.AddFeet(jointL_Hip, jointR_Hip); /** * Standard */ this.wtag.AddJoint(jointSpine); this.wtag.AddJoint(jointAbs); this.wtag.AddJoint(jointChest); this.wtag.AddJoint(jointNeck); this.wtag.AddJoint(jointHead); // Linke seite vom Körper this.wtag.AddJoint(jointL_Hip); this.wtag.AddJoint(jointL_Shoulder); // Rechte seite vom Körper this.wtag.AddJoint(jointR_Hip); this.wtag.AddJoint(jointR_Shoulder); /** * Debug Ausgabe erstellen */ C4dApi.GePrint("Der Joint wurde angelegt"); jointSpine.GetTag(C4dApi.Tweights); /** * Skin Objekt einfügen */ BaseObject skin = BaseObject.Alloc(C4dApi.Oskin); if (skin != null) { skin.InsertUnder(this.myMesh); skin.SetEditorMode(C4dApi.MODE_ON); //BaseContainer bcc = skin.GetDataInstance(); //InExcludeData list=new InExcludeData(0); //BaseList2D b2d = bcc.GetLink(SKELETT_OBJ_AUSWAHL, doc); //list.InsertObject(b2d,0); // InExcludeData list = (InExcludeData)bcc.GetCustomDataType(ID_CA_SKIN_OBJECT_INCLUDE, C4dApi.CUSTOMDATATYPE_INEXCLUDE_LIST); // list.InsertObject(this.myMesh, 0); //bcc.SetLong(ID_CA_SKIN_OBJECT_INCEXC, 1); //bcc.GetCustomDataType(ID_CA_SKIN_OBJECT_INCEXC_INCLUDE, C4dApi.CUSTOMDATATYPE_INEXCLUDE_LIST); // InExcludeData list = (InExcludeData) //bcc.SetData(ID_CA_SKIN_OBJECT_INCEXC,true); //bcc.GetCustomDataType(ID_CA_SKIN_OBJECT_INCLUDE, C4dApi.CUSTOMDATATYPE_INEXCLUDE_LIST); //int t = bcc.GetId(); //C4dApi.GePrint("list " + t); // list.InsertObject(this.myMesh, 0); //C4dApi.GePrint("list OBJ " + list.GetObjectCount()); /*c++ Variante BaseObject *skin; // a pointer to a skin object BaseContainer *bc = skin->GetDataInstance(); InExcludeData *list = (InExcludeData*)bc->GetCustomDataType(ID_CA_SKIN_OBJECT_INCLUDE, CUSTOMDATATYPE_INEXCLUDE_LIST); BaseObject *mesh; // the object you want to insert into the list list->InsertObject(mesh, 0); */ //InExcludeData iex = autoAlloc(); // InExcludeCustomGui iex = CustomDataType //iex.InsertObject(b.GetLink(SKELETT_OBJ_AUSWAHL,this.doc),1); } /**s * Zur Szene hinzufügen */ //rem.GetName(); //rem.Remove(); C4dApi.EventAdd(); //C4dApi.GetObjectName(1000023); // gibt "Biped Plugin" aus //C4dApi.GePrint("anzal der bones: "+this.wtag.GetJointCount()); doc.SetActiveObject(this.myMesh);//Selektiert das Model im OM //BaseList2D te = this.b.GetLink(1000023, this.doc); //te.Remove(); }
//wird aufgerufen, wenn ein Event ausgeführt wurde //TODO: Override gelöscht - DS public bool OnDescriptionCommand(GeListNode node, DescriptionCommand desc) { long button = desc.id.GetAt(0).id; //BaseList2D ObjSelector = bc.GetLink(SKELETT_OBJ_AUSWAHL, doc); switch (button) { case SKELETT_BTN_CREATE: BaseContainer b = GetDataInstance(node); BaseDocument doc = C4dApi.GetActiveDocument(); BaseList2D ObjSelector = b.GetLink(SKELETT_OBJ_AUSWAHL, doc); /*Eingeforene Selektion Auswählen vom Typ Polygon ENDE*/ if (ObjSelector == null) { C4dApi.MessageDialog("Bitte wählen Sie zuerst ein Polygonobjekt aus, bevor Sie ein Biped erstellen!"); } else { long skelett = b.GetLong(SKELETT_TYPE); if (skelett == 3) { this.makeAnimalJoints(node, desc); } else { this.makeJoints(node, desc); } } // C4dApi.GePrint("Der button Erstellen wurde gedrück "+objSe.GetNodeID()+objSe.GetName()); //ObjSe.GetName() liefert den namen des Selektierten Objekts zurück. break; case SKELETT_WICHTUNG_BTN: /*Eingefrorene Selektion Auswählen vom Typ Polygon START*/ BaseContainer b2 = GetDataInstance(node); BaseDocument doc2 = C4dApi.GetActiveDocument(); BaseObject op2 = b2.GetObjectLink(SKELETT_OBJ_AUSWAHL, doc2); BaseTag t = op2.GetTag(C4dApi.Tpolygonselection); //string selekname = t.GetName(); //BaseTag t2 = op2.GetTag(C4dApi.Tpolygonselection,1); //if (op2.GetTag(C4dApi.Tpolygonselection,2)==null) //{ } //C4dApi.GePrint(" blubb " + t2.GetName() + " der name der vorherigen Selektion lautet: " + selekname); //C4dApi.GePrint(" blubb der name der vorherigen Selektion lautet: " + selekname); //BaseObject j = this.wtagGlob.GetJoint(1, doc2); //C4dApi.GePrint("Knochenname "+j.GetName()); //string joinName = j.GetName(); //if (joinName == selekname) //{ // C4dApi.GePrint("stimmen ueberein"); //} //SelectionTag st = SelectionTag.Alloc(C4dApi.Tpolygonselection); //BaseSelect sel = st.GetBaseSelect(); //sel.Select(t.GetNodeID); BaseTag joints = op2.GetTag(C4dApi.Tweights); //this.wtagGlob = joints.Get C4dApi.GePrint("wichtung setzen bones anzahl: "+this.wtagGlob.GetJointCount()); //Punkte der PolygonSelektion abrufen //int pt = op2.GetTagDataCount(C4dApi.Tpolygonselection); //C4dApi.GePrint("Anzahl der Punkte : " + pt); //doc2.SetActiveObject(b2.GetObjectLink(SKELETT_OBJ_AUSWAHL, doc2)); SelectionTag st = SelectionTag.Alloc(C4dApi.Tpointselection); BaseSelect bs = st.GetBaseSelect(); PointObject pObj = PointObject.GetPointObject(op2); //pObj.GetPointS(); //for (int i = 0; i < pObj.GetPointCount(); i++) //{ //} C4dApi.GePrint("test"+bs.Select(0)); bs.Select(0); BaseSelect SelectedPoints = pObj.GetPointS(); //for (BaseTag pointTag = op2.GetFirstTag(); pointTag; pointTag = pointTag.GetNext()) //{ // desc.id.GetAt(0).id = 1000; // pointTag.Message(C4dApi.MSG_DESCRIPTION_COMMAND, desc); //} BaseTag btA = doc2.GetActiveTag(); C4dApi.GePrint("TypeName : "+btA.GetTypeName() +" Name "+btA.GetName()); if (btA.GetType() == C4dApi.Tpolygonselection) { for (int j = 0; j < wtagGlob.GetJointCount(); j++) { BaseObject JointName = wtagGlob.GetJoint(j, doc2); if (btA.GetName() == JointName.GetName()) { for (int i = 0; i < pObj.GetPointCount(); i++) { if (SelectedPoints.IsSelected(i)) { this.wtagGlob.SetWeight(j, i, 0.04); C4dApi.GePrint("Der Punkt mit dem Index " + i + " ist selektiert"); } } } } } else { } //C4dApi.GePrint("anzahl der pt " + pObj.GetPointCount()); //pObj.SetPointAt(1, new Vector3D(1, 2, 3)); //XPressoTag xt = XPressoTag.Alloc(); //xt = (BaseSelect)t; // this.wtagGlob.SetWeight(1, 2, 1.0/100); //Setweeight 1.0 == 100 entspricht 0.42 == 42.0 entspricht Deshalb ist es einfacher direkt durch hundert zu teilen break; } return true; }
internal static HandleRef getCPtr(DescriptionCommand obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
public bool makeAnimalJoints(GeListNode node, DescriptionCommand desc) { CharakterAnimal Main = new CharakterAnimal(node, desc); this.wtagGlob = Main.getwtagJoint(); return true; }
public CharakterAnimal(GeListNode node, DescriptionCommand desc) { this.b = GetDataInstance(node); this.button = desc.id.GetAt(0).id; this.doc = C4dApi.GetActiveDocument();//Speichern aller Elemente im Dokument in die Variable doc this.myMesh = b.GetObjectLink(SKELETT_OBJ_AUSWAHL, doc); //selektiertes Object in die Variable ObjSe speichern this.mcd = new ModelingCommandData(this.doc, this.myMesh, this.myMesh.GetDataInstance(), MODELINGCOMMANDMODE.MODELINGCOMMANDMODE_ALL, MODELINGCOMMANDFLAGS.MODELINGCOMMANDFLAGS_CREATEUNDO, null, null); /** * Bisheriges speichern und in die Szene zeichnen */ C4dApi.EventAdd(); /** * Wichtungstag definieren */ this.wtag = CAWeightTag.Alloc(); //this.wtagBaseTag = BaseTag.Alloc(C4dApi.Tweights); /** * Wichtungstag in das BaseObject einbauen */ this.myMesh.InsertTag(this.wtag); /** * Standard BaseObject vom Typ Joint erstellen, diese sind bei Menschen immer aktiv */ //Rückenknochen BaseObject[] jointSpineArr = this.allocBonesSwing("Spine", this.myMesh, this.b.GetLong(SKELETT_RUECKENWIRBEL), new double3(50, -2, 0)); //Nackenknochen BaseObject jointNeck = this.allocBonesCurveY("Neck", jointSpineArr[0], this.b.GetLong(SKELETT_HALSWIRBEL), new double3(-100, 0, 0)); //Kopf BaseObject jointHead = this.allocJoint("Head", jointNeck, new double3(-100,0,0)); this.wtag.AddJoint(jointHead); if (this.b.GetLong(SKELETT_BEINE) > 0) { this.addLegsFront(jointSpineArr[0]); if (this.b.GetLong(SKELETT_BEINE) >= 3) { this.addLegsBack(jointSpineArr[1]); } } //Schwanz if (this.b.GetLong(SKELETT_RUECKENWIRBEL) > 0 && this.b.GetLong(SKELETT_SCHWANZ) > 0) { BaseObject parent = jointSpineArr[1]; for (int i = 0; i < this.b.GetLong(SKELETT_SCHWANZ); i++) { BaseObject jointTail = this.allocJoint("Tail_" + i, parent, new double3(100, -50, 0)); this.wtag.AddJoint(jointTail); parent = jointTail; } } /** * Debug Ausgabe erstellen */ C4dApi.GePrint("Der Joint wurde angelegt"); jointSpineArr[0].GetTag(C4dApi.Tweights); /** * Skin Objekt einfügen */ BaseObject skin = BaseObject.Alloc(C4dApi.Oskin); if (skin != null) { skin.InsertUnder(this.myMesh); } /** * Zur Szene hinzufügen */ C4dApi.EventAdd(); C4dApi.GePrint("anzal der bones: " + this.wtag.GetJointCount()); doc.SetActiveObject(this.myMesh);//Selektiert das Model im OM }