/* chen.cpp Copyright (c) 2015 by T. */
/* */
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <opencsg.h>
#include <math.h>
//#include <windows.h>
//#include <memory.h>
#include "myShape.h"
#include "displaylistPrimitive.h"
#define KEY_ESC 27
#define PI 3.1415
#define N 4
//#pragma comment(lib,"C:\\OpenGL包\\opengl32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glu32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glaux.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\OpenCSG.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glew32.lib")
typedef struct {
float x;
float y;
float z;
float shita;
float alpha;
} US_POS;
typedef struct {
float x;
float y;
float z;
} SH_POS;
const int shoe_point = 25433;
const int us_point_left = 4;
const int us_point_right = 4;
char *file_left="3.txt";
char *file_right="4.txt";
float theta = 0.0;
float dis=200.0, tws=0.0, ele=0.0, azi=0.0;
FILE *fp_left;
FILE *fp_right;
FILE *fp_us_left;
FILE *fp_us_right;
FILE *fp;
FILE *input_0;
//FILE *input_1;
//FILE *input_2;
//FILE *input_3;
//FILE *input_4;
//FILE *input_5;
FILE *input_right;
//float x[25433],y[25433],z[25433];
SH_POS sh_left[25433];
SH_POS sh_right[25433];
US_POS us_left[us_point_left];
US_POS us_right[us_point_right];
US_POS in_us_left[us_point_left];
US_POS in_us_right[us_point_right];
SH_POS sh_left4cm[88];
SH_POS sh_right4cm[97];
SH_POS full_sh_left4cm[10000];
SH_POS full_sh_right4cm[10000];
double left_us_matrix[us_point_left][4][4];
double right_us_matrix[us_point_right][4][4];
double left_gl_matrix[us_point_left][16];
double right_gl_matrix[us_point_right][16];
int us_flag_left=1;
int us_flag_right=1;
int camera_flag = 0;
float lx=0.0, ly=-170.0, lz=0.0;
float dx=0.0, dy=0.0, dz=0.0;
float sx=0.0, sy=0.0, sz=1.0;
float left_sh_angle=0.0;
float left_sh_height=0.0;
//US_POS right_sh_pos={51.5, 51.5, 0.0, 0.0, 0.0};
US_POS left_sh_pos={0.0, 0.0, 0.0, 0.0, 0.0};
US_POS right_sh_pos={10.0, 0.0, 0.0,-90.0, 0.0};
char ss[10];
int mot_flag=0;
int stop_mot=0;
int roop_flag=0;
int solid_flag=1;
float S1,S2;
SH_POS cone_point[18772];
//double length;
int left_count_4cm = 0;
int right_count_4cm = 0;
int p_us_left=0;
int p_us_right=0;
std::vector<OpenCSG::Primitive*> primitives;
void polarview(float distance, float twist, float elevation, float azimuth);
void CreateDisplayList(void);
void SetLight( GLenum light );
void SetMaterial( GLfloat R, GLfloat G, GLfloat B , GLfloat Alpha);
void display(void);
void idle(void);
void myKbd( unsigned char key, int x, int y );
void myInit (char *progname);
void camera_pos_reset();
void shoe_pos_reset();
void DrawString( char *string, GLfloat x, GLfloat y );
void Motion(void);
void Cone(void);
void matrixmultiply(double a[N][N],double b[N][N],double c[N][N]);
void transmatrix(double a[N][N],US_POS us,double c[4]);
void para2matrix(double x, double y, double z, double shita, double c[4][4], int para);
void inverseMatrix(double a[N][N], double inv_a[N][N]);
double msr_length(US_POS point1, SH_POS point2);
void polarview(float distance, float twist, float elevation, float azimuth){
glTranslatef(0.0, 0.0, -distance);
glRotatef(-twist, 0.0, 0.0, 1.0);
glRotatef(-elevation, 1.0, 0.0, 0.0);
glRotatef(-azimuth, 0.0, 1.0, 0.0);
}
void CreateDisplayList()
{
GLuint id1 = glGenLists(1);
glNewList(id1, GL_COMPILE);
glPushMatrix();
////glColor3f(0.0, 0.0, 1.0);
glTranslatef(4.5,7.0,4.0);
glRotatef(-30.0, 0.0,0.0,1.0);
//mySolidCylinder(0.5, 0.7,10);
glRotatef(90.0, 1.0,0.0,0.0);
glTranslatef(0.0,0.0,-141.0);
glutSolidCone(51.3,141.0,10,10);
//glutSolidCone(51.3,141,20,10);
glPopMatrix();
glEndList();
GLuint id2 = glGenLists(1);
glNewList(id2, GL_COMPILE);
glPushMatrix();
glTranslatef(51.5,51.5,51.5);
glutSolidCube(103.0);
glPopMatrix();
glEndList();
primitives.push_back(new OpenCSG::DisplayListPrimitive(id1, OpenCSG::Intersection, 1));
primitives.push_back(new OpenCSG::DisplayListPrimitive(id2, OpenCSG::Subtraction, 1));
}
/* */
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <opencsg.h>
#include <math.h>
//#include <windows.h>
//#include <memory.h>
#include "myShape.h"
#include "displaylistPrimitive.h"
#define KEY_ESC 27
#define PI 3.1415
#define N 4
//#pragma comment(lib,"C:\\OpenGL包\\opengl32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glu32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glaux.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glut32.lib")
//#pragma comment(lib,"C:\\OpenGL包\\OpenCSG.lib")
//#pragma comment(lib,"C:\\OpenGL包\\glew32.lib")
typedef struct {
float x;
float y;
float z;
float shita;
float alpha;
} US_POS;
typedef struct {
float x;
float y;
float z;
} SH_POS;
const int shoe_point = 25433;
const int us_point_left = 4;
const int us_point_right = 4;
char *file_left="3.txt";
char *file_right="4.txt";
float theta = 0.0;
float dis=200.0, tws=0.0, ele=0.0, azi=0.0;
FILE *fp_left;
FILE *fp_right;
FILE *fp_us_left;
FILE *fp_us_right;
FILE *fp;
FILE *input_0;
//FILE *input_1;
//FILE *input_2;
//FILE *input_3;
//FILE *input_4;
//FILE *input_5;
FILE *input_right;
//float x[25433],y[25433],z[25433];
SH_POS sh_left[25433];
SH_POS sh_right[25433];
US_POS us_left[us_point_left];
US_POS us_right[us_point_right];
US_POS in_us_left[us_point_left];
US_POS in_us_right[us_point_right];
SH_POS sh_left4cm[88];
SH_POS sh_right4cm[97];
SH_POS full_sh_left4cm[10000];
SH_POS full_sh_right4cm[10000];
double left_us_matrix[us_point_left][4][4];
double right_us_matrix[us_point_right][4][4];
double left_gl_matrix[us_point_left][16];
double right_gl_matrix[us_point_right][16];
int us_flag_left=1;
int us_flag_right=1;
int camera_flag = 0;
float lx=0.0, ly=-170.0, lz=0.0;
float dx=0.0, dy=0.0, dz=0.0;
float sx=0.0, sy=0.0, sz=1.0;
float left_sh_angle=0.0;
float left_sh_height=0.0;
//US_POS right_sh_pos={51.5, 51.5, 0.0, 0.0, 0.0};
US_POS left_sh_pos={0.0, 0.0, 0.0, 0.0, 0.0};
US_POS right_sh_pos={10.0, 0.0, 0.0,-90.0, 0.0};
char ss[10];
int mot_flag=0;
int stop_mot=0;
int roop_flag=0;
int solid_flag=1;
float S1,S2;
SH_POS cone_point[18772];
//double length;
int left_count_4cm = 0;
int right_count_4cm = 0;
int p_us_left=0;
int p_us_right=0;
std::vector<OpenCSG::Primitive*> primitives;
void polarview(float distance, float twist, float elevation, float azimuth);
void CreateDisplayList(void);
void SetLight( GLenum light );
void SetMaterial( GLfloat R, GLfloat G, GLfloat B , GLfloat Alpha);
void display(void);
void idle(void);
void myKbd( unsigned char key, int x, int y );
void myInit (char *progname);
void camera_pos_reset();
void shoe_pos_reset();
void DrawString( char *string, GLfloat x, GLfloat y );
void Motion(void);
void Cone(void);
void matrixmultiply(double a[N][N],double b[N][N],double c[N][N]);
void transmatrix(double a[N][N],US_POS us,double c[4]);
void para2matrix(double x, double y, double z, double shita, double c[4][4], int para);
void inverseMatrix(double a[N][N], double inv_a[N][N]);
double msr_length(US_POS point1, SH_POS point2);
void polarview(float distance, float twist, float elevation, float azimuth){
glTranslatef(0.0, 0.0, -distance);
glRotatef(-twist, 0.0, 0.0, 1.0);
glRotatef(-elevation, 1.0, 0.0, 0.0);
glRotatef(-azimuth, 0.0, 1.0, 0.0);
}
void CreateDisplayList()
{
GLuint id1 = glGenLists(1);
glNewList(id1, GL_COMPILE);
glPushMatrix();
////glColor3f(0.0, 0.0, 1.0);
glTranslatef(4.5,7.0,4.0);
glRotatef(-30.0, 0.0,0.0,1.0);
//mySolidCylinder(0.5, 0.7,10);
glRotatef(90.0, 1.0,0.0,0.0);
glTranslatef(0.0,0.0,-141.0);
glutSolidCone(51.3,141.0,10,10);
//glutSolidCone(51.3,141,20,10);
glPopMatrix();
glEndList();
GLuint id2 = glGenLists(1);
glNewList(id2, GL_COMPILE);
glPushMatrix();
glTranslatef(51.5,51.5,51.5);
glutSolidCube(103.0);
glPopMatrix();
glEndList();
primitives.push_back(new OpenCSG::DisplayListPrimitive(id1, OpenCSG::Intersection, 1));
primitives.push_back(new OpenCSG::DisplayListPrimitive(id2, OpenCSG::Subtraction, 1));
}