本文整理汇总了C++中Matrix3x4::Rotate方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x4::Rotate方法的具体用法?C++ Matrix3x4::Rotate怎么用?C++ Matrix3x4::Rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3x4
的用法示例。
在下文中一共展示了Matrix3x4::Rotate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
//.........这里部分代码省略.........
if (RenderStyle.Flags & STYLEF_InvertOverlay)
{
Colormap.FadeColor = Colormap.FadeColor.InverseColor();
additivefog=false;
}
gl_SetFog(foglevel, rel, &Colormap, additivefog);
if (gltexture) gltexture->BindPatch(Colormap.colormap,translation);
else if (!modelframe) gl_RenderState.EnableTexture(false);
if (!modelframe)
{
// [BB] Billboard stuff
const bool drawWithXYBillboard = ( !(actor && actor->renderflags & RF_FORCEYBILLBOARD)
//&& GLRenderer->mViewActor != NULL
&& (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD )) );
gl_RenderState.Apply();
gl.Begin(GL_TRIANGLE_STRIP);
if ( drawWithXYBillboard )
{
// Rotate the sprite about the vector starting at the center of the sprite
// triangle strip and with direction orthogonal to where the player is looking
// in the x/y plane.
float xcenter = (x1+x2)*0.5;
float ycenter = (y1+y2)*0.5;
float zcenter = (z1+z2)*0.5;
float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw));
Matrix3x4 mat;
mat.MakeIdentity();
mat.Translate( xcenter, zcenter, ycenter);
mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch);
mat.Translate( -xcenter, -zcenter, -ycenter);
Vector v1 = mat * Vector(x1,z1,y1);
Vector v2 = mat * Vector(x2,z1,y2);
Vector v3 = mat * Vector(x1,z2,y1);
Vector v4 = mat * Vector(x2,z2,y2);
if (gltexture)
{
gl.TexCoord2f(ul, vt);
gl.Vertex3fv(&v1[0]);
gl.TexCoord2f(ur, vt);
gl.Vertex3fv(&v2[0]);
gl.TexCoord2f(ul, vb);
gl.Vertex3fv(&v3[0]);
gl.TexCoord2f(ur, vb);
gl.Vertex3fv(&v4[0]);
}
else // Particle
{
gl.Vertex3fv(&v1[0]);
gl.Vertex3fv(&v2[0]);
gl.Vertex3fv(&v3[0]);
gl.Vertex3fv(&v4[0]);
}
}
else
{
if (gltexture)
{
gl.TexCoord2f(ul, vt);
gl.Vertex3f(x1, z1, y1);
示例2: CalculateVertices
bool GLSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp)
{
const auto &HWAngles = di->Viewpoint.HWAngles;
if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
{
Matrix3x4 mat;
mat.MakeIdentity();
// [MC] Rotate around the center or offsets given to the sprites.
// Counteract any existing rotations, then rotate the angle.
// Tilt the actor up or down based on pitch (increase 'somersaults' forward).
// Then counteract the roll and DO A BARREL ROLL.
FAngle pitch = (float)-Angles.Pitch.Degrees;
pitch.Normalized180();
mat.Translate(x, z, y);
mat.Rotate(0, 1, 0, 270. - Angles.Yaw.Degrees);
mat.Rotate(1, 0, 0, pitch.Degrees);
if (actor->renderflags & RF_ROLLCENTER)
{
float cx = (x1 + x2) * 0.5;
float cy = (y1 + y2) * 0.5;
mat.Translate(cx - x, 0, cy - y);
mat.Rotate(0, 1, 0, - Angles.Roll.Degrees);
mat.Translate(-cx, -z, -cy);
}
else
{
mat.Rotate(0, 1, 0, - Angles.Roll.Degrees);
mat.Translate(-x, -z, -y);
}
v[0] = mat * FVector3(x2, z, y2);
v[1] = mat * FVector3(x1, z, y2);
v[2] = mat * FVector3(x2, z, y1);
v[3] = mat * FVector3(x1, z, y1);
return true;
}
// [BB] Billboard stuff
const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD)
//&& di->mViewActor != nullptr
&& (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD))));
const bool drawBillboardFacingCamera = gl_billboard_faces_camera;
// [Nash] has +ROLLSPRITE
const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE);
// [fgsfds] check sprite type mask
uint32_t spritetype = (uint32_t)-1;
if (actor != nullptr) spritetype = actor->renderflags & RF_SPRITETYPEMASK;
// [Nash] is a flat sprite
const bool isFlatSprite = (actor != nullptr) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE);
const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER);
// [Nash] check for special sprite drawing modes
if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite)
{
// Compute center of sprite
float xcenter = (x1 + x2)*0.5;
float ycenter = (y1 + y2)*0.5;
float zcenter = (z1 + z2)*0.5;
float xx = -xcenter + x;
float zz = -zcenter + z;
float yy = -ycenter + y;
Matrix3x4 mat;
mat.MakeIdentity();
mat.Translate(xcenter, zcenter, ycenter); // move to sprite center
// Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down).
if (drawBillboardFacingCamera && !isFlatSprite)
{
// [CMB] Rotate relative to camera XY position, not just camera direction,
// which is nicer in VR
float xrel = xcenter - vp->X;
float yrel = ycenter - vp->Y;
float absAngleDeg = RAD2DEG(atan2(-yrel, xrel));
float counterRotationDeg = 270. - HWAngles.Yaw.Degrees; // counteracts existing sprite rotation
float relAngleDeg = counterRotationDeg + absAngleDeg;
mat.Rotate(0, 1, 0, relAngleDeg);
}
// [fgsfds] calculate yaw vectors
float yawvecX = 0, yawvecY = 0, rollDegrees = 0;
float angleRad = (270. - HWAngles.Yaw).Radians();
if (actor) rollDegrees = Angles.Roll.Degrees;
if (isFlatSprite)
{
yawvecX = Angles.Yaw.Cos();
yawvecY = Angles.Yaw.Sin();
}
// [fgsfds] Rotate the sprite about the sight vector (roll)
if (spritetype == RF_WALLSPRITE)
//.........这里部分代码省略.........
示例3: gl_RenderModel
void gl_RenderModel(GLSprite * spr, int cm)
{
// [BB/EP] Take care of gl_fogmode and ZADF_FORCE_GL_DEFAULTS.
OVERRIDE_FOGMODE_IF_NECESSARY
FSpriteModelFrame * smf = spr->modelframe;
// Setup transformation.
gl.MatrixMode(GL_MODELVIEW);
gl.PushMatrix();
gl.DepthFunc(GL_LEQUAL);
// [BB] In case the model should be rendered translucent, do back face culling.
// This solves a few of the problems caused by the lack of depth sorting.
// TO-DO: Implement proper depth sorting.
if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] ))
{
gl.Enable(GL_CULL_FACE);
glFrontFace(GL_CW);
}
int translation = 0;
if ( !(smf->flags & MDL_IGNORETRANSLATION) )
translation = spr->actor->Translation;
// y scale for a sprite means height, i.e. z in the world!
float scaleFactorX = FIXED2FLOAT(spr->actor->scaleX) * smf->xscale;
float scaleFactorY = FIXED2FLOAT(spr->actor->scaleX) * smf->yscale;
float scaleFactorZ = FIXED2FLOAT(spr->actor->scaleY) * smf->zscale;
float pitch = 0;
float rotateOffset = 0;
float angle = ANGLE_TO_FLOAT(spr->actor->angle);
// [BB] Workaround for the missing pitch information.
if ( (smf->flags & MDL_PITCHFROMMOMENTUM) )
{
const double x = static_cast<double>(spr->actor->velx);
const double y = static_cast<double>(spr->actor->vely);
const double z = static_cast<double>(spr->actor->velz);
// [BB] Calculate the pitch using spherical coordinates.
pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180);
}
if( smf->flags & MDL_ROTATING )
{
const float time = smf->rotationSpeed*GetTimeFloat()/200.f;
rotateOffset = float((time - xs_FloorToInt(time)) *360.f );
}
if (gl_fogmode != 2 && (GLRenderer->mLightCount == 0 || !gl_light_models))
{
// Model space => World space
gl.Translatef(spr->x, spr->z, spr->y );
if ( !(smf->flags & MDL_ALIGNANGLE) )
gl.Rotatef(-angle, 0, 1, 0);
// [BB] Change the angle so that the object is exactly facing the camera in the x/y plane.
else
gl.Rotatef( -ANGLE_TO_FLOAT ( R_PointToAngle ( spr->actor->x, spr->actor->y ) ), 0, 1, 0);
// [BB] Change the pitch so that the object is vertically facing the camera (only makes sense combined with MDL_ALIGNANGLE).
if ( (smf->flags & MDL_ALIGNPITCH) )
{
const fixed_t distance = R_PointToDist2( spr->actor->x - viewx, spr->actor->y - viewy );
const float pitch = RAD2DEG ( atan2( FIXED2FLOAT ( spr->actor->z - viewz ), FIXED2FLOAT ( distance ) ) );
gl.Rotatef(pitch, 0, 0, 1);
}
// [BB] Workaround for the missing pitch information.
if (pitch != 0) gl.Rotatef(pitch, 0, 0, 1);
// [BB] Special flag for flat, beam like models.
if ( (smf->flags & MDL_ROLLAGAINSTANGLE) )
gl.Rotatef( gl_RollAgainstAngleHelper ( spr->actor ), 1, 0, 0);
// Model rotation.
// [BB] Added Doomsday like rotation of the weapon pickup models.
// The rotation angle is based on the elapsed time.
if( smf->flags & MDL_ROTATING )
{
gl.Translatef(smf->rotationCenterX, smf->rotationCenterY, smf->rotationCenterZ);
gl.Rotatef(rotateOffset, smf->xrotate, smf->yrotate, smf->zrotate);
gl.Translatef(-smf->rotationCenterX, -smf->rotationCenterY, -smf->rotationCenterZ);
}
// Scaling and model space offset.
gl.Scalef(scaleFactorX, scaleFactorZ, scaleFactorY);
// [BB] Apply zoffset here, needs to be scaled by 1 / smf->zscale, so that zoffset doesn't depend on the z-scaling.
gl.Translatef(0., smf->zoffset / smf->zscale, 0.);
gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), cm, NULL, NULL, translation );
}
else
{
Matrix3x4 ModelToWorld;
Matrix3x4 NormalTransform;
//.........这里部分代码省略.........