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

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

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

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

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

示例1: R_LoadMDM

//.........这里部分代码省略.........		}		// find the next surface		mdmSurf = ( mdmSurface_t * )(( byte * ) mdmSurf + mdmSurf->ofsEnd);	}	// loading is done now calculate the bounding box and tangent spaces	ClearBounds(mdmModel->bounds[0], mdmModel->bounds[1]);	for (i = 0, surf = mdmModel->surfaces; i < mdmModel->numSurfaces; i++, surf++)	{		for (j = 0, v = surf->verts; j < surf->numVerts; j++, v++)		{			vec3_t      tmpVert;			md5Weight_t *w;			VectorClear(tmpVert);			for (k = 0, w = v->weights[0]; k < v->numWeights; k++, w++)			{				//vec3_t          offsetVec;				//VectorClear(offsetVec);				//bone = &md5->bones[w->boneIndex];				//QuatTransformVector(bone->rotation, w->offset, offsetVec);				//VectorAdd(bone->origin, offsetVec, offsetVec);				VectorMA(tmpVert, w->boneWeight, w->offset, tmpVert);			}			VectorCopy(tmpVert, v->position);			AddPointToBounds(tmpVert, mdmModel->bounds[0], mdmModel->bounds[1]);		}		// calc tangent spaces#if 0		{			const float *v0, *v1, *v2;			const float *t0, *t1, *t2;			vec3_t      tangent;			vec3_t      binormal;			vec3_t      normal;			for (j = 0, v = surf->verts; j < surf->numVerts; j++, v++)			{				VectorClear(v->tangent);				VectorClear(v->binormal);				VectorClear(v->normal);			}			for (j = 0, tri = surf->triangles; j < surf->numTriangles; j++, tri++)			{				v0 = surf->verts[tri->indexes[0]].position;				v1 = surf->verts[tri->indexes[1]].position;				v2 = surf->verts[tri->indexes[2]].position;				t0 = surf->verts[tri->indexes[0]].texCoords;				t1 = surf->verts[tri->indexes[1]].texCoords;				t2 = surf->verts[tri->indexes[2]].texCoords;#if 1				R_CalcTangentSpace(tangent, binormal, normal, v0, v1, v2, t0, t1, t2);#else				R_CalcNormalForTriangle(normal, v0, v1, v2);
开发者ID:scenna,项目名称:etlegacy,代码行数:67,


示例2: FogDrawSurfaces

void FogDrawSurfaces(entity_t * e){	int             i, j, k, fogNum;	fog_t          *fog;	mapDrawSurface_t *ds;	vec3_t          mins, maxs;	int             fogged, numFogged;	int             numBaseDrawSurfs;	/* note it */	Sys_FPrintf(SYS_VRB, "----- FogDrawSurfs -----/n");	/* reset counters */	numFogged = 0;	numFogFragments = 0;	/* walk fog list */	for(fogNum = 0; fogNum < numMapFogs; fogNum++)	{		/* get fog */		fog = &mapFogs[fogNum];		/* clip each surface into this, but don't clip any of the resulting fragments to the same brush */		numBaseDrawSurfs = numMapDrawSurfs;		for(i = 0; i < numBaseDrawSurfs; i++)		{			/* get the drawsurface */			ds = &mapDrawSurfs[i];			/* no fog? */			if(ds->shaderInfo->noFog)				continue;			/* global fog doesn't have a brush */			if(fog->brush == NULL)			{				/* don't re-fog already fogged surfaces */				if(ds->fogNum >= 0)					continue;				fogged = 1;			}			else			{				/* find drawsurface bounds */				ClearBounds(mins, maxs);				for(j = 0; j < ds->numVerts; j++)					AddPointToBounds(ds->verts[j].xyz, mins, maxs);				/* check against the fog brush */				for(k = 0; k < 3; k++)				{					if(mins[k] > fog->brush->maxs[k])						break;					if(maxs[k] < fog->brush->mins[k])						break;				}				/* no intersection? */				if(k < 3)					continue;				/* ydnar: gs mods: handle the various types of surfaces */				switch (ds->type)				{						/* handle brush faces */					case SURFACE_FACE:						fogged = ChopFaceSurfaceByBrush(e, ds, fog->brush);						break;						/* handle patches */					case SURFACE_PATCH:						fogged = ChopPatchSurfaceByBrush(e, ds, fog->brush);						break;						/* handle triangle surfaces (fixme: split triangle surfaces) */					case SURFACE_TRIANGLES:					case SURFACE_FORCED_META:					case SURFACE_META:						fogged = 1;						break;						/* no fogging */					default:						fogged = 0;						break;				}			}			/* is this surface fogged? */			if(fogged)			{				numFogged += fogged;				ds->fogNum = fogNum;			}		}	}	/* emit some statistics */	Sys_FPrintf(SYS_VRB, "%9d fog polygon fragments/n", numFogFragments);//.........这里部分代码省略.........
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:101,


示例3: ExpandBrush

/*============ExpandBrush=============*/void ExpandBrush (int hullnum){	int			i, x, s;	vec3_t		corner;	winding_t	*w;	plane_t		plane;	int				j, k, numwindings;	vec_t			r;	winding_t		**windings;	plane_t			clipplane, faceplane;	mface_t			*mf;	vec3_t			point;	vec3_t		mins, maxs;	if (!numbrushfaces)		return;	num_hull_points = 0;	num_hull_edges = 0;	ClearBounds( mins, maxs );	// generate windings and bounds data	numwindings = 0;	windings = calloc(numbrushfaces, sizeof(*windings));	for (i = 0;i < numbrushfaces;i++)	{		mf = &faces[i];		windings[i] = NULL;		faceplane = mf->plane;		w = BaseWindingForPlane (&faceplane);		for (j = 0;j < numbrushfaces && w;j++)		{			clipplane = faces[j].plane;			if( j == i )				continue;			// flip the plane, because we want to keep the back side			VectorNegate(clipplane.normal, clipplane.normal);			clipplane.dist *= -1;			w = ClipWindingEpsilon (w, &clipplane, ON_EPSILON, true);		}		if (!w)			continue;	// overcontrained plane		for (j = 0;j < w->numpoints;j++)		{			for (k = 0;k < 3;k++)			{				point[k] = w->points[j][k];				r = Q_rint( point[k] );				if ( fabs( point[k] - r ) < ZERO_EPSILON)					w->points[j][k] = r;				else					w->points[j][k] = point[k];				// check for incomplete brushes				if( w->points[j][k] >= BOGUS_RANGE || w->points[j][k] <= -BOGUS_RANGE )					return;			}			AddPointToBounds( w->points[j], mins, maxs );		}		windings[i] = w;	}	// add all of the corner offsets	for (i = 0;i < numwindings;i++)	{		w = windings[i];		for (j = 0;j < w->numpoints;j++)			AddHullPoint(w->points[j], hullnum);	}	// expand the face planes	for (i = 0;i < numbrushfaces;i++)	{		mf = &faces[i];		for (x=0 ; x<3 ; x++)		{			if (mf->plane.normal[x] > 0)				corner[x] = -hullinfo.hullsizes[hullnum][0][x];			else if (mf->plane.normal[x] < 0)				corner[x] = -hullinfo.hullsizes[hullnum][1][x];		}		mf->plane.dist += DotProduct (corner, mf->plane.normal);	}	// add any axis planes not contained in the brush to bevel off corners//.........这里部分代码省略.........
开发者ID:nekonomicon,项目名称:QuakeRemakeDevkit,代码行数:101,


示例4: R_MarkFragments

/*=================R_MarkFragments=================*/int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection,                     int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ){    int              numsurfaces, numPlanes;    int              i, j, k, m, n;    surfaceType_t    *surfaces[ 64 ];    vec3_t           mins, maxs;    int              returnedFragments;    int              returnedPoints;    vec3_t           normals[ MAX_VERTS_ON_POLY + 2 ];    float            dists[ MAX_VERTS_ON_POLY + 2 ];    vec3_t           clipPoints[ 2 ][ MAX_VERTS_ON_POLY ];    int              numClipPoints;    float            *v;    srfSurfaceFace_t *face;    srfGridMesh_t    *cv;    srfTriangles_t   *trisurf;    srfVert_t        *dv;    srfTriangle_t    *tri;    vec3_t           normal;    vec3_t           projectionDir;    vec3_t           v1, v2;    //increment view count for double check prevention    tr.viewCountNoReset++;    //    VectorNormalize2( projection, projectionDir );    // find all the brushes that are to be considered    ClearBounds( mins, maxs );    for ( i = 0; i < numPoints; i++ )    {        vec3_t temp;        AddPointToBounds( points[ i ], mins, maxs );        VectorAdd( points[ i ], projection, temp );        AddPointToBounds( temp, mins, maxs );        // make sure we get all the leafs (also the one(s) in front of the hit surface)        VectorMA( points[ i ], -20, projectionDir, temp );        AddPointToBounds( temp, mins, maxs );    }    if ( numPoints > MAX_VERTS_ON_POLY )    {        numPoints = MAX_VERTS_ON_POLY;    }    // create the bounding planes for the to be projected polygon    for ( i = 0; i < numPoints; i++ )    {        VectorSubtract( points[( i + 1 ) % numPoints ], points[ i ], v1 );        VectorAdd( points[ i ], projection, v2 );        VectorSubtract( points[ i ], v2, v2 );        CrossProduct( v1, v2, normals[ i ] );        VectorNormalizeFast( normals[ i ] );        dists[ i ] = DotProduct( normals[ i ], points[ i ] );    }    // add near and far clipping planes for projection    VectorCopy( projectionDir, normals[ numPoints ] );    dists[ numPoints ] = DotProduct( normals[ numPoints ], points[ 0 ] ) - 32;    VectorCopy( projectionDir, normals[ numPoints + 1 ] );    VectorInverse( normals[ numPoints + 1 ] );    dists[ numPoints + 1 ] = DotProduct( normals[ numPoints + 1 ], points[ 0 ] ) - 20;    numPlanes = numPoints + 2;    numsurfaces = 0;    R_BoxSurfaces_r( tr.world->nodes, mins, maxs, surfaces, 64, &numsurfaces, projectionDir );    returnedPoints = 0;    returnedFragments = 0;    for ( i = 0; i < numsurfaces; i++ )    {        if ( *surfaces[ i ] == SF_GRID )        {            cv = ( srfGridMesh_t * ) surfaces[ i ];            for ( m = 0; m < cv->height - 1; m++ )            {                for ( n = 0; n < cv->width - 1; n++ )                {                    // We triangulate the grid and chop all triangles within                    // the bounding planes of the to be projected polygon.                    // LOD is not taken into account, not such a big deal though.                    //                    // It's probably much nicer to chop the grid itself and deal                    // with this chopped grid as an SF_GRID surface, so LOD will                    // be applied. However the LOD of that chopped grid must                    // be synced with the LOD of the original curve.                    // One way to do this; the chopped grid shares vertices with                    // the original curve. When LOD is applied to the original                    // curve the unused vertices are flagged. Now the chopped curve//.........这里部分代码省略.........
开发者ID:prodigeni,项目名称:Unvanquished,代码行数:101,


示例5: AAS_StoreArea

//===========================================================================//// Parameter:				-// Returns:					-// Changes Globals:		-//===========================================================================int AAS_StoreArea( tmp_area_t *tmparea ) {	int side, edgenum, i;	plane_t *plane;	tmp_face_t *tmpface;	aas_area_t *aasarea;	aas_edge_t *edge;	aas_face_t *aasface;	aas_faceindex_t aasfacenum;	vec3_t facecenter;	winding_t *w;	//when the area is merged go to the merged area	//FIXME: this isn't necessary anymore because the tree	//			is refreshed after area merging	while ( tmparea->mergedarea ) tmparea = tmparea->mergedarea;	//	if ( tmparea->invalid ) {		Error( "AAS_StoreArea: tried to store invalid area" );	}	//if there is an aas area already stored for this tmp area	if ( tmparea->aasareanum ) {		return -tmparea->aasareanum;	}	//	if ( ( *aasworld ).numareas >= max_aas.max_areas ) {		Error( "AAS_MAX_AREAS = %d", max_aas.max_areas );	} //end if	  //area zero is a dummy	if ( ( *aasworld ).numareas == 0 ) {		( *aasworld ).numareas = 1;	}	//create an area from this leaf	aasarea = &( *aasworld ).areas[( *aasworld ).numareas];	aasarea->areanum = ( *aasworld ).numareas;	aasarea->numfaces = 0;	aasarea->firstface = ( *aasworld ).faceindexsize;	ClearBounds( aasarea->mins, aasarea->maxs );	VectorClear( aasarea->center );	////	Log_Write("tmparea %d became aasarea %d/r/n", tmparea->areanum, aasarea->areanum);	//store the aas area number at the tmp area	tmparea->aasareanum = aasarea->areanum;	//	for ( tmpface = tmparea->tmpfaces; tmpface; tmpface = tmpface->next[side] )	{		side = tmpface->frontarea != tmparea;		//if there's an aas face created for the tmp face already		if ( tmpface->aasfacenum ) {			//we're at the back of the face so use a negative index			aasfacenum = -tmpface->aasfacenum;#ifdef DEBUG			if ( tmpface->aasfacenum < 0 || tmpface->aasfacenum > max_aas.max_faces ) {				Error( "AAS_CreateTree_r: face number out of range" );			} //end if#endif //DEBUG			aasface = &( *aasworld ).faces[tmpface->aasfacenum];			aasface->backarea = aasarea->areanum;		} //end if		else		{			plane = &mapplanes[tmpface->planenum ^ side];			if ( side ) {				w = tmpface->winding;				tmpface->winding = ReverseWinding( tmpface->winding );			} //end if			if ( !AAS_GetFace( tmpface->winding, plane, 0, &aasfacenum ) ) {				continue;			}			if ( side ) {				FreeWinding( tmpface->winding );				tmpface->winding = w;			} //end if			aasface = &( *aasworld ).faces[aasfacenum];			aasface->frontarea = aasarea->areanum;			aasface->backarea = 0;			aasface->faceflags = tmpface->faceflags;			//set the face number at the tmp face			tmpface->aasfacenum = aasfacenum;		} //end else		  //add face points to the area bounds and		  //calculate the face 'center'		VectorClear( facecenter );		for ( edgenum = 0; edgenum < aasface->numedges; edgenum++ )		{			edge = &( *aasworld ).edges[abs( ( *aasworld ).edgeindex[aasface->firstedge + edgenum] )];			for ( i = 0; i < 2; i++ )			{				AddPointToBounds( ( *aasworld ).vertexes[edge->v[i]], aasarea->mins, aasarea->maxs );				VectorAdd( ( *aasworld ).vertexes[edge->v[i]], facecenter, facecenter );			} //end for		} //end for		VectorScale( facecenter, 1.0 / ( aasface->numedges * 2.0 ), facecenter );		//add the face 'center' to the area 'center'		VectorAdd( aasarea->center, facecenter, aasarea->center );//.........这里部分代码省略.........
开发者ID:chegestar,项目名称:omni-bot,代码行数:101,


示例6: R_LoadMD5

//.........这里部分代码省略.........			for (k = 0; k < v->numWeights; k++)			{				v->weights[k] = surf->weights + (v->firstWeight + k);			}		}	}	// loading is done now calculate the bounding box and tangent spaces	ClearBounds(md5->bounds[0], md5->bounds[1]);	for (i = 0, surf = md5->surfaces; i < md5->numSurfaces; i++, surf++)	{		for (j = 0, v = surf->verts; j < surf->numVerts; j++, v++)		{			vec3_t      tmpVert;			md5Weight_t *w;			VectorClear(tmpVert);			for (k = 0, w = v->weights[0]; k < v->numWeights; k++, w++)			{				vec3_t offsetVec;				bone = &md5->bones[w->boneIndex];				QuatTransformVector(bone->rotation, w->offset, offsetVec);				VectorAdd(bone->origin, offsetVec, offsetVec);				VectorMA(tmpVert, w->boneWeight, offsetVec, tmpVert);			}			VectorCopy(tmpVert, v->position);			AddPointToBounds(tmpVert, md5->bounds[0], md5->bounds[1]);		}		// calc tangent spaces#if 1		{			const float *v0, *v1, *v2;			const float *t0, *t1, *t2;			vec3_t      tangent;			vec3_t      binormal;			vec3_t      normal;			for (j = 0, v = surf->verts; j < surf->numVerts; j++, v++)			{				VectorClear(v->tangent);				VectorClear(v->binormal);				VectorClear(v->normal);			}			for (j = 0, tri = surf->triangles; j < surf->numTriangles; j++, tri++)			{				v0 = surf->verts[tri->indexes[0]].position;				v1 = surf->verts[tri->indexes[1]].position;				v2 = surf->verts[tri->indexes[2]].position;				t0 = surf->verts[tri->indexes[0]].texCoords;				t1 = surf->verts[tri->indexes[1]].texCoords;				t2 = surf->verts[tri->indexes[2]].texCoords;#if 1				R_CalcTangentSpace(tangent, binormal, normal, v0, v1, v2, t0, t1, t2);#else				R_CalcNormalForTriangle(normal, v0, v1, v2);
开发者ID:scenna,项目名称:etlegacy,代码行数:67,


示例7: BuildST

/*============BuildSTBuilds the triangle_st array for the base frame andmodel.skinwidth / model.skinheight  FIXME: allow this to be loaded from a file for  arbitrary mappings============*/void BuildST (triangle_t *ptri, int numtri){	int			i, j;	int			width, height, iwidth, iheight, swidth;	float		basex, basey;	float		s_scale, t_scale;	float		scale;	vec3_t		mins, maxs;	float		*pbasevert;	vec3_t		vtemp1, vtemp2, normal;	//	// find bounds of all the verts on the base frame	//	ClearBounds (mins, maxs);	for (i=0 ; i<numtri ; i++)		for (j=0 ; j<3 ; j++)			AddPointToBounds (ptri[i].verts[j], mins, maxs);	for (i=0 ; i<3 ; i++)	{		mins[i] = floor(mins[i]);		maxs[i] = ceil(maxs[i]);	}	width = maxs[0] - mins[0];	height = maxs[2] - mins[2];	if (!g_fixedwidth)	{	// old style		scale = 8;		if (width*scale >= 150)			scale = 150.0 / width;		if (height*scale >= 190)			scale = 190.0 / height;		s_scale = t_scale = scale;		iwidth = ceil(width*s_scale);		iheight = ceil(height*t_scale);		iwidth += 4;		iheight += 4;	}	else	{	// new style		iwidth = g_fixedwidth / 2;		iheight = g_fixedheight;		s_scale = (float)(iwidth-4) / width;		t_scale = (float)(iheight-4) / height;	}//// determine which side of each triangle to map the texture to//	for (i=0 ; i<numtri ; i++)	{		VectorSubtract (ptri[i].verts[0], ptri[i].verts[1], vtemp1);		VectorSubtract (ptri[i].verts[2], ptri[i].verts[1], vtemp2);		CrossProduct (vtemp1, vtemp2, normal);		if (normal[1] > 0)		{			basex = iwidth + 2;		}		else		{			basex = 2;		}		basey = 2;		for (j=0 ; j<3 ; j++)		{			pbasevert = ptri[i].verts[j];			triangle_st[i][j][0] = Q_rint((pbasevert[0] - mins[0]) * s_scale + basex);			triangle_st[i][j][1] = Q_rint((maxs[2] - pbasevert[2]) * t_scale + basey);		}	}// make the width a multiple of 4; some hardware requires this, and it ensures// dword alignment for each scan	swidth = iwidth*2;	model.skinwidth = (swidth + 3) & ~3;	model.skinheight = iheight;}
开发者ID:raynorpat,项目名称:cake,代码行数:99,


示例8: RE_AddPolyToScene

/*=====================RE_AddPolyToScene=====================*/void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ) {	srfPoly_t	*poly;	int			i, j;	int			fogIndex;	fog_t		*fog;	vec3_t		bounds[2];	if ( !tr.registered ) {		return;	}	if ( !hShader ) {		ri.Printf( PRINT_WARNING, "WARNING: RE_AddPolyToScene: NULL poly shader/n");		return;	}	for ( j = 0; j < numPolys; j++ ) {		if ( r_numpolyverts + numVerts > max_polyverts || r_numpolys >= max_polys ) {      /*      NOTE TTimo this was initially a PRINT_WARNING      but it happens a lot with high fighting scenes and particles      since we don't plan on changing the const and making for room for those effects      simply cut this message to developer only      */			ri.Printf( PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached/n");			return;		}		poly = &backEndData[tr.smpFrame]->polys[r_numpolys];		poly->surfaceType = SF_POLY;		poly->hShader = hShader;		poly->numVerts = numVerts;		poly->verts = &backEndData[tr.smpFrame]->polyVerts[r_numpolyverts];		Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) );		if ( glConfig.hardwareType == GLHW_RAGEPRO ) {			poly->verts->modulate[0] = 255;			poly->verts->modulate[1] = 255;			poly->verts->modulate[2] = 255;			poly->verts->modulate[3] = 255;		}		// done.		r_numpolys++;		r_numpolyverts += numVerts;		// if no world is loaded		if ( tr.world == NULL ) {			fogIndex = 0;		}		// see if it is in a fog volume		else if ( tr.world->numfogs == 1 ) {			fogIndex = 0;		} else {			// find which fog volume the poly is in			VectorCopy( poly->verts[0].xyz, bounds[0] );			VectorCopy( poly->verts[0].xyz, bounds[1] );			for ( i = 1 ; i < poly->numVerts ; i++ ) {				AddPointToBounds( poly->verts[i].xyz, bounds[0], bounds[1] );			}			for ( fogIndex = 1 ; fogIndex < tr.world->numfogs ; fogIndex++ ) {				fog = &tr.world->fogs[fogIndex];				if ( bounds[1][0] >= fog->bounds[0][0]					&& bounds[1][1] >= fog->bounds[0][1]					&& bounds[1][2] >= fog->bounds[0][2]					&& bounds[0][0] <= fog->bounds[1][0]					&& bounds[0][1] <= fog->bounds[1][1]					&& bounds[0][2] <= fog->bounds[1][2] ) {					break;				}			}			if ( fogIndex == tr.world->numfogs ) {				fogIndex = 0;			}		}		poly->fogIndex = fogIndex;	}}
开发者ID:Mixone-FinallyHere,项目名称:SmokinGuns,代码行数:84,


示例9: RE_AddPolyToScene

/*=======================================================================================================================================RE_AddPolyToScene=======================================================================================================================================*/void RE_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t *verts) {	srfPoly_t   *poly;	int i;	int fogIndex;	fog_t       *fog;	vec3_t bounds[2];	if (!tr.registered) {		return;	}	if (!hShader) {		// This isn't a useful warning, and an hShader of zero isn't a null shader, it's		// the default shader.		//ri.Printf(PRINT_WARNING, "WARNING: RE_AddPolyToScene: NULL poly shader/n");		//return;	}	if (((r_numpolyverts + numVerts) >= max_polyverts) || (r_numpolys >= max_polys)) {		return;	}	poly = &backEndData->polys[r_numpolys];	poly->surfaceType = SF_POLY;	poly->hShader = hShader;	poly->numVerts = numVerts;	poly->verts = &backEndData->polyVerts[r_numpolyverts];	memcpy(poly->verts, verts, numVerts * sizeof(*verts));	// Ridah	if (glConfig.hardwareType == GLHW_RAGEPRO) {		poly->verts->modulate[0] = 255;		poly->verts->modulate[1] = 255;		poly->verts->modulate[2] = 255;		poly->verts->modulate[3] = 255;	}	// done.	r_numpolys++;	r_numpolyverts += numVerts;	// see if it is in a fog volume	if (tr.world->numfogs == 1) {		fogIndex = 0;	} else {		// find which fog volume the poly is in		VectorCopy(poly->verts[0].xyz, bounds[0]);		VectorCopy(poly->verts[0].xyz, bounds[1]);		for (i = 1 ; i < poly->numVerts ; i++) {			AddPointToBounds(poly->verts[i].xyz, bounds[0], bounds[1]);		}		for (fogIndex = 1 ; fogIndex < tr.world->numfogs ; fogIndex++) {			fog = &tr.world->fogs[fogIndex];			if (bounds[1][0] >= fog->bounds[0][0]				 && bounds[1][1] >= fog->bounds[0][1]				 && bounds[1][2] >= fog->bounds[0][2]				 && bounds[0][0] <= fog->bounds[1][0]				 && bounds[0][1] <= fog->bounds[1][1]				 && bounds[0][2] <= fog->bounds[1][2]) {				break;			}		}		if (fogIndex == tr.world->numfogs) {			fogIndex = 0;		}	}	poly->fogIndex = fogIndex;}
开发者ID:ioid3-games,项目名称:ioid3-rtcw,代码行数:73,


示例10: R_MarkFragments

/*=================R_MarkFragments=================*/int R_MarkFragments( int orientation, const vec3_t *points, const vec3_t projection,					 int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) {	int numsurfaces, numPlanes;	int i, j, k, m, n;	surfaceType_t   *surfaces[4096];	vec3_t mins, maxs;	int returnedFragments;	int returnedPoints;	vec3_t normals[MAX_VERTS_ON_POLY + 2];	float dists[MAX_VERTS_ON_POLY + 2];	vec3_t clipPoints[2][MAX_VERTS_ON_POLY];	int numClipPoints;	float           *v;	srfGridMesh_t   *cv;	drawVert_t      *dv;	vec3_t normal;	vec3_t projectionDir;	vec3_t v1, v2;	int             *indexes;	float radius;	vec3_t center;          // center of original mark	int numPoints = 4;              // Ridah, we were only ever passing in 4, so I made this local and used the parameter for the orientation	qboolean oldMapping = qfalse;	if (numPoints <= 0) {		return 0;	}	//increment view count for double check prevention	tr.viewCount++;	// RF, negative maxFragments means we want original mapping	if ( maxFragments < 0 ) {		maxFragments = -maxFragments;		oldMapping = qtrue;	}	VectorClear( center );	for ( i = 0 ; i < numPoints ; i++ ) {		VectorAdd( points[i], center, center );	}	VectorScale( center, 1.0 / numPoints, center );	//	radius = VectorNormalize2( projection, projectionDir ) / 2.0;	bestdist = 0;	VectorNegate( projectionDir, bestnormal );	// find all the brushes that are to be considered	ClearBounds( mins, maxs );	for ( i = 0 ; i < numPoints ; i++ ) {		vec3_t temp;		AddPointToBounds( points[i], mins, maxs );		VectorMA( points[i], 1 * ( 1 + oldMapping * radius * 4 ), projection, temp );		AddPointToBounds( temp, mins, maxs );		// make sure we get all the leafs (also the one(s) in front of the hit surface)		VectorMA( points[i], -20 * ( 1.0 + (float)oldMapping * ( radius / 20.0 ) * 4 ), projectionDir, temp );		AddPointToBounds( temp, mins, maxs );	}	if ( numPoints > MAX_VERTS_ON_POLY ) {		numPoints = MAX_VERTS_ON_POLY;	}	// create the bounding planes for the to be projected polygon	for ( i = 0 ; i < numPoints ; i++ ) {		VectorSubtract( points[( i + 1 ) % numPoints], points[i], v1 );		VectorAdd( points[i], projection, v2 );		VectorSubtract( points[i], v2, v2 );		CrossProduct( v1, v2, normals[i] );		VectorNormalize( normals[i] );		dists[i] = DotProduct( normals[i], points[i] );	}	// add near and far clipping planes for projection	VectorCopy( projectionDir, normals[numPoints] );	dists[numPoints] = DotProduct( normals[numPoints], points[0] ) - radius * ( 1 + oldMapping * 10 );	VectorCopy( projectionDir, normals[numPoints + 1] );	VectorInverse( normals[numPoints + 1] );	dists[numPoints + 1] = DotProduct( normals[numPoints + 1], points[0] ) - radius * ( 1 + oldMapping * 10 );	numPlanes = numPoints + 2;	numsurfaces = 0;	R_BoxSurfaces_r( tr.world->nodes, mins, maxs, surfaces, 4096, &numsurfaces, projectionDir );	returnedPoints = 0;	returnedFragments = 0;	// find the closest surface to center the decal there, and wrap around other surfaces	if ( !oldMapping ) {		VectorNegate( bestnormal, bestnormal );	}	for ( i = 0 ; i < numsurfaces ; i++ ) {		if ( *surfaces[i] == SF_GRID ) {//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,


示例11: BeginModel

void BeginModel( void ){	bspModel_t  *mod;	brush_t     *b;	entity_t    *e;	vec3_t mins, maxs;	vec3_t lgMins, lgMaxs;          /* ydnar: lightgrid mins/maxs */	parseMesh_t *p;	int i;	/* test limits */	if ( numBSPModels == MAX_MAP_MODELS ) {		Error( "MAX_MAP_MODELS" );	}	/* get model and entity */	mod = &bspModels[ numBSPModels ];	e = &entities[ mapEntityNum ];	/* ydnar: lightgrid mins/maxs */	ClearBounds( lgMins, lgMaxs );	/* bound the brushes */	ClearBounds( mins, maxs );	for ( b = e->brushes; b; b = b->next )	{		/* ignore non-real brushes (origin, etc) */		if ( b->numsides == 0 ) {			continue;		}		AddPointToBounds( b->mins, mins, maxs );		AddPointToBounds( b->maxs, mins, maxs );		/* ydnar: lightgrid bounds */		if ( b->compileFlags & C_LIGHTGRID ) {			AddPointToBounds( b->mins, lgMins, lgMaxs );			AddPointToBounds( b->maxs, lgMins, lgMaxs );		}	}	/* bound patches */	for ( p = e->patches; p; p = p->next )	{		for ( i = 0; i < ( p->mesh.width * p->mesh.height ); i++ )			AddPointToBounds( p->mesh.verts[i].xyz, mins, maxs );	}	/* ydnar: lightgrid mins/maxs */	if ( lgMins[ 0 ] < 99999 ) {		/* use lightgrid bounds */		VectorCopy( lgMins, mod->mins );		VectorCopy( lgMaxs, mod->maxs );	}	else	{		/* use brush/patch bounds */		VectorCopy( mins, mod->mins );		VectorCopy( maxs, mod->maxs );	}	/* note size */	Sys_FPrintf( SYS_VRB, "BSP bounds: { %f %f %f } { %f %f %f }/n", mins[ 0 ], mins[ 1 ], mins[ 2 ], maxs[ 0 ], maxs[ 1 ], maxs[ 2 ] );	Sys_FPrintf( SYS_VRB, "Lightgrid bounds: { %f %f %f } { %f %f %f }/n", lgMins[ 0 ], lgMins[ 1 ], lgMins[ 2 ], lgMaxs[ 0 ], lgMaxs[ 1 ], lgMaxs[ 2 ] );	/* set firsts */	mod->firstBSPSurface = numBSPDrawSurfaces;	mod->firstBSPBrush = numBSPBrushes;}
开发者ID:TTimo,项目名称:GtkRadiant,代码行数:68,


示例12: R_LoadMD5

//.........这里部分代码省略.........			for ( k = 0; k < v->numWeights; k++ )			{				v->weights[ k ] = surf->weights + ( v->firstWeight + k );			}		}	}	// loading is done now calculate the bounding box and tangent spaces	ClearBounds( md5->bounds[ 0 ], md5->bounds[ 1 ] );	for ( i = 0, surf = md5->surfaces; i < md5->numSurfaces; i++, surf++ )	{		for ( j = 0, v = surf->verts; j < surf->numVerts; j++, v++ )		{			vec3_t      tmpVert;			md5Weight_t *w;			VectorClear( tmpVert );			for ( k = 0, w = v->weights[ 0 ]; k < v->numWeights; k++, w++ )			{				vec3_t offsetVec;				bone = &md5->bones[ w->boneIndex ];				QuatTransformVector( bone->rotation, w->offset, offsetVec );				VectorAdd( bone->origin, offsetVec, offsetVec );				VectorMA( tmpVert, w->boneWeight, offsetVec, tmpVert );			}			VectorCopy( tmpVert, v->position );			AddPointToBounds( tmpVert, md5->bounds[ 0 ], md5->bounds[ 1 ] );		}		// calc normals		{			const float *v0, *v1, *v2;			const float *t0, *t1, *t2;			vec3_t      normal;			for ( j = 0, v = surf->verts; j < surf->numVerts; j++, v++ )			{				VectorClear( v->tangent );				VectorClear( v->binormal );				VectorClear( v->normal );			}			for ( j = 0, tri = surf->triangles; j < surf->numTriangles; j++, tri++ )			{				v0 = surf->verts[ tri->indexes[ 0 ] ].position;				v1 = surf->verts[ tri->indexes[ 1 ] ].position;				v2 = surf->verts[ tri->indexes[ 2 ] ].position;				t0 = surf->verts[ tri->indexes[ 0 ] ].texCoords;				t1 = surf->verts[ tri->indexes[ 1 ] ].texCoords;				t2 = surf->verts[ tri->indexes[ 2 ] ].texCoords;				R_CalcNormalForTriangle( normal, v0, v1, v2 );				for ( k = 0; k < 3; k++ )				{					float *v;					v = surf->verts[ tri->indexes[ k ] ].normal;
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:67,


示例13: sizeof

/*=================R_CreateSurfaceGridMesh=================*/static srfGridMesh_t *R_CreateSurfaceGridMesh( int width, int height,    srfVert_t ctrl[ MAX_GRID_SIZE ][ MAX_GRID_SIZE ],    float errorTable[ 2 ][ MAX_GRID_SIZE ],    int numTriangles, srfTriangle_t triangles[ SHADER_MAX_TRIANGLES ] ){	int           i, j, size;	srfVert_t     *vert;	vec3_t        tmpVec;	srfGridMesh_t *grid;	// copy the results out to a grid	size = sizeof( *grid );	if ( r_stitchCurves->integer )	{		grid = (srfGridMesh_t*)/*ri.Hunk_Alloc */ Com_Allocate( size );		Com_Memset( grid, 0, size );		grid->widthLodError = (float*)/*ri.Hunk_Alloc */ Com_Allocate( width * 4 );		Com_Memcpy( grid->widthLodError, errorTable[ 0 ], width * 4 );		grid->heightLodError = (float*)/*ri.Hunk_Alloc */ Com_Allocate( height * 4 );		Com_Memcpy( grid->heightLodError, errorTable[ 1 ], height * 4 );		grid->numTriangles = numTriangles;		grid->triangles = (srfTriangle_t*) Com_Allocate( grid->numTriangles * sizeof( srfTriangle_t ) );		Com_Memcpy( grid->triangles, triangles, numTriangles * sizeof( srfTriangle_t ) );		grid->numVerts = ( width * height );		grid->verts = (srfVert_t*) Com_Allocate( grid->numVerts * sizeof( srfVert_t ) );	}	else	{		grid = (srfGridMesh_t*) ri.Hunk_Alloc( size, ha_pref::h_low );		Com_Memset( grid, 0, size );		grid->widthLodError = (float*) ri.Hunk_Alloc( width * 4, ha_pref::h_low );		Com_Memcpy( grid->widthLodError, errorTable[ 0 ], width * 4 );		grid->heightLodError = (float*) ri.Hunk_Alloc( height * 4, ha_pref::h_low );		Com_Memcpy( grid->heightLodError, errorTable[ 1 ], height * 4 );		grid->numTriangles = numTriangles;		grid->triangles = (srfTriangle_t*) ri.Hunk_Alloc( grid->numTriangles * sizeof( srfTriangle_t ), ha_pref::h_low );		Com_Memcpy( grid->triangles, triangles, numTriangles * sizeof( srfTriangle_t ) );		grid->numVerts = ( width * height );		grid->verts = (srfVert_t*) ri.Hunk_Alloc( grid->numVerts * sizeof( srfVert_t ), ha_pref::h_low );	}	grid->width = width;	grid->height = height;	grid->surfaceType = surfaceType_t::SF_GRID;	ClearBounds( grid->bounds[ 0 ], grid->bounds[ 1 ] );	for ( i = 0; i < width; i++ )	{		for ( j = 0; j < height; j++ )		{			vert = &grid->verts[ j * width + i ];			*vert = ctrl[ j ][ i ];			AddPointToBounds( vert->xyz, grid->bounds[ 0 ], grid->bounds[ 1 ] );		}	}	// compute local origin and bounds	VectorAdd( grid->bounds[ 0 ], grid->bounds[ 1 ], grid->origin );	VectorScale( grid->origin, 0.5f, grid->origin );	VectorSubtract( grid->bounds[ 0 ], grid->origin, tmpVec );	grid->radius = VectorLength( tmpVec );	VectorCopy( grid->origin, grid->lodOrigin );	grid->lodRadius = grid->radius;	//	return grid;}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:81,


示例14: R_UpdatePortalSurface

/** R_UpdatePortalSurface*/void R_UpdatePortalSurface( portalSurface_t *portalSurface, const mesh_t *mesh,	const vec3_t mins, const vec3_t maxs, const shader_t *shader ) {	unsigned int i;	float dist;	cplane_t plane, untransformed_plane;	vec3_t v[3];	const entity_t *ent;	if( !mesh || !portalSurface ) {		return;	}	ent = portalSurface->entity;	for( i = 0; i < 3; i++ ) {		VectorCopy( mesh->xyzArray[mesh->elems[i]], v[i] );	}	PlaneFromPoints( v, &untransformed_plane );	untransformed_plane.dist += DotProduct( ent->origin, untransformed_plane.normal );	untransformed_plane.dist += 1; // nudge along the normal a bit	CategorizePlane( &untransformed_plane );	if( shader->flags & SHADER_AUTOSPRITE ) {		vec3_t centre;		// autosprites are quads, facing the viewer		if( mesh->numVerts < 4 ) {			return;		}		// compute centre as average of 4 vertices		VectorCopy( mesh->xyzArray[mesh->elems[3]], centre );		for( i = 0; i < 3; i++ )			VectorAdd( centre, v[i], centre );		VectorMA( ent->origin, 0.25, centre, centre );		VectorNegate( &rn.viewAxis[AXIS_FORWARD], plane.normal );		plane.dist = DotProduct( plane.normal, centre );		CategorizePlane( &plane );	} else {		vec3_t temp;		mat3_t entity_rotation;		// regular surfaces		if( !Matrix3_Compare( ent->axis, axis_identity ) ) {			Matrix3_Transpose( ent->axis, entity_rotation );			for( i = 0; i < 3; i++ ) {				VectorCopy( v[i], temp );				Matrix3_TransformVector( entity_rotation, temp, v[i] );				VectorMA( ent->origin, ent->scale, v[i], v[i] );			}			PlaneFromPoints( v, &plane );			CategorizePlane( &plane );		} else {			plane = untransformed_plane;		}	}	if( ( dist = PlaneDiff( rn.viewOrigin, &plane ) ) <= BACKFACE_EPSILON ) {		// behind the portal plane		if( !( shader->flags & SHADER_PORTAL_CAPTURE2 ) ) {			return;		}		// we need to render the backplane view	}	// check if portal view is opaque due to alphagen portal	if( shader->portalDistance && dist > shader->portalDistance ) {		return;	}	portalSurface->plane = plane;	portalSurface->untransformed_plane = untransformed_plane;	AddPointToBounds( mins, portalSurface->mins, portalSurface->maxs );	AddPointToBounds( maxs, portalSurface->mins, portalSurface->maxs );	VectorAdd( portalSurface->mins, portalSurface->maxs, portalSurface->centre );	VectorScale( portalSurface->centre, 0.5, portalSurface->centre );}
开发者ID:Picmip,项目名称:qfusion,代码行数:86,


示例15: RE_BuildSkeleton

//.........这里部分代码省略.........#if defined(REFBONE_NAMES)			Q_strncpyz(skel->bones[i].name, channel->name, sizeof(skel->bones[i].name));#endif		}		skel->numBones = anim->numChannels;		skel->type     = SK_RELATIVE;		return qtrue;	}	else if (skelAnim->type == AT_PSA && skelAnim->psa)	{		int               i;		psaAnimation_t    *anim = skelAnim->psa;		axAnimationKey_t  *newKey, *oldKey;		axReferenceBone_t *refBone;		vec3_t            newOrigin, oldOrigin, lerpedOrigin;		quat_t            newQuat, oldQuat, lerpedQuat;		refSkeleton_t     skeleton;		Q_clamp(startFrame, 0, anim->info.numRawFrames - 1);		Q_clamp(endFrame, 0, anim->info.numRawFrames - 1);		ClearBounds(skel->bounds[0], skel->bounds[1]);		skel->numBones = anim->info.numBones;		for (i = 0, refBone = anim->bones; i < anim->info.numBones; i++, refBone++)		{			oldKey = &anim->keys[startFrame * anim->info.numBones + i];			newKey = &anim->keys[endFrame * anim->info.numBones + i];			VectorCopy(newKey->position, newOrigin);			VectorCopy(oldKey->position, oldOrigin);			quat_copy(newKey->quat, newQuat);			quat_copy(oldKey->quat, oldQuat);			//QuatCalcW(oldQuat);			//QuatNormalize(oldQuat);			//QuatCalcW(newQuat);			//QuatNormalize(newQuat);			VectorLerp(oldOrigin, newOrigin, frac, lerpedOrigin);			quat_slerp(oldQuat, newQuat, frac, lerpedQuat);			// copy lerped information to the bone + extra data			skel->bones[i].parentIndex = refBone->parentIndex;			if (refBone->parentIndex < 0 && clearOrigin)			{				VectorClear(skel->bones[i].origin);				QuatClear(skel->bones[i].rotation);				// move bounding box back				VectorSubtract(skel->bounds[0], lerpedOrigin, skel->bounds[0]);				VectorSubtract(skel->bounds[1], lerpedOrigin, skel->bounds[1]);			}			else			{				VectorCopy(lerpedOrigin, skel->bones[i].origin);			}			quat_copy(lerpedQuat, skel->bones[i].rotation);#if defined(REFBONE_NAMES)			Q_strncpyz(skel->bones[i].name, refBone->name, sizeof(skel->bones[i].name));#endif			// calculate absolute values for the bounding box approximation			VectorCopy(skel->bones[i].origin, skeleton.bones[i].origin);			quat_copy(skel->bones[i].rotation, skeleton.bones[i].rotation);			if (refBone->parentIndex >= 0)			{				vec3_t    rotated;				quat_t    quat;				refBone_t *bone   = &skeleton.bones[i];				refBone_t *parent = &skeleton.bones[refBone->parentIndex];				QuatTransformVector(parent->rotation, bone->origin, rotated);				VectorAdd(parent->origin, rotated, bone->origin);				QuatMultiply1(parent->rotation, bone->rotation, quat);				quat_copy(quat, bone->rotation);				AddPointToBounds(bone->origin, skel->bounds[0], skel->bounds[1]);			}		}		skel->numBones = anim->info.numBones;		skel->type     = SK_RELATIVE;		return qtrue;	}	//Ren_Warning( "RE_BuildSkeleton: bad animation '%s' with handle %i/n", anim->name, hAnim);	// FIXME: clear existing bones and bounds?	return qfalse;}
开发者ID:dustinduse,项目名称:etlegacy,代码行数:101,


示例16: RadSample

static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si, radWinding_t *rw, vec3_t average, vec3_t gradient, int *style ){	int i, j, k, l, v, x, y, samples;	vec3_t color, mins, maxs;	vec4_t textureColor;	float alpha, alphaI, bf;	vec3_t blend;	float st[ 2 ], lightmap[ 2 ], *radLuxel;	radVert_t   *rv[ 3 ];	/* initial setup */	ClearBounds( mins, maxs );	VectorClear( average );	VectorClear( gradient );	alpha = 0;	/* dummy check */	if ( rw == NULL || rw->numVerts < 3 ) {		return;	}	/* start sampling */	samples = 0;	/* sample vertex colors if no lightmap or this is the initial pass */	if ( lm == NULL || lm->radLuxels[ lightmapNum ] == NULL || bouncing == qfalse ) {		for ( samples = 0; samples < rw->numVerts; samples++ )		{			/* multiply by texture color */			if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, rw->verts[ samples ].st, textureColor ) ) {				VectorCopy( si->averageColor, textureColor );				textureColor[ 4 ] = 255.0f;			}			for ( i = 0; i < 3; i++ )				color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );			AddPointToBounds( color, mins, maxs );			VectorAdd( average, color, average );			/* get alpha */			alpha += ( textureColor[ 3 ] / 255.0f ) * ( rw->verts[ samples ].color[ lightmapNum ][ 3 ] / 255.0f );		}		/* set style */		*style = ds->vertexStyles[ lightmapNum ];	}	/* sample lightmap */	else	{		/* fracture the winding into a fan (including degenerate tris) */		for ( v = 1; v < ( rw->numVerts - 1 ) && samples < MAX_SAMPLES; v++ )		{			/* get a triangle */			rv[ 0 ] = &rw->verts[ 0 ];			rv[ 1 ] = &rw->verts[ v ];			rv[ 2 ] = &rw->verts[ v + 1 ];			/* this code is embarassing (really should just rasterize the triangle) */			for ( i = 1; i < SAMPLE_GRANULARITY && samples < MAX_SAMPLES; i++ )			{				for ( j = 1; j < SAMPLE_GRANULARITY && samples < MAX_SAMPLES; j++ )				{					for ( k = 1; k < SAMPLE_GRANULARITY && samples < MAX_SAMPLES; k++ )					{						/* create a blend vector (barycentric coordinates) */						blend[ 0 ] = i;						blend[ 1 ] = j;						blend[ 2 ] = k;						bf = ( 1.0 / ( blend[ 0 ] + blend[ 1 ] + blend[ 2 ] ) );						VectorScale( blend, bf, blend );						/* create a blended sample */						st[ 0 ] = st[ 1 ] = 0.0f;						lightmap[ 0 ] = lightmap[ 1 ] = 0.0f;						alphaI = 0.0f;						for ( l = 0; l < 3; l++ )						{							st[ 0 ] += ( rv[ l ]->st[ 0 ] * blend[ l ] );							st[ 1 ] += ( rv[ l ]->st[ 1 ] * blend[ l ] );							lightmap[ 0 ] += ( rv[ l ]->lightmap[ lightmapNum ][ 0 ] * blend[ l ] );							lightmap[ 1 ] += ( rv[ l ]->lightmap[ lightmapNum ][ 1 ] * blend[ l ] );							alphaI += ( rv[ l ]->color[ lightmapNum ][ 3 ] * blend[ l ] );						}						/* get lightmap xy coords */						x = lightmap[ 0 ] / (float) superSample;						y = lightmap[ 1 ] / (float) superSample;						if ( x < 0 ) {							x = 0;						}						else if ( x >= lm->w ) {							x = lm->w - 1;						}						if ( y < 0 ) {							y = 0;						}						else if ( y >= lm->h ) {							y = lm->h - 1;						}//.........这里部分代码省略.........
开发者ID:Hewster,项目名称:GtkRadiant,代码行数:101,


示例17: R_LoadPSK

//.........这里部分代码省略.........		}		if(vboVert->numWeights > MAX_WEIGHTS)		{			ri.Error(ERR_DROP, "R_LoadPSK: vertex %i requires more weights %i than the maximum of %i in model '%s'", i, vboVert->numWeights, MAX_WEIGHTS, modName);			//ri.Printf(PRINT_WARNING, "R_LoadPSK: vertex %i requires more weights %i than the maximum of %i in model '%s'/n", i, vboVert->numWeights, MAX_WEIGHTS, modName);		}		vboVert->weights = (md5Weight_t**)ri.Hunk_Alloc(sizeof(*vboVert->weights) * vboVert->numWeights, h_low);		for(j = 0, axWeight = axWeights, k = 0; j < numWeights; j++, axWeight++)		{			if(axWeight->pointIndex == vertex->pointIndex && axWeight->weight > 0.0f)			{				weight = (md5Weight_t*)ri.Hunk_Alloc(sizeof(*weight), h_low);				weight->boneIndex = axWeight->boneIndex;				weight->boneWeight = axWeight->weight;				// FIXME?				weight->offset[0] = refBones[axWeight->boneIndex].bone.xSize;				weight->offset[1] = refBones[axWeight->boneIndex].bone.ySize;				weight->offset[2] = refBones[axWeight->boneIndex].bone.zSize;				vboVert->weights[k++] = weight;			}		}		Com_AddToGrowList(&vboVertexes, vboVert);	}	ClearBounds(md5->bounds[0], md5->bounds[1]);	for(i = 0, vertex = vertexes; i < numVertexes; i++, vertex++)	{		AddPointToBounds(points[vertex->pointIndex].point, md5->bounds[0], md5->bounds[1]);	}#if 0	ri.Printf(PRINT_ALL, "R_LoadPSK: AABB (%i %i %i) (%i %i %i)/n",			(int)md5->bounds[0][0],			(int)md5->bounds[0][1],			(int)md5->bounds[0][2],			(int)md5->bounds[1][0],			(int)md5->bounds[1][1],			(int)md5->bounds[1][2]);#endif	// sort triangles	qsort(triangles, numTriangles, sizeof(axTriangle_t), CompareTrianglesByMaterialIndex);	Com_InitGrowList(&sortedTriangles, 1000);	for(i = 0, triangle = triangles; i < numTriangles; i++, triangle++)	{		skelTriangle_t *sortTri = (skelTriangle_t*)Com_Allocate(sizeof(*sortTri));		for(j = 0; j < 3; j++)		{			sortTri->indexes[j] = triangle->indexes[j];			sortTri->vertexes[j] = (md5Vertex_t*)Com_GrowListElement(&vboVertexes, triangle->indexes[j]);		}		sortTri->referenced = qfalse;		Com_AddToGrowList(&sortedTriangles, sortTri);	}	// calc tangent spaces#if 1
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:67,


示例18: RadSubdivideDiffuseLight

static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si,									  float scale, float subdivide, qboolean original, radWinding_t *rw, clipWork_t *cw ){	int i, style;	float dist, area, value;	vec3_t mins, maxs, normal, d1, d2, cross, color, gradient;	light_t         *light, *splash;	winding_t       *w;	/* dummy check */	if ( rw == NULL || rw->numVerts < 3 ) {		return;	}	/* get bounds for winding */	ClearBounds( mins, maxs );	for ( i = 0; i < rw->numVerts; i++ )		AddPointToBounds( rw->verts[ i ].xyz, mins, maxs );	/* subdivide if necessary */	for ( i = 0; i < 3; i++ )	{		if ( maxs[ i ] - mins[ i ] > subdivide ) {			radWinding_t front, back;			/* make axial plane */			VectorClear( normal );			normal[ i ] = 1;			dist = ( maxs[ i ] + mins[ i ] ) * 0.5f;			/* clip the winding */			RadClipWindingEpsilon( rw, normal, dist, RADIOSITY_CLIP_EPSILON, &front, &back, cw );			/* recurse */			RadSubdivideDiffuseLight( lightmapNum, ds, lm, si, scale, subdivide, qfalse, &front, cw );			RadSubdivideDiffuseLight( lightmapNum, ds, lm, si, scale, subdivide, qfalse, &back, cw );			return;		}	}	/* check area */	area = 0.0f;	for ( i = 2; i < rw->numVerts; i++ )	{		VectorSubtract( rw->verts[ i - 1 ].xyz, rw->verts[ 0 ].xyz, d1 );		VectorSubtract( rw->verts[ i ].xyz, rw->verts[ 0 ].xyz, d2 );		CrossProduct( d1, d2, cross );		area += 0.5f * VectorLength( cross );	}	if ( area < 1.0f || area > 20000000.0f ) {		return;	}	/* more subdivision may be necessary */	if ( bouncing ) {		/* get color sample for the surface fragment */		RadSample( lightmapNum, ds, lm, si, rw, color, gradient, &style );		/* if color gradient is too high, subdivide again */		if ( subdivide > minDiffuseSubdivide &&			 ( gradient[ 0 ] > RADIOSITY_MAX_GRADIENT || gradient[ 1 ] > RADIOSITY_MAX_GRADIENT || gradient[ 2 ] > RADIOSITY_MAX_GRADIENT ) ) {			RadSubdivideDiffuseLight( lightmapNum, ds, lm, si, scale, ( subdivide / 2.0f ), qfalse, rw, cw );			return;		}	}	/* create a regular winding and an average normal */	w = AllocWinding( rw->numVerts );	w->numpoints = rw->numVerts;	VectorClear( normal );	for ( i = 0; i < rw->numVerts; i++ )	{		VectorCopy( rw->verts[ i ].xyz, w->p[ i ] );		VectorAdd( normal, rw->verts[ i ].normal, normal );	}	VectorScale( normal, ( 1.0f / rw->numVerts ), normal );	if ( VectorNormalize( normal, normal ) == 0.0f ) {		return;	}	/* early out? */	if ( bouncing && VectorLength( color ) < RADIOSITY_MIN ) {		return;	}	/* debug code */	//%	Sys_Printf( "Size: %d %d %d/n", (int) (maxs[ 0 ] - mins[ 0 ]), (int) (maxs[ 1 ] - mins[ 1 ]), (int) (maxs[ 2 ] - mins[ 2 ]) );	//%	Sys_Printf( "Grad: %f %f %f/n", gradient[ 0 ], gradient[ 1 ], gradient[ 2 ] );	/* increment counts */	numDiffuseLights++;	switch ( ds->surfaceType )	{	case MST_PLANAR:		numBrushDiffuseLights++;		break;	case MST_TRIANGLE_SOUP:		numTriangleDiffuseLights++;//.........这里部分代码省略.........
开发者ID:Hewster,项目名称:GtkRadiant,代码行数:101,


示例19: Com_Error

/*===================CM_GeneratePatchCollideCreates an internal structure that will be used to performcollision detection with a patch mesh.Points is packed as concatenated rows.===================*/struct patchCollide_s	*CM_GeneratePatchCollide( int width, int height, vec3_t *points ) {	patchCollide_t	*pf;	MAC_STATIC cGrid_t			grid;	int				i, j;	if ( width <= 2 || height <= 2 || !points ) {		Com_Error( ERR_DROP, "CM_GeneratePatchFacets: bad parameters: (%i, %i, %p)",			width, height, points );	}	if ( !(width & 1) || !(height & 1) ) {		Com_Error( ERR_DROP, "CM_GeneratePatchFacets: even sizes are invalid for quadratic meshes" );	}	if ( width > MAX_GRID_SIZE || height > MAX_GRID_SIZE ) {		Com_Error( ERR_DROP, "CM_GeneratePatchFacets: source is > MAX_GRID_SIZE" );	}	// build a grid	grid.width = width;	grid.height = height;	grid.wrapWidth = false;	grid.wrapHeight = false;	for ( i = 0 ; i < width ; i++ ) {		for ( j = 0 ; j < height ; j++ ) {			VectorCopy( points[j*width + i], grid.points[i][j] );		}	}	// subdivide the grid	CM_SetGridWrapWidth( &grid );	CM_SubdivideGridColumns( &grid );	CM_RemoveDegenerateColumns( &grid );	CM_TransposeGrid( &grid );	CM_SetGridWrapWidth( &grid );	CM_SubdivideGridColumns( &grid );	CM_RemoveDegenerateColumns( &grid );	// we now have a grid of points exactly on the curve	// the aproximate surface defined by these points will be	// collided against	pf = reinterpret_cast<patchCollide_t*>(Hunk_Alloc( sizeof( *pf ), h_high ));	ClearBounds( pf->bounds[0], pf->bounds[1] );	for ( i = 0 ; i < grid.width ; i++ ) {		for ( j = 0 ; j < grid.height ; j++ ) {			AddPointToBounds( grid.points[i][j], pf->bounds[0], pf->bounds[1] );		}	}	c_totalPatchBlocks += ( grid.width - 1 ) * ( grid.height - 1 );	// generate a bsp tree for the surface	CM_PatchCollideFromGrid( &grid, pf );	// expand by one unit for epsilon purposes	pf->bounds[0][0] -= 1;	pf->bounds[0][1] -= 1;	pf->bounds[0][2] -= 1;	pf->bounds[1][0] += 1;	pf->bounds[1][1] += 1;	pf->bounds[1][2] += 1;	return pf;}
开发者ID:MilitaryForces,项目名称:MilitaryForces,代码行数:77,


示例20: ParseTriSurf

/*===============ParseTriSurf===============*/static void ParseTriSurf( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int *indexes, world_t &worldData, int index ) {    srfTriangles_t	*tri;    int				i, j, k;    int				numVerts, numIndexes;    // get fog volume    surf->fogIndex = LittleLong( ds->fogNum ) + 1;    if (index && !surf->fogIndex && tr.world && tr.world->globalFog != -1)    {        surf->fogIndex = worldData.globalFog;    }    // get shader    surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles, worldData );    if ( r_singleShader->integer && !surf->shader->sky ) {        surf->shader = tr.defaultShader;    }    numVerts = LittleLong( ds->numVerts );    numIndexes = LittleLong( ds->numIndexes );    if ( numVerts >= SHADER_MAX_VERTEXES ) {        Com_Error(ERR_DROP, "ParseTriSurf: verts > MAX (%d > %d) on misc_model %s", numVerts, SHADER_MAX_VERTEXES, surf->shader->name );    }    if ( numIndexes >= SHADER_MAX_INDEXES ) {        Com_Error(ERR_DROP, "ParseTriSurf: indices > MAX (%d > %d) on misc_model %s", numIndexes, SHADER_MAX_INDEXES, surf->shader->name );    }    tri = (srfTriangles_t *) Z_Malloc( sizeof( *tri ) + numVerts * sizeof( tri->verts[0] ) + numIndexes * sizeof( tri->indexes[0] ), TAG_HUNKMISCMODELS, qfalse );    tri->dlightBits = 0; //JIC    tri->surfaceType = SF_TRIANGLES;    tri->numVerts = numVerts;    tri->numIndexes = numIndexes;    tri->verts = (drawVert_t *)(tri + 1);    tri->indexes = (int *)(tri->verts + tri->numVerts );    surf->data = (surfaceType_t *)tri;    // copy vertexes    verts += LittleLong( ds->firstVert );    ClearBounds( tri->bounds[0], tri->bounds[1] );    for ( i = 0 ; i < numVerts ; i++ ) {        for ( j = 0 ; j < 3 ; j++ ) {            tri->verts[i].xyz[j] = LittleFloat( verts[i].xyz[j] );            tri->verts[i].normal[j] = LittleFloat( verts[i].normal[j] );        }        AddPointToBounds( tri->verts[i].xyz, tri->bounds[0], tri->bounds[1] );        for ( j = 0 ; j < 2 ; j++ ) {            tri->verts[i].st[j] = LittleFloat( verts[i].st[j] );            for(k=0; k<MAXLIGHTMAPS; k++)            {                tri->verts[i].lightmap[k][j] = LittleFloat( verts[i].lightmap[k][j] );            }        }        for(k=0; k<MAXLIGHTMAPS; k++)        {            R_ColorShiftLightingBytes( verts[i].color[k], tri->verts[i].color[k] );        }    }    // copy indexes    indexes += LittleLong( ds->firstIndex );    for ( i = 0 ; i < numIndexes ; i++ ) {        tri->indexes[i] = LittleLong( indexes[i] );        if ( tri->indexes[i] < 0 || tri->indexes[i] >= numVerts ) {            Com_Error( ERR_DROP, "Bad index in triangle surface" );        }    }}
开发者ID:Elfmagi,项目名称:OpenJK,代码行数:74,


示例21: GrabFrame

/*===============GrabFrame===============*/void GrabFrame (char *frame){	triangle_t	*ptri;	int			i, j;	trivert_t	*ptrivert;	int			num_tris;	char		file1[1024];	frame_t		*fr;	vertexnormals_t	vnorms[MAX_VERTS];	int		index_xyz;	char	*framefile;	// the frame 'run1' will be looked for as either	// run.1 or run1.tri, so the new alias sequence save	// feature an be used	framefile = FindFrameFile (frame);	sprintf (file1, "%s/%s", cdarchive, framefile);	ExpandPathAndArchive (file1);	sprintf (file1, "%s/%s",cddir, framefile);	printf ("grabbing %s/n", file1);	if (model.num_frames >= MAX_FRAMES)		Error ("model.num_frames >= MAX_FRAMES");	fr = &g_frames[model.num_frames];	model.num_frames++;	strcpy (fr->name, frame);//// load the frame//	if (do3ds)		Load3DSTriangleList (file1, &ptri, &num_tris);	else		LoadTriangleList (file1, &ptri, &num_tris);	if (num_tris != model.num_tris)		Error ("%s: number of triangles doesn't match base frame/n", file1);//// allocate storage for the frame's vertices//	ptrivert = fr->v;	for (i=0 ; i<model.num_xyz ; i++)	{		vnorms[i].numnormals = 0;		VectorClear (vnorms[i].normalsum);	}	ClearBounds (fr->mins, fr->maxs);//// store the frame's vertices in the same order as the base. This assumes the// triangles and vertices in this frame are in exactly the same order as in the// base//	for (i=0 ; i<num_tris ; i++)	{		vec3_t	vtemp1, vtemp2, normal;		float	ftemp;		VectorSubtract (ptri[i].verts[0], ptri[i].verts[1], vtemp1);		VectorSubtract (ptri[i].verts[2], ptri[i].verts[1], vtemp2);		CrossProduct (vtemp1, vtemp2, normal);		VectorNormalize2 (normal, normal);	// rotate the normal so the model faces down the positive x axis		ftemp = normal[0];		normal[0] = -normal[1];		normal[1] = ftemp;		for (j=0 ; j<3 ; j++)		{			index_xyz = triangles[i].index_xyz[j];		// rotate the vertices so the model faces down the positive x axis		// also adjust the vertices to the desired origin			ptrivert[index_xyz].v[0] = ((-ptri[i].verts[j][1]) * scale_up) +										adjust[0];			ptrivert[index_xyz].v[1] = (ptri[i].verts[j][0] * scale_up) +										adjust[1];			ptrivert[index_xyz].v[2] = (ptri[i].verts[j][2] * scale_up) +										adjust[2];			AddPointToBounds (ptrivert[index_xyz].v, fr->mins, fr->maxs);			VectorAdd (vnorms[index_xyz].normalsum, normal, vnorms[index_xyz].normalsum);			vnorms[index_xyz].numnormals++;		}	}//.........这里部分代码省略.........
开发者ID:raynorpat,项目名称:cake,代码行数:101,


示例22: RE_AddPolysToScene

/*=====================RE_AddPolysToScene=====================*/void RE_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ){	srfPoly_t *poly;	int       i;	int       fogIndex;	fog_t     *fog;	vec3_t    bounds[ 2 ];	int       j;	if ( !tr.registered )	{		return;	}	if ( !hShader )	{		ri.Printf( PRINT_DEVELOPER, "WARNING: RE_AddPolysToScene: NULL poly shader/n" );		return;	}	for ( j = 0; j < numPolys; j++ )	{		if ( r_numpolyverts + numVerts > max_polyverts || r_numpolys >= max_polys )		{//          ri.Printf( PRINT_WARNING, "WARNING: RE_AddPolysToScene: MAX_POLYS or MAX_POLYVERTS reached/n");			return;		}		poly = &backEndData[ tr.smpFrame ]->polys[ r_numpolys ];		poly->surfaceType = SF_POLY;		poly->hShader = hShader;		poly->numVerts = numVerts;		poly->verts = &backEndData[ tr.smpFrame ]->polyVerts[ r_numpolyverts ];		memcpy( poly->verts, &verts[ numVerts * j ], numVerts * sizeof( *verts ) );		// Ridah		if ( glConfig.hardwareType == GLHW_RAGEPRO )		{			poly->verts->modulate[ 0 ] = 255;			poly->verts->modulate[ 1 ] = 255;			poly->verts->modulate[ 2 ] = 255;			poly->verts->modulate[ 3 ] = 255;		}		// done.		r_numpolys++;		r_numpolyverts += numVerts;		// if no world is loaded		if ( tr.world == NULL )		{			fogIndex = 0;		}		// see if it is in a fog volume		else if ( tr.world->numfogs == 1 )		{			fogIndex = 0;		}		else		{			// find which fog volume the poly is in			VectorCopy( poly->verts[ 0 ].xyz, bounds[ 0 ] );			VectorCopy( poly->verts[ 0 ].xyz, bounds[ 1 ] );			for ( i = 1; i < poly->numVerts; i++ )			{				AddPointToBounds( poly->verts[ i ].xyz, bounds[ 0 ], bounds[ 1 ] );			}			for ( fogIndex = 1; fogIndex < tr.world->numfogs; fogIndex++ )			{				fog = &tr.world->fogs[ fogIndex ];				if ( bounds[ 1 ][ 0 ] >= fog->bounds[ 0 ][ 0 ]				     && bounds[ 1 ][ 1 ] >= fog->bounds[ 0 ][ 1 ]				     && bounds[ 1 ][ 2 ] >= fog->bounds[ 0 ][ 2 ]				     && bounds[ 0 ][ 0 ] <= fog->bounds[ 1 ][ 0 ] && bounds[ 0 ][ 1 ] <= fog->bounds[ 1 ][ 1 ] && bounds[ 0 ][ 2 ] <= fog->bounds[ 1 ][ 2 ] )				{					break;				}			}			if ( fogIndex == tr.world->numfogs )			{				fogIndex = 0;			}		}		poly->fogIndex = fogIndex;	}}
开发者ID:ZdrytchX,项目名称:Unvanquished-KoRx,代码行数:98,


示例23: Select_AutoCaulk

//.........这里部分代码省略.........							idVec3 v3ZeroTest;							idVec3 v3Zero;v3Zero.Zero();	//static idVec3 v3Zero={0,0,0};							VectorAdd(pSelectedFace->plane.Normal(),pScannedFace->plane.Normal(),v3ZeroTest);							if (v3ZeroTest == v3Zero)							{								// planes are facing each other...								//								// coplanar? (this is some maths of Gil's, which I don't even pretend to understand)								//								float fTotalDist = 0;								for (int _i=0; _i<3; _i++)								{									fTotalDist += fabs(	DotProduct(pSelectedFace->plane.Normal(),(*pSelectedWinding)[0])														-														DotProduct(pSelectedFace->plane.Normal(),(*pScannedWinding)[i])														);								}								//OutputDebugString(va("Dist = %g/n",fTotalDist));								if (fTotalDist > 0.01)									continue;								// every point in the selected face must be within (or equal to) the bounds of the								//	scanned face...								//								// work out the bounds first...								//								idVec3 v3ScannedBoundsMins, v3ScannedBoundsMaxs;								ClearBounds (v3ScannedBoundsMins, v3ScannedBoundsMaxs);								int iPoint;								for (iPoint=0; iPoint<pScannedWinding->GetNumPoints(); iPoint++)								{									AddPointToBounds( (*pScannedWinding)[iPoint].ToVec3(), v3ScannedBoundsMins, v3ScannedBoundsMaxs);								}								// floor 'em... (or .001 differences mess things up...								//								FloorBounds(v3ScannedBoundsMins, v3ScannedBoundsMaxs);								// now check points from selected face...								//								bool bWithin = true;								for (iPoint=0; iPoint < pSelectedWinding->GetNumPoints(); iPoint++)								{									for (int iXYZ=0; iXYZ<3; iXYZ++)									{										float f = floor((*pSelectedWinding)[iPoint][iXYZ] + 0.5);										if (!												(												f >= v3ScannedBoundsMins[iXYZ]												&&												f <= v3ScannedBoundsMaxs[iXYZ]												)											 )										{											bWithin = false;										}									}								}								if (bWithin)								{									PairBrushFace_t PairBrushFace;													PairBrushFace.pFace = pSelectedFace;													PairBrushFace.pBrush= pSelectedBrush;
开发者ID:DanielGibson,项目名称:dhewm3,代码行数:67,


示例24: RE_ProjectDecal

//.........这里部分代码省略.........	{		// set up omnidirectional		numPoints            = 4;		temp.numPlanes       = 6;		temp.omnidirectional = qtrue;		radius               = projection[3];		Vector4Set(projection, 0.0f, 0.0f, -1.0f, radius * 2.0f);		iDist = 1.0f / (radius * 2.0f);		// set corner		VectorSet(xyz, points[0][0] - radius, points[0][1] - radius, points[0][2] + radius);		// make x axis texture matrix (yz)		VectorSet(temp.texMat[0][0], 0.0f, iDist, 0.0f);		temp.texMat[0][0][3] = -DotProduct(temp.texMat[0][0], xyz);		VectorSet(temp.texMat[0][1], 0.0f, 0.0f, iDist);		temp.texMat[0][1][3] = -DotProduct(temp.texMat[0][1], xyz);		// make y axis texture matrix (xz)		VectorSet(temp.texMat[1][0], iDist, 0.0f, 0.0f);		temp.texMat[1][0][3] = -DotProduct(temp.texMat[1][0], xyz);		VectorSet(temp.texMat[1][1], 0.0f, 0.0f, iDist);		temp.texMat[1][1][3] = -DotProduct(temp.texMat[1][1], xyz);		// make z axis texture matrix (xy)		VectorSet(temp.texMat[2][0], iDist, 0.0f, 0.0f);		temp.texMat[2][0][3] = -DotProduct(temp.texMat[2][0], xyz);		VectorSet(temp.texMat[2][1], 0.0f, iDist, 0.0f);		temp.texMat[2][1][3] = -DotProduct(temp.texMat[2][1], xyz);		// setup decal points		VectorSet(dv[0].xyz, points[0][0] - radius, points[0][1] - radius, points[0][2] + radius);		VectorSet(dv[1].xyz, points[0][0] - radius, points[0][1] + radius, points[0][2] + radius);		VectorSet(dv[2].xyz, points[0][0] + radius, points[0][1] + radius, points[0][2] + radius);		VectorSet(dv[3].xyz, points[0][0] + radius, points[0][1] - radius, points[0][2] + radius);	}	else	{		// set up unidirectional		temp.omnidirectional = qfalse;		// set up decal points		VectorCopy(points[0], dv[0].xyz);		VectorCopy(points[1], dv[1].xyz);		VectorCopy(points[2], dv[2].xyz);		VectorCopy(points[3], dv[3].xyz);		// make texture matrix		if (!MakeTextureMatrix(temp.texMat[0], projection, &dv[0], &dv[1], &dv[2]))		{			return;		}	}	// bound the projector	ClearBounds(temp.mins, temp.maxs);	for (i = 0; i < numPoints; i++)	{		AddPointToBounds(dv[i].xyz, temp.mins, temp.maxs);		VectorMA(dv[i].xyz, projection[3], projection, xyz);		AddPointToBounds(xyz, temp.mins, temp.maxs);	}	// make bounding sphere	VectorAdd(temp.mins, temp.maxs, temp.center);	VectorScale(temp.center, 0.5f, temp.center);	VectorSubtract(temp.maxs, temp.center, xyz);	temp.radius  = VectorLength(xyz);	temp.radius2 = temp.radius * temp.radius;	// make the front plane	if (!PlaneFromPoints(temp.planes[0], dv[0].xyz, dv[1].xyz, dv[2].xyz))	{		return;	}	// make the back plane	VectorSubtract(vec3_origin, temp.planes[0], temp.planes[1]);	VectorMA(dv[0].xyz, projection[3], projection, xyz);	temp.planes[1][3] = DotProduct(xyz, temp.planes[1]);	// make the side planes	for (i = 0; i < numPoints; i++)	{		VectorMA(dv[i].xyz, projection[3], projection, xyz);		if (!PlaneFromPoints(temp.planes[i + 2], dv[(i + 1) % numPoints].xyz, dv[i].xyz, xyz))		{			return;		}	}	// create a new projector	dp = &backEndData->decalProjectors[r_numDecalProjectors];	Com_Memcpy(dp, &temp, sizeof(*dp));	dp->projectorNum = totalProjectors++;	// we have a winner	r_numDecalProjectors++;}
开发者ID:Ododo,项目名称:etlegacy,代码行数:101,


示例25: Mod_LoadAliasMD3Model

//.........这里部分代码省略.........		else if( poutmesh->numverts > MD3_MAX_VERTS )			ri.Com_Error( ERR_DROP, "mesh %i in model %s has too many vertices", i, mod->name );		bufsize = ALIGN( sizeof( maliasskin_t ) * poutmesh->numskins, sizeof( vec_t ) ) +			numverts * ( sizeof( vec2_t ) + sizeof( maliasvertex_t ) * poutmodel->numframes ) +			poutmesh->numtris * sizeof( elem_t ) * 3;		buf = ( qbyte * )Mod_Malloc( mod, bufsize );		//		// load the skins		//		pinskin = ( dmd3skin_t * )( ( qbyte * )pinmesh + LittleLong( pinmesh->ofs_skins ) );		poutskin = poutmesh->skins = ( maliasskin_t * )buf;		buf += ALIGN( sizeof( maliasskin_t ) * poutmesh->numskins, sizeof( vec_t ) );		for( j = 0; j < poutmesh->numskins; j++, pinskin++, poutskin++ ) {			Q_strncpyz( poutskin->name, pinskin->name, sizeof( poutskin->name ) );			poutskin->shader = R_RegisterSkin( poutskin->name );		}		//		// load the texture coordinates		//		pincoord = ( dmd3coord_t * )( ( qbyte * )pinmesh + LittleLong( pinmesh->ofs_tcs ) );		poutcoord = poutmesh->stArray = ( vec2_t * )buf; buf += poutmesh->numverts * sizeof( vec2_t );		for( j = 0; j < poutmesh->numverts; j++, pincoord++ )		{			poutcoord[j][0] = LittleFloat( pincoord->st[0] );			poutcoord[j][1] = LittleFloat( pincoord->st[1] );		}		//		// load the vertexes and normals		//		pinvert = ( dmd3vertex_t * )( ( qbyte * )pinmesh + LittleLong( pinmesh->ofs_verts ) );		poutvert = poutmesh->vertexes = ( maliasvertex_t * )buf;		buf += poutmesh->numverts * sizeof( maliasvertex_t ) * poutmodel->numframes;		for( l = 0, poutframe = poutmodel->frames; l < poutmodel->numframes; l++, poutframe++, pinvert += poutmesh->numverts, poutvert += poutmesh->numverts )		{			vec3_t v;			for( j = 0; j < poutmesh->numverts; j++ )			{				poutvert[j].point[0] = LittleShort( pinvert[j].point[0] );				poutvert[j].point[1] = LittleShort( pinvert[j].point[1] );				poutvert[j].point[2] = LittleShort( pinvert[j].point[2] );				poutvert[j].latlong[0] = pinvert[j].norm[0];				poutvert[j].latlong[1] = pinvert[j].norm[1];				VectorCopy( poutvert[j].point, v );				AddPointToBounds( v, poutframe->mins, poutframe->maxs );			}		}				//		// load the elems		//		pinelem = ( unsigned int * )( ( qbyte * )pinmesh + LittleLong( pinmesh->ofs_elems ) );		poutelem = poutmesh->elems = ( elem_t * )buf;		for( j = 0; j < poutmesh->numtris; j++, pinelem += 3, poutelem += 3 )		{			poutelem[0] = (elem_t)LittleLong( pinelem[0] );			poutelem[1] = (elem_t)LittleLong( pinelem[1] );			poutelem[2] = (elem_t)LittleLong( pinelem[2] );		}		pinmesh = ( dmd3mesh_t * )( ( qbyte * )pinmesh + LittleLong( pinmesh->meshsize ) );	}	//	// setup drawSurfs	//	for( i = 0; i < poutmodel->nummeshes; i++ )	{		drawSurf = poutmodel->drawSurfs + i;		drawSurf->type = ST_ALIAS;		drawSurf->model = mod;		drawSurf->mesh = poutmodel->meshes + i;	}	//	// build S and T vectors for frame 0	//	Mod_AliasBuildMeshesForFrame0( mod );	//	// calculate model bounds	//	poutframe = poutmodel->frames;	for( i = 0; i < poutmodel->numframes; i++, poutframe++ )	{		VectorMA( poutframe->translate, MD3_XYZ_SCALE, poutframe->mins, poutframe->mins );		VectorMA( poutframe->translate, MD3_XYZ_SCALE, poutframe->maxs, poutframe->maxs );		poutframe->radius = RadiusFromBounds( poutframe->mins, poutframe->maxs );		AddPointToBounds( poutframe->mins, mod->mins, mod->maxs );		AddPointToBounds( poutframe->maxs, mod->mins, mod->maxs );		mod->radius = max( mod->radius, poutframe->radius );	}}
开发者ID:futurepneu,项目名称:racesow,代码行数:101,


示例26: R_AddPolysToScene

/*=====================R_AddPolysToScene=====================*/static void R_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ){	srfPoly_t *poly;	int       i, j;	int       fogIndex;	fog_t     *fog;	vec3_t    bounds[ 2 ];	if ( !tr.registered )	{		return;	}	if ( !r_drawpolies->integer )	{		return;	}	if ( !hShader )	{		Log::Warn("RE_AddPolyToScene: NULL poly shader" );		return;	}	for ( j = 0; j < numPolys; j++ )	{		if ( r_numPolyVerts + numVerts >= r_maxPolyVerts->integer || r_numPolys >= r_maxPolys->integer )		{			/*			   NOTE TTimo this was initially Log::Warn			   but it happens a lot with high fighting scenes and particles			   since we don't plan on changing the const and making for room for those effects			   simply cut this message to developer only			 */			Log::Debug("RE_AddPolyToScene: r_max_polys or r_max_polyverts reached/n" );			return;		}		poly = &backEndData[ tr.smpFrame ]->polys[ r_numPolys ];		poly->surfaceType = surfaceType_t::SF_POLY;		poly->hShader = hShader;		poly->numVerts = numVerts;		poly->verts = &backEndData[ tr.smpFrame ]->polyVerts[ r_numPolyVerts ];		Com_Memcpy( poly->verts, &verts[ numVerts * j ], numVerts * sizeof( *verts ) );		// done.		r_numPolys++;		r_numPolyVerts += numVerts;		// if no world is loaded		if ( tr.world == nullptr )		{			fogIndex = 0;		}		// see if it is in a fog volume		else if ( tr.world->numFogs == 1 )		{			fogIndex = 0;		}		else		{			// find which fog volume the poly is in			VectorCopy( poly->verts[ 0 ].xyz, bounds[ 0 ] );			VectorCopy( poly->verts[ 0 ].xyz, bounds[ 1 ] );			for ( i = 1; i < poly->numVerts; i++ )			{				AddPointToBounds( poly->verts[ i ].xyz, bounds[ 0 ], bounds[ 1 ] );			}			for ( fogIndex = 1; fogIndex < tr.world->numFogs; fogIndex++ )			{				fog = &tr.world->fogs[ fogIndex ];				if ( BoundsIntersect( bounds[ 0 ], bounds[ 1 ], fog->bounds[ 0 ], fog->bounds[ 1 ] ) )				{					break;				}			}			if ( fogIndex == tr.world->numFogs )			{				fogIndex = 0;			}		}		poly->fogIndex = fogIndex;	}}
开发者ID:Zilor,项目名称:Unvanquished,代码行数:95,


示例27: R_AddLightOccluder

//.........这里部分代码省略.........	if( rn.refdef.rdflags & RDF_NOWORLDMODEL )		return qfalse;	if( !ent->model || ent->model->type == mod_brush )		return qfalse;	VectorCopy( ent->lightingOrigin, origin );	if( ent->model->type == mod_brush )	{		vec3_t t;		VectorAdd( ent->model->mins, ent->model->maxs, t );		VectorMA( ent->origin, 0.5, t, origin );	}	if( VectorCompare( origin, vec3_origin ) )		return qfalse;	// find lighting group containing entities with same lightingOrigin as ours	hash_key = (unsigned int)( origin[0] * 7 + origin[1] * 5 + origin[2] * 3 );	hash_key &= ( SHADOWGROUPS_HASH_SIZE-1 );	for( group = r_shadowGroups_hash[hash_key]; group; group = group->hashNext )	{		if( VectorCompare( group->origin, origin ) )			goto add; // found an existing one, add	}	if( rsc.numShadowGroups == MAX_SHADOWGROUPS )		return qfalse; // no free groups	leaf = Mod_PointInLeaf( origin, rsh.worldModel );	// start a new group	group = &rsc.shadowGroups[rsc.numShadowGroups];	memset( group, 0, sizeof( *group ) );	group->id = group - rsc.shadowGroups + 1;	group->bit = ( 1<<rsc.numShadowGroups );	group->vis = Mod_ClusterPVS( leaf->cluster, rsh.worldModel );	group->useOrtho = qtrue;	group->alpha = r_shadows_alpha->value;	// clear group bounds	VectorCopy( origin, group->origin );	ClearBounds( group->mins, group->maxs );	ClearBounds( group->visMins, group->visMaxs );	// add to hash table	group->hashNext = r_shadowGroups_hash[hash_key];	r_shadowGroups_hash[hash_key] = group;	rsc.numShadowGroups++;add:	// get model bounds	if( ent->model->type == mod_alias )		R_AliasModelBBox( ent, mins, maxs );	else if( ent->model->type == mod_skeletal )		R_SkeletalModelBBox( ent, mins, maxs );	else if( ent->model->type == mod_brush )		R_BrushModelBBox( ent, mins, maxs, &bmodelRotated );	else		ClearBounds( mins, maxs );	maxSide = 0;	for( i = 0; i < 3; i++ ) {		if( mins[i] >= maxs[i] )			return qfalse;		maxSide = max( maxSide, maxs[i] - mins[i] );	}	// ignore tiny objects	if( maxSide < 10 ) {		return qfalse;	}	rsc.entShadowGroups[R_ENT2NUM(ent)] = group->id;	if( ent->flags & RF_WEAPONMODEL )		return qtrue;	if( ent->model->type == mod_brush )	{		VectorCopy( mins, group->mins );		VectorCopy( maxs, group->maxs );	}	else	{		// rotate local bounding box and compute the full bounding box for this group		R_TransformBounds( ent->origin, ent->axis, mins, maxs, bbox );		for( i = 0; i < 8; i++ ) {			AddPointToBounds( bbox[i], group->mins, group->maxs );		}	}	// increase projection distance if needed	VectorSubtract( group->mins, origin, mins );	VectorSubtract( group->maxs, origin, maxs );	group->radius = RadiusFromBounds( mins, maxs );	group->projDist = max( group->projDist, group->radius + min( r_shadows_projection_distance->value, 256 ) );	return qtrue;}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:101,


示例28: R_MarkFragments

/*=================R_MarkFragments=================*/int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection,				   int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) {	int				numsurfaces, numPlanes;	int				i, j, k, m, n;	surfaceType_t	*surfaces[64];	vec3_t			mins, maxs;	int				returnedFragments;	int				returnedPoints;	vec3_t			normals[MAX_VERTS_ON_POLY+2];	float			dists[MAX_VERTS_ON_POLY+2];	vec3_t			clipPoints[2][MAX_VERTS_ON_POLY];	int				numClipPoints;	float			*v;	srfSurfaceFace_t *surf;	srfGridMesh_t	*cv;	drawVert_t		*dv;	vec3_t			normal;	vec3_t			projectionDir;	vec3_t			v1, v2;	int				*indexes;	//increment view count for double check prevention	tr.viewCount++;	//	VectorNormalize2( projection, projectionDir );	// find all the brushes that are to be considered	ClearBounds( mins, maxs );	for ( i = 0 ; i < numPoints ; i++ ) {		vec3_t	temp;		AddPointToBounds( points[i], mins, maxs );		VectorAdd( points[i], projection, temp );		AddPointToBounds( temp, mins, maxs );		// make sure we get all the leafs (also the one(s) in front of the hit surface)		VectorMA( points[i], -20, projectionDir, temp );		AddPointToBounds( temp, mins, maxs );	}	if (numPoints > MAX_VERTS_ON_POLY) numPoints = MAX_VERTS_ON_POLY;	// create the bounding planes for the to be projected polygon	for ( i = 0 ; i < numPoints ; i++ ) {		VectorSubtract(points[(i+1)%numPoints], points[i], v1);		VectorAdd(points[i], projection, v2);		VectorSubtract(points[i], v2, v2);		CrossProduct(v1, v2, normals[i]);		VectorNormalizeFast(normals[i]);		dists[i] = DotProduct(normals[i], points[i]);	}	// add near and far clipping planes for projection	VectorCopy(projectionDir, normals[numPoints]);	dists[numPoints] = DotProduct(normals[numPoints], points[0]) - 32;	VectorCopy(projectionDir, normals[numPoints+1]);	VectorInverse(normals[numPoints+1]);	dists[numPoints+1] = DotProduct(normals[numPoints+1], points[0]) - 20;	numPlanes = numPoints + 2;	numsurfaces = 0;	R_BoxSurfaces_r(tr.world->nodes, mins, maxs, surfaces, 64, &numsurfaces, projectionDir);	//assert(numsurfaces <= 64);	//assert(numsurfaces != 64);	returnedPoints = 0;	returnedFragments = 0;	for ( i = 0 ; i < numsurfaces ; i++ ) {		if (*surfaces[i] == SF_GRID) {			cv = (srfGridMesh_t *) surfaces[i];			for ( m = 0 ; m < cv->height - 1 ; m++ ) {				for ( n = 0 ; n < cv->width - 1 ; n++ ) {					// We triangulate the grid and chop all triangles within					// the bounding planes of the to be projected polygon.					// LOD is not taken into account, not such a big deal though.					//					// It's probably much nicer to chop the grid itself and deal					// with this grid as a normal SF_GRID surface so LOD will					// be applied. However the LOD of that chopped grid must					// be synced with the LOD of the original curve.					// One way to do this; the chopped grid shares vertices with					// the original curve. When LOD is applied to the original					// curve the unused vertices are flagged. Now the chopped curve					// should skip the flagged vertices. This still leaves the					// problems with the vertices at the chopped grid edges.					//					// To avoid issues when LOD applied to "hollow curves" (like					// the ones around many jump pads) we now just add a 2 unit					// offset to the triangle vertices.					// The offset is added in the vertex normal vector direction					// so all triangles will still fit together.					// The 2 unit offset should avoid pretty much all LOD problems.					numClipPoints = 3;//.........这里部分代码省略.........
开发者ID:Drakesinger,项目名称:jediacademypc,代码行数:101,


示例29: CreateBrushFaces

//.........这里部分代码省略.........			GetVectorForKey(FoundEntity, "origin", offset);		sprintf(text, "%g %g %g", offset[0], offset[1], offset[2]);		SetKeyValue(CurrentEntity, "origin", text);	}	GetVectorForKey(CurrentEntity, "origin", offset);	//printf("%i brushfaces at offset %f %f %f/n", numbrushfaces, offset[0], offset[1], offset[2]);	for (i = 0;i < numbrushfaces;i++)	{		mf = &faces[i];		//printf("plane %f %f %f %f/n", mf->plane.normal[0], mf->plane.normal[1], mf->plane.normal[2], mf->plane.dist);		faceplane = mf->plane;		w = BaseWindingForPlane (&faceplane);		//VectorNegate( faceplane.normal, point );		for (j = 0;j < numbrushfaces && w;j++)		{			clipplane = faces[j].plane;			if( j == i/* || VectorCompare( clipplane.normal, point )*/ )				continue;			// flip the plane, because we want to keep the back side			VectorNegate(clipplane.normal, clipplane.normal);			clipplane.dist *= -1;			w = ClipWindingEpsilon (w, &clipplane, ON_EPSILON, true);		}		if (!w)		{			//printf("----- skipped plane -----/n");			continue;	// overcontrained plane		}		// this face is a keeper		f = AllocFace ();		f->winding = w;		for (j = 0;j < w->numpoints;j++)		{			for (k = 0;k < 3;k++)			{				point[k] = w->points[j][k] - offset[k];				r = Q_rint( point[k] );				if ( fabs( point[k] - r ) < ZERO_EPSILON)					w->points[j][k] = r;				else					w->points[j][k] = point[k];				// check for incomplete brushes				if( w->points[j][k] >= BOGUS_RANGE || w->points[j][k] <= -BOGUS_RANGE )					break;			}			// remove this brush			if (k < 3)			{				FreeFace (f);				for (f = brush_faces; f; f = next)				{					next = f->next;					FreeFace (f);				}				brush_faces = NULL;				//printf("----- skipped brush -----/n");				return;			}			AddPointToBounds( w->points[j], brush_mins, brush_maxs );		}		CheckWinding( w );		faceplane.dist -= DotProduct(faceplane.normal, offset);		f->texturenum = mf->texinfo;		f->planenum = FindPlane (&faceplane, &f->planeside);		f->next = brush_faces;		brush_faces = f;	}	// Rotatable objects have to have a bounding box big enough	// to account for all its rotations.	if (DotProduct(offset, offset))	{		vec_t delta;		delta = RadiusFromBounds( brush_mins, brush_maxs );		for (k = 0;k < 3;k++)		{			brush_mins[k] = -delta;			brush_maxs[k] = delta;		}	}	//printf("%i : %f %f %f : %f %f %f/n", numbrushfaces, brush_mins[0], brush_mins[1], brush_mins[2], brush_maxs[0], brush_maxs[1], brush_maxs[2]);}
开发者ID:nekonomicon,项目名称:QuakeRemakeDevkit,代码行数:101,


示例30: RE_ProjectDecal

//.........这里部分代码省略.........		radius               = projection[3];		Vector4Set(omniProjection, 0.0f, 0.0f, -1.0f, radius * 2.0f);		projection = omniProjection;		iDist      = 1.0f / (radius * 2.0f);		// set corner		VectorSet(xyz, points[0][0] - radius, points[0][1] - radius, points[0][2] + radius);		// make x axis texture matrix (yz)		VectorSet(temp.texMat[0][0], 0.0f, iDist, 0.0f);		temp.texMat[0][0][3] = -DotProduct(temp.texMat[0][0], xyz);		VectorSet(temp.texMat[0][1], 0.0f, 0.0f, iDist);		temp.texMat[0][1][3] = -DotProduct(temp.texMat[0][1], xyz);		// make y axis texture matrix (xz)		VectorSet(temp.texMat[1][0], iDist, 0.0f, 0.0f);		temp.texMat[1][0][3] = -DotProduct(temp.texMat[1][0], xyz);		VectorSet(temp.texMat[1][1], 0.0f, 0.0f, iDist);		temp.texMat[1][1][3] = -DotProduct(temp.texMat[1][1], xyz);		// make z axis texture matrix (xy)		VectorSet(temp.texMat[2][0], iDist, 0.0f, 0.0f);		temp.texMat[2][0][3] = -DotProduct(temp.texMat[2][0], xyz);		VectorSet(temp.texMat[2][1], 0.0f, iDist, 0.0f);		temp.texMat[2][1][3] = -DotProduct(temp.texMat[2][1], xyz);		// setup decal points		VectorSet(dv[0].xyz, points[0][0] - radius, points[0][1] - radius, points[0][2] + radius);		VectorSet(dv[1].xyz, points[0][0] - radius, points[0][1] + radius, points[0][2] + radius);		VectorSet(dv[2].xyz, points[0][0] + radius, points[0][1] + radius, points[0][2] + radius);		VectorSet(dv[3].xyz, points[0][0] + radius, points[0][1] - radius, points[0][2] + radius);	}	else	{		// set up unidirectional		temp.omnidirectional = qfalse;		// set up decal points		VectorCopy(points[0], dv[0].xyz);		VectorCopy(points[1], dv[1].xyz);		VectorCopy(points[2], dv[2].xyz);		VectorCopy(points[3], dv[3].xyz);		// make texture matrix		if (!MakeTextureMatrix(temp.texMat[0], projection, &dv[0], &dv[1], &dv[2]))		{			return;		}	}	// bound the projector	ClearBounds(temp.mins, temp.maxs);	for (i = 0; i < numPoints; i++)	{		AddPointToBounds(dv[i].xyz, temp.mins, temp.maxs);		VectorMA(dv[i].xyz, projection[3], projection, xyz);		AddPointToBounds(xyz, temp.mins, temp.maxs);	}	// make bounding sphere	VectorAdd(temp.mins, temp.maxs, temp.center);	VectorScale(temp.center, 0.5f, temp.center);	VectorSubtract(temp.maxs, temp.center, xyz);	temp.radius  = VectorLength(xyz);	temp.radius2 = temp.radius * temp.radius;	// frustum cull the projector (fixme: this uses a stale frustum!)	if (R_CullPointAndRadius(temp.center, temp.radius) == CULL_OUT)	{		return;	}	// make the front plane	if (!PlaneFromPoints(temp.planes[0], dv[0].xyz, dv[1].xyz, dv[2].xyz))	{		return;	}	// make the back plane	VectorSubtract(vec3_origin, temp.planes[0], temp.planes[1]);	VectorMA(dv[0].xyz, projection[3], projection, xyz);	temp.planes[1][3] = DotProduct(xyz, temp.planes[1]);	// make the side planes	for (i = 0; i < numPoints; i++)	{		VectorMA(dv[i].xyz, projection[3], projection, xyz);		if (!PlaneFromPoints(temp.planes[i + 2], dv[(i + 1) % numPoints].xyz, dv[i].xyz, xyz))		{			return;		}	}	// create a new projector	dp = &tr.refdef.decalProjectors[r_numDecalProjectors & DECAL_PROJECTOR_MASK];	Com_Memcpy(dp, &temp, sizeof(*dp));	// we have a winner	r_numDecalProjectors++;}
开发者ID:Mailaender,项目名称:etlegacy,代码行数:101,



注:本文中的AddPointToBounds函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ AddProperty函数代码示例
C++ AddPoint函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。