本文整理汇总了C++中Mat4::mul方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4::mul方法的具体用法?C++ Mat4::mul怎么用?C++ Mat4::mul使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4
的用法示例。
在下文中一共展示了Mat4::mul方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Mat4 * get_transformation(Transform *self)
{
Mat4 *t = NULL;
Mat4 *r = NULL;
Mat4 *s = NULL;
t = mat4_init_translation(self->translation->x,
self->translation->y,
self->translation->z);
r = mat4_init_rotation(self->rotation->x,
self->rotation->y,
self->rotation->z);
s = mat4_init_scaling(self->scaling->x,
self->scaling->y,
self->scaling->z);
if (t && r && s)
{
return(s->mul(s, (t->mul(t,r))));
}
else
{
return(NULL);
}
}
示例2:
Mat4 Mat4::scaled(float x, float y, float z) const {
Mat4 m;
m.v[0] = x;
m.v[5] = y;
m.v[10] = z;
return m.mul(*this);
}
示例3: sinf
Mat4 Mat4::rotated(float angle, const Vec4 &axis) const {
Mat4 m;
Vec4 r = axis.normalized();
float c, s, t;
s = sinf(angle);
c = cosf(angle);
t = 1.0f - c;
m[0] = t * r[0] * r[0] + c;
m[1] = t * r[0] * r[1] - s * r[2];
m[2] = t * r[0] * r[2] + s * r[1];
m[3] = 0.0f;
m[4] = t * r[0] * r[1] + s * r[2];
m[5] = t * r[1] * r[1] + c;
m[6] = t * r[1] * r[2] - s * r[0];
m[7] = 0.0f;
m[8] = t * r[0] * r[2] - s * r[1];
m[9] = t * r[1] * r[2] + s * r[0];
m[10] = t * r[2] * r[2] + c;
m[11] = 0.0f;
m[12] = 0.0f;
m[13] = 0.0f;
m[14] = 0.0f;
m[15] = 1.0f;
return m.mul(*this);
}
示例4: input
void input() {
SDL_PumpEvents();
SDL_Event event;
while(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT) {
running = false;
}
}
uint8_t *keystate = SDL_GetKeyState(NULL);
static int spaceDownCount = 0;
if(keystate[SDLK_SPACE]) {
spaceDownCount++;
} else {
spaceDownCount = 0;
}
if(state == TITLE) {
if(keystate[SDLK_SPACE]) {
Mix_PlayChannelTimed(-1, Mix_LoadWAV("res/startGame.wav"), 0, -1);
Mix_PlayChannelTimed(-1, music, -1, -1);
state = GAME;
}
} else if(state == GAME) {
if(keystate[SDLK_SPACE] && spaceDownCount == 1) {
running = false;
}
if(keystate[SDLK_UP]) {
player_vector -= player_forward.scaled(0.010);
player_vector.normalize();
player_forward = player_forward.orth(player_vector);
player_forward.normalize();
}
if(keystate[SDLK_DOWN]) {
player_vector += player_forward.scaled(0.007);
player_vector.normalize();
player_forward = player_forward.orth(player_vector);
player_forward.normalize();
}
if(keystate[SDLK_LEFT]) {
Mat4 rot;
rot.rotate(-0.05, player_vector);
player_forward = rot.mul(player_forward);
player_forward.normalize();
}
if(keystate[SDLK_RIGHT]) {
Mat4 rot;
rot.rotate(0.05, player_vector);
player_forward = rot.mul(player_forward);
player_forward.normalize();
}
} else if(state == END) {
if(keystate[SDLK_SPACE] && spaceDownCount == 1) {
running = false;
}
}
}
示例5: setModelView
void Render::setModelView( const Mat4& view, const Mat4& model ){
Mat4 modelview=view.mul(model);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelview);
}