Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help:Graphics Problem

eetueetu Member Posts: 3
I would like to display a polygon mesh using parallel projection.
The polygon is a simple hemisphere mesh.
The mesh data is stored in a file. The file starts with nVertex, followed by
nPatches,
then the x y z data for each vertex is given on a separate line, which is
followed by the patch data. The first number is the patch number.
I also have a class Mesh that can load in a mesh and store it in a data
structure.
Code is included below.
So, if anyone knows how to do it (since I'm new to VC++ & MFC) please help!
Thanks.
----------------------------------------------------------------------------
-----
Mesh.h
----------------------------------------------------------------------------
-----
#define NUMVERT 37 // the number of vertices in hemi.dat
#define NUMPATCHES 36 // the number of pathches (polygons) in hemi.dat

class Mesh
{
public:
void ReadData(char s[]);
int patches[NUMPATCHES][4];
float vertices[NUMVERT][3];
Mesh();
virtual ~Mesh();

};

#endif
----------------------------------------------------------------------------
----
Mesh.cpp
----------------------------------------------------------------------------
----
#include "stdafx.h"
#include "PolyDoc.h"
#include "Mesh.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Mesh::Mesh()
{

}

Mesh::~Mesh()
{

}

void Mesh::ReadData(char s[])
{
FILE *fp;
int i,dummy,numVerts,numPatches;
if ((fp = fopen(s,"r")) == 0) {
::MessageBox(NULL,s,"Can't open file",MB_OK);

exit(1);
}
fscanf(fp, "%d %d",&numVerts,&numPatches);// read num of vertices & patches
for(i=0;i<numVerts;i++)
fscanf(fp, "%f %f %f ",&vertices[i][0],&vertices[i][1],&vertices[i][2]);
for(i=0;i<numPatches;i++) {
fscanf(fp, "%d %d %d %d %d ",&dummy,&patches[i][0],&patches[i][1],
&patches[i][2],&patches[i][3]);
}
}
----------------------------------------------------------------------------
------
Mesh data
----------------------------------------------------------------------------
------
37

36

0.000000 0.000000 100.000000

50.000000 0.000009 86.602539

43.301266 -25.000010 86.602539

24.999996 -43.301273 86.602539

0.000001 -50.000000 86.602539

-24.999996 -43.301273 86.602539

-43.301273 -25.000000 86.602539

-50.000000 -0.000004 86.602539

-43.301270 25.000002 86.602539

-25.000004 43.301270 86.602539

-0.000002 50.000000 86.602539

25.000000 43.301273 86.602539

43.301270 25.000002 86.602539

86.602539 0.000015 49.999996

74.999992 -43.301285 49.999996

43.301266 -75.000008 49.999996

0.000001 -86.602539 49.999996

-43.301262 -75.000008 49.999996

-75.000000 -43.301270 49.999996

-86.602539 -0.000008 49.999996

-75.000000 43.301273 49.999996

-43.301277 75.000000 49.999996

-0.000004 86.602539 49.999996

43.301270 75.000000 49.999996

75.000000 43.301273 49.999996

100.000000 0.000017 -0.000004

86.602531 -50.000015 -0.000004

49.999992 -86.602547 -0.000004

0.000001 -100.000000 -0.000004

-49.999989 -86.602547 -0.000004

-86.602539 -50.000000 -0.000004

-100.000000 -0.000009 -0.000004

-86.602539 50.000004 -0.000004

-50.000004 86.602539 -0.000004

-0.000004 100.000000 -0.000004

49.999996 86.602539 -0.000004

86.602539 50.000000 -0.000004

0 0 1 2 2

1 0 2 3 3

2 0 3 4 4

3 0 4 5 5

4 0 5 6 6

5 0 6 7 7

6 0 7 8 8

7 0 8 9 9

8 0 9 10 10

9 0 10 11 11

10 0 11 12 12

11 0 12 1 1

12 1 13 14 2

13 2 14 15 3

14 3 15 16 4

15 4 16 17 5

16 5 17 18 6

17 6 18 19 7

18 7 19 20 8

19 8 20 21 9

20 9 21 22 10

21 10 22 23 11

22 11 23 24 12

23 12 24 13 1

24 13 25 26 14

25 14 26 27 15

26 15 27 28 16

27 16 28 29 17

28 17 29 30 18

29 18 30 31 19

30 19 31 32 20

31 20 32 33 21

32 21 33 34 22

33 22 34 35 23

34 23 35 36 24

35 24 36 25 13

Sign In or Register to comment.