示例#1
0
void ARX_FOGS_RenderAll() {
	
	EERIE_QUAT rotation;
	Quat_Init(&rotation);

	GRenderer->SetRenderState(Renderer::AlphaBlending, false);

	for(long i = 0; i < MAX_FOG; i++) {
		FOG_DEF *fog = &fogs[i];

		if(!fog->exist)
			continue;

			if(fogobj)
				DrawEERIEInter(fogobj, &rotation, &fog->pos, NULL);

			fog->bboxmin = BBOXMIN;
			fog->bboxmax = BBOXMAX;

			if(fog->special & FOG_DIRECTIONAL) {
				EERIEDraw3DLine(fog->pos, fog->pos + fog->move * 50.f, Color::white);
			}

			if(fog->selected) {
				EERIEDraw2DLine(fog->bboxmin.x, fog->bboxmin.y, fog->bboxmax.x, fog->bboxmin.y, 0.01f, Color::yellow);
				EERIEDraw2DLine(fog->bboxmax.x, fog->bboxmin.y, fog->bboxmax.x, fog->bboxmax.y, 0.01f, Color::yellow);
				EERIEDraw2DLine(fog->bboxmax.x, fog->bboxmax.y, fog->bboxmin.x, fog->bboxmax.y, 0.01f, Color::yellow);
				EERIEDraw2DLine(fog->bboxmin.x, fog->bboxmax.y, fog->bboxmin.x, fog->bboxmin.y, 0.01f, Color::yellow);
			}
	}
}
示例#2
0
static void Cedric_AnimateDrawEntityRender(EERIE_3DOBJ * eobj, const Vec3f & pos,
                                           Entity * io, float invisibility) {
	
	Skeleton *obj = eobj->m_skeleton;
	
	if(!obj)
		return;
	
	ColorMod colorMod;
	colorMod.updateFromEntity(io);
	
	/* Get nearest lights */
	Vec3f tv = pos;
	
	if(io && io->obj->fastaccess.head_group_origin != ObjVertHandle()) {
		tv.y = io->obj->vertexlist3[io->obj->fastaccess.head_group_origin.handleData()].v.y + 10;
	} else {
		tv.y -= 90.f;
	}
	
	ShaderLight lights[llightsSize];
	int lightsCount;
	UpdateLlights(lights, lightsCount, tv, false);
	
	Cedric_ApplyLighting(lights, lightsCount, eobj, obj, colorMod);
	
	Cedric_RenderObject(eobj, obj, io, pos, invisibility);
	
	// Now we can render Linked Objects
	for(size_t k = 0; k < eobj->linked.size(); k++) {
		const EERIE_LINKED & link = eobj->linked[k];
		
		if(link.lgroup == ObjVertGroup() || !link.obj)
			continue;
		
		// specific check to avoid drawing player weapon on its back when in subjective view
		if(io == entities.player() &&
			link.lidx == entities.player()->obj->fastaccess.weapon_attach &&
			!EXTERNALVIEW
		) {
			continue;
		}
		
		TransformInfo t(
			actionPointPosition(eobj, link.lidx),
			eobj->m_skeleton->bones[link.lgroup.handleData()].anim.quat,
			link.io ? link.io->scale : 1.f,
			link.obj->vertexlist[link.lidx2.handleData()].v - link.obj->vertexlist[link.obj->origin].v);
		
		DrawEERIEInter(link.obj, t, link.io, true, invisibility);
	}
}
示例#3
0
//*************************************************************************************
//*************************************************************************************
void ARX_FOGS_RenderAll(LPDIRECT3DDEVICE7 m_pd3dDevice)
{
	EERIE_3D angle;
	Vector_Init(&angle); 

	SETALPHABLEND(m_pd3dDevice, FALSE);

	for (long i = 0; i < MAX_FOG; i++)
	{
		if (fogs[i].exist)
		{
			if (fogobj)
				DrawEERIEInter(m_pd3dDevice, fogobj, &angle, &fogs[i].pos, NULL);

			Vector_Copy(&fogs[i].bboxmin, &BBOXMIN);
			Vector_Copy(&fogs[i].bboxmax, &BBOXMAX);

			if (fogs[i].special & FOG_DIRECTIONAL)
			{
				EERIE_3D orgn, dest;
				orgn.x = fogs[i].pos.x;
				orgn.y = fogs[i].pos.y;
				orgn.z = fogs[i].pos.z;
				dest.x = orgn.x + fogs[i].move.x * 50.f;
				dest.y = orgn.y + fogs[i].move.y * 50.f;
				dest.z = orgn.z + fogs[i].move.z * 50.f;
				EERIEDraw3DLine(m_pd3dDevice, &orgn, &dest, EERIECOLOR_WHITE); 
			}

			if (fogs[i].selected)
			{
				EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmin.x, fogs[i].bboxmin.y, fogs[i].bboxmax.x, fogs[i].bboxmin.y, 0.01f, EERIECOLOR_YELLOW);
				EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmax.x, fogs[i].bboxmin.y, fogs[i].bboxmax.x, fogs[i].bboxmax.y, 0.01f, EERIECOLOR_YELLOW);
				EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmax.x, fogs[i].bboxmax.y, fogs[i].bboxmin.x, fogs[i].bboxmax.y, 0.01f, EERIECOLOR_YELLOW);
				EERIEDraw2DLine(m_pd3dDevice, fogs[i].bboxmin.x, fogs[i].bboxmax.y, fogs[i].bboxmin.x, fogs[i].bboxmin.y, 0.01f, EERIECOLOR_YELLOW);
			}
		}
	}
}
示例#4
0
bool Manage3DCursor(Entity * io, bool simulate) {
	
	arx_assert(io);
	
	if(BLOCK_PLAYER_CONTROLS)
		return false;

	float ag = player.angle.getYaw();

	if(ag > 180)
		ag = ag - 360;

	float drop_miny = (float)(g_size.center().y) - g_size.center().y * (ag * (1.f/70));

	if(DANAEMouse.y < drop_miny)
		return false;
	
	Anglef temp = Anglef::ZERO;

	if(io->ioflags & IO_INVERTED) {
		temp.setYaw(180.f);
		temp.setPitch(-MAKEANGLE(270.f - io->angle.getPitch() - (player.angle.getPitch() - STARTED_ANGLE)));
	} else {
		temp.setPitch(MAKEANGLE(270.f - io->angle.getPitch() - (player.angle.getPitch() - STARTED_ANGLE)));
	}
	
	EERIE_3D_BBOX bbox;
	for(size_t i = 0; i < io->obj->vertexlist.size(); i++) {
		bbox.add(io->obj->vertexlist[i].v);
	}
	
	Vec3f mvectx = angleToVectorXZ(player.angle.getPitch() - 90.f);
	
	Vec2f mod = Vec2f(Vec2i(DANAEMouse) - g_size.center()) / Vec2f(g_size.center()) * Vec2f(160.f, 220.f);
	mvectx *= mod.x;
	Vec3f mvecty(0, mod.y, 0);

	Vec3f orgn = player.pos;
	orgn += angleToVector(player.angle) * 50.f;
	orgn += mvectx;
	orgn.y += mvecty.y;

	Vec3f dest = player.pos;
	dest += angleToVector(player.angle) * 10000.f;
	dest += mvectx;
	dest.y += mvecty.y * 5.f;
	
	Vec3f pos = orgn;

	Vec3f movev = glm::normalize(dest - orgn);

	float lastanything = 0.f;
	float height = -(bbox.max.y - bbox.min.y);

	if(height > -30.f)
		height = -30.f;
	
	Vec3f objcenter = bbox.min + (bbox.max - bbox.min) * Vec3f(0.5f);
	
	Vec3f collidpos = Vec3f_ZERO;
	bool collidpos_ok = false;
	
	{
	float maxdist = 0.f;
	
	for(size_t i = 0; i < io->obj->vertexlist.size(); i++) {
		const EERIE_VERTEX & vert = io->obj->vertexlist[i];
		
		float dist = glm::distance(Vec2f(objcenter.x, objcenter.z), Vec2f(vert.v.x, vert.v.z)) - 4.f;
		maxdist = std::max(maxdist, dist);
	}

	if(io->obj->pbox) {
		Vec2f tmpVert(io->obj->pbox->vert[0].initpos.x, io->obj->pbox->vert[0].initpos.z);
		
		for(int i = 1; i < io->obj->pbox->nb_physvert; i++) {
			const PHYSVERT & physVert = io->obj->pbox->vert[i];
			
			float dist = glm::distance(tmpVert, Vec2f(physVert.initpos.x, physVert.initpos.z)) + 14.f;
			maxdist = std::max(maxdist, dist);
		}
	}
	
	Cylinder cyl2;
	const float inc = 10.f;
	long iterating = 40;

	cyl2.height = std::min(-30.f, height);
	cyl2.radius = glm::clamp(maxdist, 20.f, 150.f);
	
	while(iterating > 0) {
		cyl2.origin = pos + movev * inc + Vec3f(0.f, bbox.max.y, 0.f);

		float anything = CheckAnythingInCylinder(cyl2, io, CFLAG_JUST_TEST | CFLAG_COLLIDE_NOCOL | CFLAG_NO_NPC_COLLIDE);

		if(anything < 0.f) {
			if(iterating == 40) {
				CANNOT_PUT_IT_HERE = 1;
				// TODO is this correct ?
				return true;
			}

			iterating = 0;

			collidpos = cyl2.origin;

			if(lastanything < 0.f) {
				pos.y += lastanything;
				collidpos.y += lastanything;
			}
		} else {
			pos = cyl2.origin;
			lastanything = anything;
		}

		iterating--;
	}
	collidpos_ok = iterating == -1;
	
	}
	
	objcenter = VRotateY(objcenter, temp.getPitch());
	
	collidpos.x -= objcenter.x;
	collidpos.z -= objcenter.z;

	pos.x -= objcenter.x;
	pos.z -= objcenter.z;

	if(!collidpos_ok) {
		CANNOT_PUT_IT_HERE = 1;
		return false;
	}

	if(collidpos_ok && closerThan(player.pos, pos, 300.f)) {
		if(simulate) {
			ARX_INTERACTIVE_Teleport(io, pos, true);

			io->gameFlags &= ~GFLAG_NOCOMPUTATION;
			
			glm::quat rotation = glm::toQuat(toRotationMatrix(temp));
			
			if(SPECIAL_DRAGINTER_RENDER) {
			if(glm::abs(lastanything) > glm::abs(height)) {
				TransformInfo t(collidpos, rotation, io->scale);

				static const float invisibility = 0.5f;

				DrawEERIEInter(io->obj, t, io, false, invisibility);
			} else {
				TransformInfo t(pos, rotation, io->scale);

				float invisibility = Cedric_GetInvisibility(io);

				DrawEERIEInter(io->obj, t, io, false, invisibility);
			}
			}
		} else {
			if(glm::abs(lastanything) > std::min(glm::abs(height), 12.0f)) {
				Entity * io = DRAGINTER;
				ARX_PLAYER_Remove_Invisibility();
				io->obj->pbox->active = 1;
				io->obj->pbox->stopcount = 0;
				io->pos = collidpos;
				io->velocity = Vec3f_ZERO;

				io->stopped = 1;

				movev.x *= 0.0001f;
				movev.y = 0.1f;
				movev.z *= 0.0001f;
				Vec3f viewvector = movev;

				Anglef angle = temp;
				io->soundtime = 0;
				io->soundcount = 0;
				EERIE_PHYSICS_BOX_Launch(io->obj, io->pos, angle, viewvector);
				ARX_SOUND_PlaySFX(SND_WHOOSH, &pos);
				io->show = SHOW_FLAG_IN_SCENE;
				Set_DragInter(NULL);
			} else {
				ARX_PLAYER_Remove_Invisibility();
				ARX_SOUND_PlayInterface(SND_INVSTD);
				ARX_INTERACTIVE_Teleport(io, pos, true);

				io->angle.setYaw(temp.getYaw());
				io->angle.setPitch(270.f - temp.getPitch());
				io->angle.setRoll(temp.getRoll());

				io->stopped = 0;
				io->show = SHOW_FLAG_IN_SCENE;
				io->obj->pbox->active = 0;
				Set_DragInter(NULL);
			}
		}

		GRenderer->SetCulling(Renderer::CullNone);
		return true;
	} else {
		CANNOT_PUT_IT_HERE=-1;
	}

	return false;
}
示例#5
0
void ARX_INTERFACE_ManageOpenedBook_Finish()
{

	Vec3f pos = Vec3f(0.f, 0.f, 2100.f);
	Anglef angle = Anglef::ZERO;
	
	EERIE_LIGHT * light = lightHandleGet(torchLightHandle);
	
	EERIE_LIGHT tl = *light;
	
	light->pos = Vec3f(500.f, -1960.f, 1590.f);
	light->exist = 1;
	light->rgb = Color3f(0.6f, 0.7f, 0.9f);
	light->intensity  = 1.8f;
	light->fallstart=4520.f;
	light->fallend = light->fallstart + 600.f;
	RecalcLight(light);
	
	EERIE_CAMERA * oldcam = ACTIVECAM;
	
	PDL[0] = light;
	TOTPDL=1;
	
	Vec2i tmpPos = Vec2i_ZERO;
	
	for(size_t i = 0; i < RUNE_COUNT; i++) {
		if(!gui::necklace.runes[i])
			continue;
		
		EERIE_3DOBJ * rune = gui::necklace.runes[i];
		
		bookcam.center.x = (382 + tmpPos.x * 45 + BOOKDEC.x) * g_sizeRatio.x;
		bookcam.center.y = (100 + tmpPos.y * 64 + BOOKDEC.y) * g_sizeRatio.y;
		
		SetActiveCamera(&bookcam);
		PrepareCamera(&bookcam, g_size);
		
		// First draw the lace
		angle.setPitch(0.f);
		
		if(player.hasRune((Rune)i)) {
			
			TransformInfo t1(pos, glm::toQuat(toRotationMatrix(angle)));
			DrawEERIEInter(gui::necklace.lacet, t1, NULL);
			
			if(rune->angle.getPitch() != 0.f) {
				if(rune->angle.getPitch() > 300.f)
					rune->angle.setPitch(300.f);
				
				angle.setPitch(std::sin(arxtime.get_updated() * (1.0f / 200)) * rune->angle.getPitch() * (1.0f / 40));
			}
			
			rune->angle.setPitch(rune->angle.getPitch() - framedelay * 0.2f);
			
			if(rune->angle.getPitch() < 0.f)
				rune->angle.setPitch(0.f);
			
			GRenderer->SetRenderState(Renderer::DepthWrite, true);
			GRenderer->SetRenderState(Renderer::AlphaBlending, false);
			
			// Now draw the rune
			TransformInfo t2(pos, glm::toQuat(toRotationMatrix(angle)));
			DrawEERIEInter(rune, t2, NULL);
			
			EERIE_2D_BBOX runeBox;
			UpdateBbox2d(*rune, runeBox);
			
			PopAllTriangleList();
			
			tmpPos.x++;
			
			if(tmpPos.x > 4) {
				tmpPos.x = 0;
				tmpPos.y++;
			}
			
			const Rect runeMouseTestRect(
			runeBox.min.x,
			runeBox.min.y,
			runeBox.max.x,
			runeBox.max.y
			);
			
			// Checks for Mouse floating over a rune...
			if(runeMouseTestRect.contains(Vec2i(DANAEMouse))) {
				long r=0;
				
				for(size_t j = 0; j < rune->facelist.size(); j++) {
					float n = PtIn2DPolyProj(rune, &rune->facelist[j], (float)DANAEMouse.x, (float)DANAEMouse.y);
					
					if(n!=0.f) {
						r=1;
						break;
					}
				}
				
				if(r) {
					GRenderer->SetRenderState(Renderer::AlphaBlending, true);
					GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
					
					TransformInfo t(pos, glm::toQuat(toRotationMatrix(angle)));
					DrawEERIEInter(rune, t, NULL);
					
					rune->angle.setPitch(rune->angle.getPitch() + framedelay*2.f);
					
					PopAllTriangleList();
					
					GRenderer->SetRenderState(Renderer::AlphaBlending, false);
					
					SpecialCursor=CURSOR_INTERACTION_ON;
					
					if(eeMouseDown1())
						if((size_t)LastRune != i) {
							PlayerBookDrawRune((Rune)i);
						}
						
						LastRune=i;
				}
			}
		}
	}
	
	GRenderer->SetCulling(Renderer::CullCCW);
	
	LastRune=-1;
	
	*light = tl;
	
	SetActiveCamera(oldcam);
	PrepareCamera(oldcam, g_size);
}
示例#6
0
void ARX_INTERFACE_ManageOpenedBook_Finish(const Vec2f & mousePos, Rectf rect, float scale)
{
	
	RenderState baseState = render3D().depthTest(false).fog(false);
	
	Vec3f pos = Vec3f(0.f, 0.f, 2100.f);
	
	EERIE_LIGHT * light = lightHandleGet(torchLightHandle);
	
	EERIE_LIGHT tl = *light;
	
	light->pos = Vec3f(500.f, -1960.f, 1590.f);
	light->m_exists = true;
	light->rgb = Color3f(0.6f, 0.7f, 0.9f);
	light->intensity = 1.8f;
	light->fallstart = 4520.f;
	light->fallend = light->fallstart + 600.f;
	RecalcLight(light);
	
	Camera * oldcam = g_camera;
	
	g_culledDynamicLights[0] = light;
	g_culledDynamicLightsCount = 1;
	
	Vec2i tmpPos(0);
	
	GRenderer->SetAntialiasing(true);
	
	float wave = timeWaveSin(g_platformTime.frameStart(), PlatformDurationMsf(1256.6370614f));
	float ptDelta = toMs(g_platformTime.lastFrameDuration());
	
	Camera bookcam;
	bookcam.angle = Anglef();
	bookcam.m_pos = Vec3f(0.f);
	bookcam.focal = 500.f;
	bookcam.cdepth = 2200.f;
	
	for(size_t i = 0; i < RUNE_COUNT; i++) {
		if(!gui::necklace.runes[i])
			continue;
		
		EERIE_3DOBJ * rune = gui::necklace.runes[i];
		
		Vec2i projectionCenter = Vec2i(rect.topLeft() + (Vec2f(285, 36) + Vec2f(tmpPos) * Vec2f(45, 64)) * scale);
		
		PrepareCamera(&bookcam, Rect(rect), projectionCenter);
		
		if(player.hasRune((Rune)i)) {
			
			Anglef angle;
			if(rune->angle.getYaw() != 0.f) {
				if(rune->angle.getYaw() > 300.f) {
					rune->angle.setYaw(300.f);
				}
				angle.setYaw(wave * rune->angle.getYaw() * (1.0f / 40));
			}
			
			rune->angle.setYaw(rune->angle.getYaw() - ptDelta * 0.2f);
			
			if(rune->angle.getYaw() < 0.f)
				rune->angle.setYaw(0.f);
			
			// Now draw the rune
			TransformInfo t2(pos, glm::quat_cast(toRotationMatrix(angle)));
			DrawEERIEInter(rune, t2, NULL, false, 0.f);
			
			Rectf runeBox = UpdateBbox2d(*rune).toRect();
			
			PopAllTriangleListOpaque(baseState);
			
			tmpPos.x++;
			
			if(tmpPos.x > 4) {
				tmpPos.x = 0;
				tmpPos.y++;
			}
			
			// TODO this is a workaround for vertexClipPositions being relative to viewport
			Vec2f mousePosInViewport = mousePos - rect.topLeft();
			
			// Checks for Mouse floating over a rune...
			if(runeBox.contains(mousePosInViewport)) {
				bool r = false;
				
				for(size_t j = 0; j < rune->facelist.size(); j++) {
					float n = PtIn2DPolyProj(rune->vertexClipPositions, &rune->facelist[j], mousePosInViewport.x, mousePosInViewport.y);
					if(n != 0.f) {
						r = true;
						break;
					}
				}
				
				if(r) {
					
					TransformInfo t(pos, glm::quat_cast(toRotationMatrix(angle)));
					DrawEERIEInter(rune, t, NULL, false, 0.f);
					
					rune->angle.setYaw(rune->angle.getYaw() + ptDelta * 2.f);
					
					PopAllTriangleListOpaque(baseState.blendAdditive());
					
					cursorSetInteraction();
					
					if(eeMouseDown1()) {
						PlayerBookDrawRune((Rune)i);
					}
				}
			}
			
			TransformInfo t1(pos, quat_identity());
			DrawEERIEInter(gui::necklace.lacet, t1, NULL, false, 0.f);
			
			PopAllTriangleListOpaque(baseState);
		}
	}
	
	*light = tl;
	
	PrepareCamera(oldcam, g_size);
	
	GRenderer->SetAntialiasing(false);
	
}