Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
in my plugin i used the following code which doesn't work in r20
Vector* vp1 = NewMem(Vector, 3); Vector* vp2 = NewMem(Vector, 3); Vector* vf = NewMem(Vector, 3);
i get the error "Initialisierung": "maxon::ResultMemT<T *>" kann nicht in "Vector *" konvertiert werden
edit: found out this
Vector vp1[3] = { endpoint1 + dir * Vector(0, 0, -20) , endpoint1 + dir * Vector(0, 5, -5) , endpoint1 + dir * Vector(0, -5, -5) };
but now i get new errors:
Fehler (aktiv) E0135 "class "maxon::ArrayInterfacemaxon::Generic"" hat keinen Member ""Iterator"". arkos C:\sdk\frameworks\core.framework\source\maxon\array.h 741
Fehler (aktiv) E0070 Ein unvollständiger Typ ist nicht zulässig. arkos C:\sdk\frameworks\core.framework\source\maxon\array.h 706
Hello,
Cinema 40 R20 introduces a new, elaborate error handling system. A function can return now a dedicated result object that stores additional information if the operation was successful or not.
NewMem does return such a result value. You find information on how to handle errors in the documentation: Error Handling. See also Error System in the API Transition.
NewMem
That being said, in most cases there should be no reason to allocate memory with NewMem. It is recommended to use arrays like BaseArray instead. Such an array provides save access to and management of the allocated data.
BaseArray
See
best wishes, Sebastian
@s_bach thank you very much for pointing me to that. however, i tried adopting that to a function retrieveing the vertex normals and now i don't know how to properly return those normals.
Vector *GetVertexNormals(PolygonObject *pObj) { Int32 numVerts = pObj->GetPointCount(); Int32 numPolys = pObj->GetPolygonCount(); const Vector *pVerts = pObj->GetPointR(); const CPolygon *pPolys = pObj->GetPolygonR(); // initialize neighbor class... this is used to compute m_SrcvNorms Neighbor neighbor; if( !neighbor.Init(numVerts, pPolys, numPolys, NULL) ) return NULL; //** those two lines worked in the old version **// //Vector *pNormals = (Vector *)NewMemClear(UChar,numVerts * sizeof(Vector)); //if( !pNormals ) return NULL; //** these are my adoption to basearray **// maxon::BaseArray<Vector> pNormals; if(pNormals.GetCount()<=0) return NULL; // Determine a Normal for each vertex of mesh Int32 i, j, faceCnt, *pFaces = NULL; Vector vNorm; for(i=0; i<numVerts; i++) { vNorm = Vector(); // (re)intitialize neighbor.GetPointPolys(i, &pFaces, &faceCnt); if( faceCnt ) { for(j=0; j<faceCnt; j++) { Vector n = CalcFaceNormal(pVerts, pPolys[pFaces[j]]); vNorm += !n; } vNorm /= faceCnt; // average the normal(s) pNormals[i] = !vNorm; // normalize and store } else pNormals[i] = Vector(0.0,1.0,0.0); // default case = Up for any stray verts } return pNormals; }
and btw, it seems to be a general problem with all parts of the plugin, cinema is not crashing with most of them, but the debugger halts everytime
the best solution is probably to create the BaseArray in the caller and hand over a reference to that BaseArray. Your function can then safely fill the BaseArray:
maxon::Result<void> GetVertexNormals(PolygonObject * const pObj, maxon::BaseArray<Vector>& normals)
If you encounter unexpected break points, please open a new thread to discuss this issue.
thank you. i got this working. maybe there are even other places in my code where i can use this knowledge