您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CrossProduct函数代码示例

51自学网 2021-06-01 20:15:29
  C++
这篇教程C++ CrossProduct函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CrossProduct函数的典型用法代码示例。如果您正苦于以下问题:C++ CrossProduct函数的具体用法?C++ CrossProduct怎么用?C++ CrossProduct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CrossProduct函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CG_ImpactMark

void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, 				   float orientation, float red, float green, float blue, float alpha,				   qboolean alphaFade, float radius, qboolean temporary ) {	vec3_t			axis[3];	float			texCoordScale;	vec3_t			originalPoints[4];	byte			colors[4];	int				i, j;	int				numFragments;	markFragment_t	markFragments[MAX_MARK_FRAGMENTS], *mf;	vec3_t			markPoints[MAX_MARK_POINTS];	vec3_t			projection;	if(markShader == 0) return;	assert(markShader);	if ( !cg_addMarks.integer ) {		return;	}	else if (cg_addMarks.integer == 2)	{		trap_R_AddDecalToScene(markShader, origin, dir, orientation, red, green, blue, alpha,			alphaFade, radius, temporary);		return;	}	if ( radius <= 0 ) {		CG_Error( "CG_ImpactMark called with <= 0 radius" );	}	//if ( markTotal >= MAX_MARK_POLYS ) {	//	return;	//}	// create the texture axis	VectorNormalize2( dir, axis[0] );	PerpendicularVector( axis[1], axis[0] );	RotatePointAroundVector( axis[2], axis[0], axis[1], orientation );	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];	}	// get the fragments	VectorScale( dir, -20, projection );	numFragments = trap_CM_MarkFragments( 4, (const vec3_t *) originalPoints,					projection, MAX_MARK_POINTS, markPoints[0],					MAX_MARK_FRAGMENTS, markFragments );	colors[0] = red * 255;	colors[1] = green * 255;	colors[2] = blue * 255;	colors[3] = alpha * 255;	for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) {		polyVert_t	*v;		polyVert_t	verts[MAX_VERTS_ON_POLY];		markPoly_t	*mark;		// we have an upper limit on the complexity of polygons		// that we store persistantly		if ( mf->numPoints > MAX_VERTS_ON_POLY ) {			mf->numPoints = MAX_VERTS_ON_POLY;		}		for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) {			vec3_t		delta;			VectorCopy( markPoints[mf->firstPoint + j], 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;		}		// if it is a temporary (shadow) mark, add it immediately and forget about it		if ( temporary ) {			trap_R_AddPolyToScene( markShader, mf->numPoints, verts );			continue;		}		// otherwise save it persistantly		mark = CG_AllocMark();		mark->time = cg.time;		mark->alphaFade = alphaFade;		mark->markShader = markShader;		mark->poly.numVerts = mf->numPoints;		mark->color[0] = red;		mark->color[1] = green;		mark->color[2] = blue;		mark->color[3] = alpha;		memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );		markTotal++;//.........这里部分代码省略.........
开发者ID:jwginge,项目名称:ojpa,代码行数:101,


示例2: CM_AddFacetBevels

void CM_AddFacetBevels( facet_t *facet ) {	int i, j, k, l;	int axis, dir, order, flipped;	float plane[4], d, newplane[4];	winding_t *w, *w2;	vec3_t mins, maxs, vec, vec2;#ifndef ADDBEVELS	return;#endif	Vector4Copy( planes[ facet->surfacePlane ].plane, plane );	w = BaseWindingForPlane( plane,  plane[3] );	for ( j = 0 ; j < facet->numBorders && w ; j++ ) {		if (facet->borderPlanes[j] == facet->surfacePlane) continue;		Vector4Copy( planes[ facet->borderPlanes[j] ].plane, plane );		if ( !facet->borderInward[j] ) {			VectorSubtract( vec3_origin, plane, plane );			plane[3] = -plane[3];		}		ChopWindingInPlace( &w, plane, plane[3], 0.1f );	}	if ( !w ) {		return;	}	WindingBounds(w, mins, maxs);	// add the axial planes	order = 0;	for ( axis = 0 ; axis < 3 ; axis++ )	{		for ( dir = -1 ; dir <= 1 ; dir += 2, order++ )		{			VectorClear(plane);			plane[axis] = dir;			if (dir == 1) {				plane[3] = maxs[axis];			}			else {				plane[3] = -mins[axis];			}			//if it's the surface plane			if (CM_PlaneEqual(&planes[facet->surfacePlane], plane, &flipped)) {				continue;			}			// see if the plane is allready present			for ( i = 0 ; i < facet->numBorders ; i++ ) {				if (CM_PlaneEqual(&planes[facet->borderPlanes[i]], plane, &flipped))					break;			}			if ( i == facet->numBorders ) {				if (facet->numBorders > 4 + 6 + 16) {					Com_Printf("ERROR: too many bevels/n");					continue;				}				facet->borderPlanes[facet->numBorders] = CM_FindPlane2(plane, &flipped);				facet->borderNoAdjust[facet->numBorders] = qfalse;				facet->borderInward[facet->numBorders] = flipped;				facet->numBorders++;			}		}	}	//	// add the edge bevels	//	// test the non-axial plane edges	for ( j = 0 ; j < w->numpoints ; j++ )	{		k = (j+1)%w->numpoints;		VectorSubtract (w->p[j], w->p[k], vec);		//if it's a degenerate edge		if (VectorNormalize (vec) < 0.5f)			continue;		CM_SnapVector(vec);		for ( k = 0; k < 3 ; k++ )			if ( vec[k] == -1 || vec[k] == 1 )				break;	// axial		if ( k < 3 )			continue;	// only test non-axial edges		// try the six possible slanted axials from this edge		for ( axis = 0 ; axis < 3 ; axis++ )		{			for ( dir = -1 ; dir <= 1 ; dir += 2 )			{				// construct a plane				VectorClear (vec2);				vec2[axis] = dir;				CrossProduct (vec, vec2, plane);				if (VectorNormalize (plane) < 0.5f)					continue;				plane[3] = DotProduct (w->p[j], plane);				// if all the points of the facet winding are//.........这里部分代码省略.........
开发者ID:ouned,项目名称:jk2mv,代码行数:101,


示例3: PM_SlideMove

//.........这里部分代码省略.........		// if this is the same plane we hit before, nudge velocity		// out along it, which fixes some epsilon issues with		// non-axial planes		//		for ( i = 0 ; i < numplanes ; i++ ) {			if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) {				VectorAdd( trace.plane.normal, pm->ps->velocity, pm->ps->velocity );				break;			}		}		if ( i < numplanes ) {			continue;		}		VectorCopy (trace.plane.normal, planes[numplanes]);		numplanes++;		//		// modify velocity so it parallels all of the clip planes		//		// find a plane that it enters		for ( i = 0 ; i < numplanes ; i++ ) {			into = DotProduct( pm->ps->velocity, planes[i] );			if ( into >= 0.1 ) {				continue;		// move doesn't interact with the plane			}			// see how hard we are hitting things			if ( -into > pml.impactSpeed ) {				pml.impactSpeed = -into;			}			// slide along the plane			PM_ClipVelocity (pm->ps->velocity, planes[i], clipVelocity, OVERCLIP );			// slide along the plane			PM_ClipVelocity (endVelocity, planes[i], endClipVelocity, OVERCLIP );			// see if there is a second plane that the new move enters			for ( j = 0 ; j < numplanes ; j++ ) {				if ( j == i ) {					continue;				}				if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) {					continue;		// move doesn't interact with the plane				}				// try clipping the move to the plane				PM_ClipVelocity( clipVelocity, planes[j], clipVelocity, OVERCLIP );				PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP );				// see if it goes back into the first clip plane				if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) {					continue;				}				// slide the original velocity along the crease				CrossProduct (planes[i], planes[j], dir);				VectorNormalize( dir );				d = DotProduct( dir, pm->ps->velocity );				VectorScale( dir, d, clipVelocity );				CrossProduct (planes[i], planes[j], dir);				VectorNormalize( dir );				d = DotProduct( dir, endVelocity );				VectorScale( dir, d, endClipVelocity );				// see if there is a third plane the the new move enters				for ( k = 0 ; k < numplanes ; k++ ) {					if ( k == i || k == j ) {						continue;					}					if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) {						continue;		// move doesn't interact with the plane					}					// stop dead at a tripple plane interaction					VectorClear( pm->ps->velocity );					return qtrue;				}			}			// if we have fixed all interactions, try another move			VectorCopy( clipVelocity, pm->ps->velocity );			VectorCopy( endClipVelocity, endVelocity );			break;		}	}	if ( gravity ) {		VectorCopy( endVelocity, pm->ps->velocity );	}	// don't change velocity if in a timer (FIXME: is this correct?)	if ( pm->ps->pm_time ) {		VectorCopy( primal_velocity, pm->ps->velocity );	}	return ( bumpcount != 0 );}
开发者ID:Mixone-FinallyHere,项目名称:SmokinGuns,代码行数:101,


示例4: R_GetPortalOrientations

/*=================R_GetPortalOrientationentityNum is the entity that the portal surface is a part of, which maybe moving and rotating.Returns qtrue if it should be mirrored=================*/qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, 							 orientation_t *surface, orientation_t *camera,							 vec3_t pvsOrigin, qboolean *mirror ) {	int			i;	cplane_t	originalPlane, plane;	trRefEntity_t	*e;	float		d;	vec3_t		transformed;	// create plane axis for the portal we are seeing	R_PlaneForSurface( drawSurf->surface, &originalPlane );	// rotate the plane if necessary	if ( entityNum != REFENTITYNUM_WORLD ) {		tr.currentEntityNum = entityNum;		tr.currentEntity = &tr.refdef.entities[entityNum];		// get the orientation of the entity		R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or );		// rotate the plane, but keep the non-rotated version for matching		// against the portalSurface entities		R_LocalNormalToWorld( originalPlane.normal, plane.normal );		plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin );		// translate the original plane		originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin );	} else {		plane = originalPlane;	}	VectorCopy( plane.normal, surface->axis[0] );	PerpendicularVector( surface->axis[1], surface->axis[0] );	CrossProduct( surface->axis[0], surface->axis[1], surface->axis[2] );	// locate the portal entity closest to this plane.	// origin will be the origin of the portal, origin2 will be	// the origin of the camera	for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) {		e = &tr.refdef.entities[i];		if ( e->e.reType != RT_PORTALSURFACE ) {			continue;		}		d = DotProduct( e->e.origin, originalPlane.normal ) - originalPlane.dist;		if ( d > 64 || d < -64) {			continue;		}		// get the pvsOrigin from the entity		VectorCopy( e->e.oldorigin, pvsOrigin );		// if the entity is just a mirror, don't use as a camera point		if ( e->e.oldorigin[0] == e->e.origin[0] && 			e->e.oldorigin[1] == e->e.origin[1] && 			e->e.oldorigin[2] == e->e.origin[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] );			*mirror = qtrue;			return qtrue;		}		// project the origin onto the surface plane to get		// an origin point we can rotate around		d = DotProduct( e->e.origin, plane.normal ) - plane.dist;		VectorMA( e->e.origin, -d, surface->axis[0], surface->origin );					// now get the camera origin and orientation		VectorCopy( e->e.oldorigin, camera->origin );		AxisCopy( e->e.axis, camera->axis );		VectorSubtract( vec3_origin, camera->axis[0], camera->axis[0] );		VectorSubtract( vec3_origin, camera->axis[1], camera->axis[1] );		// optionally rotate		if ( e->e.oldframe ) {			// if a speed is specified			if ( e->e.frame ) {				// continuous rotate				d = (tr.refdef.time/1000.0f) * e->e.frame;				VectorCopy( camera->axis[1], transformed );				RotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d );				CrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] );			} else {				// bobbing rotate, with skinNum being the rotation offset				d = sin( tr.refdef.time * 0.003f );				d = e->e.skinNum + d * 4;//.........这里部分代码省略.........
开发者ID:eyesonlyhack,项目名称:engine,代码行数:101,


示例5: GenerateTerrain

Model* GenerateTerrain(TextureData *tex){		int vertexCount = tex->width * tex->height;	int triangleCount = (tex->width-1) * (tex->height-1) * 2;	int x, z;		GLfloat *vertexArray = malloc(sizeof(GLfloat) * 3 * vertexCount);	GLfloat *normalArray = malloc(sizeof(GLfloat) * 3 * vertexCount);	GLfloat *texCoordArray = malloc(sizeof(GLfloat) * 2 * vertexCount);	GLuint *indexArray = malloc(sizeof(GLuint) * triangleCount*3);	vec3 u, v;	printf("bpp %d/n", tex->bpp);	for (x = 0; x < tex->width; x++)		for (z = 0; z < tex->height; z++)		{// Vertex array. You need to scale this properly			vertexArray[(x + z * tex->width)*3 + 0] = x / 5.0;			vertexArray[(x + z * tex->width)*3 + 1] = tex->imageData[(x + z * tex->width) * (tex->bpp/8)] / 100.0;			vertexArray[(x + z * tex->width)*3 + 2] = z / 5.0;// Normal vectors. You need to calculate these.			normalArray[(x + z * tex->width)*3 + 0] = 0.0;			normalArray[(x + z * tex->width)*3 + 1] = 1.0;			normalArray[(x + z * tex->width)*3 + 2] = 0.0;// Texture coordinates. You may want to scale them.			texCoordArray[(x + z * tex->width)*2 + 0] = x; // (float)x / tex->width;			texCoordArray[(x + z * tex->width)*2 + 1] = z; // (float)z / tex->height;		}	for (x = 0; x < tex->width-1; x++)		for (z = 0; z < tex->height-1; z++)		{		// Triangle 1			indexArray[(x + z * (tex->width-1))*6 + 0] = x + z * tex->width;			indexArray[(x + z * (tex->width-1))*6 + 1] = x + (z+1) * tex->width;			indexArray[(x + z * (tex->width-1))*6 + 2] = x+1 + z * tex->width;		// Triangle 2			indexArray[(x + z * (tex->width-1))*6 + 3] = x+1 + z * tex->width;			indexArray[(x + z * (tex->width-1))*6 + 4] = x + (z+1) * tex->width;			indexArray[(x + z * (tex->width-1))*6 + 5] = x+1 + (z+1) * tex->width;			// ber
C++ CryLog函数代码示例
C++ CreateWindowL函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。