-
Notifications
You must be signed in to change notification settings - Fork 0
/
texturewrap_code.h
182 lines (116 loc) · 5.26 KB
/
texturewrap_code.h
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
Copyright (C) 2022 BrerDawg
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; either version 2
of the License, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//texturewrap_code.h
//v1.01
#ifndef texture_wrap_code_h
#define texture_wrap_code_h
#define _FILE_OFFSET_BITS 64 //large file handling, must be before all #include...
//#define _LARGE_FILES
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <locale.h>
#include <string>
#include <vector>
#include <wchar.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <cassert>
#include "GCProfile.h"
//linux code
#ifndef compile_for_windows
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
//#include <X11/Xaw/Form.h> //64bit
//#include <X11/Xaw/Command.h> //64bit
#include <dirent.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <syslog.h> //MakeIniPathFilename(..) needs this
#endif
//windows code
#ifdef compile_for_windows
#include <windows.h>
#include <process.h>
#include <winnls.h>
#include <share.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>
#include <fstream>
#include <conio.h>
#define WC_ERR_INVALID_CHARS 0x0080 //missing from gcc's winnls.h
#endif
using namespace std;
//NOTE '+y' is up screen, '+z' is into screen (away from viewer)
struct st_texture_wrap_pixel_block_3d_tag
{
unsigned char* bf; //pixel data block in 8 bit r, g, b ordering (can be larger than block to be manipulated), this is the texture to be wrapped
int srcx; //left most pixel offset in 'bf[]' to work from, this value will be multiplied by 3 to step over r,g,b groupings
int srcy; //top most pixel offset in 'bf[]' to work from
int linedx; //this defines how many pixels exist in a whole horiz line held in 'bf[]'
int wid; //pixel size of block to be manipulated
int hei;
unsigned char* bfdest; //pixel data block in 8 bit r, g, b ordering to receive manipulated pixels, can be same as 'bf[]'
int dest_midx, dest_midy; //center of bfdest[] pixel block
int destx; //left most pixel in 'bfdest[]' to receive manipulated pixels
int desty;
int destlinedx; //this defines how many pixels exist in a whole horiz line held in 'bfdest[]'
float origin3d_x; //this is the 3d surface the pixel map is textured with, e.g. offsets the rotation point, plus 'origin3d_y' is upscreen
float origin3d_y;
float origin3d_z;
float scale; //final display scaling, adj this inconjuction with 'offset_z', to change perpective distortion (try 400.0f)
bool bflip_vert;
};
//NOTE '+y' is up screen, '+z' is into screen (away from viewer)
struct st_3d_pixel_block_texture_wrap_single_axis_tag
{
unsigned char* bf; //pixel data block in 8 bit r, g, b ordering (can be larger than block to be manipulated), this is the texture to be wrapped
int srcx; //left most pixel offset in 'bf[]' to work from, this value will be multiplied by 3 to step over r,g,b groupings
int srcy; //top most pixel offset in 'bf[]' to work from
int linedx; //this defines how many pixels exist in a whole horiz line held in 'bf[]'
int wid; //pixel size of block to be manipulated
int hei;
unsigned char* bfdest; //pixel data block in 8 bit r, g, b ordering to receive manipulated pixels, can be same as 'bf[]'
int destx; //left most pixel in 'bfdest[]' to receive manipulated pixels
int desty;
int destlinedx; //this defines how many pixels exist in a whole horiz line held in 'bfdest[]'
int rotation_axis; //0: rot. around 'x', 1: rot. around 'y' 2: rot. around 'z'
float origin3d_x; //this is the 3d surface the pixel map is textured with, e.g. offsets the rotation point, plus 'origin3d_y' is upscreen
float origin3d_y;
float origin3d_z;
float theta; //3d rotation angle about: 'origin3d_x' etc
float offset_z; //moves rotated 3d surface's 'z' position, adj this inconjuction with 'scale', to alter perpective distortion (try 400.0f)
float scale; //final display scaling, adj this inconjuction with 'offset_z', to change perpective distortion (try 400.0f)
bool bflip_vert;
};
class cl_texture_wrap
{
private: //private var
public:
int bytes_per_pixel;
public:
cl_texture_wrap();
void line_plot_in_buf( unsigned char *bf, int x1, int y1, int x2, int y2, int rr, int gg, int bb, int linedx );
void get_pixel( unsigned char *bf, int xx, int yy, int &rr, int &gg, int &bb, int linedx );
void set_pixel( unsigned char *bf, int xx, int yy, int rr, int gg, int bb, int linedx );
void copy_pixel_block( st_3d_pixel_block_texture_wrap_single_axis_tag ot );
void draw_texture_rot3d_single_axis( st_3d_pixel_block_texture_wrap_single_axis_tag ot, float sub_pixel_factor, bool plot_raster_with_fl_points );
};
#endif