Esempio n. 1
0
// Draw pixel-space box
void HUD_Box(LWViewportInfo *ViewGlobal, const LWCustomObjAccess *cob, Matrix m, LWDVector corn, double w, double h, int flags)
{
    LWDVector		a,b,c,p, home;

    VCPY(b, corn);
    b[0] += w;
    VCPY(a, b);
    b[1] -= h;
    VCPY(c, corn);
    c[1] -= h;
    VCPY(p,a);
    MatrixApply(a, m,p);
    VCPY(p,b);
    MatrixApply(b, m,p);
    VCPY(p,c);
    MatrixApply(c, m,p);
    MatrixApply(p, m,corn);

    HUDPosition(ViewGlobal, cob->view, home, cob->viewDir);

    VADD(a, home);
    VADD(b, home);
    VADD(c, home);
    VADD(p, home);

    cob->line(cob->dispData, p, a, LWCSYS_WORLD);
    cob->line(cob->dispData, a, b, LWCSYS_WORLD);
    cob->line(cob->dispData, b, c, LWCSYS_WORLD);
    cob->line(cob->dispData, c, p, LWCSYS_WORLD);
    if(flags&HUDF_FILL)
    {
        cob->triangle(cob->dispData, p, a, b, LWCSYS_WORLD);
        cob->triangle(cob->dispData, c, p, b, LWCSYS_WORLD);
    }
}
Esempio n. 2
0
	void MatrixTranslate(GLSLscalar tx, GLSLscalar ty)
	{
		mvp_matrix_[12] += (mvp_matrix_[0] * tx) + (mvp_matrix_[4] * ty);
		mvp_matrix_[13] += (mvp_matrix_[1] * tx) + (mvp_matrix_[5] * ty);
		//mvp_matrix_[14] += (mvp_matrix_[2] * tx) + (mvp_matrix_[6] * ty);
		//mvp_matrix_[15] += (mvp_matrix_[3] * tx) + (mvp_matrix_[7] * ty);
		MatrixApply();
	}
Esempio n. 3
0
	void _TEXTURE_PROGRAM_ACTIVATE()
	{
		ActiveProgram = TEXTURE;
		glUseProgram(_TEXTURE_PROGRAM);
		UNI_MVP = TEXTURE_UNI_MVP;
		glEnableVertexAttribArrayUnbuffered(ATTR_TEXCOORD); //always required
		MatrixApply();
	}
Esempio n. 4
0
	void _COLOR_PROGRAM_ACTIVATE()
	{
		ActiveProgram = COLOR;
		glDisableVertexAttribArrayUnbuffered(ATTR_TEXCOORD);
		glUseProgram(_COLOR_PROGRAM);
		UNI_MVP = COLOR_UNI_MVP;
		MatrixApply();
	}
Esempio n. 5
0
// transform pixel point into world space in place
void HUD_Point(LWViewportInfo *ViewGlobal, const LWCustomObjAccess *cob, Matrix m, LWDVector pt)
{
    LWDVector		p;

    VCPY(p,pt);
    MatrixApply(pt, m,p);
    HUDPosition(ViewGlobal, cob->view, p, cob->viewDir);
    VADD(pt, p);
}
Esempio n. 6
0
	void MatrixRotate(GLSLscalar rcos, GLSLscalar rsin)
	{
		for (int i = 0; i < /*4*/ 2; i++)
		{
			GLSLscalar tmp = mvp_matrix_[i];
			mvp_matrix_[  i] = (mvp_matrix_[4+i] * rsin) + (tmp * rcos);
			mvp_matrix_[4+i] = (mvp_matrix_[4+i] * rcos) - (tmp * rsin);
			mvp_matrix_[8+i] *= rcos;
		}
		MatrixApply();
	}
Esempio n. 7
0
	void MatrixRotate(GLSLscalar angle_rad)
	{
		GLSLscalar sinAngle = ssin(angle_rad), cosAngle = scos(angle_rad);
		for (int i = 0; i < /*4*/ 2; i++)
		{
			GLSLscalar tmp = mvp_matrix_[i];
			mvp_matrix_[  i] = (mvp_matrix_[4+i] * sinAngle) + (tmp * cosAngle);
			mvp_matrix_[4+i] = (mvp_matrix_[4+i] * cosAngle) - (tmp * sinAngle);
			mvp_matrix_[8+i] *= cosAngle;
		}
		MatrixApply();
	}
Esempio n. 8
0
	void MatrixScale(GLSLscalar sx, GLSLscalar sy)
	{
		mvp_matrix_[0] *= sx;
		mvp_matrix_[1] *= sx;
		//mvp_matrix_[2] *= sx;
		//mvp_matrix_[3] *= sx;
		mvp_matrix_[4] *= sy;
		mvp_matrix_[5] *= sy;
		//mvp_matrix_[6] *= sy;
		//mvp_matrix_[7] *= sy;
		MatrixApply();
	}
Esempio n. 9
0
void HUD_Line(LWViewportInfo *ViewGlobal, const LWCustomObjAccess *cob, Matrix m, LWDVector corn, double w, int flags)
{
    LWDVector		a,b,c,p, home;

    VCPY(b, corn);
    VCPY(a, b);
    b[0] += w;
    VCPY(p,a);
    MatrixApply(a, m,p);
    VCPY(p,b);
    MatrixApply(b, m,p);
    if(flags&HUDF_FILL)
    {
        VCPY(c, corn);
        c[0]+= 1;
        c[1]-= 1;
        c[2]+=1;
        VCPY(p, c);
        p[0] += w;
        VCPY(home,c);
        MatrixApply(c, m,home);
        VCPY(home,p);
        MatrixApply(p, m,home);
    }
    HUDPosition(ViewGlobal, cob->view, home, cob->viewDir);

    VADD(a, home);
    VADD(b, home);
    cob->line(cob->dispData, a, b, LWCSYS_WORLD);
    if(flags&HUDF_FILL)
    {
        float	shad[4] = {0, 0, 0, 0.5f};
        cob->setColor(cob->dispData, shad); // dangerous side-effect, leaves color changed
        VADD(c, home);
        VADD(p, home);
        cob->line(cob->dispData, c, p, LWCSYS_WORLD);
    }

}
Esempio n. 10
0
	void MatrixOrtho(GLSLscalar left, GLSLscalar right, GLSLscalar bottom, GLSLscalar top)
	{
		scalar deltaX = right - left, deltaY = top - bottom;
		if ((deltaX == 0.0f) || (deltaY == 0.0f)) return;
		memset(mvp_matrix_, 0, sizeof(GLSLscalar)*16);
		mvp_matrix_[0] = 2.0f / deltaX;
		mvp_matrix_[12] = -(right + left) / deltaX;
		mvp_matrix_[5] = 2.0f / deltaY;
		mvp_matrix_[13] = -(top + bottom) / deltaY;
		mvp_matrix_[10] = -1.0f;
		mvp_matrix_[15] = 1.0f;
		MatrixApply();
	}
Esempio n. 11
0
	void MatrixTransformReverse(GLSLscalar tx, GLSLscalar ty, GLSLscalar rcos, GLSLscalar rsin)
	{
		for (int i = 0; i < /*4*/ 2; i++)
		{
			GLSLscalar tmp = mvp_matrix_[i];
			mvp_matrix_[  i] = (tmp * rcos) - (mvp_matrix_[4+i] * rsin);
			mvp_matrix_[4+i] = (tmp * rsin) + (mvp_matrix_[4+i] * rcos);
			mvp_matrix_[8+i] *= rcos;
		}
		mvp_matrix_[12] -= (mvp_matrix_[0] * tx) + (mvp_matrix_[4] * ty);
		mvp_matrix_[13] -= (mvp_matrix_[1] * tx) + (mvp_matrix_[5] * ty);
		//mvp_matrix_[14] -= (mvp_matrix_[2] * tx) + (mvp_matrix_[6] * ty);
		//mvp_matrix_[15] -= (mvp_matrix_[3] * tx) + (mvp_matrix_[7] * ty);
		MatrixApply();
	}
Esempio n. 12
0
void HUD_Knob(LWViewportInfo *ViewGlobal, const LWCustomObjAccess *cob, Matrix m, LWDVector cent, double siz, int flags)
{
    LWDVector   a, b, c, home;

    VCPY(a, cent);
    VCPY(b, cent);
    VCPY(c, cent);
    siz *= 0.5;

    if(flags&HUDF_SIDE)
    {
        a[0] += siz;
        b[0] -= siz;
        c[0] -= siz;
        b[1] -= siz;
        c[1] += siz;
    }
    else if(flags&HUDF_DOWN)
    {
        a[0] += siz;
        b[0] -= siz;
        a[1] += siz;
        b[1] += siz;
        c[1] -= siz;
    }
    else
    {
        a[0] += siz;
        b[0] -= siz;
        a[1] -= siz;
        b[1] -= siz;
        c[1] += siz;
    }

    VCPY(home,a);
    MatrixApply(a, m,home);
    VCPY(home,b);
    MatrixApply(b, m,home);
    VCPY(home,c);
    MatrixApply(c, m,home);
    HUDPosition(ViewGlobal, cob->view, home, cob->viewDir);

    VADD(a, home);
    VADD(b, home);
    VADD(c, home);

    if(flags&HUDF_LOCK)
    {
        LWDVector	d, p;
        VCPY(d, cent);
        VCPY(c, cent);
        d[0] += siz;
        c[0] -= siz;
        c[1] += siz;
        d[1] += siz;
        VCPY(p,c);
        MatrixApply(c, m,p);
        VCPY(p,d);
        MatrixApply(d, m,p);
        VADD(d, home);
        VADD(c, home);

        cob->line(cob->dispData, a, b, LWCSYS_WORLD);
        cob->line(cob->dispData, c, b, LWCSYS_WORLD);
        cob->line(cob->dispData, c, d, LWCSYS_WORLD);
        cob->line(cob->dispData, a, d, LWCSYS_WORLD);
    }
    else if(flags&HUDF_FILL)
    {
        float	shad[4] = {0, 0, 0, 0.5f}, glint[4] = {1, 1, 1, 0.5f};
        cob->triangle(cob->dispData, a, b, c, LWCSYS_WORLD);
        cob->setColor(cob->dispData, glint);
        cob->line(cob->dispData, c, b, LWCSYS_WORLD);
        cob->setColor(cob->dispData, shad); // dangerous side-effect, leaves color changed
        cob->line(cob->dispData, a, b, LWCSYS_WORLD);
        cob->line(cob->dispData, a, c, LWCSYS_WORLD);
    }
    else
    {
        cob->line(cob->dispData, a, b, LWCSYS_WORLD);
        cob->line(cob->dispData, c, b, LWCSYS_WORLD);
        cob->line(cob->dispData, a, c, LWCSYS_WORLD);
    }
}
Esempio n. 13
0
	void MatrixIdentity()
	{
		memset(mvp_matrix_, 0, sizeof(GLSLscalar)*16);
		mvp_matrix_[0] = mvp_matrix_[5] = mvp_matrix_[10] = mvp_matrix_[15] = 1.0f;
		MatrixApply();
	}
Esempio n. 14
0
	void MatrixPop()
	{
		if (mvp_matrix_ == mvp_matrix_start) return;
		mvp_matrix_ -= 16;
		MatrixApply();
	}