void ApplinkDialog::Timer(const BaseContainer &msg) { Bool b; GetBool(IDC_CHK_PROMPT, b); if(b) { Filename fn; fn.SetDirectory(gPreferences.GetString(IDC_EXCH_FOLDER)); fn.SetFile("export.txt"); if(GeFExist(fn)) { GePrint("File exists!"); SetTimer(0); if(GeOutString("To import a new object?", GEMB_OKCANCEL) == GEMB_R_OK) { GePrint("Start import!"); BaseDocument* doc = GetActiveDocument(); ApplinkImporter* importer = NewObjClear(ApplinkImporter); importer->Execute(doc, &gPreferences); SetTimer(1000); } else { SetBool(IDC_CHK_PROMPT, false); } } } }
Bool ApplinkDialog::Command(Int32 id, const BaseContainer& msg) { dirty = true; saveSettings(); switch(id) { case IDC_BTN_EXPORT: { BaseDocument* doc = GetActiveDocument(); ApplinkExporter* exporter = NewObjClear(ApplinkExporter); exporter->Execute(doc, &gPreferences); String exeCoat = gPreferences.GetString(IDC_COAT_EXE_PATH); if(gPreferences.GetBool(IDC_CHK_COAT_START) && exeCoat != "") { if(!Find3DCoat()) { Int32 length = exeCoat.GetCStringLen(STRINGENCODING_8BIT) + 1; char* buffer = NewMemClear(char,length); exeCoat.GetCString(buffer, length, STRINGENCODING_8BIT); #if defined _WIN32 || defined _WIN64 SHELLEXECUTEINFO ExecuteInfo; memset(&ExecuteInfo, 0, sizeof(ExecuteInfo)); ExecuteInfo.cbSize = sizeof(ExecuteInfo); ExecuteInfo.fMask = 0; ExecuteInfo.hwnd = 0; ExecuteInfo.lpVerb = TEXT("open"); // Operation to perform wchar_t *pBuffer = (wchar_t *)malloc(MAX_PATH); mbstowcs(pBuffer, buffer, MAX_PATH); ExecuteInfo.lpFile = pBuffer; // Application name ExecuteInfo.lpDirectory = 0; // Default directory ExecuteInfo.nShow = SW_SHOWNORMAL; ExecuteInfo.hInstApp = 0; if(ShellExecuteEx(&ExecuteInfo) == false) { GePrint("3D-Coat.exe not found!"); } #elif __APPLE__ string str = "open " + string(buffer); system(str.c_str()); GePrint("Start 3D-Coat: " + String(buffer)); #endif DeleteMem(buffer); } else { GePrint("3D-Coat.exe is run!"); } } }
Bool ApplinkExporter::WriteMatsFile(BaseDocument* document, BaseContainer* bc) { Filename filenameMTL; filenameMTL.SetDirectory(bc->GetString(IDC_TMP_FOLDER)); filenameMTL.SetFile(document->GetDocumentName()); filenameMTL.SetSuffix("mtl"); GePrint(filenameMTL.GetString()); AutoAlloc<BaseFile> fileMTL; if (!fileMTL->Open(filenameMTL, FILEOPEN_WRITE, FILEDIALOG_NONE, GeGetByteOrder())) return FALSE; for(LONG i=0; i < materialArray.GetCount(); i++) { BaseMaterial* mat = materialArray[i]; String str; str = "newmtl " + mat->GetName() + "\n"; this->WriteString(str, fileMTL); //Ka str = "Ka 0.300000 0.300000 0.300000\n"; this->WriteString(str, fileMTL); ///////////////////////////////////////////////////////// //////////////////////////////////////////////////////// //Kd if(getParameterLong(*mat, MATERIAL_USE_COLOR)) { ExportChannel(document, fileMTL, *mat, MATERIAL_COLOR_SHADER, MATERIAL_COLOR_COLOR, "Kd"); } //Ks if(getParameterLong(*mat, MATERIAL_USE_REFLECTION)) { ExportChannel(document, fileMTL, *mat, MATERIAL_REFLECTION_SHADER, MATERIAL_REFLECTION_COLOR, "Ks"); } //Ns str = "Ns 50.000000\n"; this->WriteString(str, fileMTL); //Tr str = "Tr 0.000000\n"; this->WriteString(str, fileMTL); //illum str = "illum 2\n"; this->WriteString(str, fileMTL); this->WriteEndLine(fileMTL); } fileMTL->Close(); return TRUE; }
void GePrintF(const CHAR *format,...) { va_list arp; CHAR buf[1024]; va_start(arp,format); vsprintf_safe(buf,sizeof(buf),format,arp); GePrint(buf); va_end(arp); }
Bool Objectify::Init(GeListNode *node) { BaseObject *op = (BaseObject*)node; BaseContainer *data = op->GetDataInstance(); data->SetReal(TRIANGULATION_MAX_SEARCH_RADIUS,30.); GePrint("Objectify by http://twitter.com/eight_io for Cinema 4D r14"); prevFrame = 0; return TRUE; }
Bool Voxelify::Init(GeListNode *node) { BaseObject *op = (BaseObject*)node; BaseContainer *data = op->GetDataInstance(); //data->SetReal(CTTSPOBJECT_MAXSEG,1000.); //data->SetReal(CTTSPOBJECT_MINSEG,0.1); data->SetLong(SPLINEOBJECT_INTERPOLATION,SPLINEOBJECT_INTERPOLATION_ADAPTIVE); GePrint("Voxelify by http://twitter.com/eight_io for Cinema 4D r14"); return TRUE; }
void _printf(const char *format,...) { #ifndef RELEASE char fmt[1024]; sprintf(fmt,"--- Syphon: %s",format); va_list arp; va_start(arp,format); char buf[1024]; vsprintf_safe(buf,sizeof(buf),fmt,arp); GePrint(buf); va_end(arp); #endif }
Bool CSVNodeData::InitCalculation(GvNode* node, GvCalc* calc, GvRun* run) { if (!node || !calc || !run) return FALSE; m_calcInit = FALSE; m_initCsv = FALSE; if (!GvBuildValuesTable(node, m_values, calc, run, GV_EXISTING_PORTS)) { GePrint(__FUNCTION__ ": Could not build in-port values."); return FALSE; } UpdateCSVTable(node, run, NULL); m_calcInit = TRUE; return m_calcInit && super::InitCalculation(node, calc, run); }
Bool RegisterCSVNode() { Bool ok = GvRegisterOperatorPlugin( GvOperatorID(ID_CSVNODE), GeLoadString(IDC_CSVNODE_NAME), 0, CSVNodeData::Alloc, "Gvcsv", CSVNODE_VERSION, ID_GV_OPCLASS_TYPE_GENERAL, ID_GV_OPGROUP_TYPE_XPRESSOEFFECTOR, 0, // owner AutoBitmap("Gvcsv.tif")); if (!ok) { GePrint(GeLoadString(IDC_CSVNODE_NOTREGISTERED)); } return ok; }
virtual Bool Command(Int32 id, const BaseContainer& msg) { switch (id) { case 1004: { const GeData& d = msg.GetData(BFM_ACTION_VALUE); if (d.GetType() == DA_CONTAINER) { const BaseContainer* bc = d.GetContainer(); String shortcut; if (bc) { shortcut = Shortcut2String(*bc); GePrint("Shortcut received: " + shortcut); } } break; } } return true; }
//########################## C4D START ########################## Bool C4D_PlStart(void *p1, void *p2) { if (!resource.Init()) return FALSE; // don't start plugin without resource if (!RegisterTDEmitter()) return FALSE; if (!RegisterPOLYEM()) return FALSE; if (!RegisterTDMenu()) return FALSE; //TAG if (!RegisterPTPTag()) return FALSE; if (!RegisterESPTag()) return FALSE; //if (!RegisterMEMTag()) return FALSE; //if (!RegisterForcer()) return FALSE; //---PaMod--- //if (!RegisterPaMod1()) return FALSE; //if (!RegisterPaMod2()) return FALSE; //if (!RegisterPaMod3()) return FALSE; //if (!RegisterPaMod4()) return FALSE; //if (!RegisterPaMod5()) return FALSE; //if (!RegisterPaMod6()) return FALSE; //if (!RegisterPaMod7()) return FALSE; //if (!RegisterPaMod8()) return FALSE; //if (!RegisterPaMod9()) return FALSE; //if (!RegisterPaMod10()) return FALSE; // //if (!RegisterMOD()) return FALSE; //if (!RegisterOESP()) return FALSE; //if (!RegisterTDSubDialog()) return FALSE; GePrint("Remotion TDEM Loaded!");//??? return TRUE; }
Bool CSVNodeData::Calculate(GvNode* node, GvPort* port, GvRun* run, GvCalc* calc) { if (!node || !port || !run || !calc || !m_calcInit) return FALSE; // Obtain the row-index from the in-ports. GvPortCalc pCalc(node, &m_values, run, calc); GvPort* pRow = pCalc.GetInPort(CSVNODE_ROWINDEX); // node->GetInPortFirstMainID(CSVNODE_ROWINDEX); LONG rowIndex; if (!pRow || !pRow->GetInteger(&rowIndex, run)) { GePrint(__FUNCTION__ ": Could not obtain Row Index."); return FALSE; } // Update the CSV Table. if (!UpdateCSVTable(node, run, calc)) { GePrint(__FUNCTION__ ": UpdateCSVTable() failed."); return FALSE; } // Obtain the row from the CSV Table that is to be used. const StringCSVTable::Array* row = NULL; LONG rowCount = m_table.GetRowCount(); if (rowIndex >= 0 && rowIndex < rowCount) { row = &m_table.GetRow(rowIndex); } // True when setting the outgoing value for the port was // successful, false if not. Bool result = TRUE; // Obtain the port Main ID and check for fixed ports (like // the total column count, row count, etc.) LONG portId = port->GetMainID(); switch (portId) { case CSVNODE_LOADED: port->SetBool(m_table.Loaded(), run); break; case CSVNODE_COLCOUNT_TOTAL: port->SetInteger(m_table.GetColumnCount(), run); break; case CSVNODE_COLCOUNT: { LONG count = row ? row->GetCount() : 0; port->SetInteger(count, run); break; } case CSVNODE_ROWCOUNT: port->SetInteger(m_table.GetRowCount(), run); break; default: result = FALSE; break; } // If no port matched, it probably is a dynamic port representing // a CSV column. if (!result && portId >= CSVNODE_DYNPORT_START) { LONG index = portId - CSVNODE_DYNPORT_START; LONG colCount = m_table.GetColumnCount(); String value = ""; if (index >= 0 && index < colCount && row) { value = (*row)[index]; } port->SetString(value, run); result = TRUE; } return result; }
Bool ListViewDialog::Command(LONG id,const BaseContainer &msg) { switch (id) { case GADGET_LISTVIEW1: case GADGET_LISTVIEW2: { switch (msg.GetLong(BFM_ACTION_VALUE)) { case LV_SIMPLE_SELECTIONCHANGED: GePrintF("Selection changed, id: %d, val: %p ",msg.GetLong(LV_SIMPLE_ITEM_ID),msg.GetVoid(LV_SIMPLE_DATA)); break; case LV_SIMPLE_CHECKBOXCHANGED: GePrintF("CheckBox changed, id: %d, col: %d, val: %p",msg.GetLong(LV_SIMPLE_ITEM_ID),msg.GetLong(LV_SIMPLE_COL_ID),msg.GetVoid(LV_SIMPLE_DATA)); break; case LV_SIMPLE_FOCUSITEM: GePrintF("Focus set id: %d, col: %d",msg.GetLong(LV_SIMPLE_ITEM_ID),msg.GetLong(LV_SIMPLE_COL_ID)); break; case LV_SIMPLE_BUTTONCLICK: GePrintF("Button clicked id: %d, col: %d",msg.GetLong(LV_SIMPLE_ITEM_ID),msg.GetLong(LV_SIMPLE_COL_ID)); break; } } UpdateButtons(); break; // case GADGET_LISTVIEW2: // break; case GADGET_INSERT: { AutoAlloc<BaseSelect> s2; if (selection && s2) { // TEST LONG i,id,count = listview1.GetItemCount(); BaseContainer test; for (i=0;i<count;i++) { listview1.GetItemLine(i,&id,&test); } // TEST if (!listview1.GetSelection(selection)) { GePrint("No Selection"); } else { LONG i,a,b; String str; for (i=0;selection->GetRange(i,MAXLONGl,&a,&b);i++) { if (a==b) str += LongToString(a)+" "; else str += LongToString(a)+"-"+LongToString(b)+" "; } // str.Delete(str.GetLength()-1,1); GePrint("Selection: "+str); BaseContainer data; for (i=0;testdata[i].id;i++) { if (selection->IsSelected(testdata[i].id)) { data.SetLong('chck',TRUE); data.SetString('name',testdata[i].name); data.SetString('bttn',"..."); selection->Select(counter2); listview2.SetItem(counter2++,data); } } listview2.SetSelection(selection); listview2.DataChanged(); } } } UpdateButtons(); break; case GADGET_REMOVE: { if (selection && listview2.GetSelection(selection)) { LONG i,a,b; for (i=0;selection->GetRange(i,MAXLONGl,&a,&b);i++) { for (;a<=b;a++) { listview2.RemoveItem(a); } } listview2.DataChanged(); } } UpdateButtons(); break; } return TRUE; }
Bool ApplinkDialog::InitValues(void) { if (!GeDialog::InitValues()) return false; filenamePrefs = GeGetPluginPath()+ "preference.ini"; dirty = false; AutoAlloc<HyperFile> hyperfilePrefs; if(!GeFExist(filenamePrefs, false)) { if (!hyperfilePrefs->Open('coat', filenamePrefs.GetString(), FILEOPEN_WRITE, FILEDIALOG_ANY)) return false; gPreferences.SetString(IDC_TMP_FOLDER, ""); Filename path; #if defined _WIN32 || defined _WIN64 path = GeGetC4DPath(C4D_PATH_MYDOCUMENTS); #elif __APPLE__ path = GeGetC4DPath(C4D_PATH_HOME); #endif //file magic! Filename exFolder = path + "3D-CoatV3" + "Exchange"; if(GeFExist(exFolder, true)) { gPreferences.SetString(IDC_EXCH_FOLDER, exFolder.GetString()); } else { exFolder = path + "3D-CoatV4" + "Exchange"; if (GeFExist(exFolder, true)) { gPreferences.SetString(IDC_EXCH_FOLDER, exFolder.GetString()); } else { GePrint("Not Find"); #if defined _WIN32 || defined _WIN64 GePrint(String("Folder ..\\MyDocuments\\3D-CoatV3\\Exchange not found!")); #elif __APPLE__ GePrint(String("Folder ../Users/admin/3D-CoatV3/Exchange not found!")); #endif gPreferences.SetString(IDC_EXCH_FOLDER, ""); } } gPreferences.SetInt32(IDC_COMBO_MAP_TYPE, 0); gPreferences.SetBool(IDC_CHK_EXP_MAT, true); gPreferences.SetBool(IDC_CHK_EXP_UV, true); gPreferences.SetBool(IDC_CHK_SKIP_IMP_DIALOG, false); gPreferences.SetBool(IDC_CHK_SKIP_EXP_DIALOG, false); gPreferences.SetBool(IDC_CHK_IMP_MAT, true); gPreferences.SetInt32(IDC_COMBO_MAP_IMPORT, 0); gPreferences.SetBool(IDC_CHK_IMP_UV, true); gPreferences.SetBool(IDC_CHK_REPLACE, true); gPreferences.SetBool(IDC_CHK_PROMPT, false); gPreferences.SetString(IDC_COAT_EXE_PATH, ""); gPreferences.SetBool(IDC_CHK_COAT_START, false); hyperfilePrefs->WriteContainer(gPreferences); hyperfilePrefs->Close(); } if(!hyperfilePrefs->Open('coat', filenamePrefs.GetString(), FILEOPEN_READ, FILEDIALOG_ANY)) return false; hyperfilePrefs->ReadContainer(&gPreferences, true); hyperfilePrefs->Close(); SetString(IDC_TMP_FOLDER, gPreferences.GetString(IDC_TMP_FOLDER)); SetString(IDC_EXCH_FOLDER, gPreferences.GetString(IDC_EXCH_FOLDER)); SetInt32(IDC_COMBO_MAP_TYPE, gPreferences.GetInt32(IDC_COMBO_MAP_TYPE)); SetBool(IDC_CHK_EXP_MAT, gPreferences.GetBool(IDC_CHK_EXP_MAT)); SetBool(IDC_CHK_EXP_UV, gPreferences.GetBool(IDC_CHK_EXP_UV)); SetBool(IDC_CHK_SKIP_IMP_DIALOG, gPreferences.GetBool(IDC_CHK_SKIP_IMP_DIALOG)); SetBool(IDC_CHK_SKIP_EXP_DIALOG, gPreferences.GetBool(IDC_CHK_SKIP_EXP_DIALOG)); SetBool(IDC_CHK_IMP_MAT, gPreferences.GetBool(IDC_CHK_IMP_MAT)); SetInt32(IDC_COMBO_MAP_IMPORT, gPreferences.GetInt32(IDC_COMBO_MAP_IMPORT)); SetBool(IDC_CHK_IMP_UV, gPreferences.GetBool(IDC_CHK_IMP_UV)); SetBool(IDC_CHK_REPLACE, gPreferences.GetBool(IDC_CHK_REPLACE)); SetBool(IDC_CHK_PROMPT, gPreferences.GetBool(IDC_CHK_PROMPT)); SetString(IDC_COAT_EXE_PATH, gPreferences.GetString(IDC_COAT_EXE_PATH)); SetBool(IDC_CHK_COAT_START, gPreferences.GetBool(IDC_CHK_COAT_START)); #ifdef __APPLE__ //------------ temp //Enable(IDC_CHK_COAT_START, false); //Enable(IDC_COAT_EXE_PATH, false); //------------- // SetString(IDS_STATIC12, "Folder ../Users/user/3D-CoatV3/Exchange not found!"); #endif SetTimer(1000); return true; }
SplineObject* Voxelify::GetContour(BaseObject *op, BaseDocument *doc, Real lod, BaseThread *bt){ BaseContainer *data = op->GetDataInstance(); BaseObject* parent=(BaseObject*)data->GetLink(CTT_OBJECT_LINK,doc,Obase); if (!parent) return NULL; LONG startObject = data->GetLong(START_FRAME); LONG endObject = data->GetLong(END_FRAME); if (startObject >=endObject) return NULL; maxSeg = data->GetReal(CTTSPOBJECT_MAXSEG,30.); minSeg = data->GetReal(CTTSPOBJECT_MINSEG); LONG delta = data->GetLong(OBJECT_SKIP,1); delta = delta < 1 ? 1 : delta; GeDynamicArray<BaseObject*> children; GeDynamicArray<GeDynamicArray<Vector> > splineAtPoint; BaseObject* chld = NULL; LONG trck = 0; for (chld=parent->GetDownLast(); chld; chld=chld->GetPred()) { if (trck >= startObject && trck<= endObject && trck % delta == 0){ children.Push((BaseObject*)chld->GetClone(COPYFLAGS_NO_HIERARCHY|COPYFLAGS_NO_ANIMATION|COPYFLAGS_NO_BITS,NULL)); } trck++; } if (children.GetCount() < 2) { return NULL; } LONG splineInterpolation = data->GetLong(SPLINEOBJECT_INTERPOLATION); LONG longestPercent = data->GetLong(TAKE_LONGEST, 1); longestPercent = longestPercent > 100 ? 100: longestPercent; parentMatrix = parent->GetMl(); GeDynamicArray<GeDynamicArray<Vector> > objectPoints(children.GetCount()); StatusSetBar(0); StatusSetText("Collecting Points"); vector<vector<float> > points; std::vector<VGrid> grids; LONG gridSize = data->GetLong(GRID_SIZE, 1); if (!(gridSize > 0)) return NULL; for (int k= 0; k < children.GetCount(); k++){ Matrix ml; DoRecursion(op,children[k],objectPoints[k], ml); points = objectPointsToPoints(objectPoints[k]); GePrint(children[k]->GetName()); grids.push_back(vox.voxelify(points,gridSize, 12, 1.0)); if (k % 5 == 0){ LONG progress = 10 + (50*k)/children.GetCount(); StatusSetBar(progress); StatusSetText(LongToString(progress)+"%"); if (bt && bt->TestBreak()){ //break; //this break seems to be kicking in randomly killing the loop } } } StatusSetText("Building Splines"); SplineObject* parentSpline = ComputeSpline(bt, grids, longestPercent, splineAtPoint); ModelingCommandData mcd; mcd.doc = doc; mcd.op = parentSpline; if(!SendModelingCommand(MCOMMAND_JOIN, mcd)){ return NULL; } SplineObject* ret = ToSpline(mcd.result->GetIndex(0L)); ret->GetDataInstance()->SetLong(SPLINEOBJECT_INTERPOLATION, splineInterpolation); for (int k=0; k<children.GetCount(); k++){ if (children[k]){ BaseObject::Free(children[k]); } } return ret; Error: for (int i = 0; i < children.GetCount(); i++){ BaseObject::Free(children[i]); } return NULL; }
Bool ApplinkExporter::Execute(BaseDocument* document, BaseContainer* bc) { matDefault = BaseMaterial::Alloc(Mmaterial); if(!matDefault) return false; Filename fileObjPath; fileObjPath.SetDirectory(bc->GetString(IDC_TMP_FOLDER)); fileObjPath.SetFile(document->GetDocumentName()); fileObjPath.SetSuffix("obj"); Filename fileObjOutPath; fileObjOutPath.SetDirectory(bc->GetString(IDC_TMP_FOLDER)); fileObjOutPath.SetFile("output.obj"); Filename fileImport; fileImport.SetDirectory(bc->GetString(IDC_EXCH_FOLDER)); fileImport.SetFile("import.txt"); GePrint(fileObjPath.GetString()); GePrint(fileObjOutPath.GetString()); GePrint(fileImport.GetString()); const Matrix tM(LVector(0.0f, 0.0f, 0.0f), LVector(1.0f, 0.0f, 0.0f), LVector(0.0f, 1.0f, 0.0f), LVector(0.0f, 0.0f, -1.0f)); //BaseDocument* doc = document->Polygonize(); AutoAlloc<AtomArray> oSel; document->GetActiveObjects(oSel, GETACTIVEOBJECTFLAGS_0); if(oSel->GetCount() > 0) { //Write import.txt// AutoAlloc<BaseFile> basefileImport; if (!basefileImport->Open(fileImport, FILEOPEN_WRITE, FILEDIALOG_NONE, GeGetByteOrder())) return FALSE; this->WriteString(fileObjPath.GetString() + "\n", basefileImport); this->WriteString(fileObjOutPath.GetString() + "\n", basefileImport); this->WriteString(mapType(bc->GetLong(IDC_COMBO_MAP_TYPE)) + "\n", basefileImport); Bool bSkipImp = bc->GetBool(IDC_CHK_SKIP_IMP_DIALOG); if(bSkipImp) { this->WriteString("[SkipImport]\n", basefileImport); } Bool bSkipExp = bc->GetBool(IDC_CHK_SKIP_EXP_DIALOG); if(bSkipExp) { this->WriteString("[SkipExport]\n", basefileImport); } GePrint(mapType(bc->GetLong(IDC_COMBO_MAP_TYPE))); basefileImport->Close(); GePrint("File " + fileImport.GetString() + " write success!"); //Write file.obj// AutoAlloc<BaseFile> objfile; //if (!objfile) return FALSE; if (!objfile->Open(fileObjPath, FILEOPEN_WRITE, FILEDIALOG_NONE, GeGetByteOrder())) return FALSE; String str; str = "#Wavefront OBJ Export for 3D-Coat\n"; this->WriteString(str, objfile); DateTime t; GetDateTimeNow(t); str = "#File created: " + FormatTime("%d.%m.%Y %H:%M:%S", t) + "\n"; this->WriteString(str, objfile); str = "#Cinema4D Version: " + LongToString(GetC4DVersion()) + "\n"; this->WriteString(str, objfile); this->WriteEndLine(objfile); Bool expMat = bc->GetBool(IDC_CHK_EXP_MAT); vpcnt = vtcnt = 0; for(int i = 0; i < oSel->GetCount(); i++) { StatusSetSpin(); PolygonObject* ob = (PolygonObject*) oSel->GetIndex(i); if (ob->GetType() == Opolygon) { StatusSetText("Export object " + ob->GetName()); ExportObject mObject; GePrint("Name " + ob->GetName()); //GePrint("Type " + LongToString(ob->GetType())); if(expMat) { mObject.pmatidxArray.ReSize(ob->GetPolygonCount()); mObject.tempMats.ReSize(1); mObject.pmatidxArray.Fill(0); Bool haveMats = false; ////////////////////////////////////////// for(BaseTag* tag = ob->GetFirstTag(); tag != NULL; tag = tag->GetNext()) { LONG typ = tag->GetType(); if(typ == Ttexture) { if (!getParameterLink(*tag, TEXTURETAG_MATERIAL, Mbase)) continue; haveMats = true; TextureTag* txttag = (TextureTag*)tag; BaseMaterial* material = txttag->GetMaterial(); if(material == NULL) { GePrint("Material not found on " + ob->GetName() + "object."); return false; } //GePrint("Mat Name: " + material->GetName()); String restrict = getParameterString(*tag, TEXTURETAG_RESTRICTION); if (restrict.Content()) { mObject.tempMats.Push(material); //GePrint("Selection: " + restrict); for(BaseTag* seltag = ob->GetFirstTag(); seltag != NULL; seltag = seltag->GetNext()) { LONG seltyp = seltag->GetType(); if(seltyp == Tpolygonselection && seltag->GetName() == restrict) { SelectionTag* selecttag = (SelectionTag*)seltag; BaseSelect* sel = selecttag->GetBaseSelect(); //GePrint("sel data count: " + LongToString(sel->GetCount())); LONG seg = 0, a, b, p; while (sel->GetRange(seg++, &a, &b)) { for (p = a; p <= b; ++p) { //GePrint("seltpolygon: " + LongToString(p)); mObject.pmatidxArray[p] = mObject.tempMats.GetCount()-1; } } } } } else { mObject.tempMats[0] = material; mObject.pmatidxArray.Fill(0); } } } if(!mObject.tempMats[0]) { matDefault->SetName("Default"); BaseChannel* color = matDefault->GetChannel(CHANNEL_COLOR); if (!color) return false; // return some error BaseContainer cdata = color->GetData(); cdata.SetVector(BASECHANNEL_COLOR_EX, Vector(1.0f, 1.0f, 1.0f)); //document->InsertMaterial(matDefault, NULL, FALSE); //matDefault->Update(TRUE, TRUE); //matDefault->Message(MSG_UPDATE); mObject.tempMats[0] = matDefault; //GePrint("Global material not found on object " + ob->GetName() + "."); //return false; } if(haveMats) { //GePrint("mObject.tempMats.GetCount(): " + LongToString(mObject.tempMats.GetCount())); for(LONG m = 0; m < mObject.tempMats.GetCount(); m++) { Bool inMats = false; //GePrint("materialArray.GetCount(): " + LongToString(materialArray.GetCount())); for(LONG n = 0; n < materialArray.GetCount(); n++) { if(mObject.tempMats[m]->GetName() == materialArray[n]->GetName()) { inMats = true; break; } } if(!inMats) { materialArray.Push(mObject.tempMats[m]); } } } //String str1; //for (LONG p = 0; p < ob->GetPolygonCount(); p++) //{ // str1 += LongToString(mObject.pmatidxArray[p]) + ","; //} //GePrint(str1); } ///////////////////////////////////////////////// const Vector* vadr = ob->GetPointR(); const CPolygon* padr = ob->GetPolygonR(); LONG vcnt = ob->GetPointCount(); LONG pcnt = ob->GetPolygonCount(); mObject.Fpvnb.ReSize(pcnt);// poly counts for(LONG p = 0; p < pcnt; p++) { if(padr[p].c != padr[p].d) { mObject.Fpvnb[p] = 4; } else { mObject.Fpvnb[p] = 3; } } mObject.pVertexCount = PVertexLength(mObject); //Vertex positions mObject.Vp.ReSize(vcnt); Matrix mg = tM * ob->GetMgn(); for (LONG v = 0; v < vcnt; v++) { mObject.Vp[v] = vadr[v] * mg; //GePrint("Point[" + LongToString(i) + "] " + LongToString(padr[i].x) + ", " + LongToString(padr[i].y) + ", " + LongToString(padr[i].z)); //str = "v " + LongToString(vadr[p].x) + " " + LongToString(vadr[p].y) + " " + LongToString(vadr[p].z) + "\n"; //this->WriteString(str, objfile); } mObject.Fv.ReSize(mObject.pVertexCount); LONG y=0; for (LONG p = 0; p < pcnt; p++) { if(mObject.Fpvnb[p] == 4) { mObject.Fv[y] = padr[p].d; mObject.Fv[y+1] = padr[p].c; mObject.Fv[y+2] = padr[p].b; mObject.Fv[y+3] = padr[p].a; } else { mObject.Fv[y] = padr[p].c; mObject.Fv[y+1] = padr[p].b; mObject.Fv[y+2] = padr[p].a; } y += mObject.Fpvnb[p]; } //String str1; //for (LONG p = 0; p < mObject.Fv.GetCount(); p++) //{ // str1 += LongToString(mObject.Fv[p]) + " "; //} //GePrint(str1); /////////////////////////////// ///////////vertex UV ////////////////////////////// if(bc->GetBool(IDC_CHK_EXP_UV)) { // Get first UV tag (if at least one) UVWTag* uvw_tag = (UVWTag*)ob->GetTag(Tuvw, 0); if(!uvw_tag) { GePrint("Object \"" + ob->GetName() + "\" has no UVW tag.\nUV coordinates can't be exported."); return FALSE; } else { mObject.Vt.ReSize(mObject.pVertexCount); mObject.Fvt.ReSize(mObject.pVertexCount); const UVWHandle dataptr = uvw_tag->GetDataAddressR(); UVWStruct res; for(LONG t=0, y=0; t < pcnt; t++) { //GePrint("y: " + LongToString(y)); UVWTag::Get(dataptr, t, res); if(mObject.Fpvnb[t] == 4) { mObject.Vt[y] = res.d; mObject.Vt[y + 1] = res.c; mObject.Vt[y + 2] = res.b; mObject.Vt[y + 3] = res.a; mObject.Fvt[y] = y; mObject.Fvt[y + 1] = y + 1; mObject.Fvt[y + 2] = y + 2; mObject.Fvt[y + 3] = y + 3; } else { mObject.Vt[y] = res.c; mObject.Vt[y + 1] = res.b; mObject.Vt[y + 2] = res.a; mObject.Fvt[y] = y; mObject.Fvt[y + 1] = y + 1; mObject.Fvt[y + 2] = y + 2; } y += mObject.Fpvnb[t]; } } //String str1; //for (LONG p = 0; p < mObject.Fvt.GetCount(); p++) //{ // str1 += LongToString(mObject.Fvt[p]) + " "; //} //GePrint(str1); } WriteExportFile(bc, ob, objfile, mObject, vcnt, pcnt); //GePrint("Fvt: " + LongToString(Fvt.GetCount())); vpcnt += mObject.Vp.GetCount(); if(bc->GetBool(IDC_CHK_EXP_UV)) vtcnt += mObject.Vt.GetCount(); } } objfile->Close(); if(expMat && materialArray.GetCount() > 0) WriteMatsFile(document, bc); } else { GePrint("No selected objects!"); } BaseMaterial::Free(matDefault); return TRUE; }
SplineObject* Voxelify::ComputeSpline(BaseThread* bt, vector<VGrid> grids, LONG longestPercent, GeDynamicArray<GeDynamicArray<Vector> > &splinesAtPoint){ SplineObject* parentSpline = SplineObject::Alloc(0, SPLINETYPE_BSPLINE); std::vector<SplinePair >splinePairs; Real avSplineSize = 0.0, avSplineLength = 0.0; GeDynamicArray<GeDynamicArray<LONG> > validPoints(grids.size()); for (LONG k=0; k < grids.size(); k++){ validPoints[k] = GeDynamicArray<LONG>(grids[0].points.size()); validPoints[k].Fill(0,grids[0].points.size(),1); } GeDynamicArray<LONG> indxs; for (LONG i = 0; i < grids[0].points.size(); i++) { if (grids[0].indices[i] == -1) continue; GeDynamicArray<Vector> rawSpline; Vector point(grids[0].points[i][0], grids[0].points[i][1], grids[0].points[i][2]); indxs.Push(i); rawSpline.Push(point); splinesAtPoint.Push(rawSpline); } Real distMin = std::numeric_limits<float>::max(); Real distMax = 0.; AutoAlloc<SplineHelp> splineHelp; LONG i, o; for (i = 0; i < splinesAtPoint.GetCount(); i++){//iterate points bool lastPointCaptured = true; LONG indx = indxs[i]; for (o=0; o < grids.size()-1; o++){ // for each point iterate objects and collect nearest points LONG closestIndx = grids[o+1].indices[indx]; if ( closestIndx == -1){ GePrint("error finding neighbor "+LongToString(o)+"/"+LongToString(i)); if (o == grids.size()-1){ lastPointCaptured = false; } continue; } vector<float> point = grids[o].points[indx]; vector<float> point1 = grids[o+1].points[indx]; Real dist = hypot(point[0] - point1[0], hypot(point[1] - point1[1], point[2] - point1[2])); distMin = distMin < dist ? distMin : dist; distMax = distMax > dist ? distMax : dist; if (o != grids.size()-1) { //if (dist > maxSeg || dist < minSeg) { // continue; //} } validPoints[o][i] = 0; Vector clsst(point1[0],point1[1],point1[2]); if (splinesAtPoint[i].Find(clsst) == NOTOK){ splinesAtPoint[i].Push(clsst); } } if (!lastPointCaptured) continue; SplineObject* spline=SplineObject::Alloc(splinesAtPoint[i].GetCount(),SPLINETYPE_BSPLINE); if (!spline) continue; spline->GetDataInstance()->SetBool(SPLINEOBJECT_CLOSED, FALSE); Vector *padr = spline->GetPointW(); for (LONG l = 0; l < splinesAtPoint[i].GetCount(); l++){ padr[l] = splinesAtPoint[i][l]; } splineHelp->InitSpline(spline); Real splnLength = splineHelp->GetSplineLength(); if (splnLength > 0.0){ splinePairs.push_back(SplinePair(spline, splnLength)); avSplineLength += splnLength; avSplineSize += splinesAtPoint[i].GetCount(); } else { SplineObject::Free(spline); } if (i % 5 == 0){ LONG progress = 10 + (90*i)/splinesAtPoint.GetCount(); StatusSetBar(progress); StatusSetText(LongToString(progress)+"%"); if (bt && bt->TestBreak()){ //break; //this break seems to be kicking in randomly killing the loop } } } LONG splnSize = splinePairs.size(); GePrint(LongToString(i)+" points "+LongToString(splnSize)+" splines"); if (splnSize > 0) { LONG limit = splnSize * longestPercent / 100; limit = limit == 0 ? 1 : limit; std::sort(splinePairs.begin(), splinePairs.end(),comparator); for (int s = 0; s < limit; s++){ avSplineLength += splinePairs[s].second; splinePairs[s].first->InsertUnder(parentSpline); } String sizeAvg = splinesAtPoint.GetCount() == 0? "Nan":RealToString(avSplineSize/splinesAtPoint.GetCount()); GePrint("d="+RealToString(distMin)+" : "+RealToString(distMax)+" avSpln="+RealToString(avSplineLength/avSplineSize)); } StatusSetText(LongToString(i)+" points "+LongToString(splnSize)+" splines"); if (splnSize == 0) return NULL; return parentSpline; }
LONG FunkyGlMaterial::ErrorHandler(GlProgramType type, const char* pszError) { GePrint(pszError); return 0; }
void WriteElement(PresetElement* pElement) { CDynamicArray <char> arLine, arTempString; AutoAlloc <BaseFile> pFile; Filename fn = GeGetC4DPath(C4D_PATH_PREFS) + String("ResEdit"); if (!pFile) return; String strNewName; Int32 n; for (n = 0; n < pElement->strName.GetLength(); n++) { UInt16 w = (UInt16)pElement->strName[n]; #if defined _WINDOWS if (('0' <= w && w <= '9') || ('A' <= w && w <= 'z') || w == ' ' || w == '_' || w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�' || w == (UInt16)'�') #elif defined __MAC if (('0' <= w && w <= '9') || ('A' <= w && w <= 'z') || w == ' ' || w == '_' || w == (UInt16)'Š' || w == (UInt16)'š' || w == (UInt16)'Ÿ' || w == (UInt16)'€' || w == (UInt16)'…' || w == (UInt16)'†' || w == (UInt16)'§') #elif defined __LINUX if (('0' <= w && w <= '9') || ('A' <= w && w <= 'z') || w == ' ' || w == '_' || w == (UInt16)'ü' || w == (UInt16)'ö' || w == (UInt16)'ä' || w == (UInt16)'Ãœ' || w == (UInt16)'Ö' || w == (UInt16)'Ä' || w == (UInt16)'ß') #else #error Wrong operating system #endif strNewName += String(1, w); else strNewName += String(1, '_'); } if (!AssertPathExists(fn)) { GePrint(String("Could not create path ") + fn.GetString()); return; } if (GetPresetCrc(pElement) == pElement->ulCRC && (GeFExist(fn + (strNewName + ".prf")) || GeFExist(GeGetC4DPath(C4D_PATH_RESOURCE) + String("distribution") + (strNewName + ".prf")))) return; fn += (strNewName + ".prf"); if (!ForceOpenFileWrite(pFile, fn)) { GePrint(String("Could not write file ") + fn.GetString()); return; } AppendString(arLine, FILE_HEADER); WriteLine(arLine, pFile); AppendString(arLine, ORIG_PATH); AppendString(arLine, arTempString, pElement->strOrigin); WriteLine(arLine, pFile); AppendString(arLine, DEST_PATH); AppendString(arLine, arTempString, pElement->strDestination); WriteLine(arLine, pFile); AppendString(arLine, CREATE_ZIP); AppendString(arLine, pElement->bCreateZipFile ? "1" : "0"); WriteLine(arLine, pFile); Char *pszZipLevel = String::IntToString(pElement->lCreateZipCompressionLevel).GetCStringCopy(); if (pszZipLevel) { AppendString(arLine, CREATE_ZIP_COMPRESSION); AppendString(arLine, pszZipLevel); WriteLine(arLine, pFile); DeleteMem(pszZipLevel); } AppendString(arLine, CHECK_VERSION); AppendString(arLine, pElement->bCheckVersion ? "1" : "0"); WriteLine(arLine, pFile); AppendString(arLine, PARSE_SYMBOLS); AppendString(arLine, pElement->bParseSymbols ? "1" : "0"); WriteLine(arLine, pFile); AppendString(arLine, WRITE_BUILD); AppendString(arLine, pElement->bWriteBuildInfo ? "1" : "0"); WriteLine(arLine, pFile); AppendString(arLine, BATCH); AppendString(arLine, pElement->bBatch ? "1" : "0"); WriteLine(arLine, pFile); AppendString(arLine, REMOVE_SCC); AppendString(arLine, pElement->bRemoveSCC ? "1" : "0"); WriteLine(arLine, pFile); AppendString(arLine, PASSWORD); AppendString(arLine, arTempString, EncryptPassword(pElement->strPassword)); WriteLine(arLine, pFile); Int32 lFilterCount = pElement->arFilters.GetElementCount(); FilterElement** ppFilterElements = pElement->arFilters.GetArray()->GetArray(); for (n = 0; n < lFilterCount; n++) { AppendString(arLine, FILTER_STRING); AppendString(arLine, arTempString, ppFilterElements[n]->str); AppendString(arLine, " " FILTER_CONDITION); switch (ppFilterElements[n]->lCondition) { case FILTER_COND_FN_IS: AppendString(arLine, arTempString, W_FILTER_COND_FN_IS); break; case FILTER_COND_FN_EXT: AppendString(arLine, arTempString, W_FILTER_COND_FN_EXT); break; case FILTER_COND_PATH_CONTAINS: AppendString(arLine, arTempString, W_FILTER_COND_PATH_CONTAINS); break; case FILTER_COND_PATH_IS: AppendString(arLine, arTempString, W_FILTER_COND_PATH_IS); break; case FILTER_COND_DIRECTORY_IS: AppendString(arLine, arTempString, W_FILTER_COND_DIRECTORY_IS); break; default: DebugAssert(false); } AppendString(arLine, " " FILTER_ACTION); switch (ppFilterElements[n]->lAction) { case FILTER_ACTION_INCLUDE: AppendString(arLine, arTempString, W_FILTER_ACTION_INCLUDE); break; case FILTER_ACTION_EXCLUDE: AppendString(arLine, arTempString, W_FILTER_ACTION_EXCLUDE); break; case FILTER_ACTION_RENAME: AppendString(arLine, arTempString, W_FILTER_ACTION_RENAME); AppendString(arLine, " " FILTER_RENAME); AppendString(arLine, arTempString, ppFilterElements[n]->strRename); break; case FILTER_ACTION_COMPILE_INCL: AppendString(arLine, arTempString, W_FILTER_ACTION_COMPILE_INCL); break; case FILTER_ACTION_MOVE_TO: AppendString(arLine, arTempString, W_FILTER_ACTION_MOVE_TO); break; case FILTER_ACTION_FORCE_COPY: AppendString(arLine, arTempString, W_FILTER_ACTION_FORCE_COPY); break; case FILTER_ACTION_COMPILE_INCL_KILL: AppendString(arLine, arTempString, W_FILTER_ACTION_COMPILE_INCL_KILL); break; default: DebugAssert(false); } if (ppFilterElements[n]->bSetXBit) { AppendString(arLine, " " FILTER_FLAG); AppendString(arLine, arTempString, W_FILTER_FLAG_SET_XBIT); } WriteLine(arLine, pFile); } pFile->Close(); }
Bool ApplinkDialog::Command(LONG id, const BaseContainer& msg) { dirty = TRUE; saveSettings(); switch(id) { case IDC_BTN_EXPORT: { BaseDocument* doc = GetActiveDocument(); ApplinkExporter* exporter = gNew ApplinkExporter; exporter->Execute(doc, &gPreferences); //GePrint("Start export!"); String exeCoat = gPreferences.GetString(IDC_COAT_EXE_PATH); if(gPreferences.GetBool(IDC_CHK_COAT_START) && exeCoat != "") { if(!Find3DCoat()) { #ifdef _WIN32 || _WIN64 LONG length = exeCoat.GetCStringLen(STRINGENCODING_8BIT) + 1; char* buffer = (CHAR*)GeAlloc(length); exeCoat.GetCString(buffer, length, STRINGENCODING_8BIT); SHELLEXECUTEINFO ExecuteInfo; memset(&ExecuteInfo, 0, sizeof(ExecuteInfo)); ExecuteInfo.cbSize = sizeof(ExecuteInfo); ExecuteInfo.fMask = 0; ExecuteInfo.hwnd = 0; ExecuteInfo.lpVerb = "open"; // Operation to perform ExecuteInfo.lpFile = buffer; // Application name ExecuteInfo.lpDirectory = 0; // Default directory ExecuteInfo.nShow = SW_SHOWNORMAL; ExecuteInfo.hInstApp = 0; if(ShellExecuteEx(&ExecuteInfo) == FALSE) // Could not start application -> call 'GetLastError()' //if((int)::ShellExecute(NULL, TEXT("open"), buffer, NULL, NULL, SW_SHOWNORMAL) <= 32) { GePrint("3D-Coat.exe not found!"); } #endif } else { GePrint("3D-Coat.exe is run!"); } } } break; case IDC_BTN_IMPORT: { GePrint("Start import!"); BaseDocument* doc = GetActiveDocument(); ApplinkImporter* importer = gNew ApplinkImporter; importer->Execute(doc, &gPreferences); } break; case IDC_CHK_PROMPT: { Bool b; GetBool(IDC_CHK_PROMPT, b); if(b) SetTimer(1000); } break; default: break; } return TRUE; }
Bool ApplinkDialog::InitValues(void) { if (!GeDialog::InitValues()) return FALSE; filenamePrefs = GeGetPluginPath()+ "preference.ini"; dirty = FALSE; AutoAlloc<HyperFile> hyperfilePrefs; if(!GeFExist(filenamePrefs, FALSE)) { if (!hyperfilePrefs->Open(filenamePrefs.GetString(), GE_WRITE, FILE_NODIALOG)) return FALSE; gPreferences.SetString(IDC_TMP_FOLDER, ""); Filename exFolder = GeGetC4DPath(C4D_PATH_MYDOCUMENTS) + "3D-CoatV3" + "Exchange"; if(GeFExist(exFolder, TRUE)) { gPreferences.SetString(IDC_EXCH_FOLDER, exFolder.GetString()); } else { GePrint(String("Folder ..\\MyDocuments\\3D-CoatV3\\Exchange not found!")); gPreferences.SetString(IDC_EXCH_FOLDER, ""); } gPreferences.SetLong(IDC_COMBO_MAP_TYPE, 0); gPreferences.SetBool(IDC_CHK_EXP_MAT, TRUE); gPreferences.SetBool(IDC_CHK_EXP_UV, TRUE); gPreferences.SetBool(IDC_CHK_IMP_MAT, TRUE); gPreferences.SetLong(IDC_COMBO_MAP_IMPORT, 0); gPreferences.SetBool(IDC_CHK_IMP_UV, TRUE); gPreferences.SetBool(IDC_CHK_REPLACE, TRUE); gPreferences.SetBool(IDC_CHK_PROMPT, FALSE); gPreferences.SetString(IDC_COAT_EXE_PATH, ""); gPreferences.SetBool(IDC_CHK_COAT_START, FALSE); hyperfilePrefs->WriteContainer(gPreferences); hyperfilePrefs->Close(); } if(!hyperfilePrefs->Open(filenamePrefs.GetString(), GE_READ, FILE_NODIALOG)) return FALSE; hyperfilePrefs->ReadContainer(&gPreferences, TRUE); hyperfilePrefs->Close(); SetString(IDC_TMP_FOLDER, gPreferences.GetString(IDC_TMP_FOLDER)); SetString(IDC_EXCH_FOLDER, gPreferences.GetString(IDC_EXCH_FOLDER)); SetLong(IDC_COMBO_MAP_TYPE, gPreferences.GetLong(IDC_COMBO_MAP_TYPE)); SetBool(IDC_CHK_EXP_MAT, gPreferences.GetBool(IDC_CHK_EXP_MAT)); SetBool(IDC_CHK_EXP_UV, gPreferences.GetBool(IDC_CHK_EXP_UV)); SetBool(IDC_CHK_IMP_MAT, gPreferences.GetBool(IDC_CHK_IMP_MAT)); SetLong(IDC_COMBO_MAP_IMPORT, gPreferences.GetLong(IDC_COMBO_MAP_IMPORT)); SetBool(IDC_CHK_IMP_UV, gPreferences.GetBool(IDC_CHK_IMP_UV)); SetBool(IDC_CHK_REPLACE, gPreferences.GetBool(IDC_CHK_REPLACE)); SetBool(IDC_CHK_PROMPT, gPreferences.GetBool(IDC_CHK_PROMPT)); SetString(IDC_COAT_EXE_PATH, gPreferences.GetString(IDC_COAT_EXE_PATH)); SetBool(IDC_CHK_COAT_START, gPreferences.GetBool(IDC_CHK_COAT_START)); SetTimer(1000); return TRUE; }
LONG CSVNodeData::FillPortsMenu(GvNode* node, BaseContainer& names, BaseContainer& ids, GvValueID value_type, GvPortIO flag, LONG firstId) { // Validate the passed flag. switch (flag) { case GV_PORT_INPUT: case GV_PORT_OUTPUT: break; case GV_PORT_INVALID: case GV_PORT_INPUT_OR_GEDATA: default: // DEBUG: GePrint(__FUNCTION__ ": Invalid flag passed. (" + LongToString(flag) + ")"); return 0; } // end switch // Retrieve a list of already available ports. AutoAlloc<GvPortList> availPorts; if (!availPorts) return 0; // memory error node->GetPortList(flag, availPorts); // Iterate over all ports available ports and yield them. LONG countAdded = 0; for (LONG i=0; g_csvports[i].id != 0; i++) { const CSVPort& port = g_csvports[i]; // Skip this port if it is not requested (eg. an INPORT, but only // OUTPORTs are requested). if (port.inport && flag != GV_PORT_INPUT) continue; if (!port.inport && flag != GV_PORT_OUTPUT) continue; // Check if the port already exists. Bool exists = NodeHasPort(node, port.id, flag); // Fill in the menu containers. String name = GeLoadString(port.id) + String(exists ? "&d&" : ""); names.SetString(firstId + i, name); ids.SetLong(firstId + i, port.id); countAdded++; } // Add the CSV Table's output ports. if (flag == GV_PORT_OUTPUT && m_table.Loaded()) { LONG colCount = m_table.GetColumnCount(); GeData forceCols, forceColsCount; node->GetParameter(CSVNODE_FORCEOUTPORTS, forceCols, DESCFLAGS_GET_0); node->GetParameter(CSVNODE_FORCEOUTPORTS_COUNT, forceColsCount, DESCFLAGS_GET_0); if (forceCols.GetBool() && forceColsCount.GetLong() > colCount) { colCount = forceColsCount.GetLong(); } for (LONG i=0; i < colCount; i++) { // Compute the port id and check if the port already exists. LONG portId = CSVNODE_DYNPORT_START + i; Bool exists = NodeHasPort(node, portId, flag); // Compute the name of the port. String name = GetTableColumnPortName(i); names.SetString(firstId + portId, name + String(exists ? "&d&" : "")); ids.SetLong(firstId + portId, portId); countAdded++; } } return countAdded; }
Bool LiquidToolData::MouseInput(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, EditorWindow* win, const BaseContainer& msg) { Float mx = msg.GetFloat(BFM_INPUT_X); Float my = msg.GetFloat(BFM_INPUT_Y); Int32 button; switch (msg.GetInt32(BFM_INPUT_CHANNEL)) { case BFM_INPUT_MOUSELEFT: button = KEY_MLEFT; break; case BFM_INPUT_MOUSERIGHT: button = KEY_MRIGHT; break; default: return true; } BaseObject* cl = nullptr, *null = nullptr, *op = nullptr; Float dx, dy, rad = 5.0; Bool newmeta = false; op = BaseObject::Alloc(Osphere); if (!op) return false; null = BaseObject::Alloc(Ometaball); { null->GetDataInstance()->SetFloat(METABALLOBJECT_SUBEDITOR, 10.0); null->MakeTag(Tphong); } newmeta = true; if (newmeta) { doc->InsertObject(null, nullptr, nullptr); doc->SetActiveObject(null); doc->AddUndo(UNDOTYPE_NEW, null); DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW | DRAWFLAGS_NO_THREAD | DRAWFLAGS_NO_ANIMATION); } BaseContainer bc; BaseContainer device; win->MouseDragStart(button, mx, my, MOUSEDRAGFLAGS_DONTHIDEMOUSE | MOUSEDRAGFLAGS_NOMOVE); while (win->MouseDrag(&dx, &dy, &device) == MOUSEDRAGRESULT_CONTINUE) { bc = BaseContainer(); win->BfGetInputEvent(BFM_INPUT_MOUSE, &bc); if (bc.GetInt32(BFM_INPUT_CHANNEL) == BFM_INPUT_MOUSEWHEEL) { rad += bc.GetFloat(BFM_INPUT_VALUE) / 120.0; rad = ClampValue(rad, (Float) 0.1, (Float) MAXRANGE); GePrint(String::FloatToString(rad)); } if (dx == 0.0 && dy == 0.0) continue; mx += dx; my += dy; cl = (BaseObject*)op->GetClone(COPYFLAGS_0, nullptr); if (!cl) break; cl->GetDataInstance()->SetFloat(PRIM_SPHERE_RAD, rad); cl->SetAbsPos(bd->SW(Vector(mx, my, 500.0))); cl->InsertUnder(null); DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW | DRAWFLAGS_NO_THREAD | DRAWFLAGS_NO_ANIMATION); } if (win->MouseDragEnd() == MOUSEDRAGRESULT_ESCAPE) { doc->DoUndo(true); } BaseObject::Free(op); EventAdd(); return true; }