Styler Posted October 12, 2014 Posted October 12, 2014 Hello guys, could you help me?How can I save HModelCache into mdl file? All mdl files start with tags , seems like I need to be inside HOT_MODELFILE container or something like that.One more question. If select shortcut to object and actually object itself HTreeObject::GetObjectType tells me that it's the same object type. How can I get more explicit answer: who is who? Thanks! Quote
Hash Fellow robcat2075 Posted October 12, 2014 Hash Fellow Posted October 12, 2014 Hello guys, could you help me? How can I save HModelCache into mdl file? I don't even know what HModelCache is. Is it something in the copy buffer? What circumstance makes you want to put it into mdl? Quote
markw Posted October 12, 2014 Posted October 12, 2014 This is something to do with A:M's SDK I think Robert.Found this page mentioning it for v12: http://www.hash.com/ftp/pub/Sdk/AMSDKDoc/classHModelCache.html Quote
Styler Posted October 13, 2014 Author Posted October 13, 2014 Thanks for quick response!Since AM:SDK doesn't have any documentation, i could just guess what each class supposed to do =) from examples.As I understood ModelCache is actually shape object, which holds topology information. Model - is instance of ModuleCache. I would like to save specific object back to mdl format after editing its topology. When i run plugin's dialog i have access to HTreeObject that i can cast to HModelCache and get access to its methods.The thing is - it's still reference to mdl file (not actually geometry).How to jump inside mdl container?In entry point in HxtOnCommand I have HTreeObject *htreeobject, with type of HOT_MODELthen I execute CPluginApp dialog and casting this pointer to HModelCache*// Here is code example:HModelCache* shape = (HModelCache*)g_selectedTreeObject;FileStream hs;hs.Open(filename);shape->Save(hs);In beginning of output file i have:LinkedModel=../Data/Models/Actors/Thom/Thom.mdlShould be ModelFile container... Quote
Fuchur Posted October 13, 2014 Posted October 13, 2014 I can not really give you a good answer but I have asked Steffen if he could have a look into your question. he very likely will come back to you soon on that. see you *fuchur* Quote
Styler Posted October 17, 2014 Author Posted October 17, 2014 Actually i found a bug in HModelCache class methodIEPolyModel *BuildExportModel(IEPolyModelParms *iemp, const char *modelmapfilename);When it builds polymesh for model cache, it flips some face normals in 5 patches, sometimes. I suppose this is a bug in algorithm. surprisingly it works fine if i do export to OBJ, but for 3DS, LWO it doesn't work properly Quote
Hash Fellow robcat2075 Posted October 17, 2014 Hash Fellow Posted October 17, 2014 Actually i found a bug in HModelCache class method IEPolyModel *BuildExportModel(IEPolyModelParms *iemp, const char *modelmapfilename); When it builds polymesh for model cache, it flips some face normals in 5 patches, sometimes. I suppose this is a bug in algorithm. surprisingly it works fine if i do export to OBJ, but for 3DS, LWO it doesn't work properly... Definitely submit that as a bug report at hash.com/reports If you haven't previously submitted a report you'll need to get a password for that site from the admins. Make sure to include the sample model your example uses. Quote
Developer yoda64 Posted October 19, 2014 Developer Posted October 19, 2014 Saving modelcache will work first in V18h , need changes inside A:M and the SDK . For HModelCache there will be than a HModelChache::ExportModel(FileStream hs) . Quote
Styler Posted October 19, 2014 Author Posted October 19, 2014 Thanks for information, Steffen! I'm writing applink for 3DCoat and I faced with the problem that doing import/export process won't so simple, since Hash is purely spline-patch based app. As I understood you have great experience with Hash SDK. Could you tell me.. Do you know any other way to get polymesh than using BuildExportModel method? I'd like to get similar topology like patches have (4 or 5 points faces without forcing post-tesselation down to 4, 3). Thanks for your answers Quote
Hash Fellow robcat2075 Posted October 19, 2014 Hash Fellow Posted October 19, 2014 I'd like to get similar topology like patches have (4 or 5 points faces without forcing post-tesselation down to 4, 3). If you export a OBJ with "polygons per patch" set to 1 you'll get the original topology, with 5-pointers as holes. Quote
Styler Posted October 19, 2014 Author Posted October 19, 2014 Rob, i tried. it converts 5 exactly to 4, 3. See picture above with OBJ marker. Quote
Styler Posted October 19, 2014 Author Posted October 19, 2014 ok, have some ideas. gonna use poly iterators, they have access to original patch. i can combine 4, 3 to back to 5 =) Quote
Hash Fellow robcat2075 Posted October 19, 2014 Hash Fellow Posted October 19, 2014 How about this... -Save to MDL -delete the 5-point patches in the MDL file with a text editor macro -reload the altered file -export to OBJ that gets you the original topology with holes for 5-pointers instead of a 4+3 conversion. Quote
Malo Posted October 20, 2014 Posted October 20, 2014 hello,I do not know if this can help:for exporting to Blender I needed to export obj patches without subdivision, without holes and with patches with 5 sides.What I could have found that the triangles are bad writing when exporting: Type f V1 V2 V3 V1 (As patches CP1 CP2 CP3 CP1) which created with holes for export. By rewriting its triangles f V1 V2 V3, the problem is solved.Note that the subdision triangles in AM is different that in the polygon programm, because the triangular patch is a patch to four sides of which one side has no length. so that the subdivision is not ideal for export polygonal because it lost loops.For 5-sided patches exported, I reattached the lines:f V1 V2 V3 V4f V1 V4 V5 (oddly its triangles are well written)inf V1 V2 V3 V4 V5For hooks, I did not look for solution. I thought convert Ngons but when subdision this could give more than 5 poles edges, which is not great.Not being a programmer I used Construct2 to make a small program to correct its convertion problems, here are the files in a zip HTLM5. The program is very slow! But it works with last obj exporter (AMV18). Quote
Styler Posted October 22, 2014 Author Posted October 22, 2014 Does anybody know how to set In/Out Mantitude for control points in brand new created IEPatchModel object? Let's say I want to create a new flat patch like quad poly // create model IEPatchModel* model = new IEPatchModel; model->m_vertexlist.SetSize(4); model->m_vertexlist[0] = Vector(0, 0, 0); model->m_vertexlist[1] = Vector(1, 0, 0); model->m_vertexlist[2] = Vector(1, 1, 0); model->m_vertexlist[3] = Vector(0, 1, 0); // set up patches model->m_patcharray.SetSize(1); IEPatch* patch = new IEPatch(NULL); model->m_patcharray.SetAt(0, patch); // vxt index for (int i = 0; i < 4; i++) { patch->m_vertexid[i] = i; } HModelCache *hmc = HModelCache::New("plane"); hmc->MergeIEModel(model, "foo", 0.0, TRUE, TRUE); Right now i have to set In/Out Mantitude after merging IEModel: HSpline* sp = hmc->GetHeadSpline(); while (sp) { HCP* cp = sp->GetHeadCP(); while (cp) { cp->SetInMagnitude(0.0); cp->SetOutMagnitude(0.0); cp = cp->GetNext(); } sp = sp->GetNextSpline(); } Can I set them up on stage of creation patch somehow? Quote
Developer yoda64 Posted October 26, 2014 Developer Posted October 26, 2014 No , there is no way to do this . And Your code for setting the magnitudes is not correct . check for cp->IsLoop() to prevent a infinity loop. HSpline* sp = hmc->GetHeadSpline();while (sp) { HCP* cp = sp->GetHeadCP(); while (cp && !cp->IsLoop()) { cp->SetInMagnitude(0.0); cp->SetOutMagnitude(0.0); cp = cp->GetNext(); } sp = sp->GetNextSpline();} Most sdk functions are documented , download the file AM120SDKDoc.zip from the sdk download section. It represent not the latest stand , but it's a beginning point . Quote
Styler Posted October 28, 2014 Author Posted October 28, 2014 Thanks Steffen, I already spotted infinite loop issue Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.