示例#1
0
void testApp::blobOff( ofxCvBlob b) 
{
	//printf("Blob UP %i \n", b.id);
	
	if(bCalibration)
	downColor = 0xFF0000;

	if(calibrate.bCalibrating && contourFinder.nBlobs == 0)//If Calibrating, register the calibration point on blobOff
	{	
		calibrate.cameraPoints[calibrate.calibrationStep] = vector2df(b.centroid.x, b.centroid.y);
		calibrate.nextCalibrationStep();
		
		printf("%d (%f, %f)\n", calibrate.calibrationStep, b.centroid.x, b.centroid.y);
	}

	if(bTUIOMode)//If sending TUIO and blob is not outside calibration mesh, Delete Blobs from map list
	{
		std::map<int, ofxCvBlob>::iterator iter;
		for(iter = myTUIO.blobs.begin(); iter != myTUIO.blobs.end(); iter++)
		{
			if(iter->second.id == b.id)
			{
				myTUIO.blobs.erase(iter);

				break;
			}
		}
	}
}
//! Initialisation des coordonnées des points de calibration à afficher
void CalibrationUtils::initScreenPoints()
{
    int i,j;
    //Angle entre deux axes (en radian)
    float delta_degree = 2*PI/(GRID_X+1);
    //Distance entre deux cercles
    float delta_rayon = min(screenBB.lowerRightCorner.X-screenBB.upperLeftCorner.X,screenBB.lowerRightCorner.Y-screenBB.upperLeftCorner.Y)/2/(GRID_Y+1);
    //Point au centre du cercle
    vector2df center = screenBB.upperLeftCorner + screenBB.lowerRightCorner/2;
	//Degre et rayon du point à afficher
    float degree=0, rayon=delta_rayon;
    int nb_points = GRID_X;
    float dist = (2*PI*delta_rayon)/GRID_X;
    float conv = ((float)ofGetScreenWidth())/ofGetScreenHeight();

    screenPoints->clear();
	screenPoints->push_back(calibrationPoint(center,0));
	for(j=1; j <= GRID_Y+1; j++) //Pour chaque cercle
    {
        delta_degree = 2*PI/nb_points;
        if (j%2 == 0) degree = 0;
        else degree = delta_degree/2;
        for(i=0; i < nb_points; i++) //Pour chaque points sur le cercle
        {
			screenPoints->push_back(calibrationPoint(center + vector2df(rayon*cos(degree)/conv,rayon*sin(degree)), j)); //Note : /1.25
			degree += delta_degree;
        }
        rayon += delta_rayon;
        nb_points += GRID_X; //(int)((2*PI*rayon)/dist)+1;
	}
}
//! Initialisation des points à lire
void CalibrationUtils::initCameraPoints(int camWidth, int camHeight)
{
	int i,j, p = 0;
    //Angle entre deux axes (en radian)
    float delta_degree = 2*PI/(GRID_X+1);
    //Distance entre deux cercles
    float delta_rayon = min(screenBB.lowerRightCorner.X-screenBB.upperLeftCorner.X,screenBB.lowerRightCorner.Y-screenBB.upperLeftCorner.Y)/2/(GRID_Y+1);
    //Point au centre du cercle
    vector2df center = screenBB.upperLeftCorner + screenBB.lowerRightCorner/2;
	//Degre et rayon du point à afficher
    float degree=0, rayon=delta_rayon;
    int nb_points = GRID_X;
    float dist = (2*PI*delta_rayon)/GRID_X;
    float conv = ((float)ofGetScreenWidth())/ofGetScreenHeight();

	cameraPoints[p] = calibrationPoint(center,0);
	p++;
	for(j=0; j<=GRID_Y; j++) //Pour chaque cercle
    {
        delta_degree = 2*PI/nb_points;
        if (j%2 == 0) degree = 0;
        else degree = delta_degree/2;
        for(i=0; i < nb_points; i++) //Pour chaque points sur le cercle
        {
			cameraPoints[p] = calibrationPoint(center + vector2df(rayon*cos(degree)/conv,rayon*sin(degree)), j+1); //Note : /1.25
			p++;
			degree += delta_degree;
        }
        rayon += GRID_X;
	}
}
//! Convertion des valeurs de lecture d'un point théorique en valeur réelle
void CalibrationUtils::cameraToScreenSpace(float &x, float &y)
{
	vector2df pt = vector2df(x, y);
	triangle* t;
    float alpha, beta;

    //Si le point est dans la zone de calibration
	if (inCalibrationSector(x, y))
	{
        //Recherche du triangle contenant le point (ou les trois points les plus proche selon les cas)
	    t = findTriangleWithin(pt);
        //
        if ((t->s1->coord != pt) && (t->s2->coord != pt) && (t->s3->coord != pt))
        {
            //beta  = .....
            beta = ( ( t->s3->_y() - pt.Y ) * ( t->s1->_x() - pt.X ) + ( pt.X - t->s3->_x() ) * ( t->s1->_y() - pt.Y ) )
                   / ( ( t->s2->_x() - pt.X ) * ( t->s1->_y() - pt.Y) + ( pt.Y - t->s2->_y() ) * ( t->s1->_x() - pt.X ) );

            //alpha = .....
            alpha = ( beta * ( pt.X - t->s2->_x() ) + ( pt.X - t->s3->_x()) )
                    / ( t->s1->_x() - pt.X );

            //pt    = (alpha*A + beta*B + C)/(alpha+beta+1)
            x = ( alpha * t->s1->_x() + beta * t->s2->_x() + t->s3->_x() ) / ( alpha + beta + 1 );
            y = ( alpha * t->s1->_y() + beta * t->s2->_y() + t->s3->_y() ) / ( alpha + beta + 1 );
        }
	}
}
示例#5
0
// ----------------------------------------------------------------------------
Terrain::Terrain(ISceneNode* parent, ISceneManager* mgr, s32 id,
                 float x, float z, u32 nx, u32 nz)
    :ISceneNode(parent, mgr, id), m_nx(nx), m_nz(nz)
{

    m_valid        = true;
    m_visible      = true;
    m_bounding_box = aabbox3d<f32>(0, 0, 0, x, 0, z);

    setAutomaticCulling(EAC_OFF);

    m_tile_num_x = 10;
    m_tile_num_z = 10;

    m_mesh.vertex_count = nx * nz;
    m_mesh.vertices = new S3DVertex2TCoords[m_mesh.vertex_count];

    m_mesh.quad_count = (nx - 1) * (nz - 1);
    m_mesh.indices = new u16[m_mesh.quad_count * 6];

    for (u32 j = 0; j < nz; j++)
    for (u32 i = 0; i < nx; i++)
    {
        m_mesh.vertices[j * nx + i].Pos = vector3df(x / nx * i, 0, z / nz *j);
        m_mesh.vertices[j * nx + i].Color = SColor(255, 255, 255, 255);
        m_mesh.vertices[j * nx + i].TCoords  =
            vector2df(i / (float)nx * m_tile_num_x, j / (float)nz * m_tile_num_z);
        m_mesh.vertices[j * nx + i].TCoords2 = vector2df(i / (float)nx, j / (float)nz);
    }

    createIndexList(m_mesh.indices, nx, nz);

    m_x = x;
    m_z = z;

    recalculateNormals();

    m_highlight_mesh.vertices = 0;
    m_highlight_mesh.indices = 0;

    initMaterials();

    m_highlight_visible = false;

} // Terrain
void Calibration::RAWTouchHeld( Blob b) {

	if(calibrate.bCalibrating)//If Calibrating, register the calibration point on blobOff
	{
		calibrate.cameraPoints[calibrate.calibrationStep] = vector2df(b.centroid.x, b.centroid.y);
		calibrate.bGoToNextStep = true;
		targetColor = 0xFFFFFF;
	}
}
示例#7
0
void CGUIImage::setPosition(vector2df position)
{
    const core::dimension2d<u32>& imageSize = Texture->getOriginalSize();
    vector2df offset = vector2df(imageSize.Width, imageSize.Height);

    Image->setRelativePosition(core::rect<s32>(
                                   position.X - (offset.X * Scale.X),
                                   position.Y - (offset.Y * Scale.Y),
                                   position.X + (offset.X * Scale.X),
                                   position.Y + (offset.Y * Scale.Y)));
}
示例#8
0
CGUIImage::CGUIImage(IrrlichtDevice *device)
{
    Device = device;
    Video = Device->getVideoDriver();
    Gui = Device->getGUIEnvironment();
    Scale = vector2df(1,1); //In images 1,1 is the actual scale

    //Add our button
    Image = Gui->addImage(0,  core::position2d<s32>(0,0));
    Image->setScaleImage(true);

}
void CalibrationUtils::initCameraPoints(int camWidth, int camHeight)
{
	int p = 0;
	for(int j = 0; j <= GRID_Y; j++)
	{
		for(int i = 0; i <= GRID_X; i++)
		{
			cameraPoints[p] = vector2df((i * camWidth) / (float)GRID_X, (j * camHeight) / (float)GRID_Y);
			p++;
		}
	}
}
//! Convertion des valeurs d'affichage théorique en valeur réelle de tout les points
void CalibrationUtils::computeCameraToScreenMap()
{
	cameraToScreenMap = new vector2df[_camWidth * _camHeight];

	int p = 0;
	for(int y = 0; y < _camHeight; y++)
	{
		for(int x = 0; x < _camWidth; x++)
		{
			//On cast les valeurs en réel
			float transformedX = (float)x;
			float transformedY = (float)y;

			//Convertion de la valeur théorique de tout les points, en valeur réelle
			cameraToScreenSpace(transformedX, transformedY);
			cameraToScreenMap[p] = vector2df(transformedX, transformedY);
			p++;
		}
	}
}
示例#11
0
//Compute a map of camera to screen coordinates
void CalibrationUtils::computeCameraToScreenMap()
{
	cameraToScreenMap = new vector2df[_camWidth * _camHeight];

	int p = 0;
	for(int y = 0; y < _camHeight; y++)
	{
		for(int x = 0; x < _camWidth; x++)
		{
			//cast to float
			float transformedX = (float)x;
			float transformedY = (float)y;

			//convert camera to screenspace for all possible camera positions
			cameraToScreenSpace(transformedX, transformedY);
			//save these into a map of transformed camera to screenspace positions
			cameraToScreenMap[p] = vector2df(transformedX, transformedY);
			p++;
		}
	}
}
示例#12
0
/**  Always set m_fp before calling this function!!!
 *   callOnVertices will use data from tmod to find the vertices described by
 *   tmod.ray and tmod.radius, and call m_fp on them.
 *  \param tmod data about the modification
 *  \param call_outside true means that m_fp will be called on non-exsisting
    vertices as well. tmod.in_terrain flag will distinguish them
 *  \param call_in_square true means that m_fp is called if the distance is < r
 *  along (x || z) axis
 */
void Terrain::callOnVertices(TerrainMod* tmod, bool call_outside,
    bool call_in_square)
{
    s32 ix, iz, dx, dz;
    vector2df cpos;

    if (!intersectionPoint(tmod->ray, tmod->radius, &cpos, &ix, &iz))
        return;

    dx = (s32)(tmod->radius / (m_x / m_nx) + 1);
    dz = (s32)(tmod->radius / (m_z / m_nz) + 1);

    tmod->index = 0;
    for (s32 j = -dz; j <= dz; j++)
    for (s32 i = -dx; i <= dx; i++)
    {
        tmod->in_terrain = true;
        // check if the point is outside of the terrain
        if (ix + i < 1 || ix + i >(s32)m_nx - 2 || iz + j < 1 || iz + j >(s32)m_nz - 2)
            tmod->in_terrain = false;

        if (call_outside && !tmod->in_terrain) (*this.*m_fp_h)(*tmod, ix, iz, i, j);
        else if (tmod->in_terrain)
        {
            S3DVertex2TCoords vert = m_mesh.vertices[(iz + j) * m_nx + ix + i];
            vector2df pos;
            pos = vector2df(vert.Pos.X, vert.Pos.Z);

            // check if the point is in radius
            tmod->dist = tmod->radius - (cpos - pos).getLength();

            if (tmod->dist > 0 || call_in_square)
            {
                (*this.*m_fp_h)(*tmod, ix, iz, i, j);
            }
        }
        tmod->index += 1;
    } // for loop - square
} // callOnVertices
示例#13
0
void TheBeginMove::animateNode( ISceneNode* node, u32 timeMs )
{
	ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
	//初始化
	if ( IsFirst )
	{
		IsFirst = false;
		Begin = timeMs + Delay;
		vector3df dir3 = camera->getTarget() - camera->getPosition();
		vector2df direction = vector2df( dir3.X, dir3.Z );
		lastRad = (f32)direction.getAngle() - 90;
		lastRad *= DEGTORAD;
		camera ->setTarget(TheEndPoint + dir3 );
		/*std::cout<< direction.X << " , " << direction.Y << std::endl;
		std::cout<< lastRad << std::endl;*/
	}
	//还未达到动画开始时间
	if( Begin > timeMs )
		return;

	u32 t;
	t = timeMs - Begin;	
	
	//到达动画结束时间
	if ( t > Duration )
	{
		//把自己删掉
		camera->removeAnimator(this);
		return;
	}
	camera -> setPosition( vector3df
		( Center.X + (Distance - M_Distance * t) * sin( radian * t + lastRad ) , 
		Center.Y + M_y * t , 
		Center.Z + (Distance - M_Distance * t)  * cos( radian * t + lastRad ) ));	
	camera ->setTarget(TheEndPoint);
}
示例#14
0
 Player(){
     pos = vector2df(0,-16);
     vel = vector2df();
     noclip = false;
     brush = BRUSH_CIRCLE;
 }
示例#15
0
vector2df CGUIImage::getRelativePosition()
{
    const core::rect<s32>& rectangle = Image->getRelativePosition();
    return vector2df(rectangle.UpperLeftCorner.X, rectangle.UpperLeftCorner.Y);
}
示例#16
0
void Game::DrawMisc() {
	static irr::core::vector3df act_rot(0, 0, 0);
	irr::core::matrix4 im, ic, it;
	act_rot.Z += 0.02f;
	im.setRotationRadians(act_rot);
	matManager.mTexture.setTexture(0, imageManager.tAct);
	driver->setMaterial(matManager.mTexture);
	if(dField.deck_act) {
		im.setTranslation(vector3df(matManager.vFields[0].Pos.X - (matManager.vFields[0].Pos.X - matManager.vFields[1].Pos.X)/2,
			matManager.vFields[0].Pos.Y - (matManager.vFields[0].Pos.Y - matManager.vFields[3].Pos.Y)/2, dField.deck[0].size() * 0.01f + 0.02f));
		driver->setTransform(irr::video::ETS_WORLD, im);
		driver->drawVertexPrimitiveList(matManager.vActivate, 4, matManager.iRectangle, 2);
	}
	if(dField.grave_act) {
		im.setTranslation(vector3df(matManager.vFields[4].Pos.X - (matManager.vFields[4].Pos.X - matManager.vFields[5].Pos.X)/2,
			matManager.vFields[4].Pos.Y - (matManager.vFields[4].Pos.Y - matManager.vFields[6].Pos.Y)/2, dField.grave[0].size() * 0.01f + 0.02f));
		driver->setTransform(irr::video::ETS_WORLD, im);
		driver->drawVertexPrimitiveList(matManager.vActivate, 4, matManager.iRectangle, 2);
	}
	if(dField.remove_act) {
		im.setTranslation(vector3df(matManager.vFields[12].Pos.X - (matManager.vFields[12].Pos.X - matManager.vFields[13].Pos.X)/2,
			matManager.vFields[12].Pos.Y - (matManager.vFields[12].Pos.Y - matManager.vFields[14].Pos.Y)/2, dField.remove[0].size() * 0.01f + 0.02f));
		driver->setTransform(irr::video::ETS_WORLD, im);
		driver->drawVertexPrimitiveList(matManager.vActivate, 4, matManager.iRectangle, 2);
	}
	if(dField.extra_act) {
		im.setTranslation(vector3df(matManager.vFields[8].Pos.X - (matManager.vFields[8].Pos.X - matManager.vFields[9].Pos.X)/2,
			matManager.vFields[8].Pos.Y - (matManager.vFields[8].Pos.Y - matManager.vFields[10].Pos.Y)/2, dField.extra[0].size() * 0.01f + 0.02f));
		driver->setTransform(irr::video::ETS_WORLD, im);
		driver->drawVertexPrimitiveList(matManager.vActivate, 4, matManager.iRectangle, 2);
	}
	if(dField.pzone_act) {
		im.setTranslation(vector3df(matManager.vFields[60].Pos.X - (matManager.vFields[60].Pos.X - matManager.vFields[61].Pos.X)/2,
			matManager.vFields[60].Pos.Y - (matManager.vFields[60].Pos.Y - matManager.vFields[62].Pos.Y)/2, 0.03f));
		driver->setTransform(irr::video::ETS_WORLD, im);
		driver->drawVertexPrimitiveList(matManager.vActivate, 4, matManager.iRectangle, 2);
	}
	if(dField.chains.size() > 1) {
		for(size_t i = 0; i < dField.chains.size(); ++i) {
			if(dField.chains[i].solved)
				break;
			matManager.mTRTexture.setTexture(0, imageManager.tChain);
			matManager.mTRTexture.AmbientColor = 0xffffff00;
			ic.setRotationRadians(act_rot);
			ic.setTranslation(dField.chains[i].chain_pos);
			driver->setMaterial(matManager.mTRTexture);
			driver->setTransform(irr::video::ETS_WORLD, ic);
			driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
			it.setScale(0.6f);
			it.setTranslation(dField.chains[i].chain_pos);
			matManager.mTRTexture.setTexture(0, imageManager.tNumber);
			matManager.vChainNum[0].TCoords = vector2df(0.19375f * (i % 5), 0.2421875f * (i / 5));
			matManager.vChainNum[1].TCoords = vector2df(0.19375f * (i % 5 + 1), 0.2421875f * (i / 5));
			matManager.vChainNum[2].TCoords = vector2df(0.19375f * (i % 5), 0.2421875f * (i / 5 + 1));
			matManager.vChainNum[3].TCoords = vector2df(0.19375f * (i % 5 + 1), 0.2421875f * (i / 5 + 1));
			driver->setMaterial(matManager.mTRTexture);
			driver->setTransform(irr::video::ETS_WORLD, it);
			driver->drawVertexPrimitiveList(matManager.vChainNum, 4, matManager.iRectangle, 2);
		}
	}
	//lp bar
	if((dInfo.turn % 2 && dInfo.isFirst) || (!(dInfo.turn % 2) && !dInfo.isFirst)) {
		driver->draw2DRectangle(0xa0000000, recti(327, 8, 630, 51));
		driver->draw2DRectangleOutline(recti(327, 8, 630, 51), 0xffff8080);
	} else {
		driver->draw2DRectangle(0xa0000000, recti(689, 8, 991, 51));
		driver->draw2DRectangleOutline(recti(689, 8, 991, 51), 0xffff8080);
	}
	driver->draw2DImage(imageManager.tLPFrame, recti(330, 10, 629, 30), recti(0, 0, 200, 20), 0, 0, true);
	driver->draw2DImage(imageManager.tLPFrame, recti(691, 10, 990, 30), recti(0, 0, 200, 20), 0, 0, true);
	if(dInfo.lp[0] >= 8000)
		driver->draw2DImage(imageManager.tLPBar, recti(335, 12, 625, 28), recti(0, 0, 16, 16), 0, 0, true);
	else driver->draw2DImage(imageManager.tLPBar, recti(335, 12, 335 + 290 * dInfo.lp[0] / 8000, 28), recti(0, 0, 16, 16), 0, 0, true);
	if(dInfo.lp[1] >= 8000)
		driver->draw2DImage(imageManager.tLPBar, recti(696, 12, 986, 28), recti(0, 0, 16, 16), 0, 0, true);
	else driver->draw2DImage(imageManager.tLPBar, recti(986 - 290 * dInfo.lp[1] / 8000, 12, 986, 28), recti(0, 0, 16, 16), 0, 0, true);
	if(lpframe) {
		dInfo.lp[lpplayer] -= lpd;
		myswprintf(dInfo.strLP[lpplayer], L"%d", dInfo.lp[lpplayer]);
		lpccolor -= 0x19000000;
		lpframe--;
	}
	if(lpcstring) {
		if(lpplayer == 0) {
			lpcFont->draw(lpcstring, recti(400, 470, 920, 520), lpccolor | 0x00ffffff, true, false, 0);
			lpcFont->draw(lpcstring, recti(400, 472, 922, 520), lpccolor, true, false, 0);
		} else {
			lpcFont->draw(lpcstring, recti(400, 160, 920, 210), lpccolor | 0x00ffffff, true, false, 0);
			lpcFont->draw(lpcstring, recti(400, 162, 922, 210), lpccolor, true, false, 0);
		}
	}
	if(!dInfo.isReplay && dInfo.player_type < 7 && dInfo.time_limit) {
		driver->draw2DRectangle(recti(525, 34, 525 + dInfo.time_left[0] * 100 / dInfo.time_limit, 44), 0xa0e0e0e0, 0xa0e0e0e0, 0xa0c0c0c0, 0xa0c0c0c0);
		driver->draw2DRectangleOutline(recti(525, 34, 625, 44), 0xffffffff);
		driver->draw2DRectangle(recti(795 - dInfo.time_left[1] * 100 / dInfo.time_limit, 34, 795, 44), 0xa0e0e0e0, 0xa0e0e0e0, 0xa0c0c0c0, 0xa0c0c0c0);
		driver->draw2DRectangleOutline(recti(695, 34, 795, 44), 0xffffffff);
	}
	numFont->draw(dInfo.strLP[0], recti(330, 11, 629, 30), 0xff000000, true, false, 0);
	numFont->draw(dInfo.strLP[0], recti(330, 12, 631, 30), 0xffffff00, true, false, 0);
	numFont->draw(dInfo.strLP[1], recti(691, 11, 990, 30), 0xff000000, true, false, 0);
	numFont->draw(dInfo.strLP[1], recti(691, 12, 992, 30), 0xffffff00, true, false, 0);

	if(!dInfo.isTag || !dInfo.tag_player[0])
		textFont->draw(dInfo.hostname, recti(335, 31, 629, 50), 0xffffffff, false, false, 0);
	else
		textFont->draw(dInfo.hostname_tag, recti(335, 31, 629, 50), 0xffffffff, false, false, 0);
	if(!dInfo.isTag || !dInfo.tag_player[1]) {
		auto cld = textFont->getDimension(dInfo.clientname);
		textFont->draw(dInfo.clientname, recti(986 - cld.Width, 31, 986, 50), 0xffffffff, false, false, 0);
	} else {
		auto cld = textFont->getDimension(dInfo.clientname_tag);
		textFont->draw(dInfo.clientname_tag, recti(986 - cld.Width, 31, 986, 50), 0xffffffff, false, false, 0);
	}
	driver->draw2DRectangle(recti(632, 10, 688, 30), 0x00000000, 0x00000000, 0xffffffff, 0xffffffff);
	driver->draw2DRectangle(recti(632, 30, 688, 50), 0xffffffff, 0xffffffff, 0x00000000, 0x00000000);
	lpcFont->draw(dataManager.GetNumString(dInfo.turn), recti(635, 5, 685, 40), 0x80000000, true, false, 0);
	lpcFont->draw(dataManager.GetNumString(dInfo.turn), recti(635, 5, 687, 40), 0x8000ffff, true, false, 0);
	ClientCard* pcard;
	for(int i = 0; i < 5; ++i) {
		pcard = dField.mzone[0][i];
		if(pcard && pcard->code != 0) {
			int m = 493 + i * 85;
			adFont->draw(L"/", recti(m - 4, 416, m + 4, 436), 0xff000000, true, false, 0);
			adFont->draw(L"/", recti(m - 3, 417, m + 5, 437), 0xffffffff, true, false, 0);
			int w = adFont->getDimension(pcard->atkstring).Width;
			adFont->draw(pcard->atkstring, recti(m - 5 - w, 416, m - 5, 436), 0xff000000, false, false, 0);
			adFont->draw(pcard->atkstring, recti(m - 4 - w, 417, m - 4, 437),
			             pcard->attack > pcard->base_attack ? 0xffffff00 : pcard->attack < pcard->base_attack ? 0xffff2090 : 0xffffffff , false, false, 0);
			w = adFont->getDimension(pcard->defstring).Width;
			adFont->draw(pcard->defstring, recti(m + 4, 416, m + 4 + w, 436), 0xff000000, false, false, 0);
			adFont->draw(pcard->defstring, recti(m + 5, 417, m + 5 + w, 437),
			             pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0);
			adFont->draw(pcard->lvstring, recti(473 + i * 80, 356, 475 + i * 80, 366), 0xff000000, false, false, 0);
			adFont->draw(pcard->lvstring, recti(474 + i * 80, 357, 476 + i * 80, 367),
			             (pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0);
		}
	}
	for(int i = 0; i < 5; ++i) {
		pcard = dField.mzone[1][i];
		if(pcard && (pcard->position & POS_FACEUP)) {
			int m = 803 - i * 68;
			adFont->draw(L"/", recti(m - 4, 235, m + 4, 255), 0xff000000, true, false, 0);
			adFont->draw(L"/", recti(m - 3, 236, m + 5, 256), 0xffffffff, true, false, 0);
			int w = adFont->getDimension(pcard->atkstring).Width;
			adFont->draw(pcard->atkstring, recti(m - 5 - w, 235, m - 5, 255), 0xff000000, false, false, 0);
			adFont->draw(pcard->atkstring, recti(m - 4 - w, 236, m - 4, 256),
			             pcard->attack > pcard->base_attack ? 0xffffff00 : pcard->attack < pcard->base_attack ? 0xffff2090 : 0xffffffff , false, false, 0);
			w = adFont->getDimension(pcard->defstring).Width;
			adFont->draw(pcard->defstring, recti(m + 4, 235, m + 4 + w, 255), 0xff000000, false, false, 0);
			adFont->draw(pcard->defstring, recti(m + 5, 236, m + 5 + w, 256),
			             pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0);
			adFont->draw(pcard->lvstring, recti(779 - i * 71, 272, 800 - i * 71, 292), 0xff000000, false, false, 0);
			adFont->draw(pcard->lvstring, recti(780 - i * 71, 273, 800 - i * 71, 293),
			             (pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0);
		}
	}
	pcard = dField.szone[0][6];
	if(pcard) {
		adFont->draw(pcard->lscstring, recti(426, 394, 438, 414), 0xff000000, true, false, 0);
		adFont->draw(pcard->lscstring, recti(427, 395, 439, 415), 0xffffffff, true, false, 0);
	}
	pcard = dField.szone[0][7];
	if(pcard) {
		adFont->draw(pcard->rscstring, recti(880, 394, 912, 414), 0xff000000, true, false, 0);
		adFont->draw(pcard->rscstring, recti(881, 395, 913, 415), 0xffffffff, true, false, 0);
	}
	pcard = dField.szone[1][6];
	if(pcard) {
		adFont->draw(pcard->lscstring, recti(839, 245, 871, 265), 0xff000000, true, false, 0);
		adFont->draw(pcard->lscstring, recti(840, 246, 872, 266), 0xffffffff, true, false, 0);
	}
	pcard = dField.szone[1][7];
	if(pcard) {
		adFont->draw(pcard->rscstring, recti(463, 245, 495, 265), 0xff000000, true, false, 0);
		adFont->draw(pcard->rscstring, recti(464, 246, 496, 266), 0xffffffff, true, false, 0);
	}
	if(dField.extra[0].size()) {
		numFont->draw(dataManager.GetNumString(dField.extra[0].size()), recti(330, 562, 381, 552), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.extra[0].size()), recti(330, 563, 383, 553), 0xffffff00, true, false, 0);
	}
	if(dField.deck[0].size()) {
		numFont->draw(dataManager.GetNumString(dField.deck[0].size()), recti(907, 562, 1021, 552), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.deck[0].size()), recti(908, 563, 1023, 553), 0xffffff00, true, false, 0);
	}
	if(dField.grave[0].size()) {
		numFont->draw(dataManager.GetNumString(dField.grave[0].size()), recti(837, 375, 984, 456), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.grave[0].size()), recti(837, 376, 986, 457), 0xffffff00, true, false, 0);
	}
	if(dField.remove[0].size()) {
		numFont->draw(dataManager.GetNumString(dField.remove[0].size()), recti(1015, 375, 957, 380), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.remove[0].size()), recti(1015, 376, 959, 381), 0xffffff00, true, false, 0);
	}
	if(dField.extra[1].size()) {
		numFont->draw(dataManager.GetNumString(dField.extra[1].size()), recti(818, 207, 908, 232), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.extra[1].size()), recti(818, 208, 910, 233), 0xffffff00, true, false, 0);
	}
	if(dField.deck[1].size()) {
		numFont->draw(dataManager.GetNumString(dField.deck[1].size()), recti(465, 207, 481, 232), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.deck[1].size()), recti(465, 208, 483, 233), 0xffffff00, true, false, 0);
	}
	if(dField.grave[1].size()) {
		numFont->draw(dataManager.GetNumString(dField.grave[1].size()), recti(420, 310, 462, 281), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.grave[1].size()), recti(420, 311, 464, 282), 0xffffff00, true, false, 0);
	}
	if(dField.remove[1].size()) {
		numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(300, 310, 443, 340), 0xff000000, true, false, 0);
		numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(300, 311, 445, 341), 0xffffff00, true, false, 0);
	}
}
//! Chargement des paramètres de calibration depuis le fichier "config.xml"
void CalibrationUtils::loadXMLSettings(){

	bGoToNextStep = false;

	// Can this load via http?
	if( calibrationXML.loadFile("calibration.xml")){
		//WOOT!
		message = "Calibration Loaded!";
	}else{
		//FAIL!
		message = "No calibration Found...";
		// GENERATE DEFAULT XML DATA WHICH WILL BE SAVED INTO THE CONFIG
	}

	bool bboxRoot = true;
	bool screenRoot = true;

	bCalibrating = false;
	calibrationStep = 0;

	//Set grid and init everything that relates to teh grid
	GRID_X		= calibrationXML.getValue("SCREEN:GRIDMESH:GRIDX", 50);
	GRID_Y		= calibrationXML.getValue("SCREEN:GRIDMESH:GRIDY", 50);

    //setGrid(GRID_X, GRID_Y);
    setGrid(GRID_X, GRID_Y);

	//Bounding Box Points
	if(bboxRoot){
	    vector2df ul(calibrationXML.getValue("SCREEN:BOUNDINGBOX:ulx", 0.000000),calibrationXML.getValue("SCREEN:BOUNDINGBOX:uly", 0.000000));
	    vector2df lr(calibrationXML.getValue("SCREEN:BOUNDINGBOX:lrx", 1.000000),calibrationXML.getValue("SCREEN:BOUNDINGBOX:lry", 1.000000));
		rect2df boundingbox(ul, lr);
		setScreenBBox(boundingbox);
	}else{
		setScreenScale(1.0f);
	}



	//Calibration Points
	if(screenRoot)
	{
		//lets see how many <STROKE> </STROKE> tags there are in the xml file
		int numDragTags = calibrationXML.getNumTags("SCREEN:POINT");

			//if there is at least one <POINT> tag we can read the list of points
			if(numDragTags > 0){

				//we push into the last POINT tag this temporarirly treats the tag as the document root.
				calibrationXML.pushTag("SCREEN:POINT", numDragTags-1);

				//we see how many points we have stored in <POINT> tags
				int numPtTags = calibrationXML.getNumTags("POINT");

			if(numPtTags > 0){

				//We then read those x y values into our array
				for(int i = 0; i < numPtTags; i++){

					//the last argument of getValue can be used to specify
					//which tag out of multiple tags you are refering to.
					int x = calibrationXML.getValue("POINT:X", 0.000000, i);
					int y = calibrationXML.getValue("POINT:Y", 0.000000, i);

					cameraPoints[i].coord = vector2df(x,y);
					printf("Calibration: %f, %f\n", cameraPoints[i].coord.X, cameraPoints[i].coord.Y);

					bscreenPoints = true;
					bcameraPoints = true;
				}
			}
			calibrationXML.popTag(); //Set XML root back to highest level
		}
	}
	//End calibrationXML Calibration Settings

	//Set the camera calibated box.
	calculateBox();
	computeCameraToScreenMap();
}
//! Accesseur (écriture) vers l'échelle de la zone d'affichage
void CalibrationUtils::setScreenScale(float s)
{
	float offset = (1.0f - s)*0.5f;
	screenBB = rect2df(vector2df(offset,offset),vector2df(1.0f-offset,1.0f-offset));
	initScreenPoints();
}
示例#19
0
void Player::tick(World* world){
    if (this->noclip){
        this->vel=vector2df();
        if (KD(KM_UP))    this->pos+=vector2df(0,-NOCLIP_SPEED);
        if (KD(KM_DOWN))  this->pos+=vector2df(0, NOCLIP_SPEED);
        if (KD(KM_LEFT))  this->pos+=vector2df(-NOCLIP_SPEED,0);
        if (KD(KM_RIGHT)) this->pos+=vector2df(NOCLIP_SPEED, 0);
    }else{
        bool ongr = BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-3,8))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-2,8))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-1,8))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(0, 8))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(1, 8))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(2, 8))).solid;
        
        bool lsol = BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5,-7))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5,-6))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5,-5))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5,-4))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5,-3))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5,-2))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5,-1))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 0))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 1))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 2))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 3))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 4))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 5))).solid;
        
        bool rsol = BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4,-7))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4,-6))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4,-5))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4,-4))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4,-3))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4,-2))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4,-1))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4, 0))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4, 1))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4, 2))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4, 3))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4, 4))).solid ||
                    BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(4, 5))).solid;
                    
        
        if (ongr) this->vel.X/=FRICTION;
        
        if (ongr && this->vel.Y > 0) this->vel.Y = 0;
        if (!ongr) this->vel.Y += world->gravity;
        
        if (ongr && KD(KM_LEFT) && ! lsol) {
            this->vel.X = -WALK_SPEED;
            if (BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 7))).solid){
                this->pos.Y-=1;
                if (BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(-5, 7))).solid) this->pos.Y-=1;
            }
        }
        if (ongr && KD(KM_RIGHT) && ! rsol) {
            this->vel.X = WALK_SPEED;
            if (BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(5, 7))).solid){
                this->pos.Y-=1;
                if (BLOCK(world->getBlockAt(this->getIPos()+vector2d<s32>(5, 7))).solid) this->pos.Y-=1;
            }
        }
        if (ongr && KD(KM_JUMP)) this->vel.Y = -JUMP_POWER;
        
        if (lsol && this->vel.X < 0) this->vel.X = 0;
        if (rsol && this->vel.X > 0) this->vel.X = 0;
    }
    this->pos+=this->vel;
    
    vector2d<s32> cp = this->getIPos() + ((mpos - position2d<s32>(500,333)) / 4);
    stack<vector2d<s32>> pss;
    switch (this->brush) {
        case BRUSH_PX:
            pss.emplace();
        break;
        
        case BRUSH_CIRCLE:
            for (s32 i = -4; i < 4; i++) for (s32 j = -4; j < 4; j++) if (i*i+j*j<17) pss.emplace(i,j);
        break;
    }
    
    while(!pss.empty()){
        if (EVTRR->LB && world->getBlockAt(pss.top()+cp) != BLOCK_AIR) world->setBlockAt(pss.top()+cp,BLOCK_AIR);
        pss.pop();
    }
}
示例#20
0
void Materials::GenArrow(float y) {
	float ay = 1.0f;
	for (int i = 0; i < 19; ++i) {
		vArrow[i * 2] = S3DVertex(vector3df(0.1f, ay * y, -2.0f * (ay * ay - 1.0f)), vector3df(0, ay * y, 1), 0xc000ff00, vector2df(0, 0));
		vArrow[i * 2 + 1] = S3DVertex(vector3df(-0.1f, ay * y, -2.0f * (ay * ay - 1.0f)), vector3df(0, ay * y, 1), 0xc000ff00, vector2df(0, 0));
		ay -= 0.1f;
	}
	vArrow[36].Pos.X = 0.2f;
	vArrow[36].Pos.Y = vArrow[34].Pos.Y - 0.01f;
	vArrow[36].Pos.Z = vArrow[34].Pos.Z - 0.01f;
	vArrow[37].Pos.X = -0.2f;
	vArrow[37].Pos.Y = vArrow[35].Pos.Y - 0.01f;
	vArrow[37].Pos.Z = vArrow[35].Pos.Z - 0.01f;
	vArrow[38] = S3DVertex(vector3df(0.0f, -1.0f * y, 0.0f), vector3df(0.0f, -1.0f, -1.0f), 0xc0ffffff, vector2df(0, 0));
	vArrow[39] = vArrow[38];
}
示例#21
0
// ----------------------------------------------------------------------------
Terrain::Terrain(ISceneNode* parent, ISceneManager* mgr, s32 id, FILE* fp)
                                              :ISceneNode(parent, mgr, id)
{
    m_visible = true;
    m_valid   = true;
    setAutomaticCulling(EAC_OFF);

    fread(&m_x, sizeof(f32), 1, fp);
    fread(&m_z, sizeof(f32), 1, fp);

    if (m_x < 1 || m_z < 1 || m_x > 500 || m_z > 500)
    {
        m_valid = false;
        return;
    }

    fread(&m_nx, sizeof(u32), 1, fp);
    fread(&m_nz, sizeof(u32), 1, fp);

    if (m_nx > 400 || m_nz > 400)
    {
        m_valid = false;
        return;
    }

    m_bounding_box = aabbox3d<f32>(0, 0, 0, m_x, 0, m_z);

    m_tile_num_x = 10;
    m_tile_num_z = 10;

    m_mesh.vertex_count = m_nx * m_nz;
    m_mesh.vertices = new S3DVertex2TCoords[m_mesh.vertex_count];

    m_mesh.quad_count = (m_nx - 1) * (m_nz - 1);
    m_mesh.indices = new u16[m_mesh.quad_count * 6];

    for (u32 j = 0; j < m_nz; j++)
    for (u32 i = 0; i < m_nx; i++)
    {
        m_mesh.vertices[j * m_nx + i].Pos =
            vector3df(m_x / m_nx * i, 0, m_z / m_nz *j);
        fread(&m_mesh.vertices[j * m_nx + i].Pos.Y, sizeof(f32), 1, fp);
        m_mesh.vertices[j * m_nx + i].Color = SColor(255, 255, 255, 255);

        m_mesh.vertices[j * m_nx + i].TCoords =
            vector2df(i / (float)m_nx * m_tile_num_x, j / (float)m_nz * m_tile_num_z);

        m_mesh.vertices[j * m_nx + i].TCoords2 =
            vector2df(i / (float)m_nx, j / (float)m_nz);
    }

    createIndexList(m_mesh.indices, m_nx, m_nz);

    recalculateNormals();

    m_highlight_mesh.vertices = 0;
    m_highlight_mesh.indices = 0;

    initMaterials();

    u32 x, y;
    fread(&x, sizeof(u32), 1, fp);
    fread(&y, sizeof(u32), 1, fp);

    if (x != SPIMG_X || y != SPIMG_Y)
    {
        std::cerr << "Warning: splatting image size incorrect!\n";
    }

    fread(m_material.getTexture(1)->lock(ETLM_WRITE_ONLY), sizeof(u8),
                                             4 * SPIMG_X*SPIMG_Y, fp);
    m_material.getTexture(1)->unlock();
    m_material.getTexture(1)->regenerateMipMapLevels();

    m_highlight_visible = false;

    ITexture* tex;
    Editor::readTexSt(fp, &tex); m_material.setTexture(2,tex);
    Editor::readTexSt(fp, &tex); m_material.setTexture(3, tex);
    Editor::readTexSt(fp, &tex); m_material.setTexture(4, tex);
    Editor::readTexSt(fp, &tex); m_material.setTexture(5, tex);
} // Terrain - fp