本文整理汇总了C++中idMat3类的典型用法代码示例。如果您正苦于以下问题:C++ idMat3类的具体用法?C++ idMat3怎么用?C++ idMat3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了idMat3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vec
void idSimpleWindow::SetupTransforms( float x, float y )
{
static idMat3 trans;
static idVec3 org;
trans.Identity();
org.Set( origin.x + x, origin.y + y, 0 );
if( rotate )
{
static idRotation rot;
static idVec3 vec( 0, 0, 1 );
rot.Set( org, vec, rotate );
trans = rot.ToMat3();
}
static idMat3 smat;
smat.Identity();
if( shear.x() || shear.y() )
{
smat[0][1] = shear.x();
smat[1][0] = shear.y();
trans *= smat;
}
if( !trans.IsIdentity() )
{
dc->SetTransformInfo( org, trans );
}
}
示例2: ClipPush
/*
============
idPush::ClipPush
Try to push other entities by moving the given entity.
============
*/
float idPush::ClipPush( trace_t &results, idEntity *pusher, const int flags,
const idVec3 &oldOrigin, const idMat3 &oldAxis,
idVec3 &newOrigin, idMat3 &newAxis ) {
idVec3 translation;
idRotation rotation;
float mass;
mass = 0.0f;
results.fraction = 1.0f;
results.endpos = newOrigin;
results.endAxis = newAxis;
memset( &results.c, 0, sizeof( results.c ) );
// translational push
translation = newOrigin - oldOrigin;
// if the pusher translates
if ( translation != vec3_origin ) {
mass += ClipTranslationalPush( results, pusher, flags, newOrigin, translation );
if ( results.fraction < 1.0f ) {
newOrigin = oldOrigin;
newAxis = oldAxis;
return mass;
}
} else {
newOrigin = oldOrigin;
}
// rotational push
rotation = ( oldAxis.Transpose() * newAxis ).ToRotation();
rotation.SetOrigin( newOrigin );
rotation.Normalize180();
rotation.ReCalculateMatrix(); // recalculate the rotation matrix to avoid accumulating rounding errors
// if the pusher rotates
if ( rotation.GetAngle() != 0.0f ) {
// recalculate new axis to avoid floating point rounding problems
newAxis = oldAxis * rotation.ToMat3();
newAxis.OrthoNormalizeSelf();
newAxis.FixDenormals();
newAxis.FixDegeneracies();
pusher->GetPhysics()->GetClipModel()->SetPosition( newOrigin, oldAxis );
mass += ClipRotationalPush( results, pusher, flags, newAxis, rotation );
if ( results.fraction < 1.0f ) {
newOrigin = oldOrigin;
newAxis = oldAxis;
return mass;
}
} else {
newAxis = oldAxis;
}
return mass;
}
示例3: Transform
/*
============
idBrush::Transform
============
*/
void idBrush::Transform( const idVec3& origin, const idMat3& axis )
{
int i;
bool transformed = false;
if( axis.IsRotated() )
{
for( i = 0; i < sides.Num(); i++ )
{
sides[i]->plane.RotateSelf( vec3_origin, axis );
}
transformed = true;
}
if( origin != vec3_origin )
{
for( i = 0; i < sides.Num(); i++ )
{
sides[i]->plane.TranslateSelf( origin );
}
transformed = true;
}
if( transformed )
{
CreateWindings();
}
}
示例4: GetMatrixForKey
/*
=======================================================================================================================
=======================================================================================================================
*/
bool GetMatrixForKey(entity_t *ent, const char *key, idMat3 &mat)
{
const char *k;
k = ValueForKey(ent, key);
if (k && strlen(k) > 0)
{
sscanf
(
k,
"%f %f %f %f %f %f %f %f %f ",
&mat[0][0],
&mat[0][1],
&mat[0][2],
&mat[1][0],
&mat[1][1],
&mat[1][2],
&mat[2][0],
&mat[2][1],
&mat[2][2]
);
return true;
}
else
{
mat.Identity();
}
return false;
}
示例5: SetAxis
/*
================
idPhysics_Parametric::SetAxis
================
*/
void idPhysics_Parametric::SetAxis( const idMat3 &newAxis, int id ) {
idVec3 masterOrigin;
idMat3 masterAxis;
current.localAngles = newAxis.ToAngles();
current.angularExtrapolation.SetStartValue( current.localAngles );
current.angularInterpolation.SetStartValue( current.localAngles );
current.localAngles = current.angularExtrapolation.GetCurrentValue( current.time );
if ( hasMaster && isOrientated ) {
self->GetMasterPosition( masterOrigin, masterAxis );
current.axis = current.localAngles.ToMat3() * masterAxis;
current.angles = current.axis.ToAngles();
}
else {
current.axis = current.localAngles.ToMat3();
current.angles = current.localAngles;
}
if ( clipModel ) {
// RAVEN BEGIN
// ddynerman: multiple clip worlds
clipModel->Link( self, 0, current.origin, current.axis );
// RAVEN END
}
Activate();
}
示例6: Contents
/*
============
idClip::Contents
============
*/
int idClip::Contents( const idVec3 &start, const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity ) {
int i, num, contents;
idClipModel *touch, *clipModelList[MAX_GENTITIES];
idBounds traceBounds;
const idTraceModel *trm;
trm = TraceModelForClipModel( mdl );
if ( !passEntity || passEntity->entityNumber != ENTITYNUM_WORLD ) {
// test world
idClip::numContents++;
contents = collisionModelManager->Contents( start, trm, trmAxis, contentMask, 0, vec3_origin, mat3_default );
} else {
contents = 0;
}
if ( !trm ) {
traceBounds[0] = start;
traceBounds[1] = start;
} else if ( trmAxis.IsRotated() ) {
traceBounds.FromTransformedBounds( trm->bounds, start, trmAxis );
} else {
traceBounds[0] = trm->bounds[0] + start;
traceBounds[1] = trm->bounds[1] + start;
}
num = GetTraceClipModels( traceBounds, -1, passEntity, clipModelList );
for ( i = 0; i < num; i++ ) {
touch = clipModelList[i];
if ( !touch ) {
continue;
}
// no contents test with render models
if ( touch->renderModelHandle != -1 ) {
continue;
}
// if the entity does not have any contents we are looking for
if ( ( touch->contents & contentMask ) == 0 ) {
continue;
}
// if the entity has no new contents flags
if ( ( touch->contents & contents ) == touch->contents ) {
continue;
}
idClip::numContents++;
if ( collisionModelManager->Contents( start, trm, trmAxis, contentMask, touch->Handle(), touch->origin, touch->axis ) ) {
contents |= ( touch->contents & contentMask );
}
}
return contents;
}
示例7: DrawEdge
/*
================
idCollisionModelManagerLocal::DrawEdge
================
*/
void idCollisionModelManagerLocal::DrawEdge( cm_model_t* model, int edgeNum, const idVec3& origin, const idMat3& axis )
{
int side;
cm_edge_t* edge;
idVec3 start, end, mid;
bool isRotated;
isRotated = axis.IsRotated();
edge = model->edges + abs( edgeNum );
side = edgeNum < 0;
start = model->vertices[edge->vertexNum[side]].p;
end = model->vertices[edge->vertexNum[!side]].p;
if( isRotated )
{
start *= axis;
end *= axis;
}
start += origin;
end += origin;
if( edge->internal )
{
if( cm_drawInternal.GetBool() )
{
common->RW()->DebugArrow( colorGreen, start, end, 1 );
}
}
else
{
if( edge->numUsers > 2 )
{
common->RW()->DebugArrow( colorBlue, start, end, 1 );
}
else
{
common->RW()->DebugArrow( cm_color, start, end, 1 );
}
}
if( cm_drawNormals.GetBool() )
{
mid = ( start + end ) * 0.5f;
if( isRotated )
{
end = mid + 5 * ( axis * edge->normal );
}
else
{
end = mid + 5 * edge->normal;
}
common->RW()->DebugArrow( colorCyan, mid, end, 1 );
}
}
示例8: GetMatrix
/*
================
idDict::GetMatrix
================
*/
bool idDict::GetMatrix( const char *key, const char *defaultString, idMat3 &out ) const {
const char *s;
bool found;
if( !defaultString ) {
defaultString = "1 0 0 0 1 0 0 0 1";
}
found = GetString( key, defaultString, &s );
out.Identity(); // sccanf has a bug in it on Mac OS 9. Sigh.
sscanf( s, "%f %f %f %f %f %f %f %f %f", &out[0].x, &out[0].y, &out[0].z, &out[1].x, &out[1].y, &out[1].z, &out[2].x, &out[2].y, &out[2].z );
return found;
}
示例9: DrawPolygon
/*
================
idCollisionModelManagerLocal::DrawPolygon
================
*/
void idCollisionModelManagerLocal::DrawPolygon( cm_model_t *model, cm_polygon_t *p, const idVec3 &origin, const idMat3 &axis, const idVec3 &viewOrigin ) {
int i, edgeNum;
cm_edge_t *edge;
idVec3 center, end, dir;
if ( cm_backFaceCull.GetBool() ) {
edgeNum = p->edges[0];
edge = model->edges + abs(edgeNum);
dir = model->vertices[edge->vertexNum[0]].p - viewOrigin;
if ( dir * p->plane.Normal() > 0.0f ) {
return;
}
}
if ( cm_drawNormals.GetBool() ) {
center = vec3_origin;
for ( i = 0; i < p->numEdges; i++ ) {
edgeNum = p->edges[i];
edge = model->edges + abs(edgeNum);
center += model->vertices[edge->vertexNum[edgeNum < 0]].p;
}
center *= (1.0f / p->numEdges);
if ( axis.IsRotated() ) {
center = center * axis + origin;
end = center + 5 * (axis * p->plane.Normal());
} else {
center += origin;
end = center + 5 * p->plane.Normal();
}
session->rw->DebugArrow( colorMagenta, center, end, 1 );
}
if ( cm_drawFilled.GetBool() ) {
idFixedWinding winding;
for ( i = p->numEdges - 1; i >= 0; i-- ) {
edgeNum = p->edges[i];
edge = model->edges + abs(edgeNum);
winding += origin + model->vertices[edge->vertexNum[INTSIGNBITSET(edgeNum)]].p * axis;
}
session->rw->DebugPolygon( cm_color, winding );
} else {
for ( i = 0; i < p->numEdges; i++ ) {
edgeNum = p->edges[i];
edge = model->edges + abs(edgeNum);
if ( edge->checkcount == checkCount ) {
continue;
}
edge->checkcount = checkCount;
DrawEdge( model, edgeNum, origin, axis );
}
}
}
示例10: DetermineIdealRotation
/*
================
hhCameraInterpolator::DetermineIdealRotation
================
*/
idQuat hhCameraInterpolator::DetermineIdealRotation( const idVec3& idealUpVector, const idVec3& viewDir, const idMat3& untransformedViewAxis ) {
idMat3 mat;
idVec3 newViewVector( viewDir );
newViewVector.ProjectOntoPlane( idealUpVector );
if( newViewVector.LengthSqr() < VECTOR_EPSILON ) {
newViewVector = -Sign( newViewVector * idealUpVector );
}
newViewVector.Normalize();
mat[0] = newViewVector;
mat[1] = idealUpVector.Cross( newViewVector );
mat[2] = idealUpVector;
mat = untransformedViewAxis.Transpose() * mat;
return mat.ToQuat();
}
示例11: FromBoundsTranslation
/*
============
idBounds::FromBoundsTranslation
Most tight bounds for the translational movement of the given bounds.
============
*/
void idBounds::FromBoundsTranslation( const idBounds &bounds, const idVec3 &origin, const idMat3 &axis, const idVec3 &translation ) {
int i;
if ( axis.IsRotated() ) {
FromTransformedBounds( bounds, origin, axis );
}
else {
b[0] = bounds[0] + origin;
b[1] = bounds[1] + origin;
}
for ( i = 0; i < 3; i++ ) {
if ( translation[i] < 0.0f ) {
b[0][i] += translation[i];
}
else {
b[1][i] += translation[i];
}
}
}
示例12: DrawModel
/*
================
idCollisionModelManagerLocal::DrawModel
================
*/
void idCollisionModelManagerLocal::DrawModel( cmHandle_t handle, const idVec3 &modelOrigin, const idMat3 &modelAxis,
const idVec3 &viewOrigin, const float radius ) {
cm_model_t *model;
idVec3 viewPos;
if ( handle < 0 && handle >= numModels ) {
return;
}
if ( cm_drawColor.IsModified() ) {
sscanf( cm_drawColor.GetString(), "%f %f %f %f", &cm_color.x, &cm_color.y, &cm_color.z, &cm_color.w );
cm_drawColor.ClearModified();
}
model = models[ handle ];
viewPos = (viewOrigin - modelOrigin) * modelAxis.Transpose();
checkCount++;
DrawNodePolygons( model, model->node, modelOrigin, modelAxis, viewPos, radius );
}
示例13: GlobalProjectionInfoToLocal
/*
=================
idRenderModelDecal::CreateProjectionInfo
=================
*/
void idRenderModelDecal::GlobalProjectionInfoToLocal( decalProjectionInfo_t &localInfo, const decalProjectionInfo_t &info, const idVec3 &origin, const idMat3 &axis ) {
float modelMatrix[16];
R_AxisToModelMatrix( axis, origin, modelMatrix );
for( int j = 0; j < NUM_DECAL_BOUNDING_PLANES; j++ ) {
R_GlobalPlaneToLocal( modelMatrix, info.boundingPlanes[j], localInfo.boundingPlanes[j] );
}
R_GlobalPlaneToLocal( modelMatrix, info.fadePlanes[0], localInfo.fadePlanes[0] );
R_GlobalPlaneToLocal( modelMatrix, info.fadePlanes[1], localInfo.fadePlanes[1] );
R_GlobalPlaneToLocal( modelMatrix, info.textureAxis[0], localInfo.textureAxis[0] );
R_GlobalPlaneToLocal( modelMatrix, info.textureAxis[1], localInfo.textureAxis[1] );
R_GlobalPointToLocal( modelMatrix, info.projectionOrigin, localInfo.projectionOrigin );
localInfo.projectionBounds = info.projectionBounds;
localInfo.projectionBounds.TranslateSelf( -origin );
localInfo.projectionBounds.RotateSelf( axis.Transpose() );
localInfo.material = info.material;
localInfo.parallel = info.parallel;
localInfo.fadeDepth = info.fadeDepth;
localInfo.startTime = info.startTime;
localInfo.force = info.force;
}
示例14: GetMassProperties
/*
============
idTraceModel::GetMassProperties
============
*/
void idTraceModel::GetMassProperties( const float density, float &mass, idVec3 ¢erOfMass, idMat3 &inertiaTensor ) const {
volumeIntegrals_t integrals;
// if polygon trace model
if ( type == TRM_POLYGON ) {
idTraceModel trm;
VolumeFromPolygon( trm, 1.0f );
trm.GetMassProperties( density, mass, centerOfMass, inertiaTensor );
return;
}
VolumeIntegrals( integrals );
// if no volume
if ( integrals.T0 == 0.0f ) {
mass = 1.0f;
centerOfMass.Zero();
inertiaTensor.Identity();
return;
}
// mass of model
mass = density * integrals.T0;
// center of mass
centerOfMass = integrals.T1 / integrals.T0;
// compute inertia tensor
inertiaTensor[0][0] = density * (integrals.T2[1] + integrals.T2[2]);
inertiaTensor[1][1] = density * (integrals.T2[2] + integrals.T2[0]);
inertiaTensor[2][2] = density * (integrals.T2[0] + integrals.T2[1]);
inertiaTensor[0][1] = inertiaTensor[1][0] = - density * integrals.TP[0];
inertiaTensor[1][2] = inertiaTensor[2][1] = - density * integrals.TP[1];
inertiaTensor[2][0] = inertiaTensor[0][2] = - density * integrals.TP[2];
// translate inertia tensor to center of mass
inertiaTensor[0][0] -= mass * (centerOfMass[1]*centerOfMass[1] + centerOfMass[2]*centerOfMass[2]);
inertiaTensor[1][1] -= mass * (centerOfMass[2]*centerOfMass[2] + centerOfMass[0]*centerOfMass[0]);
inertiaTensor[2][2] -= mass * (centerOfMass[0]*centerOfMass[0] + centerOfMass[1]*centerOfMass[1]);
inertiaTensor[0][1] = inertiaTensor[1][0] += mass * centerOfMass[0] * centerOfMass[1];
inertiaTensor[1][2] = inertiaTensor[2][1] += mass * centerOfMass[1] * centerOfMass[2];
inertiaTensor[2][0] = inertiaTensor[0][2] += mass * centerOfMass[2] * centerOfMass[0];
}
示例15: GetPhysicsToSoundTransform
bool CFrobHandle::GetPhysicsToSoundTransform(idVec3 &origin, idMat3 &axis)
{
idVec3 eyePos = gameLocal.GetLocalPlayer()->GetEyePosition();
const idBounds& bounds = GetPhysics()->GetAbsBounds();
//gameRenderWorld->DebugBounds(colorLtGrey, bounds, vec3_origin, 5000);
// greebo: Choose the corner which is nearest to the player's eyeposition
origin.x = (idMath::Fabs(bounds[0].x - eyePos.x) < idMath::Fabs(bounds[1].x - eyePos.x)) ? bounds[0].x : bounds[1].x;
origin.y = (idMath::Fabs(bounds[0].y - eyePos.y) < idMath::Fabs(bounds[1].y - eyePos.y)) ? bounds[0].y : bounds[1].y;
origin.z = (idMath::Fabs(bounds[0].z - eyePos.z) < idMath::Fabs(bounds[1].z - eyePos.z)) ? bounds[0].z : bounds[1].z;
// The called expects the origin in local space
origin -= GetPhysics()->GetOrigin();
axis.Identity();
//gameRenderWorld->DebugArrow(colorWhite, GetPhysics()->GetOrigin() + origin, eyePos, 0, 5000);
return true;
}