Esempio n. 1
0
static void ReCenterSequence(const std::string & _pcSequence, Vec2s & iMin, Vec2s & iMax) {
	
	Vec2s iSize = Vec2s(0, 0);
	iMin = Vec2s(0, 0);
	iMax = Vec2s(0, 0);
	
	for(size_t iI = 0; iI < _pcSequence.length(); iI++) {
		Vec2s es2dVector = GetSymbVector(_pcSequence[iI]);
		es2dVector *= symbolVecScale;
		iSize += es2dVector;
		iMin = glm::min(iMin, iSize);
		iMax = glm::max(iMax, iSize);
	}
}
Esempio n. 2
0
void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io)
{
	Vec2f tmpPos0 = Vec2f(pos0);
	Vec2f tmpPos1 = Vec2f(pos1);
	
	Vec2f d = tmpPos1 - tmpPos0;
	Vec2f ad = glm::abs(d);
	
	if(ad.x > ad.y) {
		
		if(tmpPos0.x > tmpPos1.x) {
			std::swap(tmpPos0, tmpPos1);
		}
		
		float m = d.y / d.x;
		long i = tmpPos0.x;
		
		while(i < tmpPos1.x) {
			long z = rnd() * FLARELINERND;
			z += FLARELINESTEP;
			if(!io) {
				z *= g_sizeRatio.y;
			}
			i += z;
			tmpPos0.y += m * z;
			AddLFlare(Vec2s(i, tmpPos0.y), io);
		}
		
	} else {
		
		if(tmpPos0.y > tmpPos1.y) {
			std::swap(tmpPos0, tmpPos1);
		}
		
		float m = d.x / d.y;
		long i = tmpPos0.y;
		
		while(i < tmpPos1.y) {
			long z = rnd() * FLARELINERND;
			z += FLARELINESTEP;
			if(!io) {
				z *= g_sizeRatio.y;
			}
			i += z;
			tmpPos0.x += m * z;
			AddLFlare(Vec2s(tmpPos0.x, i), io);
		}
		
	}
}
Esempio n. 3
0
static Vec2s GetSymbVector(char c) {
	switch(c) {
		case '1': return Vec2s(-1,  1);
		case '2': return Vec2s( 0,  1);
		case '3': return Vec2s( 1,  1);
		case '4': return Vec2s(-1,  0);
		case '6': return Vec2s( 1,  0);
		case '7': return Vec2s(-1, -1);
		case '8': return Vec2s( 0, -1);
		case '9': return Vec2s( 1, -1);
		default : return Vec2s( 0,  0);
	}
}
Esempio n. 4
0
MenuCursor::MenuCursor()
	: m_size(Vec2s(64, 64))
{
	exited = true;
	
	bMouseOver=false;
	
	m_currentFrame=0;
	lFrameDiff = PlatformDuration_ZERO;
}
MaterialLayerBase::MaterialLayerBase(void) :
    Inherited(),
    _sfMaterial               (NULL),
    _sfColor                  (Color4f(1.0f,1.0f,1.0f,1.0f)),
    _sfScale                  (UInt32(MaterialLayer::SCALE_STRETCH)),
    _sfScaleAbsoluteSize      (Vec2s(1,1)),
    _sfVerticalAlignment      (Real32(0.5)),
    _sfHorizontalAlignment    (Real32(0.5))
{
}
Esempio n. 6
0
MenuCursor::MenuCursor()
	: m_size(Vec2s(64, 64))
{
	exited = true;
	
	bMouseOver = false;
	
	m_currentFrame = 0;
	lFrameDiff = 0;
}
Esempio n. 7
0
bool Input::init(Window * window) {
	arx_assert(backend == NULL);
	
	backend = window->getInputBackend();
	
	int x, y;
	backend->getAbsoluteMouseCoords(x, y);
	m_lastMousePosition = Vec2s(x, y);
	
	return (backend != NULL);
}
Esempio n. 8
0
void MenuCursor::update() {
	
	bool inWindow = GInput->isMouseInWindow();
	if(inWindow && exited) {
		// Mouse is re-entering the window - reset the cursor trail
		reset();
	}
	exited = !inWindow;
	
	Vec2s iDiff = m_size / Vec2s(2);
	
	trail.add(g_platformTime.lastFrameDuration(), GInput->getMousePosition() + iDiff);
}
Esempio n. 9
0
void MenuCursor::update(PlatformDuration time) {
	
	bool inWindow = GInput->isMouseInWindow();
	if(inWindow && exited) {
		// Mouse is re-entering the window - reset the cursor trail
		reset();
	}
	exited = !inWindow;
	
	Vec2s iDiff = m_size / Vec2s(2);
	
	trail.add(time, GInput->getMousePosAbs() + iDiff);
}
CubeMapGeneratorBase::CubeMapGeneratorBase(void) :
    Inherited(),
    _sfRoot                   (NULL),
    _mfExclude                (),
    _sfTexture                (NULL),
    _sfTextureSize            (Vec2s(0, 0)),
    _sfTextureFormat          (GLenum(GL_NONE)),
    _sfBeacon                 (NULL),
    _sfOrigin                 (Pnt3f(0.f,0.f,0.f)),
    _sfOriginMode             (UInt32(CubeMapGenerator::UseCurrentVolumeCenter)),
    _sfTexUnit                (UInt32(0)),
    _sfSetupMode              (UInt32(CubeMapGenerator::SetupAll)),
    _sfBackground             (NULL),
    _sfCamera                 (NULL)
{
}
Esempio n. 11
0
/*!
 * \brief Returns true if xx,yy is a position in player inventory
 */
bool PlayerInventoryHud::containsPos(const Vec2s & pos) {
	Vec2f anchorPos = anchorPosition();
	
	Vec2s iPos = Vec2s(anchorPos);

	if(player.Interface & INTER_INVENTORY) {
		Vec2s t = pos - iPos;
		
		return InPlayerInventoryBag(t);
	} else if(player.Interface & INTER_INVENTORYALL) {
		float fBag = (player.bag - 1) * (-121 * m_scale);

		short iY = checked_range_cast<short>(fBag);

		if(   pos.x >= iPos.x
		   && pos.x <= iPos.x + INVENTORY_X * (32 * m_scale)
		   && pos.y >= iPos.y + iY
		   && pos.y <= g_size.height()
		) {
			return true;
		}

		for(int i = 0; i < player.bag; i++) {
			Vec2s t = pos - iPos;
			t.y -= iY;
			
			if(InPlayerInventoryBag(t))
				return true;
			
			float fRatio	= (121 * m_scale);

			iY = checked_range_cast<short>(iY + fRatio);
		}
	}

	return false;
}
Esempio n. 12
0
static void drawDebugMaterials() {
	
	if(!ACTIVEBKG || !ACTIVEBKG->exist) {
		return;
	}
	
	PolyType skip = POLY_NODRAW | POLY_HIDE;
	if(GInput->isKeyPressed(Keyboard::Key_LeftShift)) {
		skip |= POLY_TRANS | POLY_WATER;
	}
	
	Vec2f point(DANAEMouse);
	
	Entity * owner = GetFirstInterAtPos(Vec2s(point));
	TextureContainer * material = NULL;
	size_t count = 0;
	Vec2f pp[4];
	Vec2f puv[4];
	PolyType flags;
	
	float minz = std::numeric_limits<float>::max();
	
	for(size_t k = 1; k < entities.size(); k++) {
		
		EntityHandle h = EntityHandle(k);
		if(!entities[h] || !entities[h]->obj) {
			continue;
		}
		Entity * entity = entities[h];
		
		if((entity->ioflags & IO_CAMERA) || (entity->ioflags & IO_MARKER))
			continue;
		
		if(!(entity->gameFlags & GFLAG_ISINTREATZONE))
			continue;
		if((entity->gameFlags & GFLAG_INVISIBILITY))
			continue;
		if((entity->gameFlags & GFLAG_MEGAHIDE))
			continue;
		
		switch(entity->show) {
			case SHOW_FLAG_DESTROYED:    continue;
			case SHOW_FLAG_IN_INVENTORY: continue;
			case SHOW_FLAG_ON_PLAYER:    continue;
			case SHOW_FLAG_LINKED:       break;
			case SHOW_FLAG_NOT_DRAWN:    continue;
			case SHOW_FLAG_HIDDEN:       continue;
			case SHOW_FLAG_MEGAHIDE:     continue;
			case SHOW_FLAG_KILLED:       continue;
			case SHOW_FLAG_IN_SCENE:     break;
			case SHOW_FLAG_TELEPORTING:  break;
		}
		
		if(!entity->bbox2D.valid()) {
			continue;
		}
		
		for(size_t j = 0; j < entity->obj->facelist.size(); j++) {
			const EERIE_FACE & face = entity->obj->facelist[j];
			
			if(face.facetype & skip) {
				continue;
			}
			
			bool valid = true;
			bool bvalid = false;
			Vec3f p[3];
			Vec2f uv[3];
			for(size_t i = 0; i < 3; i++) {
				unsigned short v = face.vid[i];
				valid = valid && v < entity->obj->vertexlist3.size();
				if(valid) {
					if(entity->animlayer[0].cur_anim) {
						p[i] = entity->obj->vertexlist3[v].vert.p;
						uv[i] = entity->obj->vertexlist3[v].vert.uv;
					} else {
						p[i] = entity->obj->vertexlist[v].vert.p;
						uv[i] = entity->obj->vertexlist[v].vert.uv;
					}
					valid = valid && (p[i].z > 0.000001f);
					bvalid = bvalid || (p[i].x >= g_size.left && p[i].x < g_size.right
					                 && p[i].y >= g_size.top && p[i].y < g_size.bottom);
				}
			}
			
			if(!valid || !bvalid) {
				continue;
			}
			
			float z = pointInTriangle(point, p[0], p[1], p[2]);
			
			if(z > 0 && z <= minz) {
				count = 3;
				for(size_t i = 0; i < count; i++) {
					pp[i] = Vec2f(p[i].x, p[i].y);
					puv[i] = uv[i];
				}
				if(face.texid >= 0 && size_t(face.texid) < entity->obj->texturecontainer.size()) {
					material = entity->obj->texturecontainer[face.texid];
				} else {
					material = NULL;
				}
				owner = entity;
				minz = z;
				flags = face.facetype & ~(POLY_WATER | POLY_LAVA);
			}
			
		}
	}
	
	for(short z = 0; z < ACTIVEBKG->Zsize; z++)
	for(short x = 0; x < ACTIVEBKG->Xsize; x++) {
		const EERIE_BKG_INFO & feg = ACTIVEBKG->fastdata[x][z];
		
		if(!feg.treat) {
			continue;
		}
		
		for(long l = 0; l < feg.nbpolyin; l++) {
			EERIEPOLY * ep = feg.polyin[l];
			
			if(!ep) {
				continue;
			}
			
			if(ep->type & skip) {
				continue;
			}
			
			bool valid = true;
			bool bvalid = false;
			Vec3f p[4];
			for(size_t i = 0; i < ((ep->type & POLY_QUAD) ? 4u : 3u); i++) {
				TexturedVertex tv;
				tv.p = EE_RT(ep->v[i].p);
				valid = valid && (tv.p.z > 0.000001f);
				EE_P(tv.p, tv);
				bvalid = bvalid || (tv.p.x >= g_size.left && tv.p.x < g_size.right
				                 && tv.p.y >= g_size.top && tv.p.y < g_size.bottom);
				p[i] = tv.p;
			}
			
			if(!valid || !bvalid) {
				continue;
			}
			
			float z = pointInTriangle(point, p[0], p[1], p[2]);
			if(z <= 0 && (ep->type & POLY_QUAD)) {
				z = pointInTriangle(point, p[1], p[3], p[2]);
			}
			
			if(z > 0 && z <= minz) {
				count = ((ep->type & POLY_QUAD) ? 4 : 3);
				for(size_t i = 0; i < count; i++) {
					pp[i] = Vec2f(p[i].x, p[i].y);
					puv[i] = ep->v[i].uv;
				}
				material = ep->tex;
				owner = NULL;
				minz = z;
				flags = ep->type;
			}
			
		}
	}
	
	if(count) {
		
		GRenderer->SetRenderState(Renderer::DepthTest, false);
		
		drawLine2D(pp[0], pp[1], 0.1f, Color::magenta);
		drawLine2D(pp[2], pp[0], 0.1f, Color::magenta);
		if(count == 4) {
			drawLine2D(pp[2], pp[3], 0.1f, Color::magenta);
			drawLine2D(pp[3], pp[1], 0.1f, Color::magenta);
		} else {
			drawLine2D(pp[1], pp[2], 0.1f, Color::magenta);
		}
		
		Vec2f c = Vec2f(0.f);
		float miny = std::numeric_limits<float>::max();
		float maxy = std::numeric_limits<float>::min();
		for(size_t i = 0; i < count; i++) {
			c += pp[i];
			miny = std::min(miny, pp[i].y);
			maxy = std::max(maxy, pp[i].y);
		}
		c *= 1.f / count;
		
		Vec2f textpos(c.x, miny - 2 * hFontDebug->getLineHeight());
		
		std::ostringstream oss;
		
		if(owner) {
			textpos.y -= hFontDebug->getLineHeight();
		}
		if(material && material->m_pTexture) {
			textpos.y -= hFontDebug->getLineHeight();
		}
		if((flags & (POLY_WATER | POLY_LAVA)) && enviro && enviro->m_pTexture) {
			textpos.y -= hFontDebug->getLineHeight();
		}
		if(textpos.y < g_size.top + 5) {
			textpos.y = maxy + 2 * hFontDebug->getLineHeight();
		}
		
		
		if(owner) {
			drawTextCentered(hFontDebug, textpos, owner->idString(), Color::cyan);
			textpos.y += hFontDebug->getLineHeight();
		}
		if(material && material->m_pTexture) {
			drawDebugMaterialTexture(textpos, "Diffuse: ", *material->m_pTexture, Color::green);
		}
		if((flags & (POLY_WATER | POLY_LAVA)) && enviro && enviro->m_pTexture) {
			oss.str(std::string());
			oss << "Animation: ";
			oss << ((flags & (POLY_LAVA)) ? "lava" : "water");
			if(flags & POLY_FALL) {
				oss << " (flowing)";
			}
			drawDebugMaterialTexture(textpos, oss.str(), *enviro->m_pTexture, Color::yellow);
		}
		
		(void)textpos;
		
		for(size_t i = 0; i < count; i++) {
			
			oss.str(std::string());
			oss.setf(std::ios_base::fixed, std::ios_base::floatfield);
			oss.precision(2);
			oss << '(' << puv[i].x << ',' << puv[i].y << ')';
			std::string text = oss.str();
			
			Vec2f textpos = pp[i];
			if(pp[i].y < c.y) {
				textpos.y -= hFontDebug->getLineHeight();
			}
			
			if(pp[i].x < c.x) {
				Vec2i size = hFontDebug->getTextSize(text);
				textpos.x -= size.x;
			}
			
			hFontDebug->draw(textpos.x, textpos.y, text, Color::gray(0.7f));
		}
		
		GRenderer->SetRenderState(Renderer::DepthTest, true);
		
	}
	
}
Esempio n. 13
0
Entity::Entity(const res::path & classPath, EntityInstance instance)
	: mainevent(SM_MAIN)
	, m_index(size_t(-1))
	, m_id(classPath, instance)
	, m_classPath(classPath)
{
	
	m_index = entities.add(this);
	
	ioflags = 0;
	lastpos = Vec3f_ZERO;
	pos = Vec3f_ZERO;
	move = Vec3f_ZERO;
	lastmove = Vec3f_ZERO;
	forcedmove = Vec3f_ZERO;
	
	angle = Anglef::ZERO;
	physics = IO_PHYSICS();
	room = -1;
	requestRoomUpdate = true;
	original_height = 0.f;
	original_radius = 0.f;
	m_icon = NULL;
	obj = NULL;
	std::fill_n(anims, MAX_ANIMS, (ANIM_HANDLE *)NULL);
	
	for(size_t l = 0; l < MAX_ANIM_LAYERS; l++) {
		animlayer[l] = AnimLayer();
	}
	
	animBlend.m_active = false;
	animBlend.lastanimtime = 0;
	
	std::memset(&bbox3D, 0, sizeof(EERIE_3D_BBOX)); // TODO use constructor
	
	bbox2D.min = Vec2f(-1.f, -1.f);
	bbox2D.max = Vec2f(-1.f, -1.f);

	tweaky = NULL;
	sound = audio::INVALID_ID;
	type_flags = 0;
	scriptload = 0;
	target = Vec3f_ZERO;
	targetinfo = EntityHandle(TARGET_NONE);
	
	_itemdata = NULL;
	_fixdata = NULL;
	_npcdata = NULL;
	_camdata = NULL;
	
	inventory = NULL;
	show = SHOW_FLAG_IN_SCENE;
	collision = 0;
	infracolor = Color3f::blue;
	changeanim = -1;
	
	weight = 1.f;
	gameFlags = GFLAG_NEEDINIT | GFLAG_INTERACTIVITY;
	fall = 0.f;
	
	initpos = Vec3f_ZERO;
	initangle = Anglef::ZERO;
	scale = 1.f;
	
	usepath = NULL;
	symboldraw = NULL;
	dynlight = LightHandle();
	lastspeechflag = 2;
	inzone = NULL;
	halo = IO_HALO();
	halo_native = IO_HALO();
	halo_native.color = Color3f(0.2f, 0.5f, 1.f);
	halo_native.radius = 45.f;
	halo_native.flags = 0;
	ARX_HALO_SetToNative(this);
	
	for(size_t j = 0; j < MAX_SCRIPTTIMERS; j++) {
		m_scriptTimers[j] = 0;
	}
	m_disabledEvents = 0;
	
	stat_count = 0;
	stat_sent = 0;
	tweakerinfo = NULL;
	material = MATERIAL_NONE;
	
	m_inventorySize = Vec2s(1, 1);
	
	soundtime = 0;
	soundcount = 0;
	
	sfx_time = 0;
	collide_door_time = 0;
	ouch_time = 0;
	dmg_sum = 0.f;
	
	spellcast_data = IO_SPELLCAST_DATA();
	flarecount = 0;
	no_collide = EntityHandle();
	invisibility = 0.f;
	basespeed = 1.f;
	
	speed_modif = 0.f;
	
	rubber = BASE_RUBBER;
	max_durability = durability = 100.f;
	poisonous = 0;
	poisonous_count = 0;
	
	ignition = 0.f;
	ignit_light = LightHandle();
	ignit_sound = audio::INVALID_ID;
	head_rot = 0.f;
	
	damager_damages = 0;
	damager_type = 0;
	
	sfx_flag = 0;
	secretvalue = -1;
	
	shop_multiply = 1.f;
	isHit = false;
	inzone_show = 0;
	summoner = EntityHandle();
	spark_n_blood = 0;

	special_color = Color3f::white;
	highlightColor = Color3f::black;
	
}
Esempio n. 14
0
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindowEventProducer = createDefaultWindowEventProducer();
    WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();

    TutorialWindowEventProducer->setDisplayCallback(display);
    TutorialWindowEventProducer->setReshapeCallback(reshape);

    //Add Window Listener
    TutorialKeyListener TheKeyListener;
    TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
    TutorialWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

	
    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindowEventProducer->getWindow());

    //Make a SphereNode for the point light
    LambertMaterialPtr TheLightMat = LambertMaterial::create();
    beginEditCP(TheLightMat, LambertMaterial::IncandescenceFieldMask);
        TheLightMat->setIncandescence(Color3f(1.0,1.0,1.0));
    endEditCP(TheLightMat, LambertMaterial::IncandescenceFieldMask);

    GeometryPtr LightSphereGeo = makeSphereGeo(2,2.0);
    beginEditCP(LightSphereGeo, Geometry::MaterialFieldMask);
        LightSphereGeo->setMaterial(TheLightMat);
    endEditCP  (LightSphereGeo, Geometry::MaterialFieldMask);

    NodePtr LightSphereNode = Node::create();
    beginEditCP(LightSphereNode, Node::CoreFieldMask);
		LightSphereNode->setCore(LightSphereGeo);
    endEditCP  (LightSphereNode, Node::CoreFieldMask);

    //Create the beacon for the Point Light
    Matrix ThePointLightMat;
    ThePointLightMat.setTranslate(Vec3f(0.0,100.0,0.0));
    
    ThePointLightBeaconTransform = Transform::create();
    beginEditCP(ThePointLightBeaconTransform);
        ThePointLightBeaconTransform->setMatrix(ThePointLightMat);
    endEditCP(ThePointLightBeaconTransform);

    NodePtr ThePointLightBeaconNode = Node::create();
    beginEditCP(ThePointLightBeaconNode);
        ThePointLightBeaconNode->setCore(ThePointLightBeaconTransform);
        ThePointLightBeaconNode->addChild(LightSphereNode);
    endEditCP(ThePointLightBeaconNode);

    //Set the light properties desired
    PointLightPtr ThePointLight = PointLight::create();
    beginEditCP(ThePointLight);
        ThePointLight->setAmbient(0.3,0.3,0.3,0.3);
        ThePointLight->setDiffuse(1.0,1.0,1.0,1.0);
        ThePointLight->setSpecular(1.0,1.0,1.0,1.0);
        ThePointLight->setBeacon(ThePointLightBeaconNode);
    endEditCP(ThePointLight);

    NodePtr ThePointLightNode = Node::create();
    beginEditCP(ThePointLightNode);
        ThePointLightNode->setCore(ThePointLight);
    endEditCP(ThePointLightNode);
    
    //Set the light properties desired
    SpotLightPtr TheSpotLight = SpotLight::create();
    beginEditCP(TheSpotLight);
        TheSpotLight->setAmbient(0.3,0.3,0.3,0.3);
        TheSpotLight->setDiffuse(1.0,1.0,1.0,1.0);
        TheSpotLight->setSpecular(1.0,1.0,1.0,1.0);
        TheSpotLight->setBeacon(ThePointLightBeaconNode);
        TheSpotLight->setDirection(Vec3f(0.0,-1.0,0.0));
        TheSpotLight->setSpotExponent(5.0);
        TheSpotLight->setSpotCutOff(1.1);
    endEditCP(TheSpotLight);

    NodePtr TheSpotLightNode = Node::create();
    beginEditCP(TheSpotLightNode);
        TheSpotLightNode->setCore(TheSpotLight);
    endEditCP(TheSpotLightNode);

	//Load in the Heightmap Image
	ImagePtr PerlinNoiseImage = createPerlinImage(Vec2s(256,256), Vec2f(10.0f,10.0f),0.5f,1.0f,Vec2f(0.0f,0.0f),0.25f,6,PERLIN_INTERPOLATE_COSINE,false,Image::OSG_L_PF, Image::OSG_UINT8_IMAGEDATA);

    TextureChunkPtr TheTextureChunk = TextureChunk::create();
    beginEditCP(TheTextureChunk);
        TheTextureChunk->setImage(PerlinNoiseImage);
    endEditCP(TheTextureChunk);

    //Lambert Material
    LambertMaterialPtr TheLambertMat = LambertMaterial::create();
    beginEditCP(TheLambertMat, LambertMaterial::ColorFieldMask | LambertMaterial::AmbientColorFieldMask | LambertMaterial::DiffuseFieldMask
                              | LambertMaterial::NumLightsFieldMask | LambertMaterial::DiffuseTextureFieldMask);
        TheLambertMat->setColor(Color3f(0.0,1.0,0.0));
        TheLambertMat->setAmbientColor(Color3f(1.0,0.0,0.0));
        TheLambertMat->setDiffuse(0.5);
        TheLambertMat->setNumLights(1);
    endEditCP(TheLambertMat, LambertMaterial::ColorFieldMask | LambertMaterial::AmbientColorFieldMask | LambertMaterial::DiffuseFieldMask
                              | LambertMaterial::NumLightsFieldMask | LambertMaterial::DiffuseTextureFieldMask);
    

    //Blinn Material
    TheBlinnMat = BlinnMaterial::create();
    beginEditCP(TheBlinnMat, BlinnMaterial::ColorFieldMask | BlinnMaterial::AmbientColorFieldMask | BlinnMaterial::DiffuseFieldMask
         | BlinnMaterial::SpecularColorFieldMask | BlinnMaterial::SpecularEccentricityFieldMask | BlinnMaterial::SpecularRolloffFieldMask | BlinnMaterial::DiffuseTextureFieldMask);
        TheBlinnMat->setColor(Color3f(1.0,0.0,0.0));
        TheBlinnMat->setAmbientColor(Color3f(0.0,0.0,0.0));
        TheBlinnMat->setSpecularColor(Color3f(0.0,0.0,1.0));
        TheBlinnMat->setSpecularEccentricity(0.35);
        TheBlinnMat->setSpecularRolloff(0.85);
        TheBlinnMat->setDiffuse(0.65);
        TheBlinnMat->setDiffuseTexture(TheTextureChunk);
    endEditCP(TheBlinnMat, BlinnMaterial::ColorFieldMask | BlinnMaterial::AmbientColorFieldMask | BlinnMaterial::DiffuseFieldMask
         | BlinnMaterial::SpecularColorFieldMask | BlinnMaterial::SpecularEccentricityFieldMask | BlinnMaterial::SpecularRolloffFieldMask | BlinnMaterial::DiffuseTextureFieldMask);
    
    //Phong Material
    Phong2MaterialPtr ThePhongMat = Phong2Material::create();
    beginEditCP(ThePhongMat, Phong2Material::ColorFieldMask | Phong2Material::AmbientColorFieldMask | Phong2Material::DiffuseFieldMask
         | Phong2Material::SpecularColorFieldMask | Phong2Material::SpecularCosinePowerFieldMask);
        ThePhongMat->setColor(Color3f(1.0,0.0,0.0));
        ThePhongMat->setAmbientColor(Color3f(0.0,0.0,0.0));
        ThePhongMat->setSpecularColor(Color3f(0.0,0.0,1.0));
        ThePhongMat->setSpecularCosinePower(50.0);
        ThePhongMat->setDiffuse(0.65);
    endEditCP(ThePhongMat, Phong2Material::ColorFieldMask | Phong2Material::AmbientColorFieldMask | Phong2Material::DiffuseFieldMask
         | Phong2Material::SpecularColorFieldMask | Phong2Material::SpecularCosinePowerFieldMask);

    //Anisotropic Material
    AnisotropicMaterialPtr TheAnisotropicMat = AnisotropicMaterial::create();
    beginEditCP(TheAnisotropicMat, AnisotropicMaterial::ColorFieldMask | AnisotropicMaterial::AmbientColorFieldMask | AnisotropicMaterial::DiffuseFieldMask
         | AnisotropicMaterial::SpecularColorFieldMask | AnisotropicMaterial::SpecularRoughnessFieldMask | AnisotropicMaterial::SpecularFresnelIndexFieldMask
          | AnisotropicMaterial::SpecularSpreadXFieldMask | AnisotropicMaterial::SpecularSpreadYFieldMask);
        TheAnisotropicMat->setColor(Color3f(1.0,0.0,0.0));
        TheAnisotropicMat->setAmbientColor(Color3f(0.0,0.0,0.0));
        TheAnisotropicMat->setDiffuse(0.65);
        TheAnisotropicMat->setSpecularColor(Color3f(0.0,0.0,1.0));
        TheAnisotropicMat->setSpecularRoughness(32.0);
        TheAnisotropicMat->setSpecularFresnelIndex(0.85);
        TheAnisotropicMat->setSpecularSpreadX(1.0);
        TheAnisotropicMat->setSpecularSpreadY(1.0);
    endEditCP(TheAnisotropicMat, AnisotropicMaterial::ColorFieldMask | AnisotropicMaterial::AmbientColorFieldMask | AnisotropicMaterial::DiffuseFieldMask
         | AnisotropicMaterial::SpecularColorFieldMask | AnisotropicMaterial::SpecularRoughnessFieldMask | AnisotropicMaterial::SpecularFresnelIndexFieldMask
          | AnisotropicMaterial::SpecularSpreadXFieldMask | AnisotropicMaterial::SpecularSpreadYFieldMask);

    PointChunkPtr TempChunk = PointChunk::create();
    //addRefCP(TempChunk);

    //Anisotropic Material
    TheRampMat = RampMaterial::create();
    beginEditCP(TheRampMat);
        //Color
        TheRampMat->setRampSource(RampMaterial::RAMP_SOURCE_FACING_ANGLE);
        TheRampMat->getColors().push_back(Color3f(1.0,0.0,0.0));
        TheRampMat->getColorPositions().push_back(0.4);
        TheRampMat->getColorInterpolations().push_back(RampMaterial::RAMP_INTERPOLATION_SMOOTH);
        TheRampMat->getColors().push_back(Color3f(0.0,1.0,0.0));
        TheRampMat->getColorPositions().push_back(1.0);
        
        //Transparency
        TheRampMat->getTransparencies().push_back(Color3f(0.0,0.0,0.0));
        TheRampMat->getTransparencyPositions().push_back(0.83);
        TheRampMat->getTransparencyInterpolations().push_back(RampMaterial::RAMP_INTERPOLATION_SMOOTH);
        TheRampMat->getTransparencies().push_back(Color3f(1.0,1.0,1.0));
        TheRampMat->getTransparencyPositions().push_back(1.0);

        TheRampMat->setAmbientColor(Color3f(0.0,0.0,0.0));
        TheRampMat->setSpecularity(1.0);
        TheRampMat->setSpecularEccentricity(0.8);
        TheRampMat->getSpecularColors().push_back(Color3f(1.0,1.0,1.0));
        TheRampMat->getSpecularColorPositions().push_back(0.95);
        TheRampMat->getSpecularColorInterpolations().push_back(RampMaterial::RAMP_INTERPOLATION_SMOOTH);
        TheRampMat->getSpecularColors().push_back(Color3f(0.0,0.0,1.0));
        TheRampMat->getSpecularColorPositions().push_back(1.0);
        TheRampMat->getSpecularRolloffs().push_back(1.0);
        TheRampMat->getExtraChunks().push_back(TempChunk);
    endEditCP(TheRampMat);



	//Make the Heightmap Geometry
	HeightmapGeometryPtr TutorialHeightmapGeo = HeightmapGeometry::create();
	beginEditCP(TutorialHeightmapGeo, HeightmapGeometry::HeightImageFieldMask | HeightmapGeometry::DimensionsFieldMask | HeightmapGeometry::SegmentsFieldMask | HeightmapGeometry::ScaleFieldMask | HeightmapGeometry::OffsetFieldMask | HeightmapGeometry::MaterialFieldMask);
		TutorialHeightmapGeo->setHeightImage(PerlinNoiseImage);
		TutorialHeightmapGeo->setDimensions(Vec2f(200.0,200.0));
		TutorialHeightmapGeo->setSegments(Vec2f(150.0,150.0));
		TutorialHeightmapGeo->setScale(30.0);
		TutorialHeightmapGeo->setOffset(0.0);
		TutorialHeightmapGeo->setMaterial( TheBlinnMat );
	endEditCP(TutorialHeightmapGeo, HeightmapGeometry::HeightImageFieldMask | HeightmapGeometry::DimensionsFieldMask | HeightmapGeometry::SegmentsFieldMask | HeightmapGeometry::ScaleFieldMask | HeightmapGeometry::OffsetFieldMask | HeightmapGeometry::MaterialFieldMask);

    calcVertexNormals(TutorialHeightmapGeo);
    calcVertexTangents(TutorialHeightmapGeo,0,Geometry::TexCoords7FieldId, Geometry::TexCoords6FieldId);

    //Make the Heightmap Node
    NodePtr TutorialHeightmapNode = Node::create();
    beginEditCP(TutorialHeightmapNode, Node::CoreFieldMask);
		TutorialHeightmapNode->setCore(TutorialHeightmapGeo);
    endEditCP  (TutorialHeightmapNode, Node::CoreFieldMask);

    //Make a SphereNode
    GeometryPtr SphereGeo = makeSphereGeo(2,50.0);
    //GeometryPtr SphereGeo = makeCylinderGeo(50,20.0, 16,true,true,true);
    beginEditCP(SphereGeo, Geometry::MaterialFieldMask);
		SphereGeo->setMaterial(TheLambertMat);
    endEditCP  (SphereGeo, Geometry::MaterialFieldMask);
    calcVertexNormals(SphereGeo);
    calcVertexTangents(SphereGeo,0,Geometry::TexCoords7FieldId, Geometry::TexCoords6FieldId);

    NodePtr SphereNode = Node::create();
    beginEditCP(SphereNode, Node::CoreFieldMask);
		SphereNode->setCore(SphereGeo);
    endEditCP  (SphereNode, Node::CoreFieldMask);

    //Make Main Scene Node
    NodePtr scene = Node::create();
    beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
		scene->setCore(Group::create());
 
        // add the torus as a child
        scene->addChild(TutorialHeightmapNode);
        //scene->addChild(SphereNode);
        scene->addChild(ThePointLightBeaconNode);
    endEditCP  (scene, Node::CoreFieldMask | Node::ChildrenFieldMask);

    //Add the scene to the Light Nodes
    //beginEditCP(ThePointLightNode, Node::ChildrenFieldMask);
        //ThePointLightNode->addChild(scene);
    //endEditCP(ThePointLightNode, Node::ChildrenFieldMask);


    //// tell the manager what to manage
    //mgr->setRoot  (ThePointLightNode);

    beginEditCP(TheSpotLightNode, Node::ChildrenFieldMask);
        TheSpotLightNode->addChild(scene);
    endEditCP(TheSpotLightNode, Node::ChildrenFieldMask);


    // tell the manager what to manage
    mgr->setRoot  (TheSpotLightNode);
    mgr->turnHeadlightOff();

    // show the whole scene
    mgr->showAll();
    
    //Open Window
    Vec2f WinSize(TutorialWindowEventProducer->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindowEventProducer->getDesktopSize() - WinSize) *0.5);
    TutorialWindowEventProducer->openWindow(WinPos,
                        WinSize,
                                        "06Heightmap");

    //Main Loop
    TutorialWindowEventProducer->mainLoop();

    osgExit();

    return 0;
}
Esempio n. 15
0
void Input::update() {
	int iDTime;

	backend->update();

	bool keyJustPressed = false;
	iKeyId = -1;
	int modifier = 0;

	for(int i = 0; i < Keyboard::KeyCount; i++) {
		if(isKeyPressed(i)) {
			switch(i) {
			case Keyboard::Key_LeftShift:
			case Keyboard::Key_RightShift:
			case Keyboard::Key_LeftCtrl:
			case Keyboard::Key_RightCtrl:
			case Keyboard::Key_LeftAlt:
			case Keyboard::Key_RightAlt:
				modifier = i;
				break;
			}

			if(keysStates[i] < 2) {
				keysStates[i]++;
			}

			if(!keyJustPressed) {
				if(keysStates[i] == 1) {
					iKeyId = i;
					keyJustPressed = true;
				} else {
					iKeyId = i;
				}
			}
		} else {
			if(keysStates[i] > 0) {
				keysStates[i]--;
			}
		}
	}

	if(modifier != 0 && iKeyId != modifier) {
		iKeyId |= (modifier << 16);
	}

	if(iKeyId >= 0) {   //keys priority
		switch(iKeyId) {
		case Keyboard::Key_LeftShift:
		case Keyboard::Key_RightShift:
		case Keyboard::Key_LeftCtrl:
		case Keyboard::Key_RightCtrl:
		case Keyboard::Key_LeftAlt:
		case Keyboard::Key_RightAlt: {
				bool bFound=false;

				for(int i = 0; i < Keyboard::KeyCount; i++) {
					if(bFound) {
						break;
					}

					switch(i & 0xFFFF) {
					case Keyboard::Key_LeftShift:
					case Keyboard::Key_RightShift:
					case Keyboard::Key_LeftCtrl:
					case Keyboard::Key_RightCtrl:
					case Keyboard::Key_LeftAlt:
					case Keyboard::Key_RightAlt:
						continue;
					default: {
						if(keysStates[i]) {
							bFound=true;
							iKeyId&=~0xFFFF;
							iKeyId|=i;
						}
						}
						break;
					}
				}
			}
		}
	}

	const int iArxTime = checked_range_cast<int>(arxtime.get_updated(false));

	for(int buttonId = Mouse::ButtonBase; buttonId < Mouse::ButtonMax; buttonId++) {
		int i = buttonId - Mouse::ButtonBase;

		int iNumClick;
		int iNumUnClick;
		backend->getMouseButtonClickCount(buttonId, iNumClick, iNumUnClick);

		iOldNumClick[i]+=iNumClick+iNumUnClick;

		if(!bMouseButton[i] && iOldNumClick[i] == iNumUnClick) {
			iOldNumClick[i]=0;
		}

		bOldMouseButton[i]=bMouseButton[i];

		if(bMouseButton[i]) {
			if(iOldNumClick[i]) {
				bMouseButton[i]=false;
			}
		} else {
			if(iOldNumClick[i]) {
				bMouseButton[i]=true;
			}
		}

		if(iOldNumClick[i]) 
			iOldNumClick[i]--;

		backend->isMouseButtonPressed(buttonId,iDTime);

		if(iDTime) {
			iMouseTime[i]=iDTime;
			iMouseTimeSet[i]=2;
		} else {
			if(iMouseTimeSet[i] > 0 && (arxtime.get_updated(false)-iMouseTime[i]) > 300) {
				iMouseTime[i]=0;
				iMouseTimeSet[i]=0;
			}

			if(getMouseButtonNowPressed(buttonId)) {
				switch(iMouseTimeSet[i]) {
				case 0:
					iMouseTime[i] = iArxTime;
					iMouseTimeSet[i]++;
					break;
				case 1:
					iMouseTime[i] = iArxTime - iMouseTime[i];
					iMouseTimeSet[i]++;
					break;
				}
			}
		}
	}
	
	// Get the new coordinates
	int absX, absY;
	mouseInWindow = backend->getAbsoluteMouseCoords(absX, absY);
	
	Vec2i wndSize = mainApp->getWindow()->getSize();
	if(absX >= 0 && absX < wndSize.x && absY >= 0 && absY < wndSize.y) {
		
		// Use the absolute mouse position reported by the backend, as is
		iMouseA = Vec2s((short)absX, (short)absY);
		
		int relX, relY;
		backend->getRelativeMouseCoords(relX, relY, iWheelDir);
		
		// Use the sensitivity config value to adjust relative mouse mouvements
		float fSensMax = 1.f / 6.f;
		float fSensMin = 2.f;
		float fSens = ( ( fSensMax - fSensMin ) * ( (float)iSensibility ) / 10.f ) + fSensMin;
		fSens = std::pow(0.7f, fSens) * 2.f;
		iMouseR.x = relX * fSens;
		iMouseR.y = relY * fSens;
		
	} else {
		mouseInWindow = false;
	}
}
Esempio n. 16
0
void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io)
{
	float m;
	long i;
	long z;

	float x0 = pos0.x;
	float x1 = pos1.x;
	float y0 = pos0.y;
	float y1 = pos1.y;

	float dx = (x1 - x0);
	float adx = glm::abs(dx);
	float dy = (y1 - y0);
	float ady = glm::abs(dy);

	if(adx > ady) {
		if(x0 > x1) {
			z = x1;
			x1 = x0;
			x0 = z;
			z = y1;
			y0 = z;
		}

		if(x0 < x1) {
			m = dy / dx;
			i = x0;

			while(i < x1) {
				z = rnd() * FLARELINERND;
				z += FLARELINESTEP;
				i += z;
				y0 += m * z;
				AddLFlare(Vec2s(i, y0), io);
			}
		} else {
			m = dy / dx;
			i = x1;

			while(i < x0) {
				z = rnd() * FLARELINERND;
				z += FLARELINESTEP;
				i += z;
				y0 += m * z;
				AddLFlare(Vec2s(i, y0), io);
			}
		}
	} else {
		if(y0 > y1) {
			z = x1;
			x0 = z;
			z = y1;
			y1 = y0;
			y0 = z;
		}

		if(y0 < y1) {
			m = dx / dy;
			i = y0;

			while(i < y1) {
				z = rnd() * FLARELINERND;
				z += FLARELINESTEP;
				i += z;
				x0 += m * z;
				AddLFlare(Vec2s(x0, i), io);
			}
		} else {
			m = dx / dy;
			i = y1;

			while(i < y0) {
				z = rnd() * FLARELINERND;
				z += FLARELINESTEP;
				i += z;
				x0 += m * z;
				AddLFlare(Vec2s(x0, i), io);
			}
		}
	}
}
Esempio n. 17
0
void Input::centerMouse() {
	setMousePosAbs(Vec2s(mainApp->getWindow()->getSize() / s32(2)));
}
Esempio n. 18
0
void levelInit() {
	
	arx_assert(entities.player());
	
	LogDebug("Initializing level ...");
	
	ARX_PARTICLES_FirstInit();
	g_renderBatcher.reset();
	
	progressBarAdvance(2.f);
	LoadLevelScreen();
	
	g_particleManager.Clear();
	
	if(GMOD_RESET)
		ARX_GLOBALMODS_Reset();

	GMOD_RESET = true;
	
	STARTDRAG = Vec2s(0);
	DANAEMouse = Vec2s(0);
	
	PolyBoomClear();
	ARX_DAMAGES_Reset();
	ARX_MISSILES_ClearAll();
	spells.clearAll();
	ARX_SPELLS_ClearAllSymbolDraw();
	
	ARX_PARTICLES_ClearAll();
	ParticleSparkClear();
	
	if(LOAD_N_ERASE) {
		CleanScriptLoadedIO();
		RestoreInitialIOStatus();
		DRAGINTER = NULL;
	}
	
	ARX_SPELLS_ResetRecognition();
	
	eyeball.exist = 0;
	
	resetDynLights();
	
	if(LOAD_N_ERASE) {
		CleanInventory();
		ARX_SCRIPT_Timer_ClearAll();
		UnlinkAllLinkedObjects();
		ARX_SCRIPT_ResetAll(false);
	}
	
	SecondaryInventory = NULL;
	TSecondaryInventory = NULL;
	ARX_FOGS_Render();
	
	if(LOAD_N_ERASE) {
		
		if(!DONT_ERASE_PLAYER)
			ARX_PLAYER_InitPlayer();

		g_hudRoot.playerInterfaceFader.resetSlid();

		player.lifePool.current = player.lifePool.max;
		player.manaPool.current = player.manaPool.max;
		if(!DONT_ERASE_PLAYER) {
			ARX_PLAYER_MakeFreshHero();
		}
	}
	
	InitSnapShot(fs::getUserDir() / "snapshot");
	
	progressBarAdvance(4.f);
	LoadLevelScreen();

	if(player.torch) {
		player.torch_loop = ARX_SOUND_PlaySFX_loop(g_snd.TORCH_LOOP, NULL, 1.0F);
	}
	
	g_playerCamera.m_pos = g_moveto = player.pos;
	g_playerCamera.angle = player.angle;
	
	RestoreLastLoadedLightning(*ACTIVEBKG);

	progressBarAdvance();
	LoadLevelScreen();

	if(LOAD_N_ERASE) {
		SetEditMode();
		ARX_SOUND_MixerStop(ARX_SOUND_MixerGame);
		ARX_SCRIPT_ResetAll(true);
		EERIE_ANIMMANAGER_PurgeUnused();
	}

	progressBarAdvance();
	LoadLevelScreen();

	LOAD_N_ERASE = true;
	DONT_ERASE_PLAYER = false;

	progressBarAdvance();
	LoadLevelScreen();
	
	PrepareIOTreatZone(1);
	
	progressBarAdvance();
	LoadLevelScreen();
	
	if(DONT_WANT_PLAYER_INZONE) {
		player.inzone = NULL;
		DONT_WANT_PLAYER_INZONE = 0;
	}
	
	progressBarAdvance();
	LoadLevelScreen();

	player.desiredangle.setPitch(0.f);
	player.angle.setPitch(0.f);
	ARX_PLAYER_RectifyPosition();

	entities.player()->_npcdata->vvpos = -99999;
	
	SendMsgToAllIO(NULL, SM_GAME_READY);
	
	PLAYER_MOUSELOOK_ON = false;
	
	g_note.clear();
	
	EntityHandle t = entities.getById("seat_stool1_0012");
	if(ValidIONum(t)) {
		entities[t]->ioflags |= IO_FORCEDRAW;
	}
	
	ARX_NPC_RestoreCuts();
	
	ResetVVPos(entities.player());
	
	progressBarAdvance();
	LoadLevelScreen();
	LoadLevelScreen(-2);
	
	if(!CheckInPoly(player.pos) && LastValidPlayerPos.x != 0.f
	   && LastValidPlayerPos.y != 0.f && LastValidPlayerPos.z != 0.f) {
		player.pos = LastValidPlayerPos;
	}
	
	LastValidPlayerPos = player.pos;
	
	g_platformTime.updateFrame();
	
	g_gameTime.resume(GameTime::PauseInitial | GameTime::PauseMenu);
}
Esempio n. 19
0
void Input::update() {

	backend->update();

	bool keyJustPressed = false;
	iKeyId = -1;
	int modifier = 0;

	for(int i = 0; i < Keyboard::KeyCount; i++) {
		if(isKeyPressed(i)) {
			switch(i) {
			case Keyboard::Key_LeftShift:
			case Keyboard::Key_RightShift:
			case Keyboard::Key_LeftCtrl:
			case Keyboard::Key_RightCtrl:
			case Keyboard::Key_LeftAlt:
			case Keyboard::Key_RightAlt:
				modifier = i;
				break;
			}

			if(keysStates[i] < 2) {
				keysStates[i]++;
			}

			if(!keyJustPressed) {
				if(keysStates[i] == 1) {
					iKeyId = i;
					keyJustPressed = true;
				} else {
					iKeyId = i;
				}
			}
		} else {
			if(keysStates[i] > 0) {
				keysStates[i]--;
			}
		}
	}

	if(modifier != 0 && iKeyId != modifier) {
		iKeyId |= (modifier << 16);
	}

	if(iKeyId >= 0) {   //keys priority
		switch(iKeyId) {
		case Keyboard::Key_LeftShift:
		case Keyboard::Key_RightShift:
		case Keyboard::Key_LeftCtrl:
		case Keyboard::Key_RightCtrl:
		case Keyboard::Key_LeftAlt:
		case Keyboard::Key_RightAlt: {
				bool bFound=false;

				for(int i = 0; i < Keyboard::KeyCount; i++) {
					if(bFound) {
						break;
					}

					switch(i & 0xFFFF) {
					case Keyboard::Key_LeftShift:
					case Keyboard::Key_RightShift:
					case Keyboard::Key_LeftCtrl:
					case Keyboard::Key_RightCtrl:
					case Keyboard::Key_LeftAlt:
					case Keyboard::Key_RightAlt:
						continue;
					default: {
						if(keysStates[i]) {
							bFound=true;
							iKeyId&=~0xFFFF;
							iKeyId|=i;
						}
						}
						break;
					}
				}
			}
		}
	}
	
	const s64 now = platform::getTimeMs();
	
	for(int buttonId = Mouse::ButtonBase; buttonId < Mouse::ButtonMax; buttonId++) {
		int i = buttonId - Mouse::ButtonBase;
		
		int iNumClick;
		int iNumUnClick;
		backend->getMouseButtonClickCount(buttonId, iNumClick, iNumUnClick);
		
		iOldNumClick[i] += iNumClick + iNumUnClick;
		
		if(!bMouseButton[i] && iOldNumClick[i] == iNumUnClick) {
			iOldNumClick[i] = 0;
		}
		
		bOldMouseButton[i] = bMouseButton[i];
		
		if(bMouseButton[i]) {
			if(iOldNumClick[i]) {
				bMouseButton[i] = false;
			}
		} else {
			if(iOldNumClick[i]) {
				bMouseButton[i] = true;
			}
		}
		
		if(iOldNumClick[i]) 
			iOldNumClick[i]--;
		
		int iDTime;
		backend->isMouseButtonPressed(buttonId, iDTime);
		
		if(iDTime) {
			iMouseTime[i] = iDTime;
			iMouseTimeSet[i] = 2;
		} else {
			if(iMouseTimeSet[i] > 0 && (now - iMouseTime[i]) > 300) {
				iMouseTime[i] = 0;
				iMouseTimeSet[i] = 0;
			}
			
			if(getMouseButtonNowPressed(buttonId)) {
				switch(iMouseTimeSet[i]) {
				case 0:
					iMouseTime[i] = now;
					iMouseTimeSet[i]++;
					break;
				case 1:
					iMouseTime[i] = now - iMouseTime[i];
					iMouseTimeSet[i]++;
					break;
				}
			}
		}
	}
	
	// Get the new coordinates
	int absX, absY;
	mouseInWindow = backend->getAbsoluteMouseCoords(absX, absY);
	Vec2s newMousePosition(absX, absY);
	
	Vec2i wndSize = mainApp->getWindow()->getSize();
	if(absX >= 0 && absX < wndSize.x && absY >= 0 && absY < wndSize.y) {
		
		// Use the absolute mouse position reported by the backend, as is
		if(m_mouseMode == Mouse::Absolute) {
			iMouseA = newMousePosition;
		} else {
			iMouseA = wndSize / s32(2);
		}
		
	} else {
		mouseInWindow = false;
	}
	
	int relX, relY;
	backend->getRelativeMouseCoords(relX, relY, iWheelDir);
	
	if(m_mouseMode == Mouse::Relative) {
		
		if(m_useRawMouseInput) {
			iMouseR = Vec2s(relX * 2, relY * 2);
		} else {
			iMouseR = newMousePosition - m_lastMousePosition;
			m_lastMousePosition = newMousePosition;
			if(iMouseR != Vec2s_ZERO) {
				centerMouse();
			}
		}
		
		// Use the sensitivity config value to adjust relative mouse mouvements
		float fSensMax = 1.f / 6.f;
		float fSensMin = 2.f;
		float fSens = ( ( fSensMax - fSensMin ) * ( (float)iSensibility ) / 10.f ) + fSensMin;
		fSens = std::pow(0.7f, fSens) * 2.f;
		iMouseR *= fSens;
		
		if(!mouseInWindow) {
			LogWarning << "Cursor escaped the window while in relative input mode";
			centerMouse();
		}
		
	} else {
		iMouseR = Vec2s_ZERO;
		m_lastMousePosition = newMousePosition;
	}
	
}