[Glmom-devel] Re: HI.. Liu..
Status: Beta
Brought to you by:
yxliu
|
From: Yaxun L. <yx...@ho...> - 2000-07-06 03:15:38
|
I'm quite busy recently, so I can only work on GLMoM
occasionally in my spare time.
I've just added rotating by holding down right mouse
button and dragging. The changes are mainly made in
GlmomView classes so it should not cause conflict
with your codes if you have done some modification
to your local copy. You may try checking out the
changes and updating your local copy.
I'm now adding translating and magnifying by dragging.
I'd like to see your class member functions of TPolygon.
As my understanding, the purpose of TPolygon is mainly
to provide a storage of general geometry which describes
the structures to be simulated by GLMoM.
I would like to see the class declaration of TObect
first, then I can decide whether to let TSurface, TBox,etc...
to be its subclass. Since the purpose of these classes
are quite different, there may be some difficulty to
do this.
I suggest to use TPolygon.cpp and TPolygon.h for class
TPolygon, use TObect.cpp and TObect.h for class TObect.
These classes should not contain system-specific codes.
They also should not call OpenGL API's. They should
focus on data representation, data enquiry, indexing,...
in a word, they should focus on geometrical data.
I suggest TPolygon contains the following functions:
/////////////////////////////////////////////////////
/* Vertex Operations */
int GetNumberOfVtx();
VEC3 GetVtx(int index);
//each vertex has an global index number
int AddVtx(const VEC3& point);
//add a new vertex should not change old vertex's
//index number, the new vertex will get a new index
//number
void DelVtx(int id);
//delete a vertex may change other vertex's
//index number, therefore polygons affected by
//this operation should also be updated
int FindNearestVtx(const VEC3& point);
//find the index number for the nearest vertex
//to the given point
void SetVtx(int index, const VEC3& point);
//the vertex-editting feature which you
//appreciated :-)
/* polygon operations */
int GetNumberOfPolys();
int PolyGetNumberOfVtx(int polyIndex);
//Get the number of vertexes of a polygon, the
//polygon is identified by its index number
int PolyGetVtx(int polyIndex, int n);
//Get the global index number of the n-th vertex
//of a polygon, the polygon is identified by its
//index number
int PolyAddVtx(int polyIndex, int vtx);
//Add a vertex to a polygon, vtx is the global
//index number of the vertex
int PolyDelVtx(int polyIndex, int n);
//Delete the n-th index of a polygon
int PolyFindVtx(int polyIndex, int vtx);
//Find the local index number of a vertex in
//a polygon, vtx is the global index number of
//the vertex
int AddPoly(int nvtx, int vtx[]);
//add a polygon, nvtx is the number of vertexes
//of the polygon, vtx[] contains the global index
//of each vertex
int DelPoly(int index);
/////////////////////////////////////////////////////
These functions are needed for displaying, editing,
saving and creating the polygons. As you can see,
they are mainly functions mapping global index to
local index, or vice versa, and their implementation
is quite tedious and bug prone. Their efficiency
strongly depends on the data structures used. If the
usual C++ array is used as the container, you may
need to allocate and deallocate arrays frequently,
which may be quite inconvenient and inefficient.
So I suggest using some sophisticated container class
with variable length. When I implement TSurface I
implement a simple container template TVector
(in container.h), but it is quite crude.
In implementing TPolygon it may be quite useful
to display it in GLMoM. I think this part of
codes can go to class TPolygonUI, it contains
attributes and methods for displaying, creating,
and editing the polygons through user interface.
I think we can add a TPolygon object m_poly to GlmomDoc
and add a TPolygonUI m_polyUI to GlmomView. Then we add
menu itmes for creating, editing and displaying
polygons. Users will interact with m_poly through
m_polyUI. In this way, we can keep the new added
codes isolated from the old codes as much as possible,
so that keep the structure of programs clear.
Yaxun
----Original Message Follows----
From: iceberg <ic...@mw...>
To: Yaxun Liu <yx...@ho...>
Subject: Re: HI.. Liu..
Date: Thu, 06 Jul 2000 01:19:41 +0900
MIME-Version: 1.0
Received: from [165.132.116.86] by hotmail.com (3.2) with ESMTP id
MHotMailBB2CAB250031D820F396A5847456055F0; Wed Jul 05 09:19:52 2000
Received: from mwant.yonsei.ac.kr ([165.132.116.90])by mwant.yonsei.ac.kr
(8.9.3/8.9.3) with ESMTP id BAA11332for <yx...@ho...>; Thu, 6 Jul
2000 01:26:58 +0900 (kst)
|