Example #1
0
void WallsUnits::applyHeightCorrections(ULength& dist, UAngle& fsInc, UAngle& bsInc, ULength ih, ULength th) const
{
    if (inch.isNonzero() || ih.isNonzero() || th.isNonzero())
    {
        UAngle inc = avgInc(fsInc + incv, bsInc + incvb);
        if (inc.isValid() && !isVertical(inc))
        {
            // horizontal offset before height correction
            ULength ne = ucos(inc) * (dist + incd);
            // vertical offset before height correction
            ULength u = usin(inc) * (dist + incd);

            u += inch;
            if (ih.isValid()) u += ih;
            if (th.isValid()) u -= th;

            // adjust fsInc/bsInc so that their new avg
            // is the corrected inclination
            UAngle dinc = uatan2(u, ne) - inc;
            fsInc += dinc;
            bsInc += (typevb_corrected ? dinc : -dinc);

            dist = usqrt(usq(ne) + usq(u)) - incd;
        }
    }
}
Example #2
0
void drawCircle(const glPoint* point,GLfloat radius,const GLfloat* color,float width,int isFilled){
	/*座標設定*/
	glPushMatrix();
	glTranslatef(point->x,point->y,0.0);
	/*太さ設定*/
	glLineWidth(width);
	/*ブレンド設定*/
	int is_blend = (color[3] != 1.0);
	if(is_blend){
		glEnable( GL_BLEND );
		glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	}else{
		glDisable( GL_BLEND );
	}
	/*カラー設定*/
	glColor4fv(color);
	/*頂点設定*/
	GLfloat vertex[724];
	int idx;
	if(isFilled){
		vertex[0] = vertex[1] = 0.0f;
		vertex[722] = radius;
		vertex[723] = 0.0f;
		idx = 1;
	}else{
		idx = 0;
	}
	int i=0;
	int arr_idx = 0;
	for(;i<360;i++){
		arr_idx = (idx+i)<<1;
		vertex[arr_idx] = (radius*ucos(i)) / BIT_POINT;
		vertex[arr_idx+1] = (radius*usin(i)) / BIT_POINT;
	}
	glEnableClientState( GL_VERTEX_ARRAY );
	glVertexPointer( 2, GL_FLOAT, 0, vertex );

	if(isFilled){
		glDrawArrays( GL_TRIANGLE_FAN, 0, 362 );
	}else{
		glDrawArrays( GL_LINE_LOOP, 0, 360 );
	}
	if(is_blend){
		glDisable( GL_BLEND );
	}
	glPopMatrix();
}
Example #3
0
void render_cubes(float time)
{
	int i;

	OLRenderParams mpar;

	memcpy(&mpar, &params, sizeof(OLRenderParams));

	if (time > 32) {
		time += 1.0;
		mpar.on_speed = 0.022 + (1-usin(time, 2.0)) * 0.02;
		mpar.corner_dwell = 8*usin(time, 2.0);
		mpar.start_dwell = 2+3*usin(time, 2.0);
		mpar.start_wait = 3+5*usin(time, 2.0);
		mpar.end_dwell = 2+3*usin(time, 2.0);
		mpar.end_wait = 2*usin(time, 2.0);
		olSetRenderParams(&mpar);
		time -= 1.0;
	}
	printf("%f %d %d %d %d %d\n", mpar.on_speed, mpar.corner_dwell, mpar.start_dwell, mpar.start_wait, mpar.end_dwell, mpar.end_wait);

	olLoadIdentity3();
	olPerspective(60, 1, 1, 100);
	olTranslate3(0, 0, -2.1);

	for(i=0; i<3; i++) {
		if (i>0)
			olPushMatrix3();
		olScale3(0.6, 0.6, 0.6);
		if (i>0) {
			float tx = sinf(time + (i-1)*M_PI);
			float ty = cosf(time + (i-1)*M_PI);
			float tz = sinf(time + (i-1)*M_PI);
			float s = sinf(0.6*time);
			olTranslate3(tx*s,ty*s,tz*s);
			//olScale3(s,s,s);
			olScale3(0.3,0.3,0.3);
		}

		float mult;
		if (i==0)
			mult = 1;
		else if (i==1)
			mult = 1.5;
		else if (i==2)
			mult = -1.5;

		if (i==0)
			olMultColor(C_GREY(120));
		else
			olResetColor();



		olRotate3Z(mult*time * M_PI * 0.1 / 3.0);
		olRotate3Y(mult*time * M_PI * 0.8 / 3.0);
		olRotate3X(mult*time * M_PI * 0.73 / 3.0);

		olBegin(OL_LINESTRIP);
		olVertex3(-1, -1, -1, C_RED);
		olVertex3( 1, -1, -1, C_RED);
		olVertex3( 1,  1, -1, C_RED);
		olVertex3(-1,  1, -1, C_RED);
		olVertex3(-1, -1, -1, C_RED);
		olVertex3(-1, -1,  1, C_RED);
		olEnd();

		olBegin(OL_LINESTRIP);
		olVertex3( 1,  1,  1, C_GREEN);
		olVertex3(-1,  1,  1, C_GREEN);
		olVertex3(-1, -1,  1, C_GREEN);
		olVertex3( 1, -1,  1, C_GREEN);
		olVertex3( 1,  1,  1, C_GREEN);
		olVertex3( 1,  1, -1, C_GREEN);
		olEnd();

		olBegin(OL_LINESTRIP);
		olVertex3( 1, -1, -1, C_RED);
		olVertex3( 1, -1,  1, C_RED);
		olEnd();

		olBegin(OL_LINESTRIP);
		olVertex3(-1,  1,  1, C_GREEN);
		olVertex3(-1,  1, -1, C_GREEN);
		olEnd();

		/*olBegin(OL_BEZIERSTRIP);
		olVertex3(-1, 1, 0, C_WHITE);
		olVertex3(0, -1, 0, C_WHITE);
		olVertex3(0, -1, 0, C_WHITE);
		olVertex3(1, 1, 0, C_WHITE);
		olVertex3(-1, 0, 0, C_WHITE);
		olVertex3(-1, 0, 0, C_WHITE);
		olVertex3(1, -1, 0, C_WHITE);
		olVertex3(0, 1, 0, C_WHITE);
		olVertex3(0, 1, 0, C_WHITE);
		olVertex3(-1, -1, 0, C_WHITE);
		olVertex3(1, 0, 0, C_WHITE);
		olVertex3(1, 0, 0, C_WHITE);
		olVertex3(-1, 1, 0, C_WHITE);
		olEnd();*/
		if (i>0)
			olPopMatrix3();
	}
	olLoadIdentity3();
	olLoadIdentity();
	olSetRenderParams(&params);
	olResetColor();
}
Example #4
0
int16 __ext_sin_int16 ( int16 y ) {
	return (int16)usin(y);
}