本文整理汇总了C++中PerpendicularVector函数的典型用法代码示例。如果您正苦于以下问题:C++ PerpendicularVector函数的具体用法?C++ PerpendicularVector怎么用?C++ PerpendicularVector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PerpendicularVector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RotatePointAroundVector
/*
===============
RotatePointAroundVector
This is not implemented very well...
===============
*/
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,
float degrees ) {
float m[3][3];
float im[3][3];
float zrot[3][3];
float tmpmat[3][3];
float rot[3][3];
int i;
vec3_t vr, vup, vf;
float rad;
vf[0] = dir[0];
vf[1] = dir[1];
vf[2] = dir[2];
PerpendicularVector( vr, dir );
CrossProduct( vr, vf, vup );
m[0][0] = vr[0];
m[1][0] = vr[1];
m[2][0] = vr[2];
m[0][1] = vup[0];
m[1][1] = vup[1];
m[2][1] = vup[2];
m[0][2] = vf[0];
m[1][2] = vf[1];
m[2][2] = vf[2];
memcpy( im, m, sizeof( im ) );
im[0][1] = m[1][0];
im[0][2] = m[2][0];
im[1][0] = m[0][1];
im[1][2] = m[2][1];
im[2][0] = m[0][2];
im[2][1] = m[1][2];
memset( zrot, 0, sizeof( zrot ) );
zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;
rad = (float)DEG2RAD( degrees );
zrot[0][0] = (vec_t)cos( rad );
zrot[0][1] = (vec_t)sin( rad );
zrot[1][0] = (vec_t)-sin( rad );
zrot[1][1] = (vec_t)cos( rad );
MatrixMultiply( m, zrot, tmpmat );
MatrixMultiply( tmpmat, im, rot );
for ( i = 0; i < 3; i++ ) {
dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2];
}
}
开发者ID:Garux,项目名称:netradiant-custom,代码行数:62,代码来源:mathlib.c
示例2: RotatePointAroundVector
void RotatePointAroundVector( vec3_t &dst, const vec3_t &dir, const vec3_t &point, float degrees )
{
float m[3][3];
float im[3][3];
float zrot[3][3];
float tmpmat[3][3];
float rot[3][3];
int i;
vec3_t vr, vup, vf;
vf[0] = dir[0];
vf[1] = dir[1];
vf[2] = dir[2];
PerpendicularVector( vr, dir );
//CrossProduct( vr, vf, vup );
vup = CrossProduct( vr, vf );
m[0][0] = vr[0];
m[1][0] = vr[1];
m[2][0] = vr[2];
m[0][1] = vup[0];
m[1][1] = vup[1];
m[2][1] = vup[2];
m[0][2] = vf[0];
m[1][2] = vf[1];
m[2][2] = vf[2];
memcpy( im, m, sizeof( im ) );
im[0][1] = m[1][0];
im[0][2] = m[2][0];
im[1][0] = m[0][1];
im[1][2] = m[2][1];
im[2][0] = m[0][2];
im[2][1] = m[1][2];
memset( zrot, 0, sizeof( zrot ) );
zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;
zrot[0][0] = cos( DEG2RAD( degrees ) );
zrot[0][1] = sin( DEG2RAD( degrees ) );
zrot[1][0] = -sin( DEG2RAD( degrees ) );
zrot[1][1] = cos( DEG2RAD( degrees ) );
R_ConcatRotations( m, zrot, tmpmat );
R_ConcatRotations( tmpmat, im, rot );
for ( i = 0; i < 3; i++ )
{
dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2];
}
}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:55,代码来源:frustum.cpp
示例3: RotatePointAroundVector
/**
* @brief Rotate a point around a given vector
* @param[in] dir The vector around which to rotate
* @param[in] point The point to be rotated
* @param[in] degrees How many degrees to rotate the point by
* @param[out] dst The point after rotation
* @note Warning: @c dst must be different from @c point (otherwise the result has no meaning)
* @pre @c dir must be normalized
*/
void RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
{
float m[3][3];
float im[3][3];
float zrot[3][3];
float tmpmat[3][3];
float rot[3][3];
int i;
vec3_t vr, vup, vf;
vf[0] = dir[0];
vf[1] = dir[1];
vf[2] = dir[2];
PerpendicularVector(vr, dir);
CrossProduct(vr, vf, vup);
m[0][0] = vr[0];
m[1][0] = vr[1];
m[2][0] = vr[2];
m[0][1] = vup[0];
m[1][1] = vup[1];
m[2][1] = vup[2];
m[0][2] = vf[0];
m[1][2] = vf[1];
m[2][2] = vf[2];
memcpy(im, m, sizeof(im));
im[0][1] = m[1][0];
im[0][2] = m[2][0];
im[1][0] = m[0][1];
im[1][2] = m[2][1];
im[2][0] = m[0][2];
im[2][1] = m[1][2];
OBJZERO(zrot);
/* now prepare the rotation matrix */
zrot[0][0] = cos(degrees * torad);
zrot[0][1] = sin(degrees * torad);
zrot[1][0] = -sin(degrees * torad);
zrot[1][1] = cos(degrees * torad);
zrot[2][2] = 1.0F;
R_ConcatRotations(m, zrot, tmpmat);
R_ConcatRotations(tmpmat, im, rot);
for (i = 0; i < 3; i++) {
dst[i] = DotProduct(rot[i], point);
}
}
开发者ID:kevlund,项目名称:ufoai,代码行数:63,代码来源:mathlib.c
示例4: RotatePointAroundVector
/*
-----------------------------------------------------------------------------
Function: RotatePointAroundVector -Rotate a point around a vector.
Parameters: dst -[out] Point after rotation.
dir -[in] vector.
point -[in] Point.
degrees -[in] Degrees of rotation.
Returns: Nothing.
Notes:
-----------------------------------------------------------------------------
*/
PUBLIC void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees )
{
mat3_t m;
mat3_t im;
mat3_t zrot;
mat3_t tmpmat;
mat3_t rot;
vec3_t vr, vup, vf;
float rad;
vf[0] = dir[0];
vf[1] = dir[1];
vf[2] = dir[2];
PerpendicularVector( vr, dir );
vectorCrossProduct( vr, vf, vup );
m[0] = vr[0];
m[3] = vr[1];
m[6] = vr[2];
m[1] = vup[0];
m[4] = vup[1];
m[7] = vup[2];
m[2] = vf[0];
m[5] = vf[1];
m[8] = vf[2];
memcpy( im, m, sizeof( im ) );
im[1] = m[3];
im[2] = m[6];
im[3] = m[1];
im[5] = m[7];
im[6] = m[2];
im[7] = m[5];
memset( zrot, 0, sizeof( zrot ) );
zrot[0] = zrot[4] = zrot[8] = 1.0F;
rad = DEG2RAD( degrees );
zrot[0] = (float)cos( rad );
zrot[1] = (float)sin( rad );
zrot[3] = (float)-sin( rad );
zrot[4] = (float)cos( rad );
Matrix3x3Multiply( m, zrot, tmpmat );
Matrix3x3Multiply( tmpmat, im, rot );
dst[0] = rot[0] * point[0] + rot[1] * point[1] + rot[2] * point[2];
dst[1] = rot[3] * point[0] + rot[4] * point[1] + rot[5] * point[2];
dst[2] = rot[6] * point[0] + rot[7] * point[1] + rot[8] * point[2];
}
开发者ID:Oppen,项目名称:Wolf3DRedux,代码行数:68,代码来源:vector.c
示例5: vector_Perpendicular
static int vector_Perpendicular(lua_State * L)
{
vec_t *dst;
vec_t *src;
dst = lua_getvector(L, 1);
src = lua_getvector(L, 2);
PerpendicularVector(dst, src);
return 1;
}
开发者ID:redrumrobot,项目名称:dretchstorm,代码行数:12,代码来源:lua_vector.c
示例6: R_GetSurfaceOrientations
/*
========================
GetSurfaceOrientations
========================
*/
void R_GetSurfaceOrientations( cplane_t *plane, orientation_t *surface, orientation_t *camera )
{
VectorCopy( plane->normal, surface->axis[0] );
PerpendicularVector( surface->axis[1], surface->axis[0] );
CrossProduct( surface->axis[0], surface->axis[1], surface->axis[2] );
VectorScale( plane->normal, plane->dist, surface->origin );
VectorCopy( surface->origin, camera->origin );
VectorSubtract( vec3_origin, surface->axis[0], camera->axis[0] );
VectorCopy( surface->axis[1], camera->axis[1] );
VectorCopy( surface->axis[2], camera->axis[2] );
}
开发者ID:shawnd,项目名称:urt-bumpy-engine,代码行数:18,代码来源:tr_main.c
示例7: RotatePointAroundVector
void RotatePointAroundVector( Coord *dst, Coord dir, Coord point, float degrees )
{
float m[3][3];
float im[3][3];
float zrot[3][3];
float tmpmat[3][3];
float rot[3][3];
Coord vr, vup, vf;
vf.x = dir.x;
vf.y = dir.y;
vf.z = dir.z;
PerpendicularVector( &vr, dir );
CrossProduct( vr, vf, &vup );
m[0][0] = vr.x;
m[1][0] = vr.y;
m[2][0] = vr.z;
m[0][1] = vup.x;
m[1][1] = vup.y;
m[2][1] = vup.z;
m[0][2] = vf.x;
m[1][2] = vf.y;
m[2][2] = vf.z;
memcpy( im, m, sizeof( im ) );
im[0][1] = m[1][0];
im[0][2] = m[2][0];
im[1][0] = m[0][1];
im[1][2] = m[2][1];
im[2][0] = m[0][2];
im[2][1] = m[1][2];
memset( zrot, 0, sizeof( zrot ) );
zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;
zrot[0][0] = cos( ( degrees*DEGTORAD ) );
zrot[0][1] = sin( ( degrees*DEGTORAD ) );
zrot[1][0] = -sin( ( degrees*DEGTORAD ) );
zrot[1][1] = cos( ( degrees*DEGTORAD ) );
R_ConcatRotations( m, zrot, tmpmat );
R_ConcatRotations( tmpmat, im, rot );
dst->x = rot[0][0] * point.x + rot[0][1] * point.y + rot[0][2] * point.z;
dst->y = rot[1][0] * point.x + rot[1][1] * point.y + rot[1][2] * point.z;
dst->z = rot[2][0] * point.x + rot[2][1] * point.y + rot[2][2] * point.z;
}
开发者ID:anthonyrego,项目名称:with_iron_force,代码行数:51,代码来源:graphics.c
示例8: CG_EffectMark
void CG_EffectMark(qhandle_t markShader, const vec3_t origin, const vec3_t dir, float alpha, float radius)
{
// 'quick' version of the CG_ImpactMark function
vec3_t axis[3], originalPoints[4];
float texCoordScale;
byte colors[4];
int i;
polyVert_t *v, verts[4];
if (!cg_addMarks.integer) {
return;
}
if (radius <= 0) {
CG_Error("CG_EffectMark called with <= 0 radius");
}
// create the texture axis
VectorNormalize2(dir, axis[0]);
PerpendicularVector(axis[1], axis[0]);
VectorSet(axis[2], 1, 0, 0); // This is _wrong_, but the function is for water anyway (i.e. usually flat)
CrossProduct(axis[0], axis[2], axis[1]);
texCoordScale = 0.5 * 1.0 / radius;
// create the full polygon
for (i = 0; i < 3; i++) {
originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i];
originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i];
originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i];
originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i];
}
colors[0] = 127;
colors[1] = 127;
colors[2] = 127;
colors[3] = alpha * 255;
for (i = 0, v = verts; i < 4; i++, v++) {
vec3_t delta;
VectorCopy(originalPoints[i], v->xyz);
VectorSubtract(v->xyz, origin, delta);
v->st[0] = 0.5 + DotProduct(delta, axis[1]) * texCoordScale;
v->st[1] = 0.5 + DotProduct(delta, axis[2]) * texCoordScale;
*(int *) v->modulate = *(int *) colors;
}
trap_R_AddPolyToScene(markShader, 4, verts);
}
开发者ID:Zekom,项目名称:reaction,代码行数:50,代码来源:cg_atmospheric.c
示例9: RotatePointAroundVector
// This is not implemented very well...
void RotatePointAroundVector( vector3 *dst, const vector3 *dir, const vector3 *point, float degrees ) {
vector3 m[3], im[3], zrot[3], tmpmat[3], rot[3];
vector3 vr, vup, vf;
int i;
float rad;
vf.x = dir->x;
vf.y = dir->y;
vf.z = dir->z;
PerpendicularVector( &vr, dir );
CrossProduct( &vr, &vf, &vup );
m[0].x = vr.x;
m[1].x = vr.y;
m[2].x = vr.z;
m[0].y = vup.x;
m[1].y = vup.y;
m[2].y = vup.z;
m[0].z = vf.x;
m[1].z = vf.y;
m[2].z = vf.z;
memcpy( im, m, sizeof(im) );
im[0].y = m[1].x;
im[0].z = m[2].x;
im[1].x = m[0].y;
im[1].z = m[2].y;
im[2].x = m[0].z;
im[2].y = m[1].z;
memset( zrot, 0, sizeof(zrot) );
zrot[0].x = zrot[1].y = zrot[2].z = 1.0f;
rad = DEG2RAD( degrees );
zrot[0].x = cosf( rad );
zrot[0].y = sinf( rad );
zrot[1].x = -sinf( rad );
zrot[1].y = cosf( rad );
MatrixMultiply( m, zrot, tmpmat );
MatrixMultiply( tmpmat, im, rot );
for ( i = 0; i < 3; i++ ) {
dst->raw[i] = DotProduct( &rot[i], point );
}
}
开发者ID:Arcadiaprime,项目名称:japp,代码行数:51,代码来源:q_math.cpp
示例10: fire_weaponDir
qboolean fire_weaponDir(gentity_t *self, vec3_t start, vec3_t dir, int weaponnum, float quadFactor, int handSide)
{
vec3_t right, up;
if (weaponnum <= 0 || weaponnum >= BG_NumWeapons()) {
return qfalse;
}
// Get up and right from dir (which is "forward")
PerpendicularVector( up, dir );
CrossProduct( up, dir, right );
return fire_projectile(self, start, dir, right, up, bg_weaponinfo[weaponnum].projnum,
quadFactor, bg_weaponinfo[weaponnum].mod, bg_weaponinfo[weaponnum].splashMod, handSide);
}
开发者ID:Extraordinary-Beat-X,项目名称:ebx-code,代码行数:15,代码来源:g_missile.c
示例11: ShotgunPattern
// this should match CG_ShotgunPattern
void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) {
int i, n, c;
float r, u, d;
vec3_t end;
vec3_t forward, right, up;
qboolean hitClient = qfalse;
// derive the right and up vectors from the forward vector, because
// the client won't have any other information
VectorNormalize2( origin2, forward );
PerpendicularVector( right, forward );
CrossProduct( forward, right, up );
n = DEFAULT_SHOTGUN_COUNT;
d = DEFAULT_SHOTGUN_SPREAD / 2;
c = 3;
while (n > 0) {
float stepSize = (2 * M_PI) / c;
float step;
for (step = -M_PI; step < M_PI && n > 0; step += stepSize) {
r = cos(step) * d;
u = sin(step) * d;
VectorMA( origin, 8192, forward, end);
VectorMA (end, r, right, end);
VectorMA (end, u, up, end);
if( ShotgunPellet( origin, end, ent ) && !hitClient ) {
hitClient = qtrue;
ent->client->accuracy_hits++;
}
n--;
}
d += DEFAULT_SHOTGUN_SPREAD / 2;
c += 4;
}
/*
// generate the "random" spread pattern
for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) {
r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD; // CPM
u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD; // CPM
VectorMA( origin, 8192, forward, end);
VectorMA (end, r, right, end);
VectorMA (end, u, up, end);
if( ShotgunPellet( origin, end, ent ) && !hitClient ) {
hitClient = qtrue;
ent->client->accuracy_hits++;
}
}
*/
}
开发者ID:jangroothuijse,项目名称:openpromode,代码行数:49,代码来源:g_weapon.c
示例12: RotateAroundDirection
void RotateAroundDirection( vector3 axis[3], float yaw ) {
// create an arbitrary axis[1]
PerpendicularVector( &axis[1], &axis[0] );
// rotate it around axis[0] by yaw
if ( yaw ) {
vector3 temp;
VectorCopy( &axis[1], &temp );
RotatePointAroundVector( &axis[1], &axis[0], &temp, yaw );
}
// cross to get axis[2]
CrossProduct( &axis[0], &axis[1], &axis[2] );
}
开发者ID:Arcadiaprime,项目名称:japp,代码行数:16,代码来源:q_math.cpp
示例13: ShotgunPattern
// this should match CG_ShotgunPattern
void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) {
int i;
float r, u;
vec3_t end;
vec3_t forward, right, up;
qboolean hitClient = qfalse;
//unlagged - attack prediction #2
// use this for testing
/*
if ( g_unlagged.integer )
Com_Printf( "Server seed: %d\n", seed );
*/
//-unlagged - attack prediction #2
// derive the right and up vectors from the forward vector, because
// the client won't have any other information
VectorNormalize2( origin2, forward );
PerpendicularVector( right, forward );
CrossProduct( forward, right, up );
//unlagged - backward reconciliation #2
// backward-reconcile the other clients
if ( g_unlagged.integer )
G_DoTimeShiftFor( ent );
//-unlagged - backward reconciliation #2
// generate the "random" spread pattern
for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) {
r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;
u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;
VectorMA( origin, 8192 * 16, forward, end);
VectorMA (end, r, right, end);
VectorMA (end, u, up, end);
if( ShotgunPellet( origin, end, ent ) && !hitClient ) {
hitClient = qtrue;
ent->client->accuracy_hits++;
}
}
//unlagged - backward reconciliation #2
// put them back
if ( g_unlagged.integer )
G_UndoTimeShiftFor( ent );
//-unlagged - backward reconciliation #2
}
开发者ID:themuffinator,项目名称:fnq3,代码行数:47,代码来源:g_weapon.c
示例14: Use_Shooter
void Use_Shooter(gentity_t * ent, gentity_t * other, gentity_t * activator)
{
vec3_t dir;
float deg;
vec3_t up, right;
// see if we have a target
if(ent->enemy)
{
VectorSubtract(ent->enemy->r.currentOrigin, ent->s.origin, dir);
VectorNormalize(dir);
}
else
{
VectorCopy(ent->movedir, dir);
}
// randomize a bit
PerpendicularVector(up, dir);
CrossProduct(up, dir, right);
deg = crandom() * ent->random;
VectorMA(dir, deg, up, dir);
deg = crandom() * ent->random;
VectorMA(dir, deg, right, dir);
VectorNormalize(dir);
switch (ent->s.weapon)
{
case WP_GRENADE_LAUNCHER:
fire_grenade(ent, ent->s.origin, dir);
break;
case WP_ROCKET_LAUNCHER:
fire_rocket(ent, ent->s.origin, dir);
break;
case WP_PLASMAGUN:
fire_plasma(ent, ent->s.origin, dir);
break;
}
G_AddEvent(ent, EV_FIRE_WEAPON, 0);
}
开发者ID:otty,项目名称:cake3,代码行数:44,代码来源:g_misc.c
示例15: RB_DrawSun
/*
** RB_DrawSun
*/
void RB_DrawSun( float scale, shader_t *shader ) {
float size;
float dist;
vec3_t origin, vec1, vec2;
if ( !backEnd.skyRenderedThisView ) {
return;
}
//qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
//qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);
{
// FIXME: this could be a lot cleaner
mat4_t translation, modelview;
Mat4Translation( backEnd.viewParms.or.origin, translation );
Mat4Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview );
GL_SetModelviewMatrix( modelview );
}
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
size = dist * scale;
VectorScale( tr.sunDirection, dist, origin );
PerpendicularVector( vec1, tr.sunDirection );
CrossProduct( tr.sunDirection, vec1, vec2 );
VectorScale( vec1, size, vec1 );
VectorScale( vec2, size, vec2 );
// farthest depth range
qglDepthRange( 1.0, 1.0 );
RB_BeginSurface( shader, 0, 0 );
RB_AddQuadStamp(origin, vec1, vec2, colorWhite);
RB_EndSurface();
// back to normal depth range
qglDepthRange( 0.0, 1.0 );
}
开发者ID:BruceJohnJennerLawso,项目名称:ioq3,代码行数:45,代码来源:tr_sky.c
示例16: ShotgunPattern
/*
================
Keep this in sync with ShotgunPattern in CGAME!
================
*/
static void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *self )
{
int i;
float r, u, a;
vec3_t end;
vec3_t forward, right, up;
trace_t tr;
gentity_t *traceEnt;
// derive the right and up vectors from the forward vector, because
// the client won't have any other information
VectorNormalize2( origin2, forward );
PerpendicularVector( right, forward );
CrossProduct( forward, right, up );
// generate the "random" spread pattern
for ( i = 0; i < SHOTGUN_PELLETS; i++ )
{
r = Q_crandom( &seed ) * M_PI;
a = Q_random( &seed ) * SHOTGUN_SPREAD * 16;
u = sin( r ) * a;
r = cos( r ) * a;
VectorMA( origin, SHOTGUN_RANGE, forward, end );
VectorMA( end, r, right, end );
VectorMA( end, u, up, end );
trap_Trace( &tr, origin, NULL, NULL, end, self->s.number, MASK_SHOT );
traceEnt = &g_entities[ tr.entityNum ];
// do the damage
if ( !( tr.surfaceFlags & SURF_NOIMPACT ) )
{
if ( traceEnt->takedamage )
{
G_Damage( traceEnt, self, self, forward, tr.endpos, SHOTGUN_DMG, 0, MOD_SHOTGUN );
}
}
}
}
开发者ID:Xecantur,项目名称:Unvanquished,代码行数:46,代码来源:g_weapon.cpp
示例17: CG_ExplosionsDust
void CG_ExplosionsDust( vec3_t pos, vec3_t dir, float radius )
{
const int count = 32; /* Number of sprites used to create the circle */
lentity_t *le;
struct shader_s *shader = CG_MediaShader( cgs.media.shaderSmokePuff3 );
vec3_t dir_per1;
vec3_t dir_per2;
vec3_t dir_temp = { 0.0f, 0.0f, 0.0f };
int i;
float angle;
if( CG_PointContents( pos ) & MASK_WATER )
return; // no smoke under water :)
PerpendicularVector( dir_per2, dir );
CrossProduct( dir, dir_per2, dir_per1 );
//VectorScale( dir_per1, VectorNormalize( dir_per1 ), dir_per1 );
//VectorScale( dir_per2, VectorNormalize( dir_per2 ), dir_per2 );
// make a circle out of the specified number (int count) of sprites
for( i = 0; i < count; i++ )
{
angle = (float)( 6.2831f / count * i );
VectorSet( dir_temp, 0.0f, 0.0f, 0.0f );
VectorMA( dir_temp, sin( angle ), dir_per1, dir_temp );
VectorMA( dir_temp, cos( angle ), dir_per2, dir_temp );
//VectorScale(dir_temp, VectorNormalize(dir_temp),dir_temp );
VectorScale( dir_temp, crandom()*8 + radius + 16.0f, dir_temp );
// make the sprite smaller & alpha'd
le = CG_AllocSprite( LE_ALPHA_FADE, pos, 10, 10,
1.0f, 1.0f, 1.0f, 1.0f,
0, 0, 0, 0,
shader );
VectorCopy( dir_temp, le->velocity );
}
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:38,代码来源:cg_lents.c
示例18: CG_ShotgunPattern
/*
================
CG_ShotgunPattern
Perform the same traces the server did to locate the
hit splashes
================
*/
static void CG_ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int otherEntNum )
{
int i;
float r, u;
vec3_t end;
vec3_t forward, right, up;
trace_t tr;
// derive the right and up vectors from the forward vector, because
// the client won't have any other information
VectorNormalize2( origin2, forward );
PerpendicularVector( right, forward );
CrossProduct( forward, right, up );
// generate the "random" spread pattern
for( i = 0; i < SHOTGUN_PELLETS; i++ )
{
r = Q_crandom( &seed ) * SHOTGUN_SPREAD * 16;
u = Q_crandom( &seed ) * SHOTGUN_SPREAD * 16;
VectorMA( origin, 8192 * 16, forward, end );
VectorMA( end, r, right, end );
VectorMA( end, u, up, end );
CG_Trace( &tr, origin, NULL, NULL, end, otherEntNum, MASK_SHOT );
if( !( tr.surfaceFlags & SURF_NOIMPACT ) )
{
if( cg_entities[ tr.entityNum ].currentState.eType == ET_PLAYER ||
cg_entities[ tr.entityNum ].currentState.eType == ET_BUILDABLE )
CG_MissileHitEntity( WP_SHOTGUN, WPM_PRIMARY, tr.endpos, tr.plane.normal, tr.entityNum, 0 );
else if( tr.surfaceFlags & SURF_METALSTEPS )
CG_MissileHitWall( WP_SHOTGUN, WPM_PRIMARY, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_METAL, 0 );
else
CG_MissileHitWall( WP_SHOTGUN, WPM_PRIMARY, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_DEFAULT, 0 );
}
}
}
开发者ID:ZdrytchX,项目名称:cuboid,代码行数:45,代码来源:cg_weapons.c
示例19: ShotgunPattern
// this should match CG_ShotgunPattern
void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) {
int i;
float r, u;
vec3_t end;
vec3_t forward, right, up;
int oldScore;
qboolean hitClient = qfalse;
/* LQ3A */
int spread;
// derive the right and up vectors from the forward vector, because
// the client won't have any other information
VectorNormalize2( origin2, forward );
PerpendicularVector( right, forward );
CrossProduct( forward, right, up );
oldScore = ent->client->ps.persistant[PERS_SCORE];
/* LQ3A */
spread = (g_damageBulletSpread.integer > 0) ? g_damageBulletSpread.integer : 0;
// generate the "random" spread pattern
for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) {
/* LQ3A */
r = Q_crandom( &seed ) * spread * 16;
u = Q_crandom( &seed ) * spread * 16;
VectorMA( origin, 8192 * 16, forward, end);
VectorMA (end, r, right, end);
VectorMA (end, u, up, end);
if( ShotgunPellet( origin, end, ent ) && !hitClient ) {
hitClient = qtrue;
ent->client->accuracy_hits++;
}
}
}
开发者ID:monoknot,项目名称:loaded-q3a,代码行数:38,代码来源:g_weapon.c
示例20: RB_DrawSun
/*
** RB_DrawSun
*/
void RB_DrawSun( void ) {
bfixed size;
bfixed dist;
bvec3_t origin;
avec3_t vec1, vec2;
bvec3_t bvec1, bvec2;
bvec3_t temp;
if ( !backEnd.skyRenderedThisView ) {
return;
}
if ( !r_drawSun->integer ) {
return;
}
glLoadMatrixX( backEnd.viewParms.world.modelMatrix );
glTranslateX ( REINTERPRET_GFIXED(backEnd.viewParms._or.origin[0]),
REINTERPRET_GFIXED(backEnd.viewParms._or.origin[1]),
REINTERPRET_GFIXED(backEnd.viewParms._or.origin[2]));
dist = backEnd.viewParms.zFar / BFIXED(1,75); // div sqrt(3)
size = dist * BFIXED(0,4);
FIXED_VEC3SCALE_R( tr.sunDirection, dist, origin );
PerpendicularVector( vec1, tr.sunDirection );
CrossProduct( tr.sunDirection, vec1, vec2 );
FIXED_VEC3SCALE_R( vec1, size, bvec1 );
FIXED_VEC3SCALE_R( vec2, size, bvec2 );
// farthest depth range
glDepthRangeX( GFIXED_1, GFIXED_1 );
// FIXME: use quad stamp
RB_BeginSurface( tr.sunShader, tess.fogNum );
VectorCopy( origin, temp );
VectorSubtract( temp, bvec1, temp );
VectorSubtract( temp, bvec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = GFIXED_0;
tess.texCoords[tess.numVertexes][0][1] = GFIXED_0;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorAdd( temp, bvec1, temp );
VectorSubtract( temp, bvec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = GFIXED_0;
tess.texCoords[tess.numVertexes][0][1] = GFIXED_1;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorAdd( temp, bvec1, temp );
VectorAdd( temp, bvec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = GFIXED_1;
tess.texCoords[tess.numVertexes][0][1] = GFIXED_1;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
VectorCopy( origin, temp );
VectorSubtract( temp, bvec1, temp );
VectorAdd( temp, bvec2, temp );
VectorCopy( temp, tess.xyz[tess.numVertexes] );
tess.texCoords[tess.numVertexes][0][0] = GFIXED_1;
tess.texCoords[tess.numVertexes][0][1] = GFIXED_0;
tess.vertexColors[tess.numVertexes][0] = 255;
tess.vertexColors[tess.numVertexes][1] = 255;
tess.vertexColors[tess.numVertexes][2] = 255;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 1;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 3;
RB_EndSurface();
// back to normal depth range
glDepthRangeX( GFIXED_0, GFIXED_1);
}
开发者ID:Jsoucek,项目名称:q3ce,代码行数:93,代码来源:tr_sky.cpp
注:本文中的PerpendicularVector函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论