forked from VB6Hobbyst7/cgx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataGeo.c
95 lines (89 loc) · 3.46 KB
/
dataGeo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* -------------------------------------------------------------------- */
/* CALCULIX */
/* - GRAPHICAL INTERFACE - */
/* */
/* A 3-dimensional pre- and post-processor for finite elements */
/* Copyright (C) 1996 Klaus Wittig */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation; version 2 of */
/* the License. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* -------------------------------------------------------------------- */
#include <cgx.h>
void descalPoints ( int anz_p, Points *point, Scale *scale )
{
register int i;
for (i=0; i<anz_p; i++ )
{
/* descalieren */
point[i].px = (point[i].px* scale->w+scale->x);
point[i].py = (point[i].py* scale->w+scale->y);
point[i].pz = (point[i].pz* scale->w+scale->z);
}
}
void scalPoints ( int anz_p, Points *point, Scale *scale )
{
register int i;
for (i=0; i<anz_p; i++ )
{
/* scalieren */
point[i].px = (point[i].px-scale->x)/scale->w;
point[i].py = (point[i].py-scale->y)/scale->w;
point[i].pz = (point[i].pz-scale->z)/scale->w;
}
}
void descalSurfs ( int anz_s, Gsur *surf, Scale *scale )
{
register int i,j,n,k;
for (i=0; i<anz_s; i++ )
{
n=0;
while((surf[i].npgn-n))
{
n++; /* jump over the polygon token (ie.GL_POLYGON_TOKEN) */
j=surf[i].pgn[n++];
n+=3;
for(k=0; k<j; k++)
{
surf[i].pgn[n]=(surf[i].pgn[n]*scale->w)+scale->x;
surf[i].pgn[n+1]=(surf[i].pgn[n+1]*scale->w)+scale->y;
surf[i].pgn[n+2]=(surf[i].pgn[n+2]*scale->w)+scale->z;
n+=3;
}
}
}
}
void scalSurfs ( int anz_s, Gsur *surf, Scale *scale )
{
register int i,j,n,k;
for (i=0; i<anz_s; i++ )
{
/* printf("surf:%s w:%lf xyz: %lf %lf %lf\n",surf[i].name,scale->w,scale->x,scale->y,scale->z); */
n=0;
while((surf[i].npgn-n))
{
n++; /* jump over the polygon token (ie.GL_POLYGON_TOKEN) */
j=surf[i].pgn[n++];
n+=3;
for(k=0; k<j; k++)
{
/* printf(" %lf %lf %lf -> ", surf[i].pgn[n],surf[i].pgn[n+1],surf[i].pgn[n+2]); */
surf[i].pgn[n]=(surf[i].pgn[n]-scale->x)/scale->w;
surf[i].pgn[n+1]=(surf[i].pgn[n+1]-scale->y)/scale->w;
surf[i].pgn[n+2]=(surf[i].pgn[n+2]-scale->z)/scale->w;
n+=3;
/* printf(" %lf %lf %lf\n", surf[i].pgn[n-3],surf[i].pgn[n-2],surf[i].pgn[n-1]); */
}
}
}
}