Ejemplo n.º 1
0
void CBoxProxyView::drawTest()
{
	glColor3f(1.0,0,0);
	//drawBoxLines(*testBoxA);
	if (GraphCreated&&!GraphFinished)
	{
		for (int i=0;i<conGraph->getNodeNum();i++)
		{
			Box b(conGraph->getNode(i));
			drawBoxLines(b);
		}
		for (int i=0;i<conGraph->getNodeNum()-1;i++)
		{
			for (int j=i+1;j<conGraph->getNodeNum();j++)
			{
				Contact con=conGraph->getActiveEdge(i,j);
				if (!con.NoExtension)
					drawContact(con);
			}
		}
	}
	if (GraphFinished)
	{
		for (int i=0;i<conGraph->getNodeNum();i++)
		{
			Box b(conGraph->getBestBox(i));
			drawBoxLines(b);
		}
		for (int i=0;i<conGraph->getNodeNum()-1;i++)
		{
			for (int j=i+1;j<conGraph->getNodeNum();j++)
			{
				Contact con=conGraph->getBestEdge(i,j);
				if (!con.NoExtension)
					drawContact(con);
			}
		}
	}
	/*glPointSize(5);
	glBegin(GL_POINTS);
	glVertex3f(-0.077,0.06,1.50);
	glEnd();
	glPointSize(1);*/
	//drawContact(conGraph->getActiveEdge(1,2));
	//drawBoxLines(*testBoxA);
	//drawBoxLines(*testBoxB);
	//drawBoxLines(*testBoxC);

	//Contact con=testConSet.at(0);
	//drawContact(con);
	//drawContact(testConSet2.at(1));
}
Ejemplo n.º 2
0
void ContactListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
	doSetOptions(option, index);

	// prepare
	painter->save();
	// if (hasClipping())
	// 	painter->setClipRect(d->opt.rect);

	QVariant value;

	d->iconMode  = ::iconMode(opt().state);
	d->iconState = ::iconState(opt().state);

	switch (ContactListModel::indexType(index)) {
	case ContactListModel::ContactType:
		drawContact(painter, opt(), index);
		break;
	case ContactListModel::GroupType:
		drawGroup(painter, opt(), index);
		break;
	case ContactListModel::AccountType:
		drawAccount(painter, opt(), index);
		break;
	case ContactListModel::InvalidType:
		painter->fillRect(option.rect, Qt::red);
		break;
	default:
		QItemDelegate::paint(painter, option, index);
	}
	painter->restore();

}
// radar is damaged, so make blips dance around
void HudGaugeRadarDradis::blipDrawDistorted(blip *b, vec3d *pos, float alpha)
{
	float temp_scale;
	float dist = vm_vec_normalize(pos);
	vec3d out;
	float distortion_angle=20;

	// maybe alter the effect if EMP is active
	if (emp_active_local())
	{
		temp_scale = emp_current_intensity();
		dist *= frand_range(MAX(0.75f, 0.75f*temp_scale), MIN(1.25f, 1.25f*temp_scale));
		distortion_angle *= frand_range(-3.0f,3.0f)*frand_range(0.0f, temp_scale);

		if (dist > 1.0f) dist = 1.0f;
		if (dist < 0.1f) dist = 0.1f;
	}

	vm_vec_random_cone(&out, pos, distortion_angle);
	vm_vec_scale(&out, dist);

	drawContact(&out, -1, unknown_contact_icon, b->dist, alpha, 1.0f);
}
// blip is for a target immune to sensors, so cause to flicker in/out with mild distortion
void HudGaugeRadarDradis::blipDrawFlicker(blip *b, vec3d *pos, float alpha)
{
	int flicker_index;

	float dist=vm_vec_normalize(pos);
	vec3d out;
	float distortion_angle=10;

	if ((b-Blips) & 1)
		flicker_index=0;
	else
		flicker_index=1;
	

	if (timestamp_elapsed(Radar_flicker_timer[flicker_index])) {
		Radar_flicker_timer[flicker_index] = timestamp_rand(50,1000);
		Radar_flicker_on[flicker_index] ^= 1;
	}

	if (!Radar_flicker_on[flicker_index])
		return;

	if (rand() & 1)
	{
		distortion_angle *= frand_range(0.1f,2.0f);
		dist *= frand_range(0.75f, 1.25f);

		if (dist > 1.0f) dist = 1.0f;
		if (dist < 0.1f) dist = 0.1f;
	}
	
	vm_vec_random_cone(&out,pos,distortion_angle);
	vm_vec_scale(&out,dist);

	drawContact(&out, -1, unknown_contact_icon, b->dist, alpha, 1.0f);
}
// Draw all the active radar blips
void HudGaugeRadarDradis::drawBlips(int blip_type, int bright, int distort)
{
	blip *b = NULL;
	blip *blip_head;
	vec3d pos;
	float alpha;
	
	Assert((blip_type >= 0) && (blip_type < MAX_BLIP_TYPES));
	
	//long frametime = timer_get_approx_seconds();
	// Need to set font.
	gr_set_font(FONT1);

	if(bright) {
		blip_head = &Blip_bright_list[blip_type];
	} else {
		blip_head = &Blip_dim_list[blip_type];
	}
	
	float scale_factor = 1.0f;

	// draw all blips of this type
	for (b = GET_FIRST(blip_head); b != END_OF_LIST(blip_head); b = GET_NEXT(b))
	{
		plotBlip(b, &pos, &alpha);
		
		gr_set_color_fast(b->blip_color);

		scale_factor = 1.0f;

		// maybe draw cool blip to indicate current target
		if (b->flags & BLIP_CURRENT_TARGET)
		{
			if (radar_target_id_flags & RTIF_PULSATE) {
				scale_factor *= 1.3f + (sinf(10 * f2fl(Missiontime)) * 0.3f);
			}
			if (radar_target_id_flags & RTIF_BLINK) {
				if (Missiontime & 8192)
					continue;
			}
			if (radar_target_id_flags & RTIF_ENLARGE) {
				scale_factor *= 1.3f;
			}

			alpha = 1.0;
			b->rad = Radar_blip_radius_target;
			drawContact(&pos, -1, target_brackets, b->dist, alpha, scale_factor);
		}
		else {
			b->rad = Radar_blip_radius_normal;
		}

		// maybe distort blip
		if (distort) {
			blipDrawDistorted(b, &pos, alpha);
		} else {
			if (b->flags & BLIP_DRAW_DISTORTED) {
				blipDrawFlicker(b, &pos, alpha);
			} else if (b->radar_image_2d >= 0 || b->radar_color_image_2d >= 0) {
				drawContact(&pos, b->radar_image_2d, b->radar_color_image_2d, b->dist, alpha, scale_factor);
			} else {
				drawContact(&pos, -1, unknown_contact_icon, b->dist, alpha, scale_factor);
			}
		}
	}
}