~ivantis/armagetronad/sty+ct+ivantis

« back to all changes in this revision

Viewing changes to src/tools/transfab.cpp

  • Committer: ivantis
  • Date: 2008-09-09 21:33:18 UTC
  • Revision ID: ivantis@ivantis.net-20080909213318-k43y6yuq0zd6wbsa
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
*************************************************************************
 
4
 
 
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
 
6
Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
 
7
 
 
8
**************************************************************************
 
9
 
 
10
This program is free software; you can redistribute it and/or
 
11
modify it under the terms of the GNU General Public License
 
12
as published by the Free Software Foundation; either version 2
 
13
of the License, or (at your option) any later version.
 
14
 
 
15
This program is distributed in the hope that it will be useful,
 
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
GNU General Public License for more details.
 
19
 
 
20
You should have received a copy of the GNU General Public License
 
21
along with this program; if not, write to the Free Software
 
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
23
  
 
24
***************************************************************************
 
25
 
 
26
*/
 
27
 
 
28
#include <iostream>
 
29
#include <ctype.h>
 
30
#include <string>
 
31
 
 
32
int main(){
 
33
    float sk[4][4]={{0,.1,0,0},
 
34
                    {-.1,0,0,0},
 
35
                    {0,0,.1,0},
 
36
                    //{1,.2,-1.05,1}};
 
37
                    {1/.025,.2/.025,-1.05/.025,1}};
 
38
 
 
39
    float sn[3][3]={{0,1,0},
 
40
                    {-1,0,0},
 
41
                    {0,0,1}};
 
42
 
 
43
    while(!std::cin.eof() && std::cin.good()){
 
44
        char name[1000];
 
45
        std::cin >> name;
 
46
        std::cout << name;
 
47
 
 
48
        float in[4];
 
49
        int n;
 
50
 
 
51
        if (!strcmp("*MESH_VERTEX",name)){
 
52
            std::cin >> n >> in[0] >> in[1] >> in[2];
 
53
            in[3]=1;
 
54
            std::cout << " " << n;
 
55
            int i,j;
 
56
 
 
57
            for(i=0;i<3;i++){
 
58
                float x=0;
 
59
                for(j=0;j<4;j++)
 
60
                    x+=sk[j][i]*in[j];
 
61
                std::cout << " " << x;
 
62
            }
 
63
        }
 
64
 
 
65
        if (!strcmp("*MESH_FACENORMAL",name)){
 
66
            std::cin >> n >> in[0] >> in[1] >> in[2];
 
67
            in[3]=1;
 
68
            std::cout << " " << n;
 
69
            int i,j;
 
70
 
 
71
            for(i=0;i<3;i++){
 
72
                float x=0;
 
73
                for(j=0;j<3;j++)
 
74
                    x+=sn[j][i]*in[j];
 
75
                std::cout << " " << x;
 
76
            }
 
77
        }
 
78
 
 
79
        char c;
 
80
        std::cin.get(c);
 
81
        while (isspace(c) && !std::cin.eof() && std::cin.good()){
 
82
            std::cout.put(c);
 
83
            std::cin.get(c);
 
84
        }
 
85
        std::cin.unget();
 
86
    }
 
87
}