当前位置: 首页>>代码示例>>C++>>正文


C++ duRGBA函数代码示例

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


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

示例1: duDebugDrawTriMeshSlope

void duDebugDrawTriMeshSlope(duDebugDraw* dd, const float* verts, int /*nverts*/,
							 const int* tris, const float* normals, int ntris,
							 const float walkableSlopeAngle)
{
	if (!dd) return;
	if (!verts) return;
	if (!tris) return;
	if (!normals) return;
	
	const float walkableThr = cosf(walkableSlopeAngle/180.0f*(float)M_PI);

	dd->begin(DU_DRAW_TRIS);
	for (int i = 0; i < ntris*3; i += 3)
	{
		const float* norm = &normals[i];
		unsigned int color;
		unsigned char a = (unsigned char)(255*(2+normals[i+0]+normals[i+1])/4);
		if (norm[1] < walkableThr)
			color = duRGBA(a,a/4,a/16,255);
		else
			color = duRGBA(a,a,a,255);
		
		dd->vertex(&verts[tris[i+0]*3], color);
		dd->vertex(&verts[tris[i+1]*3], color);
		dd->vertex(&verts[tris[i+2]*3], color);
	}
	dd->end();
}
开发者ID:randomcoding,项目名称:PlaneShift-PSAI,代码行数:28,代码来源:RecastDebugDraw.cpp

示例2: bind

	void bind()
	{
		if (m_texId == 0)
		{
			// Create checker pattern.
			const unsigned int col0 = duRGBA(215,215,215,255);
			const unsigned int col1 = duRGBA(255,255,255,255);
			static const int TSIZE = 64;
			unsigned int data[TSIZE*TSIZE];
			
			glGenTextures(1, &m_texId);
			glBindTexture(GL_TEXTURE_2D, m_texId);

			int level = 0;
			int size = TSIZE;
			while (size > 0)
			{
				for (int y = 0; y < size; ++y)
					for (int x = 0; x < size; ++x)
						data[x+y*size] = (x==0 || y==0) ? col0 : col1;
				glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, size,size, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
				size /= 2;
				level++;
			}
			
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		}
		else
		{
			glBindTexture(GL_TEXTURE_2D, m_texId);
		}
	}
开发者ID:SteerSuite,项目名称:Release,代码行数:33,代码来源:SampleInterfaces.cpp

示例3: duDebugDrawTriMesh

void duDebugDrawTriMesh(duDebugDraw* dd, const float* verts, int /*nverts*/,
						const int* tris, const float* normals, int ntris,
						const unsigned char* flags)
{
	if (!dd) return;
	if (!verts) return;
	if (!tris) return;
	if (!normals) return;

	dd->begin(DU_DRAW_TRIS);
	for (int i = 0; i < ntris*3; i += 3)
	{
		unsigned int color;
		unsigned char a = (unsigned char)(150*(2+normals[i+0]+normals[i+1])/4);
		if (flags && !flags[i/3])
			color = duRGBA(a,a/4,a/16,255);
		else
			color = duRGBA(a,a,a,255);
			
		dd->vertex(&verts[tris[i+0]*3], color);
		dd->vertex(&verts[tris[i+1]*3], color);
		dd->vertex(&verts[tris[i+2]*3], color);
	}
	dd->end();
}
开发者ID:randomcoding,项目名称:PlaneShift-PSAI,代码行数:25,代码来源:RecastDebugDraw.cpp

示例4: duDebugDrawHeightfieldSolid

void duDebugDrawHeightfieldSolid(duDebugDraw* dd, const rcHeightfield& hf)
{
	if (!dd) return;

	const float* orig = hf.bmin;
	const float cs = hf.cs;
	const float ch = hf.ch;
	
	const int w = hf.width;
	const int h = hf.height;
		
	unsigned int fcol[6];
	duCalcBoxColors(fcol, duRGBA(255,255,255,255), duRGBA(255,255,255,255));
	
	dd->begin(DU_DRAW_QUADS);
	
	for (int y = 0; y < h; ++y)
	{
		for (int x = 0; x < w; ++x)
		{
			float fx = orig[0] + x*cs;
			float fz = orig[2] + y*cs;
			const rcSpan* s = hf.spans[x + y*w];
			while (s)
			{
				duAppendBox(dd, fx, orig[1]+s->smin*ch, fz, fx+cs, orig[1] + s->smax*ch, fz+cs, fcol);
				s = s->next;
			}
		}
	}
	dd->end();
}
开发者ID:educharlie,项目名称:HNA-Algorithm,代码行数:32,代码来源:RecastDebugDraw.cpp

示例5: duRGBA

void RecastMapRenderer::DrawAgents(duDebugDraw* dd)
{
	for (int i = 0; i < m_RecastMap->GetCrowd()->getAgentCount(); ++i)
	{
		const dtCrowdAgent* ag = m_RecastMap->GetCrowd()->getAgent(i);
		if (!ag->active) continue;
		
		const float height = ag->params.height;
		const float radius = ag->params.radius;
		const float* pos = ag->npos;
		
		unsigned int col = duRGBA(220,220,220,128);
		if (ag->targetState == DT_CROWDAGENT_TARGET_REQUESTING || ag->targetState == DT_CROWDAGENT_TARGET_WAITING_FOR_QUEUE)
			col = duLerpCol(col, duRGBA(128,0,255,128), 32);
		else if (ag->targetState == DT_CROWDAGENT_TARGET_WAITING_FOR_PATH)
			col = duLerpCol(col, duRGBA(128,0,255,128), 128);
		else if (ag->targetState == DT_CROWDAGENT_TARGET_FAILED)
			col = duRGBA(255,32,16,128);
		else if (ag->targetState == DT_CROWDAGENT_TARGET_VELOCITY)
			col = duLerpCol(col, duRGBA(64,255,0,128), 128);
		
		duDebugDrawCylinder(dd, pos[0]-radius, pos[1]+radius*0.1f, pos[2]-radius,
							pos[0]+radius, pos[1]+height, pos[2]+radius, col);
	}
}
开发者ID:ngoaho91,项目名称:BambooOF,代码行数:25,代码来源:RecastMapRenderer.cpp

示例6: duRGBA

void cocos2d::NavMesh::drawOffMeshConnections()
{
    unsigned int conColor = duRGBA(192, 0, 128, 192);
    unsigned int baseColor = duRGBA(0, 0, 0, 64);
    _debugDraw.begin(DU_DRAW_LINES, 2.0f);
    for (int i = 0; i < _geomData->offMeshConCount; ++i)
    {
        float* v = &_geomData->offMeshConVerts[i * 3 * 2];

        _debugDraw.vertex(v[0], v[1], v[2], baseColor);
        _debugDraw.vertex(v[0], v[1] + 0.2f, v[2], baseColor);

        _debugDraw.vertex(v[3], v[4], v[5], baseColor);
        _debugDraw.vertex(v[3], v[4] + 0.2f, v[5], baseColor);

        duAppendCircle(&_debugDraw, v[0], v[1] + 0.1f, v[2], _geomData->offMeshConRads[i], baseColor);
        duAppendCircle(&_debugDraw, v[3], v[4] + 0.1f, v[5], _geomData->offMeshConRads[i], baseColor);

        if (/*hilight*/true)
        {
            duAppendArc(&_debugDraw, v[0], v[1], v[2], v[3], v[4], v[5], 0.25f,
                (_geomData->offMeshConDirs[i] & 1) ? 0.6f : 0.0f, 0.6f, conColor);
        }
    }
    _debugDraw.end();
}
开发者ID:RyunosukeOno,项目名称:rayjack,代码行数:26,代码来源:CCNavMesh.cpp

示例7: duRGBA

void InputGeom::drawOffMeshConnections(duDebugDraw* dd, bool hilight)
{
	unsigned int conColor = duRGBA(192,0,128,192);
	unsigned int baseColor = duRGBA(0,0,0,64);
	dd->depthMask(false);

	dd->begin(DU_DRAW_LINES, 2.0f);
	for (int i = 0; i < m_offMeshConCount; ++i)
	{
		float* v = &m_offMeshConVerts[i*3*2];

		dd->vertex(v[0],v[1],v[2], baseColor);
		dd->vertex(v[0],v[1]+0.2f,v[2], baseColor);
		
		dd->vertex(v[3],v[4],v[5], baseColor);
		dd->vertex(v[3],v[4]+0.2f,v[5], baseColor);
		
		duAppendCircle(dd, v[0],v[1]+0.1f,v[2], m_offMeshConRads[i], baseColor);
		duAppendCircle(dd, v[3],v[4]+0.1f,v[5], m_offMeshConRads[i], baseColor);

		if (hilight)
		{
			duAppendArc(dd, v[0],v[1],v[2], v[3],v[4],v[5], 0.25f,
						(m_offMeshConDirs[i]&1) ? 0.6f : 0.0f, 0.6f, conColor);
		}
	}	
	dd->end();

	dd->depthMask(true);
}
开发者ID:randomcoding,项目名称:PlaneShift-PSAI,代码行数:30,代码来源:InputGeom.cpp

示例8: duDebugDrawTriMeshSlope

void duDebugDrawTriMeshSlope(duDebugDraw* dd, const float* verts, int /*nverts*/,
							 const int* tris, const float* normals, int ntris,
							 const float walkableSlopeAngle, const float texScale)
{
	if (!dd) return;
	if (!verts) return;
	if (!tris) return;
	if (!normals) return;
	
	const float walkableThr = cosf(walkableSlopeAngle/180.0f*DU_PI);
	
	float uva[2];
	float uvb[2];
	float uvc[2];
	
	dd->texture(true);

	const unsigned int unwalkable = duRGBA(192,128,0,255);
	
	dd->begin(DU_DRAW_TRIS);
	for (int i = 0; i < ntris*3; i += 3)
	{
		const float* norm = &normals[i];
		unsigned int color;
		unsigned char a = (unsigned char)(220*(2+norm[0]+norm[1])/4);
		if (norm[1] < walkableThr)
			color = duLerpCol(duRGBA(a,a,a,255), unwalkable, 64);
		else
			color = duRGBA(a,a,a,255);
		
		const float* va = &verts[tris[i+0]*3];
		const float* vb = &verts[tris[i+1]*3];
		const float* vc = &verts[tris[i+2]*3];
		
		int ax = 0, ay = 0;
		if (rcAbs(norm[1]) > rcAbs(norm[ax]))
			ax = 1;
		if (rcAbs(norm[2]) > rcAbs(norm[ax]))
			ax = 2;
		ax = (1<<ax)&3; // +1 mod 3
		ay = (1<<ax)&3; // +1 mod 3
		
		uva[0] = va[ax]*texScale;
		uva[1] = va[ay]*texScale;
		uvb[0] = vb[ax]*texScale;
		uvb[1] = vb[ay]*texScale;
		uvc[0] = vc[ax]*texScale;
		uvc[1] = vc[ay]*texScale;
		
		dd->vertex(va, color, uva);
		dd->vertex(vb, color, uvb);
		dd->vertex(vc, color, uvc);
	}
	dd->end();

	dd->texture(false);
}
开发者ID:educharlie,项目名称:HNA-Algorithm,代码行数:57,代码来源:RecastDebugDraw.cpp

示例9: duDebugDrawHeightfieldLayer

void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLayer& layer, const int idx)
{
	const float cs = layer.cs;
	const float ch = layer.ch;
	const int w = layer.width;
	const int h = layer.height;
	
	unsigned int color = duIntToCol(idx+1, 255);
	
	// Layer bounds
	float bmin[3], bmax[3];
	bmin[0] = layer.bmin[0] + layer.minx*cs;
	bmin[1] = layer.bmin[1];
	bmin[2] = layer.bmin[2] + layer.miny*cs;
	bmax[0] = layer.bmin[0] + (layer.maxx+1)*cs;
	bmax[1] = layer.bmax[1];
	bmax[2] = layer.bmin[2] + (layer.maxy+1)*cs;
	duDebugDrawBoxWire(dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duTransCol(color,128), 2.0f);
	
	// Layer height
	dd->begin(DU_DRAW_QUADS);
	for (int y = 0; y < h; ++y)
	{
		for (int x = 0; x < w; ++x)
		{
			const int lidx = x+y*w;
			const int lh = (int)layer.heights[lidx];
			if (h == 0xff) continue;
			const unsigned char area = layer.areas[lidx];
			
			unsigned int col;
			if (area == RC_WALKABLE_AREA)
				col = duLerpCol(color, duRGBA(0,192,255,64), 32);
			else if (area == RC_NULL_AREA)
				col = duLerpCol(color, duRGBA(0,0,0,64), 32);
			else
				col = duLerpCol(color, duIntToCol(area, 255), 32);
			
			const float fx = layer.bmin[0] + x*cs;
			const float fy = layer.bmin[1] + (lh+1)*ch;
			const float fz = layer.bmin[2] + y*cs;
			
			dd->vertex(fx, fy, fz, col);
			dd->vertex(fx, fy, fz+cs, col);
			dd->vertex(fx+cs, fy, fz+cs, col);
			dd->vertex(fx+cs, fy, fz, col);
		}
	}
	dd->end();
	
	// Portals
	drawLayerPortals(dd, &layer);
}
开发者ID:educharlie,项目名称:HNA-Algorithm,代码行数:53,代码来源:RecastDebugDraw.cpp

示例10: drawGraphBackground

void Visualization::renderDebugInfoOverlay()
{
    GraphParams gp;
    gp.setRect(10, 10, 500, 200, 8);
    gp.setValueRange(0.0f, 2.0f, 4, "ms");
    
    drawGraphBackground(&gp);
    drawGraph(&gp, &m_debugInfo->m_crowdTotalTime, 1, "Crowd update", duRGBA(255,128,0,255));
    
    gp.setRect(10, 10, 500, 200, 8);
    gp.setValueRange(0.0f, 2000.0f, 1, "");
    drawGraph(&gp, &m_debugInfo->m_crowdSampleCount, 0, "Sample Count", duRGBA(96,96,96,128));
}
开发者ID:Conglang,项目名称:recastdetour,代码行数:13,代码来源:Visualization.cpp

示例11: rcMin

void ConvexVolumeTool::handleRender()
{
	DebugDrawGL dd;
	
	// Find height extents of the shape.
	float minh = FLT_MAX, maxh = 0;
	for (int i = 0; i < m_npts; ++i)
		minh = rcMin(minh, m_pts[i*3+1]);
	minh -= m_boxDescent;
	maxh = minh + m_boxHeight;

	dd.begin(DU_DRAW_POINTS, 4.0f);
	for (int i = 0; i < m_npts; ++i)
	{
		unsigned int col = duRGBA(255,255,255,255);
		if (i == m_npts-1)
			col = duRGBA(240,32,16,255);
		dd.vertex(m_pts[i*3+0],m_pts[i*3+1]+0.1f,m_pts[i*3+2], col);
	}
	dd.end();

	dd.begin(DU_DRAW_LINES, 2.0f);
	for (int i = 0, j = m_nhull-1; i < m_nhull; j = i++)
	{
		const float* vi = &m_pts[m_hull[j]*3];
		const float* vj = &m_pts[m_hull[i]*3];
		dd.vertex(vj[0],minh,vj[2], duRGBA(255,255,255,64));
		dd.vertex(vi[0],minh,vi[2], duRGBA(255,255,255,64));
		dd.vertex(vj[0],maxh,vj[2], duRGBA(255,255,255,64));
		dd.vertex(vi[0],maxh,vi[2], duRGBA(255,255,255,64));
		dd.vertex(vj[0],minh,vj[2], duRGBA(255,255,255,64));
		dd.vertex(vj[0],maxh,vj[2], duRGBA(255,255,255,64));
	}
	dd.end();	
}
开发者ID:0jpq0,项目名称:server,代码行数:35,代码来源:ConvexVolumeTool.cpp

示例12: glDepthFunc

void RecastMapRenderer::Render()
{
	if (!m_RecastMap->GetGeometry() || !m_RecastMap->GetGeometry()->getMesh())
		return;
	// ========================================== setup
	glDepthFunc(GL_LESS);
	glDepthMask(GL_TRUE);
	DebugDrawGL dd;
	const float texScale = 1.0f / (RECAST_CELL_SIZE * 10.0f);
	duDebugDrawTriMeshSlope(&dd, 
		m_RecastMap->GetGeometry()->getMesh()->getVerts(), 
		m_RecastMap->GetGeometry()->getMesh()->getVertCount(),
		m_RecastMap->GetGeometry()->getMesh()->getTris(), 
		m_RecastMap->GetGeometry()->getMesh()->getNormals(), 
		m_RecastMap->GetGeometry()->getMesh()->getTriCount(),
		RECAST_AGENT_MAX_SLOPE, 
		texScale);
	
	DrawAgents(&dd);
	
	glDepthMask(GL_FALSE);
	// Draw bounds
	const float* bmin = m_RecastMap->GetGeometry()->getMeshBoundsMin();
	const float* bmax = m_RecastMap->GetGeometry()->getMeshBoundsMax();
	duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
	
	// Tiling grid.
	int gw = 0, gh = 0;
	rcCalcGridSize(bmin, bmax, RECAST_CELL_SIZE, &gw, &gh);
	const int tw = (gw + RECAST_TILE_SIZE - 1) / RECAST_TILE_SIZE;
	const int th = (gh + RECAST_TILE_SIZE - 1) / RECAST_TILE_SIZE;
	const float s = RECAST_TILE_SIZE*RECAST_CELL_SIZE;
	duDebugDrawGridXZ(&dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);

	if(m_RecastMap->GetMesh() && m_RecastMap->GetQuery())
	{
		duDebugDrawNavMesh(&dd, *(m_RecastMap->GetMesh()), 
			DU_DRAWNAVMESH_COLOR_TILES|DU_DRAWNAVMESH_CLOSEDLIST|DU_DRAWNAVMESH_OFFMESHCONS);
		duDebugDrawNavMeshPolysWithFlags(&dd, *(m_RecastMap->GetMesh()), POLY_ABILITY_DISABLED, duRGBA(0,0,0,128));
	}
	if (m_RecastMap->GetTileCache())
		//DrawTiles(&dd, m_RecastMap->GetTileCache());
	
	if (m_RecastMap->GetTileCache())
		DrawObstacles(&dd, m_RecastMap->GetTileCache());

	if (m_RecastMap->GetGeometry())
		DrawConvexVolumes(&dd, m_RecastMap->GetGeometry());
}
开发者ID:ngoaho91,项目名称:BambooOF,代码行数:49,代码来源:RecastMapRenderer.cpp

示例13: duRGBA

void Sample_TileMesh::buildTile(const float* pos)
{
	if (!m_geom) return;
	if (!m_navMesh) return;
		
	const float* bmin = m_geom->getMeshBoundsMin();
	const float* bmax = m_geom->getMeshBoundsMax();
	
	const float ts = m_tileSize*m_cellSize;
	const int tx = (int)((pos[0] - bmin[0]) / ts);
	const int ty = (int)((pos[2] - bmin[2]) / ts);
	
	m_tileBmin[0] = bmin[0] + tx*ts;
	m_tileBmin[1] = bmin[1];
	m_tileBmin[2] = bmin[2] + ty*ts;
	
	m_tileBmax[0] = bmin[0] + (tx+1)*ts;
	m_tileBmax[1] = bmax[1];
	m_tileBmax[2] = bmin[2] + (ty+1)*ts;
	
	m_tileCol = duRGBA(77,204,0,255);
	
	int dataSize = 0;
	unsigned char* data = buildTileMesh(tx, ty, m_tileBmin, m_tileBmax, dataSize);
	
	if (data)
	{
		// Remove any previous data (navmesh owns and deletes the data).
		m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty),0,0);
		
		// Let the navmesh own the data.
		if (!m_navMesh->addTile(data,dataSize,DT_TILE_FREE_DATA))
			dtFree(data);
	}
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:35,代码来源:Sample_TileMesh.cpp

示例14: m_keepInterResults

Sample_TileMesh::Sample_TileMesh() :
	m_keepInterResults(false),
	m_buildAll(true),
	m_totalBuildTimeMs(0),
	m_triareas(0),
	m_solid(0),
	m_chf(0),
	m_cset(0),
	m_pmesh(0),
	m_dmesh(0),
	m_drawMode(DRAWMODE_NAVMESH),
	m_maxTiles(0),
	m_maxPolysPerTile(0),
	m_tileSize(32),
	m_tileCol(duRGBA(0,0,0,32)),
	m_tileBuildTime(0),
	m_tileMemUsage(0),
	m_tileTriCount(0)
{
	resetCommonSettings();
	memset(m_lastBuiltTileBmin, 0, sizeof(m_lastBuiltTileBmin));
	memset(m_lastBuiltTileBmax, 0, sizeof(m_lastBuiltTileBmax));
	
	setTool(new NavMeshTileTool);
}
开发者ID:ArtStealer,项目名称:recastnavigation,代码行数:25,代码来源:Sample_TileMesh.cpp

示例15: duIntToCol

unsigned int duIntToCol(int i, int a)
{
    int r = bit(i, 1) + bit(i, 3) * 2 + 1;
    int g = bit(i, 2) + bit(i, 4) * 2 + 1;
    int b = bit(i, 0) + bit(i, 5) * 2 + 1;
    return duRGBA(r*63,g*63,b*63,a);
}
开发者ID:wtfcolt,项目名称:MadMangos,代码行数:7,代码来源:DebugDraw.cpp


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