bool schema_validator::read_config_file(const std::string &filename){ config cfg; try { preproc_map preproc( game_config::config_cache::instance().get_preproc_map()); filesystem::scoped_istream stream = preprocess_file(filename, &preproc); read(cfg, *stream); } catch(config::error& e) { ERR_VL << "Failed to read file "<< filename << ":\n" << e.what() << "\n"; return false; } for(const config &g : cfg.child_range("wml_schema")) { for(const config &schema : g.child_range("tag")) { if (schema["name"].str() == "root"){ //@NOTE Don't know, maybe merging of roots needed. root_ = class_tag (schema); } } for(const config &type : g.child_range("type")) { try{ types_[type["name"].str()] = boost::regex( type["value"].str()); } catch (std::exception){ // Need to check all type values in schema-generator } } } config_read_ = true; return true; }
Value* SnapPoint_cf(Value** arg_list, int count) { check_arg_count_with_keys(SnapPoint, 1, count); def_snap_types(); IPoint2 out; IPoint2 loc = to_ipoint2(arg_list[0]); Value *val = key_arg(snapType); int flags = (val == &unsupplied) ? 0 : GetID(snapTypes, elements(snapTypes), val); Value *snapPlane = key_arg(snapPlane); Matrix3* plane = NULL; if (snapPlane != &unsupplied) { if (!snapPlane->is_kind_of(class_tag(Matrix3Value))) throw TypeError (_T("snapPlane requires a Matrix3 value"), snapPlane); Matrix3Value* mv = static_cast<Matrix3Value*>(snapPlane); plane = new Matrix3(mv->m); } Point3 ret = MAXScript_interface->GetActiveViewExp().SnapPoint(loc, out, plane, flags); if (plane != NULL) delete plane; return new Point3Value(ret); }
bool schema_validator::read_config_file(const std::string &filename){ config cfg; try { preproc_map preproc( game_config::config_cache::instance().get_preproc_map()); scoped_istream stream = preprocess_file(filename, &preproc); read(cfg, *stream); } catch(config::error&) { return false; } BOOST_FOREACH(const config &g, cfg.child_range("wml_schema")) { BOOST_FOREACH(const config &schema, g.child_range("tag")) { if (schema["name"].str() == "root"){ //@NOTE Don't know, maybe merging of roots needed. root_ = class_tag (schema); } } BOOST_FOREACH(const config &type, g.child_range("type")) { try{ types_[type["name"].str()] = boost::regex( type["value"].str()); } catch (std::exception){ // Need to check all type values in schema-generator } } } config_read_ = true; return true; }
class_source_parser(): input_ (""), output_(""), f_(), line_(0), current_(), root_(class_tag("root",1,1)), parent_name_(""), orphan_tags_(), errors_(), types_(), forbidden_() { }
Value* UABAddVtxOnVertexBuffer_cf(Value **arg_list, int count) { check_arg_count(UABAddVtxOnVertexBuffer, 2, count); type_check(arg_list[0], Integer, "uab_add_vtx_on_vertex_buffer"); type_check(arg_list[1], Array, "uab_add_vtx_on_vertex_buffer"); Value *v1=arg_list[0]; Value *v2=arg_list[1]; if(v2->is_kind_of(class_tag(Array)) && v1->is_kind_of(class_tag(Integer))) { Array *l_MaxVtx=(Array *)v2; VFloats l_Vertex; size_t l_IdMaterial=v1->to_int(); while(l_IdMaterial>=g_VertexBuffer.size()) { MInts l_Map; g_VertexBuffer.push_back(l_Map); } for(int i=0;i<l_MaxVtx->size;++i) { Value *l_Component=l_MaxVtx->get(i+1); l_Vertex.push_back(l_Component->to_float()); } if(g_VertexBuffer[l_IdMaterial].find(l_Vertex)==g_VertexBuffer[l_IdMaterial].end()) { int l_Idx=g_VertexBuffer[l_IdMaterial].size(); g_VertexBuffer[l_IdMaterial][l_Vertex]=l_Idx; return Integer::intern(l_Idx); } else { return Integer::intern(g_VertexBuffer[l_IdMaterial][l_Vertex]); } } return &false_value; }
Value* ExportCalSkel_cf(Value** arg_list, int count) { int i; INodeTab tabnode; std::tstring fullpathfilename; int ArraySize ; bool bShowUI ; check_arg_count(ExportCalSkel, 3, count); type_check(arg_list[0], String, _T("[The first argument of ExportCalSkel should be a string that is a full path name of the file to export]")); type_check(arg_list[1], Array , _T("[The 2nd argument of ExportCalSkel should be an array of nodes]")); type_check(arg_list[2], Boolean,_T("[The 3rd argument of ExportCalSkel should be a boolean that tells if you want to use the UI or not to select nodes of skeleton]")); try { fullpathfilename = arg_list[0]->to_string(); //Get Array Array* BonesArray = static_cast<Array*>(arg_list[1]); ArraySize = BonesArray->size; bShowUI = !!(arg_list[2]->to_bool()); if (fullpathfilename.length() == 0) return new Integer (1); if (! ArraySize) return new Integer (2); for (i=0;i<ArraySize;i++) { if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) ) { INode* _node = BonesArray->data[i]->to_node(); if (! _node)return new Integer (3); tabnode.Append(1,&_node); } } //Call the exporter from Maxscript if (CMaxSkeletonExport::ExportSkeletonFromMaxscriptCall(fullpathfilename.c_str(), tabnode, bShowUI) ) return new Integer (0); return new Integer (-1); } catch(...) { //MessageBox(NULL,"Exception catched in ExportCalSkel C++ function","Error",MB_OK); return new Integer (-2); } }
Value* ExportCalMat_cf(Value** arg_list, int count) { int i = 0; char* fullpathfilename; check_arg_count(ExportCalMat, 2, count); type_check(arg_list[0], String, "[The first argument of ExportCalMat should be a string]"); type_check(arg_list[1], MAXMaterial , "[The 2nd argument of ExportCalMat should be a standard material]"); try { fullpathfilename = arg_list[0]->to_string(); StdMat* stdmat; if (! strcmp(fullpathfilename,"")) return new Integer(1); //Get material Value* val; val = arg_list[1]; if (! val)return new Integer(2); if (val->is_kind_of(class_tag(MAXMaterial)) ) { MtlBase* _mtl; _mtl = val->to_mtlbase(); if (! _mtl)return new Integer(3); stdmat = static_cast<StdMat*>(_mtl); } else { return new Integer(3); } if ( CMaxMaterialExport::ExportMaterialFromMaxscriptCall(fullpathfilename, stdmat) ) return new Integer(0); return new Integer(-1); } catch(...) { //MessageBox(NULL,"Exception catched in ExportCalMat C++ function","Error",MB_OK); return new Integer(-2); } }
// ============================================================================ AngleControl::AngleControl(Value* name, Value* caption, Value** keyparms, int keyparm_count) : RolloutControl(name, caption, keyparms, keyparm_count) { tag = class_tag(AngleControl); m_hWnd = NULL; m_hToolTip = NULL; m_diameter = 0; m_lButtonDown = FALSE; m_degrees = 0.f; m_startDegrees = 90.f; m_min = -360.0f; m_max = 360.0f; m_dirCCW = TRUE; m_color = RGB(0,0,255); m_oldCursor = NULL; m_hBrush = NULL; m_maxBitMap = NULL; }
FooControl(Value* name, Value* caption, Value** keyparms, int keyparm_count) : RolloutControl(name, caption, keyparms, keyparm_count) { tag = class_tag(FooControl); }
// Constructor ish3_ProgressBar::ish3_ProgressBar(Value* name, Value* caption, Value** keyparms, int keyparm_count) : RolloutControl(name, caption, keyparms, keyparm_count) { tag = class_tag(ish3_ProgressBar); progbar = NULL; }
Value* ExportCalSkel_cf(Value** arg_list, int count) { int i; INodeTab tabnode; char* fullpathfilename; int ArraySize ; bool bShowUI ; bool bUseAxisGL=false; // Cedric Pinson, now we can export in gl coordinates check_arg_count_with_keys(ExportCalSkel, 3, count); Value* transform= key_arg_or_default(transform, &false_value); type_check(transform, Boolean, "[The axisGL argument of ExportCalSkel should be a boolean that is true if you want to export in openGL axis]"); type_check(arg_list[0], String, "[The first argument of ExportCalSkel should be a string that is a full path name of the file to export]"); type_check(arg_list[1], Array , "[The 2nd argument of ExportCalSkel should be an array of nodes]"); type_check(arg_list[2], Boolean,"[The 3rd argument of ExportCalSkel should be a boolean that tells if you want to use the UI or not to select nodes of skeleton]"); try { fullpathfilename = arg_list[0]->to_string(); bUseAxisGL = (transform->to_bool() != 0); //Get Array Array* BonesArray = static_cast<Array*>(arg_list[1]); ArraySize = BonesArray->size; bShowUI = !!(arg_list[2]->to_bool()); if (! strcmp(fullpathfilename,"")) return new Integer (1); if (! ArraySize) return new Integer (2); for (i=0;i<ArraySize;i++) { if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) ) { INode* _node = BonesArray->data[i]->to_node(); if (! _node)return new Integer (3); tabnode.Append(1,&_node); } } theExporter.SetAxisGL(bUseAxisGL); //Call the exporter from Maxscript if (CMaxSkeletonExport::ExportSkeletonFromMaxscriptCall(fullpathfilename,tabnode, bShowUI) ) { // reset axis gl theExporter.SetAxisGL(false); return new Integer (0); } theExporter.SetAxisGL(false); return new Integer (-1); } catch(...) { theExporter.SetAxisGL(false); //MessageBox(NULL,"Exception catched in ExportCalSkel C++ function","Error",MB_OK); return new Integer (-2); } }
Value* ExportCalAnim_cf(Value** arg_list, int count) { int i ; char* Filefullpathfilename ; char* Skeletonfullpathfilename ; Array* BonesArray ; int StartFrame ; int EndFrame ; int FrameOffset ; int FrameRate ; bool bUseAxisGL=false; // Cedric Pinson, now we can export in gl coordinates check_arg_count_with_keys(ExportCalAnim, 7, count); Value* transform= key_arg_or_default(transform, &false_value); type_check(transform, Boolean, "[The axisGL argument of ExportCalAnim should be a boolean that is true if you want to export in openGL axis]"); type_check(arg_list[0], String , "[The first argument of ExportCalAnim should be a string that is a full path name of the file to export]"); type_check(arg_list[1], String , "[The 2nd argument of ExportCalAnim should be a string that is the fullpath name of the skeleton file]"); type_check(arg_list[2], Array , "[The 3rd argument of ExportCalAnim should be an array of nodes to get anim from]"); type_check(arg_list[3], Integer , "[The 4th argument of ExportCalAnim should be an integer that is the start frame number]"); type_check(arg_list[4], Integer , "[The 5th argument of ExportCalAnim should be an integer that is the end frame number]"); type_check(arg_list[5], Integer , "[The 6th argument of ExportCalAnim should be an integer that is the frame offset]"); type_check(arg_list[6], Integer , "[The 7th argument of ExportCalAnim should be an integer that is the framerate]"); try { bool bUseAxisGL=false; // Cedric Pinson, now we can export in gl coordinates check_arg_count_with_keys(ExportCalAnim, 7, count); Value* transform= key_arg_or_default(transform, &false_value); type_check(transform, Boolean, "[The axisGL argument of ExportCalAnim should be a boolean that is true if you want to export in openGL axis]"); Filefullpathfilename = arg_list[0]->to_string(); Skeletonfullpathfilename = arg_list[1]->to_string(); BonesArray = static_cast<Array*>(arg_list[2]); StartFrame = arg_list[3]->to_int(); EndFrame = arg_list[4]->to_int(); FrameOffset = arg_list[5]->to_int(); FrameRate = arg_list[6]->to_int(); if (! strcmp(Filefullpathfilename,""))return new Integer(1); if (! strcmp(Skeletonfullpathfilename,"")) return new Integer(2); //Does skeleton file exist ? FILE* _stream; _stream = fopen(Skeletonfullpathfilename,"r"); if (! _stream)return new Integer(3); //Error code number 3 fclose(_stream); //Get the elements of the bones array int ArraySize; bUseAxisGL = (transform->to_bool() != 0); ArraySize = BonesArray->size; if (! ArraySize) return new Integer(4); if (StartFrame < 0) return new Integer(5); if (EndFrame < 0)return new Integer(6); if (StartFrame > EndFrame ) return new Integer(7); if (FrameOffset < 0) return new Integer(8); if (FrameRate < 0) return new Integer(9); INodeTab tabnode; for (i=0;i<ArraySize;i++) { if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) ) { INode* _node = BonesArray->data[i]->to_node(); if (! _node)return new Integer(10); tabnode.Append(1,&_node); } } AnimExportParams param(Skeletonfullpathfilename, tabnode, StartFrame, EndFrame, FrameOffset, FrameRate); theExporter.SetAxisGL(bUseAxisGL); // set axis wanted if (CMaxAnimationExport::ExportAnimationFromMaxscriptCall(Filefullpathfilename, ¶m)) { //reset to default theExporter.SetAxisGL(false); return new Integer(0); } theExporter.SetAxisGL(false); return new Integer(-1); } catch(...) { theExporter.SetAxisGL(false); //MessageBox(NULL,"Exception catched in ExportCalAnim C++ function","Error",MB_OK); return new Integer(-2); } }