Пример #1
0
//-----------------------------------------------------------------------------
void HexMapTest::Render()
{
//	if (mouse_mode == MOUSE_MODE_CHECKING) 
	{
//		int32 px = IwGxGetScreenWidth() - s3ePointerGetX();
//		int32 py = IwGxGetScreenHeight() - s3ePointerGetY();
		int32 closestX = -1, closestY = -1;

		CIwVec3 vect = getWorldCoords(s3ePointerGetX(), s3ePointerGetY());
//		hexGrid->findClosestArray(origin, dir, closestX, closestY);
		//WORKING!!!
		hexGrid->findClosestSimple(vect.x, vect.y, closestX, closestY);
		DebugPrint(closestX, closestY);
	}
//		s_PickSurface->MakeCurrent();
    // Clear the screen
    IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
	// Set the model matrix
    IwGxSetModelMatrix(&s_ModelMatrix);
	hexGrid->render();


    // End drawing
    IwGxFlush();

	IwGxPrintSetScale(2);
	IwGxPrintFrameRate(0, 0); 
	// Swap buffers
	IwGxSwapBuffers();
}
Пример #2
0
void renderImageWorldSpace(CIwFVec2& position, float angle, float scaleFactor,
                        int textureSize, float worldRot, int frameNumber, int numFrames, float z) {
	
	static CIwSVec3 vertices[4];
	static CIwSVec2 UVs[4];
	
	//set up model space vertices
	
	int vertexDist = scaleFactor*textureSize/2;
	
	vertices[0] = CIwSVec3(-1*vertexDist, -1*vertexDist, z);
	vertices[2] = CIwSVec3(vertexDist, -1*vertexDist,    z);
	vertices[3] = CIwSVec3(vertexDist, vertexDist,       z);
	vertices[1] = CIwSVec3(-1*vertexDist, vertexDist,    z);
	
	CIwMat modelTransform = CIwMat::g_Identity;
	modelTransform.SetRotZ(IW_ANGLE_FROM_RADIANS(angle));
	modelTransform.SetTrans(CIwVec3(position.x, -position.y, 0));
	    
	CIwMat rot = CIwMat::g_Identity;
 	rot.SetRotZ(IW_ANGLE_FROM_RADIANS(worldRot));
	modelTransform = modelTransform*rot;
	
	IwGxSetModelMatrix(&modelTransform, false);
	
	float frameRatio = 1.0/numFrames;
	
	//set up sprite UV's
    
    iwfixed cf = IW_FIXED((float)frameNumber  / numFrames);
    iwfixed nf = IW_FIXED((frameNumber + 1.0) / numFrames);
    
	UVs[0] = CIwSVec2(cf, 0);
	UVs[2] = CIwSVec2(nf, 0);
	UVs[3] = CIwSVec2(nf, IW_GEOM_ONE);
	UVs[1] = CIwSVec2(cf, IW_GEOM_ONE);
		
	//render the unit in model space
	IwGxSetUVStream(UVs);
	
	IwGxSetZDepthFixed(8);	
	
	IwGxSetVertStreamModelSpace(vertices, 4);
	IwGxDrawPrims(IW_GX_QUAD_STRIP, NULL, 4);
	
    IwGxFlush();
}
Пример #3
0
void CzPlatformRender::SetModelMatrix(CzMatrix4* mat)
{
	CIwFMat m;
	m.SetIdentity();
	m.m[0][0] = mat->m[0][0];
	m.m[1][0] = mat->m[1][0];
	m.m[2][0] = mat->m[2][0];
	m.m[0][1] = mat->m[0][1];
	m.m[1][1] = mat->m[1][1];
	m.m[2][1] = mat->m[2][1];
	m.m[0][2] = mat->m[0][2];
	m.m[1][2] = mat->m[1][2];
	m.m[2][2] = mat->m[2][2];
	m.t.x = mat->m[0][3];
	m.t.y = mat->m[1][3];
	m.t.z = mat->m[2][3];

	IwGxSetModelMatrix(&m);
}
Пример #4
0
void renderGhost() {

	if (!getGameState()->getPlayer()->isReady()) {
		return;
	}

	IwGxLightingOff();

	Ghost *ghost = getGameState()->getGhost();

	CIwFVec3 ghostPosition(0, 0, ghost->getDistance());
	double ghostRotation = rad(ghost->getRotation());

    // Place the markers on the edge of the compass radius
    // rotated to their correct bearing to current location
	ghostMatrix->SetRotY(rad(ghost->getBearing()));
	ghostMatrix->SetTrans(ghostMatrix->RotateVec(ghostPosition));
	ghostMatrix->PostRotateY(ghostRotation);

    IwGxSetModelMatrix(ghostMatrix);

	if (ghost->pollAnimCaptured()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_CAPTURED], 1, 0, BLEND_DURATION);
	} else if (ghost->pollAnimAgro()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_AGRO], 1, 0, BLEND_DURATION);
	} else if (ghost->pollAnimDodge()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_DODGE], 1, 0, BLEND_DURATION);
	} else if (ghost->pollAnimAttack()) {
		ghost_Player->PlayAnim(ghost_Anims[GHOST_ANIM_ATTACK], 1, 0, BLEND_DURATION);
	}
	
	IwGxLightingAmbient(true);
	IwGxSetLightType(0, IW_GX_LIGHT_AMBIENT);
	
	int sinceHit = clock() - ghost->getHitTime();
	CIwColour colAmbient;

	if (sinceHit < GHOST_HIT_LENGTH) {
		int halfAnimation = GHOST_HIT_LENGTH/2;

		float animState = (float) sinceHit / halfAnimation;
		if (animState > 1) {
			animState = 2 - animState;
		}

		colAmbient.Set(0xff, 0xff*(1-animState), 0xff*(1-animState), 0xff);
	} else {
		// The default state that displays the image as it is
		colAmbient.Set(0xff, 0xff, 0xff, 0xff);
	}
	
	IwGxSetLightCol(0, &colAmbient);

	IwGxSetScreenSpaceSlot(1);
    IwAnimSetSkelContext(ghost_Player->GetSkel());
    IwAnimSetSkinContext(ghost_Skin);
    ghost_Model->Render();

	//outline the face under the cursor
	if (clickX > 0 && clickY > 0) {
		int32 faceID = ghostCollision->GetFaceUnderCursor(clickX, clickY);
		if (faceID != -1)
		{
			getGameState()->getGhost()->tapped();
			clickX = clickY = -1;
		} else {
			clickX = clickY = -1;
		}
	}

    // Tidier to reset these
    IwAnimSetSkelContext(NULL);
    IwAnimSetSkinContext(NULL);

	if (ghost->isFound() && !ghost->isDead()) {
		ghostCollision->RenderEctoplasmaBar((float)ghost->getEctoplasm() / GHOST_MAX_ECTOPLASM, ghostRotation);
	}
}
Пример #5
0
void GhostCollision::RenderEctoplasmaBar(float ectoPercent, double ghostRotation)
{
	CIwFMat ectoMatrix = CIwFMat();
	ectoMatrix.CopyRot(*modelMatrix);
	ectoMatrix.CopyTrans(*modelMatrix);
	ectoMatrix.PostRotateY(PI-ghostRotation);

	IwGxSetModelMatrix(&ectoMatrix);
	IwGxSetScreenSpaceSlot(1);

	if (ghostW < 0 || ghostX < 0 || ghostY < 0) ResolveLocation();

	const int16 w = 180;
	const int16 border_x1 = ghostX+ghostW/2 - (float)w*ectobarScale;
	const int16 border_x2 = ghostX+ghostW/2 + (float)w*ectobarScale;

	const float border_y1 = ghostY+0x20;
	const float border_y2 = ghostY+0x20 + (float)0x10*ectobarScale;
	const int16 z = 0x6;

	{
		CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
		pMat->SetModulateMode(CIwMaterial::MODULATE_RGB);
		pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
		pMat->SetTexture(borderTexture);

		int16 x1 = border_x1, x2 = border_x2; 
		float y1 = border_y1, y2 = border_y2;
		border_Verts[0] = CIwFVec3(x1, y2, -z);
		border_Verts[1] = CIwFVec3(x2, y2, -z);
		border_Verts[2] = CIwFVec3(x2, y1, -z);
		border_Verts[3] = CIwFVec3(x1, y1, -z);
		border_Verts[4] = CIwFVec3(x1, y2,  z);
		border_Verts[5] = CIwFVec3(x2, y2,  z);
		border_Verts[6] = CIwFVec3(x2, y1,  z);
		border_Verts[7] = CIwFVec3(x1, y1,  z);

		IwGxSetMaterial(pMat);
		IwGxSetVertStream(border_Verts, 8);
		//IwGxSetColStream(s_Cols, 8);
		IwGxSetUVStream(s_UVs);
		IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4);
	}

	float start_y1 = border_y1 + fabs((float)(border_y2 - border_y1)*0.200);
	float start_y2 = start_y1  + fabs((float)(border_y2 - border_y1)*0.720);
	float startWhScale = (float)((double)startTexture->GetWidth() / startTexture->GetHeight());
	int16 startW = (start_y2 - start_y1) * startWhScale;
	int16 start_x1 = border_x1 + abs((float)(border_x2 - border_x1)*0.0097);
	int16 start_x2 = start_x1 + startW;
	
	{
		CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
		pMat->SetModulateMode(CIwMaterial::MODULATE_RGB);
		pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
		pMat->SetTexture(startTexture);

		int16 x1 = start_x1, x2 = start_x2;
		float y1 = start_y1, y2 = start_y2;
		start_Verts[0] = CIwFVec3(x1, y2, -z);
		start_Verts[1] = CIwFVec3(x2, y2, -z);
		start_Verts[2] = CIwFVec3(x2, y1, -z);
		start_Verts[3] = CIwFVec3(x1, y1, -z);
		start_Verts[4] = CIwFVec3(x1, y2,  z);
		start_Verts[5] = CIwFVec3(x2, y2,  z);
		start_Verts[6] = CIwFVec3(x2, y1,  z);
		start_Verts[7] = CIwFVec3(x1, y1,  z);

		IwGxSetMaterial(pMat);
		IwGxSetVertStream(start_Verts, 8);
		//IwGxSetColStream(s_Cols, 8);
		IwGxSetUVStream(s_UVs);
		IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4);
	}

	float end_y1 = start_y1;
	float end_y2 = start_y2;
	float endWhScale = (float)((double)endTexture->GetWidth() / endTexture->GetHeight());
	int16 endW = (end_y2 - end_y1) * endWhScale;

	int endMaxX = border_x2 - abs((float)(border_x2 - border_x1)*0.0097) - endW;
	int endMinX = start_x2;
	int16 end_x1 = (double)(endMaxX - endMinX)*ectoPercent + endMinX;
	int16 end_x2 = end_x1 + endW;
	
	{
		CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
		pMat->SetModulateMode(CIwMaterial::MODULATE_RGB);
		pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
		pMat->SetTexture(endTexture);

		int16 x1 = end_x1, x2 = end_x2;
		float y1 = end_y1, y2 = end_y2;
		end_Verts[0] = CIwFVec3(x1, y2, -z);
		end_Verts[1] = CIwFVec3(x2, y2, -z);
		end_Verts[2] = CIwFVec3(x2, y1, -z);
		end_Verts[3] = CIwFVec3(x1, y1, -z);
		end_Verts[4] = CIwFVec3(x1, y2,  z);
		end_Verts[5] = CIwFVec3(x2, y2,  z);
		end_Verts[6] = CIwFVec3(x2, y1,  z);
		end_Verts[7] = CIwFVec3(x1, y1,  z);

		IwGxSetMaterial(pMat);
		IwGxSetVertStream(end_Verts, 8);
		//IwGxSetColStream(s_Cols, 8);
		IwGxSetUVStream(s_UVs);
		IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4);
	}
	
	float center_y1 = start_y1;
	float center_y2 = start_y2;
	int16 center_x1 = start_x2 - 1;
	int16 center_x2 = end_x1 + 1;
	
	{
		CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
		pMat->SetModulateMode(CIwMaterial::MODULATE_RGB);
		pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
		pMat->SetTexture(centerTexture);

		int16 x1 = center_x1, x2 = center_x2; 
		float y1 = center_y1, y2 = center_y2;
		center_Verts[0] = CIwFVec3(x1, y2, -z);
		center_Verts[1] = CIwFVec3(x2, y2, -z);
		center_Verts[2] = CIwFVec3(x2, y1, -z);
		center_Verts[3] = CIwFVec3(x1, y1, -z);
		center_Verts[4] = CIwFVec3(x1, y2,  z);
		center_Verts[5] = CIwFVec3(x2, y2,  z);
		center_Verts[6] = CIwFVec3(x2, y1,  z);
		center_Verts[7] = CIwFVec3(x1, y1,  z);

		IwGxSetMaterial(pMat);
		IwGxSetVertStream(center_Verts, 8);
		//IwGxSetColStream(s_Cols, 8);
		IwGxSetUVStream(s_UVs);
		IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4);
	}
	
}