2004-05-24 04:15 PM - last edited on 2023-08-07 12:23 PM by Doreena Deng
API_Component3D component; long j, nVertices, nEdges, nPolygons; GSErrCode err; BNZeroMemory (&component, sizeof (component)); component.header.typeID = API_BodyID; component.header.index = ibody; ACAPI_3D_GetComponent (&component); nVertices = component.body.nVert; nEdges = component.body.nEdge; nPolygons = component.body.nPgon;and then I step through all polygons:
for (j = 1; j <= nPolygons; j++) { component.header.typeID = API_PgonID; component.header.index = j; ACAPI_3D_GetComponent(&component); long firstEdge, lastEdge; firstEdge = component.pgon.fpedg; lastEdge = component.pgon.lpedg; // Walk through the edges for (long e = firstEdge; e < lastEdge; e++) { component.header.typeID = API_PedgID; component.header.index = e; ACAPI_3D_GetComponent(&component); // get the edge API_PedgType &edge = ?????????? } }I'm not sure if I'm doing this correct, but I did this in about the same way as stepping through the other elements. So how do I get the list of vertices that is used in one particular polygon?
2004-05-24 06:23 PM
2004-05-25 02:47 PM
for (long e = firstEdge; e <= lastEdge; e++) { // Get Current edge component.header.typeID = API_EdgeID; component.header.index = e; ACAPI_3D_GetComponent (&component); long vert1 = component.edge.vert1; long vert2 = component.edge.vert2; // Now get the vertices // vert1 component.header.typeID = API_VertID; component.header.index = vert1; ACAPI_3D_GetComponent (&component); WriteReport (" vertex 1 index = %d coord (%Lf, %Lf, %Lf)", component.header.index, component.vert.x, component.vert.y, component.vert.z); // vert2 --> similar....... }When I do this, I can step through most of the vertices of the polygon, but the output seems not really usable... When I follow the vertices around in the output, I can see where they are coming from, but they don't seem to build up a real valid polygon. I guess the last point is automatically connected to the first, but in between them? Sometimes two consecutive edges are not connected and sometimes they are. I guess I'm forgetting to check on certain edges.
2004-05-25 03:22 PM
2004-05-25 04:30 PM
2004-05-25 07:54 PM
2004-05-25 09:20 PM
Karl wrote:My opinion, that from the point of memory size and 3D transformation perfomance, it seems logical.
I have to assume that the overly complex structure is to hide a performance 'hit' the happens in the implementation of retrieving edges. If not, I can't see why this is such a complicated process. What do you think?
Karl
2004-05-25 09:49 PM
Oleg wrote:Thanks, Oleg. That makes sense.
My opinion, that from the point of memory size and 3D transformation perfomance, it seems logical.
Each vertex can belong to different polygons.
The edge can belongs to two adjacent polygons (with an opposite direction).
...
Besides ( probably it is more important ) 3D transformation (apply matrix etc.) is vertex based, an uniform array of vertices can be processed faster.
Unfortunately, API seems is very based on internal implementation, therefore we have such indirect process.
Though I am not sure, that any other approach would be easier or better for different tasks.
2004-05-26 10:57 AM
2004-06-02 12:16 AM
Karl wrote:Oleg is correct regarding the efficiencies of the internal implementation. I also agree with your observation regarding a wrapper class - I have implemented classes for this very purpose. It was more time-consuming to write up-front, but the long-term gain through ease of use has made it worthwhile. Very efficient too. The other main benefit is that we won't suffer so much if the API for this data changes - the differences should be absorbed by the wrapper and not everything based on it.Oleg wrote:I was thinking less deeply ... and more in terms of what simple and clean functionality an appropriate collection of wrapper classes might provide to hide the internal complexities.
My opinion, that from the point of memory size and 3D transformation perfomance, it seems logical.