예제 #1
0
void LXTransform3DSetIdentity(LXTransform3DRef r)
{
    if ( !r) return;
    LXTransform3DImpl *imp = (LXTransform3DImpl *)r;
    
    setIdentityMatrix(&(imp->mat));
}
예제 #2
0
// Defines a transformation matrix mat with a scale
void setScaleMatrix(float *mat, float sx, float sy, float sz) {

	setIdentityMatrix(mat,4);
	mat[0] = sx;
	mat[5] = sy;
	mat[10] = sz;
}
// Defines a transformation matrix mat with a translation
void setTranslationMatrix(float *mat, float x, float y, float z)
{
	setIdentityMatrix(mat,4);
	mat[12] = x;
	mat[13] = y;
	mat[14] = z;
}
예제 #4
0
파일: mat4.cpp 프로젝트: NoRines/3d_motor
 mat4& mat4::setScalingMatrix(const vec3& scaling)
 {
         setIdentityMatrix();
         setElement(0, 0, scaling.x);
         setElement(1, 1, scaling.y);
         setElement(2, 2, scaling.z);
         return *this;
 }
예제 #5
0
파일: mat4.cpp 프로젝트: NoRines/3d_motor
 mat4& mat4::setTranslationMatrix(const vec3& translation)
 {
         setIdentityMatrix();
         setElement(3, 0, translation.x);
         setElement(3, 1, translation.y);
         setElement(3, 2, translation.z);
         return *this;
 }
예제 #6
0
파일: vsml.c 프로젝트: arokem/Fos
// glLoadIdentity implementation
void
VSML::loadIdentity(MatrixTypes aType)
{
    setIdentityMatrix(mMatrix[aType]);
 
#ifdef VSML_ALWAYS_SEND_TO_OPENGL
    matrixToGL(aType);
#endif
}
예제 #7
0
void setRotateMatrixZ(ofMatrix4x4 & _m, double angle) {
    double sine = sin(angle);
    double cosine = cos(angle);
    setIdentityMatrix(_m);
    _m(0,0) = cosine;
    _m(0,1) = -sine;
    _m(1,0) = sine;
    _m(1,1) = cosine;
};
예제 #8
0
void doTranslationMatrix(float x, float y, float z, float* m) {
	memset(m, 0, 16 *sizeof(*m));

	setIdentityMatrix(m, 4);

	m[3] = x;
	m[7] = y;
	m[11] = z;
}
예제 #9
0
파일: matrix.cpp 프로젝트: jhk2/dxsandbox
void Matrix::translate(const float x, const float y, const float z)
{
    float mat[16];
    setIdentityMatrix(mat);
    mat[12] = x;
    mat[13] = y;
    mat[14] = z;

    multMatrix(mat);
}
예제 #10
0
void doRotationMatrixX(float degree, float *m) {
	memset(m, 0, 16 *sizeof(*m));

	setIdentityMatrix(m, 4);

	m[5] = cos(degree);
	m[6] = -sin(degree);
	m[9] = sin(degree);
	m[10] = cos(degree);
}
예제 #11
0
파일: matrix.cpp 프로젝트: jhk2/dxsandbox
void Matrix::ortho(const float left, const float right, const float bottom, const float top, const float nearp, const float farp)
{
    setIdentityMatrix(entries_);
    entries_[0] = 2 / (right - left);
    entries_[5] = 2 / (top - bottom);
    entries_[10] = -2 / (farp - nearp);
    entries_[12] = -(right + left) / (right - left);
    entries_[13] = -(top + bottom) / (top - bottom);
    entries_[14] = -(farp + nearp) / (farp - nearp);
}
예제 #12
0
파일: mat4.cpp 프로젝트: NoRines/3d_motor
        mat4& mat4::setLookAtMatrix(const vec3& forward, const vec3& up, const vec3& right)
        {
                setIdentityMatrix();

                setElement(0, 0, right.x);      setElement(1, 0, right.y);      setElement(2, 0, right.z);
                setElement(0, 1, up.x);         setElement(1, 1, up.y);         setElement(2, 1, up.z);
                setElement(0, 2, forward.x);    setElement(1, 2, forward.y);    setElement(2, 2, forward.z);

                return *this;
        }
예제 #13
0
파일: matrix.cpp 프로젝트: jhk2/dxsandbox
void Matrix::scale(const float x, const float y, const float z)
{
    float mat[16];
    setIdentityMatrix(mat);
    mat[0] = x;
    mat[5] = y;
    mat[10] = z;

    multMatrix(mat);
}
예제 #14
0
파일: vsml.c 프로젝트: arokem/Fos
// gluLookAt implementation
void
VSML::lookAt(float xPos, float yPos, float zPos,
                    float xLook, float yLook, float zLook,
                    float xUp, float yUp, float zUp)
{
    float dir[3], right[3], up[3];
 
    up[0] = xUp;    up[1] = yUp;    up[2] = zUp;
 
    dir[0] =  (xLook - xPos);
    dir[1] =  (yLook - yPos);
    dir[2] =  (zLook - zPos);
    normalize(dir);
 
    crossProduct(dir,up,right);
    normalize(right);
 
    crossProduct(right,dir,up);
    normalize(up);
 
    float m1[16],m2[16];
 
    m1[0]  = right[0];
    m1[4]  = right[1];
    m1[8]  = right[2];
    m1[12] = 0.0f;
 
    m1[1]  = up[0];
    m1[5]  = up[1];
    m1[9]  = up[2];
    m1[13] = 0.0f;
 
    m1[2]  = -dir[0];
    m1[6]  = -dir[1];
    m1[10] = -dir[2];
    m1[14] =  0.0f;
 
    m1[3]  = 0.0f;
    m1[7]  = 0.0f;
    m1[11] = 0.0f;
    m1[15] = 1.0f;
 
    setIdentityMatrix(m2,4);
    m2[12] = -xPos;
    m2[13] = -yPos;
    m2[14] = -zPos;
 
    multMatrix(MODELVIEW, m1);
    multMatrix(MODELVIEW, m2);
 
#ifdef VSML_ALWAYS_SEND_TO_OPENGL
    matrixToGL(MODELVIEW);
#endif
}
예제 #15
0
// glScale implementation with matrix selection
void scale(MatrixTypes aType, float x, float y, float z) 
{
	float mat[16];

	setIdentityMatrix(mat,4);
	mat[0] = x;
	mat[5] = y;
	mat[10] = z;

	multMatrix(aType,mat);
}
예제 #16
0
파일: SPED3.cpp 프로젝트: srjek/dcpu16
 void buildProjectionMatrix(float fov, float ratio, float nearP, float farP) {
     float f = 1.0f / tan(fov * PI / 360.0f);
     setIdentityMatrix(projMatrix,4);
  
     projMatrix[0] = f / ratio;
     projMatrix[1 * 4 + 1] = f;
     projMatrix[2 * 4 + 2] = -(nearP+farP) / (nearP - farP);
     projMatrix[3 * 4 + 2] = (2*farP*nearP) / (nearP - farP);
     projMatrix[2 * 4 + 3] = 1.0f;
     projMatrix[3 * 4 + 3] = 0.0f;
 }
예제 #17
0
// glTranslate implementation with matrix selection
void translate(MatrixTypes aType, float x, float y, float z) 
{
	float mat[16];

	setIdentityMatrix(mat);
	mat[12] = x;
	mat[13] = y;
	mat[14] = z;

	multMatrix(aType,mat);
}
예제 #18
0
파일: gl_matrix.cpp 프로젝트: AkumaKing/Xeu
// gl Translate implementation with matrix selection
void 
VSMatrix::translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) 
{
	FLOATTYPE mat[16];

	setIdentityMatrix(mat);
	mat[12] = x;
	mat[13] = y;
	mat[14] = z;

	multMatrix(mat);
}
예제 #19
0
LXTransform3DRef LXTransform3DCreateWithMatrix(LX4x4Matrix *matrix)
{
    LXTransform3DRef r = LXTransform3DCreateIdentity();
    LXTransform3DImpl *imp = (LXTransform3DImpl *)r;
    
    if (matrix)
        imp->mat = *matrix;
    else
        setIdentityMatrix(&(imp->mat));
    
    return r;
}
예제 #20
0
파일: matrix.cpp 프로젝트: jhk2/dxsandbox
void Matrix::frustum(const float left, const float right, const float bottom, const float top, const float nearp, const float farp)
{
    setIdentityMatrix(entries_);
    entries_[0] = 2 * nearp / (right - left);
    entries_[5] = 2 * nearp / (top - bottom);
    entries_[8] = (right + left) / (right - left);
    entries_[9] = (top + bottom) / (top - bottom);
    entries_[10] = (farp + nearp) / (farp - nearp);
    entries_[11] = -1.0f;
    entries_[12] = 2 * farp * nearp / (farp - nearp);
    entries_[15] = 0.0f;
}
예제 #21
0
파일: gl_matrix.cpp 프로젝트: AkumaKing/Xeu
// gl Scale implementation with matrix selection
void 
VSMatrix::scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) 
{
	FLOATTYPE mat[16];

	setIdentityMatrix(mat,4);
	mat[0] = x;
	mat[5] = y;
	mat[10] = z;

	multMatrix(mat);
}
예제 #22
0
void buildProjectionMatrix(float fov, float ratio, float nr, float fr) {
 
    double f = 1.0f / tan (fov * (TwoPi / 720.0));
 
    setIdentityMatrix(projMatrix,4);
 
    projMatrix[0] = float(f) / ratio;
    projMatrix[1 * 4 + 1] = float(f);
    projMatrix[2 * 4 + 2] = (fr + nr) / (nr - fr);
    projMatrix[3 * 4 + 2] = (2.0f * fr * nr) / (nr - fr);
    projMatrix[2 * 4 + 3] = -1.0f;
    projMatrix[3 * 4 + 3] = 0.0f;
}
예제 #23
0
파일: matrix.cpp 프로젝트: jhk2/dxsandbox
void Matrix::perspective(const float fov, const float ratio, const float nearp, const float farp)
{
    const float f = 1.0f / tan(fov * (M_PI / 360.f));

    setIdentityMatrix(entries_);

    entries_[0] = f / ratio;
    entries_[5] = f;
    entries_[10] = (farp + nearp) / (nearp - farp);
    entries_[14] = (2.0f * farp * nearp) / (nearp - farp);
    entries_[11] = -1.0f;
    entries_[15] = 0.0f;
}
예제 #24
0
void LXTransform3DTranslate(LXTransform3DRef r, LXFloat tx, LXFloat ty, LXFloat tz)
{
    if ( !r) return;
    LX4x4Matrix mm;
    
    setIdentityMatrix(&mm);
    mm.m14 = tx;
    mm.m24 = ty;
    mm.m34 = tz;
    mm.m44 = 1.0;
    
    LXTransform3DConcatMatrix(r, &mm);
}
예제 #25
0
void LXTransform3DScale(LXTransform3DRef r, LXFloat sx, LXFloat sy, LXFloat sz)
{
    if ( !r) return;
    LX4x4Matrix mm;
    
    setIdentityMatrix(&mm);
    mm.m11 = sx;
    mm.m22 = sy;
    mm.m33 = sz;
    mm.m44 = 1.0;
    
    LXTransform3DConcatMatrix(r, &mm);
}
예제 #26
0
LXTransform3DRef LXTransform3DCreateIdentity()
{
    // LX4x4Matrix is a struct, but we want its size to be equal to a 4x4 array of floats --
    // check that the compiler doesn't do any evil padding
    assert(sizeof(LX4x4Matrix) == 4*4*sizeof(LXFloat));
    
    LXTransform3DImpl *imp = (LXTransform3DImpl *) _lx_calloc(sizeof(LXTransform3DImpl), 1);

    LXREF_INIT(imp, LXTransform3DTypeID(), LXTransform3DRetain, LXTransform3DRelease);

    setIdentityMatrix(&(imp->mat));

    return (LXTransform3DRef)imp;
}
예제 #27
0
파일: gl_matrix.cpp 프로젝트: AkumaKing/Xeu
// gluLookAt implementation
void 
VSMatrix::lookAt(FLOATTYPE xPos, FLOATTYPE yPos, FLOATTYPE zPos,
					FLOATTYPE xLook, FLOATTYPE yLook, FLOATTYPE zLook,
					FLOATTYPE xUp, FLOATTYPE yUp, FLOATTYPE zUp)
{
	FLOATTYPE dir[3], right[3], up[3];

	up[0] = xUp;	up[1] = yUp;	up[2] = zUp;

	dir[0] =  (xLook - xPos);
	dir[1] =  (yLook - yPos);
	dir[2] =  (zLook - zPos);
	normalize(dir);

	crossProduct(dir,up,right);
	normalize(right);

	crossProduct(right,dir,up);
	normalize(up);

	FLOATTYPE m1[16],m2[16];

	m1[0]  = right[0];
	m1[4]  = right[1];
	m1[8]  = right[2];
	m1[12] = 0.0f;

	m1[1]  = up[0];
	m1[5]  = up[1];
	m1[9]  = up[2];
	m1[13] = 0.0f;

	m1[2]  = -dir[0];
	m1[6]  = -dir[1];
	m1[10] = -dir[2];
	m1[14] =  0.0f;

	m1[3]  = 0.0f;
	m1[7]  = 0.0f;
	m1[11] = 0.0f;
	m1[15] = 1.0f;

	setIdentityMatrix(m2,4);
	m2[12] = -xPos;
	m2[13] = -yPos;
	m2[14] = -zPos;

	multMatrix(m1);
	multMatrix(m2);
}
예제 #28
0
// gluLookAt implementation
void lookAt(float xPos, float yPos, float zPos,
					float xLook, float yLook, float zLook,
					float xUp, float yUp, float zUp)
{
	float dir[3], right[3], up[3];

	up[0] = xUp;	up[1] = yUp;	up[2] = zUp;

	dir[0] =  (xLook - xPos);
	dir[1] =  (yLook - yPos);
	dir[2] =  (zLook - zPos);
	normalize(dir);

	crossProduct(dir,up,right);
	normalize(right);

	crossProduct(right,dir,up);
	normalize(up);

	float m1[16],m2[16];

	m1[0]  = right[0];
	m1[4]  = right[1];
	m1[8]  = right[2];
	m1[12] = 0.0f;

	m1[1]  = up[0];
	m1[5]  = up[1];
	m1[9]  = up[2];
	m1[13] = 0.0f;

	m1[2]  = -dir[0];
	m1[6]  = -dir[1];
	m1[10] = -dir[2];
	m1[14] =  0.0f;

	m1[3]  = 0.0f;
	m1[7]  = 0.0f;
	m1[11] = 0.0f;
	m1[15] = 1.0f;

	setIdentityMatrix(m2,4);
	m2[12] = -xPos;
	m2[13] = -yPos;
	m2[14] = -zPos;

	multMatrix(VIEW, m1);
	multMatrix(VIEW, m2);
}
예제 #29
0
파일: vsml.c 프로젝트: arokem/Fos
// glTranslate implementation with matrix selection
void
VSML::translate(MatrixTypes aType, float x, float y, float z)
{
    float mat[16];
 
    setIdentityMatrix(mat);
    mat[12] = x;
    mat[13] = y;
    mat[14] = z;
 
    multMatrix(aType,mat);
 
#ifdef VSML_ALWAYS_SEND_TO_OPENGL
    matrixToGL(aType);
#endif
}
예제 #30
0
파일: vsml.c 프로젝트: arokem/Fos
// glScale implementation with matrix selection
void
VSML::scale(MatrixTypes aType, float x, float y, float z)
{
    float mat[16];
 
    setIdentityMatrix(mat,4);
    mat[0] = x;
    mat[5] = y;
    mat[10] = z;
 
    multMatrix(aType,mat);
 
#ifdef VSML_ALWAYS_SEND_TO_OPENGL
    matrixToGL(aType);
#endif
}