idk
This commit is contained in:
parent
0c7dcd4ea2
commit
69e76764d0
232
src/point.c
232
src/point.c
|
@ -1,9 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include "glfww.h"
|
||||
#include <unistd.h>
|
||||
float NUU = 1;
|
||||
double NUU = 0.0;
|
||||
typedef struct {
|
||||
double x;
|
||||
double y;
|
||||
|
@ -35,17 +36,7 @@ double binominal(int n, int k){
|
|||
return v;
|
||||
}
|
||||
int ma = 4;
|
||||
void mul_matr(double a[][ma],double b[][ma], double res[][ma]){
|
||||
for(int i = 0; i<ma; i++){
|
||||
for(int j = 0; j<ma;j++){
|
||||
res[i][j] = 0;
|
||||
for(int k = 0; k<ma;k++){
|
||||
res[i][j]+=a[i][k]*b[k][j];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GLfloat* at;
|
||||
int len;
|
||||
|
@ -91,24 +82,27 @@ GLuint build_shader(GLuint vertid, GLuint fragid){
|
|||
return progid;
|
||||
}
|
||||
point_arr* basier2d(double*xx,double*yy,int n,float rr, float gg, float bb){
|
||||
point_arr* pa;
|
||||
pa = malloc(sizeof(*pa));
|
||||
pa->c = malloc(sizeof(*pa->c)*(get_w()*60));
|
||||
pa->vert = malloc(sizeof(*pa->vert)*(n*60));
|
||||
|
||||
if(pa->c==NULL||pa->vert==NULL)
|
||||
err("failed to allocate basier array",pexit);
|
||||
|
||||
//double xx[5] = {5.0,5.0,50.0,5.0,5.0};
|
||||
//double yy[5] = {5.0,5.0,5.0,5.0,10.0};
|
||||
//double zz[5] = {10.0,5.0,5.0,5.0,5.0};
|
||||
//int n = 5-1;
|
||||
pa->len = get_w();
|
||||
|
||||
n-=1;
|
||||
|
||||
int lle = diff(get_w(),greater(yy[0]+yy[1],xx[0]+xx[1]))/2;
|
||||
double aaar = (1.0/lle);
|
||||
|
||||
double aaar = (1.0/get_w());
|
||||
for(int iy = 0; iy<=get_w();iy+=1){
|
||||
point_arr* pa;
|
||||
pa = malloc(sizeof(*pa));
|
||||
pa->c = malloc(sizeof(*pa->c)*(lle*60));
|
||||
pa->vert = malloc(sizeof(*pa->vert)*(n*60));
|
||||
|
||||
if(pa->c==NULL||pa->vert==NULL)
|
||||
err("failed to allocate basier array",pexit);
|
||||
|
||||
pa->len = lle;
|
||||
for(int iy = 0; iy<=lle;iy+=1){
|
||||
double t = aaar*iy;
|
||||
double bcx = 0;
|
||||
double bcy = 0;
|
||||
|
@ -157,9 +151,9 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
//printf("s\n");
|
||||
//GLfloat pixels[(int)ceil(c->len*3)];
|
||||
//GLfloat colors[(int)ceil(c->len*3)];
|
||||
GLfloat* pixels = malloc(sizeof(*pixels)*(c->len*3));
|
||||
GLfloat* pixels = malloc(sizeof(*pixels)*((1+c->len)*4));
|
||||
//GLfloat* abpixels = malloc(sizeof(*abpixels)*(c->len*3));
|
||||
GLfloat* colors = malloc(sizeof(*colors)*(c->len*3));
|
||||
GLfloat* colors = malloc(sizeof(*colors)*((1+c->len)*4));
|
||||
//GLfloat* colors = malloc(sizeof(*colors)*c->len*4);
|
||||
if(pixels==NULL||colors==NULL)
|
||||
err("failed to allocate perspective array:(",pexit);
|
||||
|
@ -173,7 +167,7 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
double six = sin(ctx);
|
||||
double siy = sin(cty);
|
||||
double cox = cos(ctx);
|
||||
double fov = .01;
|
||||
double fov = 0.002;
|
||||
double ex = cx;
|
||||
double ey = cy;
|
||||
//glfwGetFramebufferSize(b,&w,&h);
|
||||
|
@ -182,8 +176,11 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
//double ez = 1/tan(fov/2);
|
||||
//glBegin(GL_POINTS);
|
||||
//printf("e\n");
|
||||
//printf("---\n");
|
||||
GLuint fb = 0;
|
||||
double ez=get_h()*2; //i dont get this at all
|
||||
int c_len = 0;
|
||||
//double ez=1/tan(fov/2); //i dont get this at all
|
||||
double ez=get_w()*2;
|
||||
//glGenFramebuffers(1,&fb);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
//glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -204,19 +201,23 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
double by = ez/dz*dy+dy;
|
||||
//printf("%f %f | %f %f %f\n",bx,by,ctx,cty,ctz);
|
||||
//int aaa = round((150-dz)/2);
|
||||
if(dz>=0){
|
||||
if(dz>-1){
|
||||
ab_to_vp(xa,ya,get_w(),get_h(),bx,by);
|
||||
//printf("%f\n",dz);
|
||||
//return;
|
||||
//printf("%i:%f %f | %f %f\n",i*2,xa,ya,bx,by);
|
||||
//return;
|
||||
pixels[i*2] = xa+1;
|
||||
pixels[i*2+1] = ya;
|
||||
//if(c->c[i].at.vertex&&i==4800)
|
||||
// printf("%i : %f:%f %f:%f\n",i,bx,xa,by,ya);
|
||||
pixels[c_len*2] = xa+1;
|
||||
pixels[c_len*2+1] = ya;
|
||||
//abpixels[i*2] = bx;
|
||||
//abpixels[i*2+1] = by;
|
||||
colors[i*3] = c->c[i].color.r;
|
||||
colors[i*3+1] = c->c[i].color.g;
|
||||
colors[i*3+2] = c->c[i].color.b;
|
||||
} else {
|
||||
colors[c_len*3] = c->c[i].color.r;
|
||||
colors[c_len*3+1] = c->c[i].color.g;
|
||||
colors[c_len*3+2] = c->c[i].color.b;
|
||||
c_len++;
|
||||
}/* else {
|
||||
pixels[i*2] = -20;
|
||||
pixels[i*2+1]= -20;
|
||||
//abpixels[i*2] = -20;
|
||||
|
@ -224,13 +225,38 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
colors[i*3] = 0.0f;
|
||||
colors[i*3+1] = 1.0f;
|
||||
colors[i*3+2] = 0.0f;
|
||||
}
|
||||
}*/
|
||||
//glfw_circle_partial(b,nearbyint(bx),nearbyint(by),/*(0>=aaa?1:*/1/*)*/);
|
||||
//glfw_pixel_partial(b,round(bx),round(by));
|
||||
}
|
||||
//int c_len = c->len;
|
||||
//connect all verticies
|
||||
double fc_len = c_len;
|
||||
for(int i = 0; i<=fc_len-1; i++){
|
||||
double x22[2] = {pixels[i*2],pixels[(i+1)*2]};
|
||||
double y22[2] = {pixels[i*2+1],pixels[(i+1)*2+1]};
|
||||
point_arr* bas = basier2d(x22,y22,2,0.1f,0.1f,0.1f);
|
||||
for(int zaa=0; zaa<=bas->len; zaa++){
|
||||
pixels = realloc(pixels,sizeof *pixels *((c_len+1)*3));
|
||||
colors = realloc(colors,sizeof *colors *((c_len+1)*4));
|
||||
pixels[c_len*2] = bas->c[zaa].at.x;
|
||||
pixels[c_len*2+1] = bas->c[zaa].at.y;
|
||||
colors[c_len*3] = 0.1f;
|
||||
colors[c_len*3+1] = 1.0f;
|
||||
colors[c_len*3+2] = 1.0f;
|
||||
c_len++;
|
||||
}
|
||||
free(bas->c);
|
||||
free(bas->vert);
|
||||
free(bas);
|
||||
}
|
||||
//c->len = c_len;
|
||||
double dclen = c_len;
|
||||
//highlight vertic
|
||||
int vvi = 0;
|
||||
int c_len = c->len;
|
||||
|
||||
//printf("l:%i\n",c_len);
|
||||
//printf("%i\n",c_len);
|
||||
glfl_m* trline = malloc(sizeof(*trline)*get_w()*30);
|
||||
trline->len = 0;
|
||||
//printf("ss\n");
|
||||
|
@ -240,10 +266,13 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
if(pixels==NULL||colors==NULL)
|
||||
abort();
|
||||
vvi++;
|
||||
//printf("%i\n",i);
|
||||
//printf("%i\n",i);
|
||||
//printf("%i : %f %f\n",i,pixels[i*2],pixels[i*2+1]);
|
||||
//trline.at = realloc(trline.at,sizeof(*trline.at)*(vvi+1));
|
||||
//printf("1\n");
|
||||
//trline->at[trline->len].at = malloc(sizeof(*trline->at[trline->len].at)*(get_w()+(trline->len+1))*20);
|
||||
trline->at[trline->len].at = malloc(sizeof(*trline->at[trline->len].at)*(get_w()));
|
||||
trline->at[trline->len].at = malloc(sizeof(*trline->at[trline->len].at)*(c_len+get_w()*2)*30);
|
||||
trline->at[trline->len].len = 0;
|
||||
//printf("2\n");
|
||||
double ttt = -1.0;
|
||||
|
@ -252,16 +281,25 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
int p_b3 = 0;
|
||||
int p_b4 = 0;
|
||||
double ttt2 = 1.0;
|
||||
for(int jj = 0; jj<=c->len; jj++){
|
||||
float sad = 3.4f;
|
||||
float sad2 = 30;
|
||||
//printf("%f\n",NUU);
|
||||
|
||||
//
|
||||
//todo: start search after pointer leaves the first line,
|
||||
// then stop when it hits the second line
|
||||
//
|
||||
int found1 = 1;
|
||||
int found2 = 1;
|
||||
for(int jj = 0; jj<=dclen-1; jj++){
|
||||
float sad = 3.0f;
|
||||
float sad2 = 30.0f;
|
||||
if(pixels[jj*2]<pixels[i*2]&&diff(pixels[jj*2],pixels[i*2])>(float)sad2/get_w()
|
||||
&&diff(pixels[jj*2+1],pixels[i*2+1])<(float)sad/get_w()&&i!=jj){
|
||||
//printf("%f %f\n",ttt,pixels[jj*2]);
|
||||
//if(ttt<pixels[jj*2])
|
||||
p_b=1;
|
||||
if(pixels[jj*2]>ttt)
|
||||
ttt=pixels[jj*2];
|
||||
ttt=pixels[jj*2];
|
||||
|
||||
}
|
||||
if(diff(pixels[jj*2],pixels[i*2])>(float)sad2/get_w()
|
||||
&&diff(pixels[jj*2+1],pixels[i*2+1])<(float)sad/get_w()&&i!=jj&&
|
||||
|
@ -269,8 +307,13 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
//printf("%f %f\n",ttt,pixels[jj*2]);
|
||||
//if(ttt<pixels[jj*2])
|
||||
p_b2=1;
|
||||
//printf("sss\n");
|
||||
//printf("%i/%f, %f %f\n",jj,c->len,pixels[jj*2],ttt2);
|
||||
//printf("aaa\n");
|
||||
if(pixels[jj*2]<ttt2)
|
||||
ttt2=pixels[jj*2];
|
||||
ttt2=pixels[jj*2];
|
||||
//printf("lll\n");
|
||||
|
||||
}
|
||||
if(diff(pixels[jj*2+1],pixels[i*2+1])>(float)sad/get_w()
|
||||
&&diff(pixels[jj*2],pixels[i*2])<(float)sad2/get_w()&&i!=jj&&pixels[jj*2+1]>pixels[i*2+1]){
|
||||
|
@ -283,17 +326,25 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
|
||||
}
|
||||
//printf("%i\n",trline->len);
|
||||
//printf("aaaa\n");
|
||||
if(!p_b3||!p_b4){
|
||||
free(trline->at[trline->len].at);
|
||||
//printf("fffff\n");
|
||||
continue;
|
||||
}
|
||||
//printf("aaa\n");
|
||||
//printf("%f %f\n",ttt,ttt2);
|
||||
//printf("%i : %f %f\n",i,ttt,ttt2);
|
||||
//printf("3\n");
|
||||
double cb = 2;
|
||||
double sb = 0.6f;
|
||||
// printf("%f\n",NUU);
|
||||
|
||||
double cb = 1.0;
|
||||
double sb = 1.0/get_w();
|
||||
double ib = cb/get_w();
|
||||
if(p_b)
|
||||
for(double zz = pixels[i*2]; diff(zz,ttt)>(float)cb/get_w()&&zz>-1;zz-=(float)sb/get_w()){
|
||||
for(double zz = pixels[i*2]; diff(zz,ttt)>ib&&zz>-1;zz-=(float)sb){
|
||||
//printf("4 %lu\n",sizeof *pixels *((c_len+1)*3));
|
||||
trline->at[trline->len].at = realloc(trline->at[trline->len].at,sizeof(*trline->at[trline->len].at)*(trline->at[trline->len].len+1)*30);
|
||||
//trline->at[trline->len].at = realloc(trline->at[trline->len].at,sizeof(*trline->at[trline->len].at)*(trline->at[trline->len].len+1)*30);
|
||||
pixels = realloc(pixels,sizeof *pixels *((c_len+1)*3));
|
||||
//printf("4.5\n");
|
||||
colors = realloc(colors,sizeof *colors *((c_len+1)*4));
|
||||
|
@ -316,14 +367,14 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
}
|
||||
//printf("4\n");
|
||||
if(p_b2)
|
||||
for(double zz = pixels[i*2]; diff(zz,ttt2)>(float)cb/get_w()&&zz<1;zz+=(float)sb/get_w()){
|
||||
trline->at[trline->len].at = realloc(trline->at[trline->len].at,sizeof(*trline->at[trline->len].at)*(trline->at[trline->len].len+1)*30);
|
||||
for(double zz = pixels[i*2]; diff(zz,ttt2)>ib&&zz<1;zz+=(float)sb){
|
||||
//trline->at[trline->len].at = realloc(trline->at[trline->len].at,sizeof(*trline->at[trline->len].at)*(trline->at[trline->len].len+1)*30);
|
||||
pixels = realloc(pixels,sizeof *pixels *((c_len+1)*3));
|
||||
colors = realloc(colors,sizeof *colors *((c_len+1)*4));
|
||||
int brea = 0;
|
||||
trline->at[trline->len].at[trline->at[trline->len].len*2] = zz;
|
||||
trline->at[trline->len].at[trline->at[trline->len].len*2+1] = pixels[i*2+1];
|
||||
|
||||
//printf("%f %f\n",zz,ttt2);
|
||||
pixels[c_len*2] = zz;
|
||||
pixels[c_len*2+1] = pixels[i*2+1];
|
||||
colors[c_len*3] = 0.1f;
|
||||
|
@ -333,11 +384,14 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
trline->at[trline->len].len++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
trline->len++;
|
||||
}
|
||||
}
|
||||
//printf("aa\n");
|
||||
//printf(">>>\n");
|
||||
if(trline->len>1){
|
||||
for(int ii = 0; ii!=trline->len-1; ii++){
|
||||
//printf("[%i] %f %i < %f %i\n",ii,trline->at[ii].at[3],trline->at[ii].len,trline->at[ii+1].at[3],trline->at[ii+1].len);
|
||||
if(trline->at[ii].at[3]<trline->at[ii+1].at[3]){
|
||||
|
@ -348,11 +402,12 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
ii=-1;
|
||||
}
|
||||
|
||||
}/*
|
||||
}}/*
|
||||
printf("---\n");
|
||||
for(int ii = 0; ii!=trline->len;ii++){
|
||||
printf("%f %i\n",trline->at[ii].at[3],trline->at[ii].len);
|
||||
}*/
|
||||
//printf("---\n");
|
||||
double lmax_t = -2.0;
|
||||
double lmin_t = 2.0;
|
||||
double lmax2_t = -2.0;
|
||||
|
@ -368,7 +423,7 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
max_t = trline->at[zzi].at[zzi2*2];
|
||||
max2_t = trline->at[zzi].at[zzi2*2+1];
|
||||
}
|
||||
if(min_t>trline->at[zzi].at[zzi2*2]){
|
||||
if(min_t>=trline->at[zzi].at[zzi2*2]){
|
||||
min_t = trline->at[zzi].at[zzi2*2];
|
||||
min2_t = trline->at[zzi].at[zzi2*2+1];
|
||||
}
|
||||
|
@ -382,7 +437,7 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
if(lmax2_t!=max2_t&&lmin_t!=2.0&&lmax_t!=-2.0){
|
||||
float color = (float)zzi/trline->len;
|
||||
float color2 = 1.0f-((float)zzi/trline->len);
|
||||
double di = pow(lmin_t-max_t,2)+pow(lmin2_t-max2_t,2);
|
||||
double di = pow(lmin_t-max_t,2)+pow(lmin2_t-max2_t,2);//sqrt should be used here
|
||||
double di2 = pow(lmax_t-min_t,2)+pow(lmax2_t-min2_t,2);
|
||||
double ux1,uy1,ux2,uy2;
|
||||
if(di>di2){
|
||||
|
@ -396,6 +451,7 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
ux2 = lmax_t;
|
||||
uy2 = lmax2_t;
|
||||
}
|
||||
//printf("%f %f >> %f %f (f,%f) | %f %f\n",di,di2,ux1,uy1,min_t,ux2,uy2);
|
||||
color2 = 1.0f;
|
||||
//printf("%f\n",color2);
|
||||
double bb[] = {ux1,ux2};
|
||||
|
@ -406,7 +462,17 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
colors = realloc(colors,sizeof *colors *((c_len+1)*5));
|
||||
//ab_to_vp(nn1,nn2,get_w(),get_h(),abba->c[hhi].at.x,abba->c[hhi].at.y)
|
||||
//printf("%f->%f %f->%f\n",abba->c[hhi].at.x,nn1,abba->c[hhi].at.y,nn2);
|
||||
|
||||
int brr = 0;
|
||||
for(int yyu = 0; yyu!=c->len; yyu++){
|
||||
if(!(pixels[yyu*2]==ux2&&pixels[yyu*2+1]==uy2)&&!(pixels[yyu*2]==ux1&&pixels[yyu*2+1]==uy1)&&
|
||||
diff(pixels[yyu*2],asd->c[lli].at.x)<1.0f/get_w()&&
|
||||
diff(pixels[yyu*2+1],asd->c[lli].at.y)<1.0f/get_h()){
|
||||
brr=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(brr)
|
||||
break;
|
||||
pixels[c_len*2] = asd->c[lli].at.x;
|
||||
pixels[c_len*2+1] = asd->c[lli].at.y;
|
||||
colors[c_len*3] = color2;
|
||||
|
@ -432,8 +498,8 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
colors = realloc(colors,sizeof *colors *((c_len+1)*5));
|
||||
//ab_to_vp(nn1,nn2,get_w(),get_h(),abba->c[hhi].at.x,abba->c[hhi].at.y)
|
||||
//printf("%f->%f %f->%f\n",abba->c[hhi].at.x,nn1,abba->c[hhi].at.y,nn2);
|
||||
pixels[c_len*2] = ux1;
|
||||
pixels[c_len*2+1] = uy1;
|
||||
pixels[c_len*2] = ux2;
|
||||
pixels[c_len*2+1] = uy2;
|
||||
colors[c_len*3] = color2;
|
||||
colors[c_len*3+1] = color;//vvi==3?0.1f:vvi==4?0.5f:1.0f;
|
||||
colors[c_len*3+2] = 0.0f;
|
||||
|
@ -448,7 +514,7 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
free(trline->at);
|
||||
free(trline);
|
||||
//return;
|
||||
glPointSize(5.0f);
|
||||
glPointSize(4.0f);
|
||||
//glUseProgram(prog);
|
||||
//glVertexAttribPointer(0,3,GL_FLOAT,0, 7*4,0);
|
||||
//glVertexAttribPointer(3,4,GL_FLOAT,0, 7*4,3*4);
|
||||
|
@ -477,16 +543,7 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
glBindBuffer(GL_ARRAY_BUFFER,colorb);
|
||||
glVertexAttribPointer(1,3,GL_FLOAT,GL_FALSE,0,(void*)0);
|
||||
*/// return;
|
||||
|
||||
const GLfloat tr[] = {
|
||||
1.0f, 1.0f,
|
||||
1.0f, -1.0f,
|
||||
-1.0f, -1.0f,
|
||||
|
||||
-1.0f, -1.0f,
|
||||
-1.0f, 1.0f,
|
||||
1.0f, 1.0f,
|
||||
};
|
||||
|
||||
GLuint verta;
|
||||
glGenVertexArrays(1,&verta);
|
||||
glBindVertexArray(verta);
|
||||
|
@ -495,7 +552,7 @@ void perspective_proj(GLFWwindow* b,point_arr* c,double ctx,double cty,double ct
|
|||
glGenBuffers(1,&vetb);
|
||||
glBindBuffer(GL_ARRAY_BUFFER,vetb);
|
||||
glBufferData(GL_ARRAY_BUFFER,sizeof(*pixels)*(c_len*3),pixels,GL_STATIC_DRAW);
|
||||
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER,vetb);
|
||||
glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,0,(void*)0);
|
||||
|
@ -546,13 +603,15 @@ point_arr* basier3d(double*xx,double*yy,double*zz,int n,float rr, float gg, floa
|
|||
//double yy[5] = {5.0,5.0,5.0,5.0,10.0};
|
||||
//double zz[5] = {10.0,5.0,5.0,5.0,5.0};
|
||||
//int n = 5-1;
|
||||
pa->len = get_w();
|
||||
|
||||
n-=1;
|
||||
|
||||
|
||||
double aaar = (1.0/get_w());
|
||||
for(int iy = 0; iy<=get_w();iy+=1){
|
||||
double t = aaar*iy;
|
||||
double am = 2;
|
||||
pa->len = am;
|
||||
for(int iy = 0; iy<=2;iy+=1){
|
||||
double t = (1.0/am)*iy;
|
||||
double bcx = 0;
|
||||
double bcy = 0;
|
||||
double bcz = 0;
|
||||
|
@ -833,7 +892,11 @@ int main(int argc,char*argv[]){
|
|||
double pl_z = 0;
|
||||
double plr_x = 0;
|
||||
double plr_y = 0;
|
||||
clock_t t;
|
||||
double frames = 0;
|
||||
t = clock();
|
||||
for(;;){
|
||||
|
||||
double p1 = plr_x*0.01;
|
||||
double p2 = plr_y*0.01;
|
||||
double p3 = 0;
|
||||
|
@ -845,10 +908,19 @@ int main(int argc,char*argv[]){
|
|||
|
||||
glfw_load(w);
|
||||
//break;
|
||||
int mod_move=1;
|
||||
int mod_move=5;
|
||||
double run_mul=2;
|
||||
//usleep(10000);
|
||||
glfwPollEvents();
|
||||
if(glfwGetKey(w,GLFW_KEY_R)){
|
||||
pl_x = 0;
|
||||
pl_y = 0;
|
||||
pl_z = 0;
|
||||
plr_x = 0;
|
||||
plr_y = 0;
|
||||
}
|
||||
if(glfwGetKey(w,GLFW_KEY_P))
|
||||
printf("(x:%f,y:%f,z:%f),rot(x:%f,y:%f,z:%f)||l(p1:%f,p2:%f,p3:%f,p4:%f,p5:%f,p6:%f)\n",pl_x,pl_y,pl_z,plr_x,plr_y,0.0,p1,p2,p3,p4,p5,p6);
|
||||
if(glfwGetKey(w,GLFW_KEY_I)){
|
||||
if(glfwGetKey(w,GLFW_KEY_LEFT_SHIFT))
|
||||
plr_x-=mod_move;
|
||||
|
@ -913,16 +985,24 @@ int main(int argc,char*argv[]){
|
|||
pl_x+=cosf((half_max_r+plr_y)*0.01)*mul;
|
||||
pl_y+=sinf((half_max_r+plr_y)*0.01)*mul;
|
||||
}
|
||||
if(glfwGetKey(w,GLFW_KEY_O))
|
||||
NUU+=0.1;
|
||||
if(glfwGetKey(w,GLFW_KEY_P))
|
||||
NUU-=0.1;
|
||||
//printf("%f\n",NUU);
|
||||
/*if(glfwGetKey(w,GLFW_KEY_M))
|
||||
NUU+=0.001;
|
||||
if(glfwGetKey(w,GLFW_KEY_N))
|
||||
NUU-=0.001;
|
||||
printf("%f\n",NUU);*/
|
||||
//printf("%f %f %f\n",plr_y,cosf(plr_y*0.01),sinf(plr_y*0.01));
|
||||
usleep(1000*1000/60);
|
||||
//usleep(1000*1000/60);
|
||||
glfw_clear(w);
|
||||
|
||||
if(glfwWindowShouldClose(w)||(glfwGetKey(w,GLFW_KEY_Q)))break;
|
||||
//t = clock() - t;
|
||||
frames+=1;
|
||||
if(((double)clock() - t)/CLOCKS_PER_SEC > 1){
|
||||
printf("%f fps\n",frames);
|
||||
frames=0;
|
||||
t = clock();
|
||||
}
|
||||
//printf("took %f\n",((double)clock() - t)/CLOCKS_PER_SEC);
|
||||
}
|
||||
free(a->c);
|
||||
free(a->vert);
|
||||
|
|
Loading…
Reference in New Issue