AlembicFloatController* createFloatController(const std::string& path, const std::string& identifier, const std::string& prop) { AlembicFloatController* pControl = static_cast<AlembicFloatController*>(GetCOREInterface()->CreateInstance( CTRL_FLOAT_CLASS_ID, ALEMBIC_FLOAT_CONTROLLER_CLASSID)); if (!pControl) { return NULL; } TimeValue zero(0); // Set the alembic id pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "path"), zero, EC_UTF8_to_TCHAR(path.c_str())); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "identifier"), zero, EC_UTF8_to_TCHAR(identifier.c_str())); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "property"), zero, EC_UTF8_to_TCHAR(prop.c_str())); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "time"), zero, 0.0f); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "muted"), zero, FALSE); return pControl; }
void AlembicImport_ConnectTimeControl( const char* szControllerName, alembic_importoptions &options ) { char szBuffer[10000]; if(options.loadTimeControl && options.pTimeControl){ std::string objectNameName = EC_MCHAR_to_UTF8( options.pTimeControl->GetObjectName() ); sprintf_s( szBuffer, 10000, "%s.controller = float_expression()\n" "%s.controller.AddScalarTarget \"current\" $'%s'.time.controller\n" "%s.controller.setExpression \"current\"\n", szControllerName, szControllerName, objectNameName.c_str(), szControllerName, objectNameName.c_str(), szControllerName, objectNameName.c_str(), szControllerName ); } else{ sprintf_s( szBuffer, 10000, "%s.controller = float_expression()\n" "%s.controller.setExpression \"S\"\n" , szControllerName, szControllerName, szControllerName, szControllerName ); } ExecuteMAXScriptScript( EC_UTF8_to_TCHAR( szBuffer ) ); }
void addControllersToModifierV2(const std::string& modkey, const std::string& modname, std::vector<AbcProp>& props, const std::string& file, const std::string& identifier, const std::string& category, alembic_importoptions &options, INode* pNode) { ESS_PROFILE_FUNC(); std::stringstream evalStream; std::string nodeName("$"); if(pNode){ evalStream<<GET_MAXSCRIPT_NODE(pNode); nodeName = std::string("mynode2113"); } for(int i=0; i<props.size(); i++){ std::string propName = props[i].name; std::string& val = props[i].displayVal; bool& bConstant = props[i].bConstant; const AbcA::DataType& datatype = props[i].propHeader.getDataType(); const AbcA::MetaData& metadata = props[i].propHeader.getMetaData(); if(datatype.getPod() == AbcA::kFloat32POD){ std::stringstream propStream; propStream<<propName; if(datatype.getExtent() == 1){ addFloatControllerV2(evalStream, options, nodeName, modkey, propName, file, identifier, category, propStream.str()); } else if(datatype.getExtent() == 3){ std::stringstream xStream, yStream, zStream; xStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".x"; yStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".y"; zStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".z"; addFloatControllerV2(evalStream, options, nodeName, modkey, propName + std::string("x"), file, identifier, category, xStream.str()); addFloatControllerV2(evalStream, options, nodeName, modkey, propName + std::string("y"), file, identifier, category, yStream.str()); addFloatControllerV2(evalStream, options, nodeName, modkey, propName + std::string("z"), file, identifier, category, zStream.str()); } } else if(datatype.getPod() == AbcA::kInt32POD){ std::stringstream propStream; propStream<<propName; if(datatype.getExtent() == 1){ addFloatControllerV2(evalStream, options, nodeName, modkey, propName, file, identifier, category, propStream.str()); } } else{ } evalStream<<"\n"; } //ESS_LOG_WARNING(evalStream.str()); ExecuteMAXScriptScript( EC_UTF8_to_TCHAR((char*)evalStream.str().c_str())); }
void addControllersToModifier(const std::string& modkey, const std::string& modname, std::vector<AbcProp>& props, const std::string& target, const std::string& type, const std::string& file, const std::string& identifier, alembic_importoptions &options) { ESS_PROFILE_FUNC(); //the script assumes a single object is selected std::stringstream evalStream; for(int i=0; i<props.size(); i++){ std::string propName = props[i].name; std::string& val = props[i].displayVal; bool& bConstant = props[i].bConstant; const AbcA::DataType& datatype = props[i].propHeader.getDataType(); const AbcA::MetaData& metadata = props[i].propHeader.getMetaData(); if(datatype.getPod() == AbcA::kFloat32POD){ std::stringstream propStream; propStream<<target<<"."<<type<<"."<<propName; if(datatype.getExtent() == 1){ addFloatController(evalStream, options, modkey, propName, file, identifier, propStream.str()); } else if(datatype.getExtent() == 3){ std::stringstream xStream, yStream, zStream; xStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".x"; yStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".y"; zStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".z"; addFloatController(evalStream, options, modkey, propName + std::string("x"), file, identifier, xStream.str()); addFloatController(evalStream, options, modkey, propName + std::string("y"), file, identifier, yStream.str()); addFloatController(evalStream, options, modkey, propName + std::string("z"), file, identifier, zStream.str()); } } else{ } evalStream<<"\n"; } //ESS_LOG_WARNING(evalStream.str()); ExecuteMAXScriptScript( EC_UTF8_to_TCHAR((char*)evalStream.str().c_str())); }
void createStringPropertyDisplayModifier(std::string modname, std::vector<std::pair<std::string, std::string>>& nameValuePairs) { //Example usage: // //std::vector<std::pair<std::string, std::string>> nameValuePairs; //nameValuePairs.push_back(std::pair<std::string, std::string>("Prop1", "Prop1Val")); //nameValuePairs.push_back(std::pair<std::string, std::string>("Prop2", "Prop2Val")); //nameValuePairs.push_back(std::pair<std::string, std::string>("Prop3", "Prop3Val")); //nameValuePairs.push_back(std::pair<std::string, std::string>("Prop4", "Prop4Val")); //createPropertiesDisplayModifier(std::string("My Properties"), nameValuePairs); //the script assumes a single object is selected std::stringstream evalStream; evalStream<<"propModifier = EmptyModifier()"<<"\n"; evalStream<<"propModifier.name = \""<<modname<<"\""<<"\n"; evalStream<<"modCount = $.modifiers.count"<<"\n"; evalStream<<"addmodifier $ propModifier before:modCount"<<"\n"; evalStream<<"$.modifiers[\""<<modname<<"\"].enabled = false"<<"\n"; evalStream<<"propAttribute = attributes propAttribute"<<"\n"; evalStream<<"("<<"\n"; evalStream<<"parameters propAttributePRM1 rollout:propAttributeRLT1"<<"\n"; evalStream<<"("<<"\n"; for(int i=0; i<nameValuePairs.size(); i++){ std::string& name = nameValuePairs[i].first; std::string& val = nameValuePairs[i].second; evalStream<<name<<" type:#string ui:e"<<name<<" default:\""<<val<<"\""<<"\n"; } evalStream<<")"<<"\n"; evalStream<<"rollout propAttributeRLT1 \""<<modname<<"\""<<"\n"; evalStream<<"("<<"\n"; for(int i=0; i<nameValuePairs.size(); i++){ std::string& name = nameValuePairs[i].first; //std::string& val = nameValuePairs[i].second; evalStream<<"edittext e"<<name<<" \""<<name<<"\" fieldWidth:140 labelOnTop:true"<<"\n"; } evalStream<<")"<<"\n"; evalStream<<")"<<"\n"; evalStream<<"custattributes.add $.modifiers[\""<<modname<<"\"] propAttribute baseobject:false"<<"\n"; ExecuteMAXScriptScript( EC_UTF8_to_TCHAR((char*)evalStream.str().c_str()) ); }
void importMetadata(INode* pNode, AbcG::IObject& iObj) { ESS_PROFILE_FUNC(); AbcG::IObject* metadataChild = NULL; if (getCompoundFromObject(iObj).getPropertyHeader(".metadata") == NULL) { return; } Abc::IStringArrayProperty metaDataProp = Abc::IStringArrayProperty(getCompoundFromObject(iObj), ".metadata"); Abc::StringArraySamplePtr ptr = metaDataProp.getValue(0); // for(unsigned int i=0;i<ptr->size();i++){ // const char* name = ptr->get()[i].c_str(); // Abc::StringArraySamplePtr ptr = metaDataProp.getValue(0); // //} std::stringstream exeBuffer; exeBuffer << GET_MAXSCRIPT_NODE(pNode); exeBuffer << "ImportMetadata mynode2113"; exeBuffer << "#("; for (int i = 0; i < ptr->size() - 1; i++) { exeBuffer << "\""; exeBuffer << ptr->get()[i]; exeBuffer << "\", "; } exeBuffer << "\""; exeBuffer << ptr->get()[ptr->size() - 1]; exeBuffer << "\")"; exeBuffer << " \n"; ExecuteMAXScriptScript(EC_UTF8_to_TCHAR((char*)exeBuffer.str().c_str())); // delete[] szBuffer; }
/////////////////////////////////////////////////////////////////////////////////////////////////// // AlembicImport_vis /////////////////////////////////////////////////////////////////////////////////////////////////// void AlembicImport_SetupVisControl(std::string const &file, std::string const &identifier, AbcG::IObject &obj, INode *pNode, alembic_importoptions &options) { if (!pNode) { return; } AbcG::IVisibilityProperty visibilityProperty = getAbcVisibilityProperty(obj); bool isConstant = true; if (visibilityProperty.valid()) { isConstant = visibilityProperty.isConstant(); } if (isConstant) { Animatable *pAnimatable = pNode->SubAnim(0); if (pAnimatable && pAnimatable->ClassID() == ALEMBIC_VISIBILITY_CONTROLLER_CLASSID) { pNode->DeleteSubAnim(0); } alembic_fillvis_options visFillOptions; visFillOptions.pIObj = &obj; visFillOptions.dTicks = 0; visFillOptions.bOldVisibility = true; AlembicImport_FillInVis(visFillOptions); BOOL bVis = visFillOptions.bVisibility ? TRUE : FALSE; float fBool = bVis ? 1.0f : 0.0f; pNode->SetVisibility(0, fBool); } else { // Create the xform modifier AlembicVisibilityController *pControl = static_cast<AlembicVisibilityController *>( GetCOREInterface()->CreateInstance( CTRL_FLOAT_CLASS_ID, ALEMBIC_VISIBILITY_CONTROLLER_CLASSID)); // Set the alembic id TimeValue t = GET_MAX_INTERFACE()->GetTime(); TimeValue zero(0); // Set the alembic id pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "path"), zero, EC_UTF8_to_TCHAR(file.c_str())); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "identifier"), zero, EC_UTF8_to_TCHAR(identifier.c_str())); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "time"), zero, 0.0f); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "muted"), zero, FALSE); // Add the modifier to the node pNode->SetVisController(pControl); if (!isConstant) { std::stringstream controllerName; controllerName << GET_MAXSCRIPT_NODE(pNode); controllerName << "mynode2113.visibility.controller.time"; AlembicImport_ConnectTimeControl(controllerName.str().c_str(), options); } } }
int AlembicImport_Light(const std::string &path, AbcG::IObject& iObj, alembic_importoptions &options, INode** pMaxNode) { //#define OMNI_LIGHT_CLASS_ID 0x1011 //#define SPOT_LIGHT_CLASS_ID 0x1012 //#define DIR_LIGHT_CLASS_ID 0x1013 //#define FSPOT_LIGHT_CLASS_ID 0x1014 //#define TDIR_LIGHT_CLASS_ID 0x1015 //#define OMNI_LIGHT 0 // Omnidirectional //#define TSPOT_LIGHT 1 // Targeted //#define DIR_LIGHT 2 // Directional //#define FSPOT_LIGHT 3 // Free //#define TDIR_LIGHT 4 // Targeted directional if(options.attachToExisting){ ESS_LOG_WARNING("Attach to existing for lights is not yet supported. Could not attach "<<iObj.getFullName()); return alembic_success; } std::vector<matShader> shaders; AbcG::ILight objLight = AbcG::ILight(iObj, Alembic::Abc::kWrapExisting); std::string identifier = objLight.getFullName(); //CompoundPropertyReaderPtr propReader = objLight.getProperties(); Abc::ICompoundProperty props = objLight.getProperties(); InputLightType::enumt lightType = InputLightType::NUM_INPUT_LIGHT_TYPES; for(int i=0; i<props.getNumProperties(); i++){ Abc::PropertyHeader propHeader = props.getPropertyHeader(i); if(AbcM::IMaterialSchema::matches(propHeader)){ AbcM::IMaterialSchema matSchema(props, propHeader.getName()); //ESS_LOG_WARNING("MaterialSchema present on light."); lightType = readShader(matSchema, shaders); } //ESS_LOG_WARNING("name: "<<propHeader.getName()); //if( AbcG::ICameraSchema::matches(propHeader) ){ // ESS_LOG_WARNING("Found light camera."); // //AbcG::ICameraSchema camSchema(props, propHeader.getName()); //} } bool bReplaceExisting = false; int nodeRes = alembic_failure; if(lightType == InputLightType::AMBIENT_LIGHT){ nodeRes = createNode(iObj, LIGHT_CLASS_ID, Class_ID(OMNI_LIGHT_CLASS_ID, 0), pMaxNode, bReplaceExisting); //Modifier* pModifier = FindModifier(*pMaxNode, Class_ID(OMNI_LIGHT_CLASS_ID, 0)); //if(pModifier){ // ESS_LOG_WARNING("NumParamBlocks: "<<pModifier->NumParamBlocks()); //} //printControllers(*pMaxNode); //pMaxNode>GetParamBlockByID( 0 )->SetValue( GetParamIdByName( pModifier, 0, "muted" ), zero, FALSE ); GET_MAX_INTERFACE()->SelectNode(*pMaxNode); //set the ambient check box, intensity controller, and light colour controller (not sure how to this in C++) std::stringstream evalStream; std::string modkey(""); for(int s=0; s<shaders.size(); s++){ std::string target = shaders[s].target; std::string type = shaders[s].type; for(int i=0; i<shaders[s].props.size(); i++){ std::string propName = shaders[s].props[i].name; std::string& val = shaders[s].props[i].displayVal; bool& bConstant = shaders[s].props[i].bConstant; const AbcA::DataType& datatype = shaders[s].props[i].propHeader.getDataType(); const AbcA::MetaData& metadata = shaders[s].props[i].propHeader.getMetaData(); if(datatype.getPod() == AbcA::kFloat32POD){ std::stringstream propStream; propStream<<target<<"."<<type<<"."<<propName; if(datatype.getExtent() == 1 && propName.find("intensity") != std::string::npos ){ //intensity property found, so attach controller addFloatController(evalStream, options, modkey, std::string("multiplier"), path, iObj.getFullName(), propStream.str()); } else if(datatype.getExtent() == 3 && propName.find("lightcolor") != std::string::npos ){ //color property found, so attach controller std::stringstream xStream, yStream, zStream; xStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".x"; yStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".y"; zStream<<propStream.str()<<"."<<metadata.get("interpretation")<<".z"; evalStream<<"$.rgb.controller = Color_RGB()\n"; addFloatController(evalStream, options, modkey, std::string("rgb.controller.r"), path, iObj.getFullName(), xStream.str()); addFloatController(evalStream, options, modkey, std::string("rgb.controller.g"), path, iObj.getFullName(), yStream.str()); addFloatController(evalStream, options, modkey, std::string("rgb.controller.b"), path, iObj.getFullName(), zStream.str()); } } else{ } evalStream<<"\n"; } } evalStream<<"$.ambientOnly = true\n"; ExecuteMAXScriptScript( EC_UTF8_to_TCHAR((char*)evalStream.str().c_str())); } else{//create a null, if we don't know what type of light this is nodeRes = createNode(iObj, HELPER_CLASS_ID, Class_ID(DUMMY_CLASS_ID,0), pMaxNode, bReplaceExisting); } if(nodeRes == alembic_failure){ return nodeRes; } GET_MAX_INTERFACE()->SelectNode(*pMaxNode); for(int i=0; i<shaders.size(); i++){ std::sort(shaders[i].props.begin(), shaders[i].props.end(), sortFunc); Modifier* pMod = createDisplayModifier("Shader Properties", shaders[i].name, shaders[i].props); std::string target = shaders[i].target; std::string type = shaders[i].type; addControllersToModifier("Shader Properties", shaders[i].name, shaders[i].props, target, type, path, iObj.getFullName(), options); } // ----- TODO: add camera modifier //createCameraModifier(path, identifier, *pMaxNode); // ----- TODO: don't attach controllers for constant parameters //TODO: make the spinners read only return alembic_success; }
Modifier* createDisplayModifier(std::string modkey, std::string modname, std::vector<AbcProp>& props, INode* pNode) { ESS_PROFILE_FUNC(); //the script assumes a single object is selected std::stringstream evalStream; std::string nodeName("$"); if(pNode){ evalStream<<GET_MAXSCRIPT_NODE(pNode); nodeName = std::string("mynode2113"); } evalStream<<"propModifier = EmptyModifier()"<<"\n"; evalStream<<"propModifier.name = \""<<modkey<<"\""<<"\n"; evalStream<<"modCount = "<<nodeName<<".modifiers.count"<<"\n"; evalStream<<"addmodifier "<<nodeName<<" propModifier before:modCount"<<"\n"; evalStream<<nodeName<<".modifiers[\""<<modkey<<"\"].enabled = false"<<"\n"; evalStream<<"propAttribute = attributes propAttribute"<<"\n"; evalStream<<"("<<"\n"; evalStream<<"parameters propAttributePRM1 rollout:propAttributeRLT1"<<"\n"; evalStream<<"("<<"\n"; for(int i=0; i<props.size(); i++){ std::string& name = props[i].name; std::string& val = props[i].displayVal; bool& bConstant = props[i].bConstant; const AbcA::DataType& datatype = props[i].propHeader.getDataType(); const AbcA::MetaData& metadata = props[i].propHeader.getMetaData(); if(datatype.getPod() == AbcA::kInt32POD && datatype.getExtent() == 1){ evalStream<<name<<" type:#integer animatable:true ui:e"<<name<<" default:"<<val; } else if(datatype.getPod() == AbcA::kFloat32POD && datatype.getExtent() == 1){ evalStream<<name<<" type:#float animatable:true ui:e"<<name<<" default:"<<val; } else if(datatype.getPod() == AbcA::kFloat32POD && datatype.getExtent() == 3){ //if(metadata.get("interpretation") == std::string("rgb")){ // evalStream<<name<<" type:#color animatable:false ui:e"<<name<<" default:(["<<val<<"] as color)"; //} //else{ //evalStream<<name<<" type:#point3 animatable:false ui:e"<<name<<" ["<<val<<"]"; evalStream<<name<<"x type:#float animatable:true ui:e"<<name<<"x default:300\n"; evalStream<<name<<"y type:#float animatable:true ui:e"<<name<<"y default:300\n"; evalStream<<name<<"z type:#float animatable:true ui:e"<<name<<"z default:300\n"; //} } else{ evalStream<<name<<" type:#string animatable:false ui:e"<<name<<" default:\""<<val<<"\""; } evalStream<<"\n"; } evalStream<<")"<<"\n"; evalStream<<"rollout propAttributeRLT1 \""<<modname<<"\""<<"\n"; evalStream<<"("<<"\n"; for(int i=0; i<props.size(); i++){ std::string& name = props[i].name; bool& bConstant = props[i].bConstant; const AbcA::DataType& datatype = props[i].propHeader.getDataType(); const AbcA::MetaData& metadata = props[i].propHeader.getMetaData(); const int nSize = (const int) props[i].displayVal.size(); if(datatype.getPod() == AbcA::kInt32POD && datatype.getExtent() == 1){ evalStream<<"label lbl"<<name<<" \""<<name<<"\" align:#left fieldWidth:140\n"; evalStream<<"spinner e"<<name<<" \"\" type:#integer range:[-9999999,9999999,0] align:#left labelOnTop:true\n"; } else if(datatype.getPod() == AbcA::kFloat32POD && datatype.getExtent() == 1){ evalStream<<"label lbl"<<name<<" \""<<name<<"\" align:#left fieldWidth:140\n"; evalStream<<"spinner e"<<name<<" \"\" type:#float range:[-9999999,9999999,0]align:#left labelOnTop:true\n"; } else if(datatype.getPod() == AbcA::kFloat32POD && datatype.getExtent() == 3){ evalStream<<"label lbl"<<name<<" \""<<name<<"\" align:#left fieldWidth:140\n"; evalStream<<"spinner e"<<name<<"x\"\" across:3 type:#float range:[-9999999,9999999,0] fieldWidth:39 readOnly:true\n"; evalStream<<"spinner e"<<name<<"y\"\" type:#float range:[-9999999,9999999,0] fieldWidth:39\n"; evalStream<<"spinner e"<<name<<"z\"\" type:#float range:[-9999999,9999999,0] fieldWidth:39\n"; } else{ //TODO: better fit for large strings evalStream<<"edittext e"<<name<<" \" "<<name<<"\" fieldWidth:140 "; if(nSize > 140){ evalStream<<"height:54"; } evalStream<<" labelOnTop:true"; if(bConstant) evalStream<<" readOnly:true"; } evalStream<<"\n"; } //evalStream<<"on propAttributePRM1 changed do\n"; //evalStream<<"("<<"\n"; //for(int i=0; i<props.size(); i++){ // std::string& name = props[i].name; // const AbcA::DataType& datatype = props[i].propHeader.getDataType(); // const AbcA::MetaData& metadata = props[i].propHeader.getMetaData(); // evalStream<<"e"<<name<<".text = "<<name<<" as string"; // evalStream<<"\n"; //} //evalStream<<")"<<"\n"; evalStream<<")"<<"\n"; evalStream<<")"<<"\n"; evalStream<<"custattributes.add "<<nodeName<<".modifiers[\""<<modkey<<"\"] propAttribute baseobject:false"<<"\n"; //ESS_LOG_WARNING(evalStream.str()); evalStream<<nodeName<<".modifiers[\""<<modkey<<"\"]\n"; FPValue fpVal; ExecuteMAXScriptScript( EC_UTF8_to_TCHAR((char*)evalStream.str().c_str()), 0, &fpVal); Modifier* pMod = (Modifier*)fpVal.r; return pMod; }
int AlembicImport_Camera(const std::string& path, AbcG::IObject& iObj, alembic_importoptions& options, INode** pMaxNode) { const std::string& identifier = iObj.getFullName(); if (!AbcG::ICamera::matches(iObj.getMetaData())) { return alembic_failure; } AbcG::ICamera objCamera = AbcG::ICamera(iObj, Abc::kWrapExisting); if (!objCamera.valid()) { return alembic_failure; } bool isConstant = objCamera.getSchema().isConstant(); TimeValue zero(0); INode* pNode = *pMaxNode; CameraObject* pCameraObj = NULL; if (!pNode) { // Create the camera object and place it in the scene GenCamera* pGenCameraObj = GET_MAX_INTERFACE()->CreateCameraObject(FREE_CAMERA); if (pGenCameraObj == NULL) { return alembic_failure; } pGenCameraObj->Enable(TRUE); pGenCameraObj->SetConeState(TRUE); pGenCameraObj->SetManualClip(TRUE); IMultiPassCameraEffect* pCameraEffect = pGenCameraObj->GetIMultiPassCameraEffect(); const int TARGET_DISTANCE = 0; pCameraEffect->GetParamBlockByID(0)->SetValue(TARGET_DISTANCE, zero, FALSE); pCameraObj = pGenCameraObj; Abc::IObject parent = iObj.getParent(); std::string name = removeXfoSuffix(parent.getName().c_str()); pNode = GET_MAX_INTERFACE()->CreateObjectNode( pGenCameraObj, EC_UTF8_to_TCHAR(name.c_str())); if (pNode == NULL) { return alembic_failure; } *pMaxNode = pNode; } else { Object* obj = pNode->EvalWorldState(zero).obj; if (obj->CanConvertToType(Class_ID(SIMPLE_CAM_CLASS_ID, 0))) { pCameraObj = reinterpret_cast<CameraObject*>( obj->ConvertToType(zero, Class_ID(SIMPLE_CAM_CLASS_ID, 0))); } else if (obj->CanConvertToType(Class_ID(LOOKAT_CAM_CLASS_ID, 0))) { pCameraObj = reinterpret_cast<CameraObject*>( obj->ConvertToType(zero, Class_ID(LOOKAT_CAM_CLASS_ID, 0))); } else { return alembic_failure; } } // Fill in the mesh // alembic_fillcamera_options dataFillOptions; // dataFillOptions.pIObj = &iObj; // dataFillOptions.pCameraObj = pCameraObj; // dataFillOptions.dTicks = GET_MAX_INTERFACE()->GetTime(); // AlembicImport_FillInCamera(dataFillOptions); // printAnimatables(pCameraObj); Interval interval = FOREVER; AlembicFloatController* pControl = NULL; { std::string prop("horizontalFOV"); if (options.attachToExisting) { pControl = getController(pCameraObj, identifier, prop, 0, 0); } if (pControl) { pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "path"), zero, EC_UTF8_to_TCHAR(path.c_str())); } else if (assignController(createFloatController(path, identifier, prop), pCameraObj, 0, 0) && !isConstant) { std::stringstream controllerName; controllerName << GET_MAXSCRIPT_NODE(pNode); controllerName << "mynode2113.FOV.controller.time"; AlembicImport_ConnectTimeControl(controllerName.str().c_str(), options); } } { std::string prop("FocusDistance"); if (options.attachToExisting) { pControl = getController(pCameraObj, identifier, prop, 1, 0, 1); } if (pControl) { pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "path"), zero, EC_UTF8_to_TCHAR(path.c_str())); } else if (assignController(createFloatController(path, identifier, prop), pCameraObj, 1, 0, 1) && !isConstant) { std::stringstream controllerName; controllerName << GET_MAXSCRIPT_NODE(pNode); controllerName << "mynode2113.MultiPass_Effect.focalDepth.controller.time"; AlembicImport_ConnectTimeControl(controllerName.str().c_str(), options); } } { std::string prop("NearClippingPlane"); if (options.attachToExisting) { pControl = getController(pCameraObj, identifier, prop, 0, 2); } if (pControl) { pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "path"), zero, EC_UTF8_to_TCHAR(path.c_str())); } else if (assignController(createFloatController(path, identifier, prop), pCameraObj, 0, 2) && !isConstant) { std::stringstream controllerName; controllerName << GET_MAXSCRIPT_NODE(pNode); controllerName << "mynode2113.nearclip.controller.time"; AlembicImport_ConnectTimeControl(controllerName.str().c_str(), options); } } { std::string prop("FarClippingPlane"); if (options.attachToExisting) { pControl = getController(pCameraObj, identifier, prop, 0, 3); } if (pControl) { pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "path"), zero, EC_UTF8_to_TCHAR(path.c_str())); } else if (assignController(createFloatController(path, identifier, prop), pCameraObj, 0, 3) && !isConstant) { std::stringstream controllerName; controllerName << GET_MAXSCRIPT_NODE(pNode); controllerName << "mynode2113.farclip.controller.time"; AlembicImport_ConnectTimeControl(controllerName.str().c_str(), options); } } // if(assignControllerToLevel1SubAnim(createFloatController(path, identifier, // std::string("FocusDistance")), pCameraObj, 0, 1) && !isConstant){ // AlembicImport_ConnectTimeControl( "$.targetDistance.controller.time", // options ); //} createCameraModifier(path, identifier, pNode); // Add the new inode to our current scene list SceneEntry* pEntry = options.sceneEnumProc.Append( pNode, pCameraObj, OBTYPE_CAMERA, &std::string(iObj.getFullName())); options.currentSceneList.Append(pEntry); // Set the visibility controller AlembicImport_SetupVisControl(path, identifier, iObj, pNode, options); importMetadata(pNode, iObj); return 0; }
void createCameraModifier(const std::string& path, const std::string& identifier, INode* pNode) { ////Create the Camera modifier Modifier* pModifier = static_cast<Modifier*>(GET_MAX_INTERFACE()->CreateInstance( OSM_CLASS_ID, ALEMBIC_CAMERA_MODIFIER_CLASSID)); TimeValue now = GET_MAX_INTERFACE()->GetTime(); // Set the alembic id pModifier->GetParamBlockByID(0)->SetValue( GetParamIdByName(pModifier, 0, "path"), now, EC_UTF8_to_TCHAR(path.c_str())); pModifier->GetParamBlockByID(0)->SetValue( GetParamIdByName(pModifier, 0, "identifier"), now, EC_UTF8_to_TCHAR(identifier.c_str())); // Set the alembic id // pModifier->SetCamera(pCameraObj); // Add the modifier to the node GET_MAX_INTERFACE()->AddModifier(*pNode, *pModifier); // AlembicImport_ConnectTimeControl("$.modifiers[\"AlembicCameraProperties\"].time", // options ); // printControllers(pModifier->GetParamBlockByID(0)); IParamBlock2* pBlock = pModifier->GetParamBlockByID(0); if (pBlock) { pBlock->AssignController( createFloatController(path, identifier, "horizontalFOV"), 0); pBlock->AssignController( createFloatController(path, identifier, "verticalFOV"), 1); pBlock->AssignController( createFloatController(path, identifier, "FocalLength"), 2); pBlock->AssignController( createFloatController(path, identifier, "HorizontalAperture"), 3); pBlock->AssignController( createFloatController(path, identifier, "VerticalAperture"), 4); pBlock->AssignController( createFloatController(path, identifier, "HorizontalFilmOffset"), 5); pBlock->AssignController( createFloatController(path, identifier, "VerticalFilmOffset"), 6); pBlock->AssignController( createFloatController(path, identifier, "LensSqueezeRatio"), 7); pBlock->AssignController( createFloatController(path, identifier, "OverScanLeft"), 8); pBlock->AssignController( createFloatController(path, identifier, "OverScanRight"), 9); pBlock->AssignController( createFloatController(path, identifier, "OverScanTop"), 10); pBlock->AssignController( createFloatController(path, identifier, "OverScanBottom"), 11); pBlock->AssignController(createFloatController(path, identifier, "FStop"), 12); pBlock->AssignController( createFloatController(path, identifier, "FocusDistance"), 13); pBlock->AssignController( createFloatController(path, identifier, "ShutterOpen"), 14); pBlock->AssignController( createFloatController(path, identifier, "ShutterClose"), 15); pBlock->AssignController( createFloatController(path, identifier, "NearClippingPlane"), 16); pBlock->AssignController( createFloatController(path, identifier, "FarClippingPlane"), 17); } }