Exemplo n.º 1
0
void GraphicsDeviceGL_1_3::drawFullscreenQuad(TextureGL* tex)
{
	f32 u0 = 0.0f, v0 = 0.0f;
	f32 u1 = 1.0f, v1 = 1.0f;

	tex->bind(0);
	if ( !supportsFeature(CAP_NON_POWER_2_TEX) )
	{
		u32 w, h;
		tex->getDimensions(w, h);
		u1 = f32(m_frameWidth)  / f32(w);
		v1 = f32(m_frameHeight) / f32(h);
	}

	u32 white = 0xffffffff;
	glBegin(GL_QUADS);
		glColor4ubv((GLubyte*)&white);

		glTexCoord2f(u0, v0);
		glVertex3f(-1.0f, 1.0f, -1.0f);
		glTexCoord2f(u1, v0);
		glVertex3f( 1.0f, 1.0f, -1.0f);

		glTexCoord2f(u1, v1);
		glVertex3f( 1.0f, -1.0f, -1.0f);
		glTexCoord2f(u0, v1);
		glVertex3f(-1.0f, -1.0f, -1.0f);
	glEnd();
}
Exemplo n.º 2
0
//! Returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail.
IMesh* CAnimatedMeshMD3::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop)
{
	if (0 == Mesh)
		return 0;

	//! check if we have the mesh in our private cache
	SCacheInfo candidate(frame, startFrameLoop, endFrameLoop);
	if (candidate == Current)
		return MeshIPol;

	startFrameLoop = core::s32_max(0, startFrameLoop >> IPolShift);
	endFrameLoop = core::if_c_a_else_b(endFrameLoop < 0, Mesh->MD3Header.numFrames - 1, endFrameLoop >> IPolShift);

	const u32 mask = 1 << IPolShift;

	s32 frameA;
	s32 frameB;
	f32 iPol;

	if (LoopMode)
	{
		// correct frame to "pixel center"
		frame -= mask >> 1;

		// interpolation
		iPol = f32(frame & (mask - 1)) * core::reciprocal(f32(mask));

		// wrap anim
		frame >>= IPolShift;
		frameA = core::if_c_a_else_b(frame < startFrameLoop, endFrameLoop, frame);
		frameB = core::if_c_a_else_b(frameA + 1 > endFrameLoop, startFrameLoop, frameA + 1);
	}
	else
	{
	//! Load from disk
	void OpenGLTexture::ResourceInit()
	{		
		if(m_pData)
		{
			SHOOT_WARNING(false, "Texture '%s' disk data already loaded", m_strPath.c_str());
			return;
		}

		s32 width, height, channels;
		if(m_pData = TextureLoader::Load(m_strPath.c_str(), width, height, channels, m_bpp))
		{
			m_vSize.Set(f32(width), f32(height));

			if(!OpenGLExtensionHandler::Instance()->HasExtension(OpenGLExtensionHandler::E_RectangleTexture))
			{
				m_vHardwareSize.Set(f32(Math::GetNextPow2(width)), f32(Math::GetNextPow2(height)));
			}
			else
			{
				m_vHardwareSize = m_vSize;
			}

			switch(channels)
			{
			case 3:	m_eFormat = TF_RGB;	break;
			case 4:	m_eFormat = TF_RGBA; break;			
			default: SHOOT_ASSERT(0, "Texture '%s' has unsupported format", m_strPath.c_str());
			}
		}
	}
Exemplo n.º 4
0
void	CRender::Statistics	(CGameFont* _F)
{
    CGameFont&	F	= *_F;
    F.OutNext	(" **** LT:%2d,LV:%2d **** ",stats.l_total,stats.l_visible		);
    stats.l_visible = 0;
    F.OutNext	("    S(%2d)   | (%2d)NS   ",stats.l_shadowed,stats.l_unshadowed);
    F.OutNext	("smap use[%2d], merge[%2d], finalclip[%2d]",stats.s_used,stats.s_merged-stats.s_used,stats.s_finalclip);
    stats.s_used = 0;
    stats.s_merged = 0;
    stats.s_finalclip = 0;
    F.OutSkip	();
    F.OutNext	(" **** Occ-Q(%03.1f) **** ",100.f*f32(stats.o_culled)/f32(stats.o_queries?stats.o_queries:1));
    F.OutNext	(" total  : %2d",	stats.o_queries	);
    stats.o_queries = 0;
    F.OutNext	(" culled : %2d",	stats.o_culled	);
    stats.o_culled	= 0;
    F.OutSkip	();
    u32	ict		= stats.ic_total + stats.ic_culled;
    F.OutNext	(" **** iCULL(%03.1f) **** ",100.f*f32(stats.ic_culled)/f32(ict?ict:1));
    F.OutNext	(" visible: %2d",	stats.ic_total	);
    stats.ic_total	= 0;
    F.OutNext	(" culled : %2d",	stats.ic_culled	);
    stats.ic_culled	= 0;
#ifdef DEBUG
    HOM.stats	();
#endif
}
Exemplo n.º 5
0
	//! returns a random number between 0 and 1
	f32 Random::GetFloat()
	{
		u32 u = NextU32();
		// The magic number below is 1/(2^32 + 2).
		// The result is strictly between 0 and 1.
		return f32(u + 1) * f32(2.328306435454494e-10);
	}
Exemplo n.º 6
0
// fills attributes with statistics information
void CImpostorSceneNode::getStats( io::IAttributes* statistics)
{
	statistics->setAttribute("Nodes", s32(Impostors.size()));
	//statistics->setAttribute("Lights", 0 ); // todo
	statistics->setAttribute("Buffers", s32(Buffers.size()));
	s32 TotalSlots=0, UsedSlots=0;
	for (u32 i=0; i<Buffers.size(); ++i)
	{
		TotalSlots+= Buffers[i].Slots.size();
		UsedSlots += Buffers[i].Slots.size() - Buffers[i].FreeSlots;
	}
	statistics->setAttribute("TotalSlots", TotalSlots);
	statistics->setAttribute("UsedSlots", UsedSlots);
	statistics->setAttribute("SlotUsage%", f32(UsedSlots)/ f32(TotalSlots) * 100.0f);

	statistics->setAttribute("TotalTextureMB", f32(Buffers.size()*TextureWidth*TextureWidth*4)/1048576.0f );


	statistics->setAttribute("QueueLength", s32(RenderQueue.size()));
	//statistics->setAttribute("AverageQueueLength", 0); // todo

	// todo
	statistics->setAttribute("RenderCount", RenderCount);
	statistics->setAttribute("CacheHit%", (f32(CacheHits) / f32(CacheHits + CacheMisses)) * 100.0f );
	statistics->setAttribute("CacheHits", CacheHits);
	statistics->setAttribute("CacheMisses", CacheMisses);

	//statistics->setAttribute("LastRegisterTime", 0);
	//statistics->setAttribute("TotalRegisterTime", 0);
	//statistics->setAttribute("AvgRegisterTime", 0);

	//statistics->setAttribute("LastRenderTime", 0);
	//statistics->setAttribute("TotalRenderTime", 0);
	//statistics->setAttribute("AvgRenderTime", 0);
}
Exemplo n.º 7
0
IWorld::IWorld(ID _id, const char *_name, s32 _width, s32 _height, s32 _fieldSize, IWorldDataManager *_data,
			   IWorldServer *_server)
	: ITimed()
	, m_id(_id)
	, m_name(_name)
	, m_width(_width)
	, m_height(_height)
	, m_fieldSize(_fieldSize)
	, m_data(_data)
	, m_pserver(_server)
{
	FDASSERT(m_data);
	FDASSERT(m_pserver);

	u32 t_newWidth = static_cast<u32>(ceil(f32(m_width) / f32(m_fieldSize)));
	u32 t_newHeight = static_cast<u32>(ceil(f32(m_height) / f32(m_fieldSize)));

	m_fields.resize(t_newWidth);

	u32 j;
	for (u32 i = 0; i < t_newWidth; ++i)
	{
		m_fields[i].resize(t_newHeight);

		for (j = 0; j < t_newHeight; ++j)
		{
			m_fields[i][j].setPosition(CVec2D<u32>(i, j));
		}
	}
}
Exemplo n.º 8
0
//*************************************************************************************
//
//*************************************************************************************
void	CColourPulser::Update( u32 elapsed_ms )
{
	mTimeCounter = (mTimeCounter + elapsed_ms) % mCyclePeriod;

	f32	cycle_fraction( f32(mTimeCounter) / f32(mCyclePeriod) );

	f32	sin_val( vfpu_cosf( cycle_fraction * 2.0f * PI ) );				// In range -1..+1
	f32	factor( ( sin_val + 1.0f ) / 2.0f );							// In range 0..1

	mCurrentColour = mDimColour.Interpolate( mBrightColour, factor );
}
Exemplo n.º 9
0
s32 CGUIScrollBar::getPosFromMousePos(s32 x, s32 y) const
{
	if (Horizontal)
	{
		const f32 w = RelativeRect.getWidth() - f32(RelativeRect.getHeight())*3.0f;
		const f32 p = x - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight()*1.5f;
		return s32( p/w * f32(Max) );
	}
	else
	{
		const f32 h = RelativeRect.getHeight() - f32(RelativeRect.getWidth())*3.0f;
		const f32 p = y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth()*1.5f;
		return s32( p/h * f32(Max) );
	}
}
Exemplo n.º 10
0
//!
s32 CGUIScrollBar::getPosFromMousePos(const core::position2di &pos) const
{
	f32 w, p;
	if (Horizontal)
	{
		w = RelativeRect.getWidth() - f32(RelativeRect.getHeight())*3.0f;
		p = pos.X - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight()*1.5f;
	}
	else
	{
		w = RelativeRect.getHeight() - f32(RelativeRect.getWidth())*3.0f;
		p = pos.Y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth()*1.5f;
	}
	return (s32) ( p/w * range() ) + Min;
}
Exemplo n.º 11
0
void GameVisualScene::updateCamera()
{
	static f32 rotz;
	static f32 rotx = 5.0;
	static f32 roty = 5.0;

	rotz += f32(game->inputSystem.getMouseMovement(2))/200.0f; 
	//rotz  = clampValue(rotz,1.0f,50.0f);
	rotz  = clampValue(rotz,5.0f,25.0f);

	if(game->inputSystem.mouse.state.isBtnDown(1)) 
	{
		rotx += (f32)game->inputSystem.getMouseMovement(0);
		roty += (f32)game->inputSystem.getMouseMovement(1);

		rotx = circularValue(rotx,0.0f,360.0f);
		roty = clampValue(roty,5.0f,85.0f); 

		Ogre::Vector3 pos = Ogre::Vector3::ZERO;
		pos.z = rotz*cos(hmath::deg(rotx).asRad())*sin(hmath::deg(roty).asRad());
		pos.x = rotz*sin(hmath::deg(rotx).asRad())*sin(hmath::deg(roty).asRad());
		pos.y = rotz*cos(hmath::deg(roty).asRad());

		game->visualSystem.getCamera()->setPosition(pos - Ogre::Vector3(2.5f,1.5f,0.0f));
		game->inputSystem.resetMouseMovement();
	}	
}
Exemplo n.º 12
0
void f33( int b )
{
    if( b )
	int dummy = f32();
    else
	int dummy = f32();
    switch( b )
	int dummy = f32();
    while( b )
	int dummy = f31( b );
    do
	int dummy = f31( b );
    while( b > -10 );
    for( int i = 0; i < 10; ++i )
	int dummy = f31( b );
}
Exemplo n.º 13
0
void CameraController::LookAt(const vec3 &pos)
{
	/*
	Texel/Raster bug - arrendodar a posicao da camera para pixel-perfect.
	*/
	auto p = pos + cOffset;
	auto x = s32(p.x);
	auto y = s32(p.y);
	auto z = f32(p.z);

	auto halfScreenWidth = s32(kHalfViewW);//pScreen->GetWidth() / 2;
	auto halfScreenHeight = s32(kHalfViewH);//pScreen->GetHeight() / 2;

	if (x < s32(cArea.x1 - 16))
		x = s32(cArea.x1 - 16);

	if (y < s32(cArea.y1 - 16))
		y = s32(cArea.y1 - 16);

	if (y > s32(cArea.y2 - 16 - halfScreenHeight * 2))
		y = s32(cArea.y2 - 16 - halfScreenHeight * 2);

	if (x > s32(cArea.x2 - 16 - halfScreenWidth * 2))
		x = s32(cArea.x2 - 16 - halfScreenWidth * 2);

	vec3 np(static_cast<f32>(x), static_cast<f32>(y), z);
	pCamera->SetPosition(np);
}
//---------------------------------------------------------------------------------------
// Gets the distance between va and vb
// Returns:    distance between va and vb
// Author(s):   Conan Reis
inline f32 a_dist(const AVec2i & va, const AVec2i & vb)
  {
  int dx = va.m_x - vb.m_x;
  int dy = va.m_y - vb.m_y;

  return a_sqrt(f32((dx * dx) + (dy * dy)));
  }
Exemplo n.º 15
0
	//! Engine's main loop
	void AppSDL::Run()
	{
		u32 previousTime = SDL_GetTicks();

		while(true)
		{			
			// calc delta time
			const u32 currentTime = SDL_GetTicks();			
			const f32 deltaTimeSecs = f32(currentTime - previousTime) / 1000.0f; 
			previousTime = currentTime;

			if(Update(deltaTimeSecs))
			{
				Engine::Instance()->Render();

				if(GraphicsDriver::Instance()->GetType() == GraphicsDriver::DT_OpenGL)
				{
					SDL_GL_SwapWindow(m_Window);
				}
				else
				{
					GraphicsDriver::Instance()->Present();
				}
			}
			else
			{
				break;
			}
		}
	}
Exemplo n.º 16
0
void testrun_f32(void)
{
    norx32_ctx_t ctx;
    memset(ctx.s, 0, sizeof(ctx.s));
    ctx.s[0] = 1;
    ctx.r = 8;
    f32(&ctx);
}
void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 timeMs)
{
    if (node != Object)
    {
        os::Printer::log("CollisionResponseAnimator only works with same scene node as set as object during creation", ELL_ERROR);
        return;
    }

    if (!World)
        return;

    u32 diff = timeMs - LastTime;
    LastTime = timeMs;

    core::vector3df pos = Object->getPosition();
    core::vector3df vel = pos - LastPosition;

    //g = Gravity * (f32)((timeMs - FallStartTime) * diff);

    f32 dt = 1.f;
    if (Falling)
    {
        dt = f32 ( ( timeMs - FallStartTime ) * diff );
    }
    core::vector3df g = Gravity * dt;

    core::triangle3df triangle = RefTriangle;

    core::vector3df force = vel + g;

    const core::vector3df nullVector ( 0.f, 0.f, 0.f );

    if ( force != nullVector )
    {
        // TODO: divide SlidingSpeed by frame time

        bool f = false;
        pos = SceneManager->getSceneCollisionManager()->getCollisionResultPosition(
                  World, LastPosition-Translation,
                  Radius, vel, triangle, f, SlidingSpeed, g);

        pos += Translation;

        if (f)//triangle == RefTriangle)
        {
            if (!Falling)
                FallStartTime = timeMs;

            Falling = true;
        }
        else
            Falling = false;

        Object->setPosition(pos);
    }

    LastPosition = Object->getPosition();
}
Exemplo n.º 18
0
int main(void) {
        f0();
    f1();
    f2();
    f3();
    f4();
    f5();
    f6();
    f7();
    f8();
    f9();
    f10();
    f11();
    f12();
    f13();
    f14();
    f15();
    f16();
    f17();
    f18();
    f19();
    f20();
    f21();
    f22();
    f23();
    f24();
    f25();
    f26();
    f27();
    f28();
    f29();
    f30();
    f31();
    f32();
    f33();
    f34();
    f35();
    f36();
    f37();
    f38();
    f39();
    f40();
    f41();
    f42();
    f43();
    f44();
    f45();
    f46();
    f47();
    f48();
    f49();
    f50();
    f51();
    f52();


    return 0;
}
Exemplo n.º 19
0
 //--------------------------------------------------------
 //--------------------------------------------------------
 void TapGesture::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)
 {
     CheckForExpiration(in_timestamp);
     
     if (in_inputType == m_requiredInputType && m_tapPending == true)
     {
         if (m_pendingPointers.size() == m_requiredPointerCount)
         {
             bool tapFinished = true;
             
             for (auto& pointerInfo : m_pendingPointers)
             {
                 if (in_pointer.GetId() == pointerInfo.m_pointerId)
                 {
                     pointerInfo.m_isDown = false;
                 }
                 else if (pointerInfo.m_isDown == true)
                 {
                     tapFinished = false;
                 }
             }
             
             if (tapFinished == true)
             {
                 if (m_tapCount == 0)
                 {
                     m_firstTapPendingPointers = m_pendingPointers;
                 }
                 
                 ResetTap();
                 m_tapCount++;
                 m_lastTapEndTimestamp = in_timestamp;
                 
                 if (m_tapCount == m_requiredTapCount)
                 {
                     Core::Vector2 gesturePosition = Core::Vector2::k_zero;
                     for (auto& pointerInfo : m_firstTapPendingPointers)
                     {
                         gesturePosition += pointerInfo.m_initialPosition;
                     }
                     gesturePosition /= f32(m_firstTapPendingPointers.size());
                     
                     Reset();
                     
                     if (ResolveConflicts() == true)
                     {
                         m_tappedEvent.NotifyConnections(this, gesturePosition);
                     }
                 }
             }
         }
         else
         {
             ResetTap();
         }
     }
 }
Exemplo n.º 20
0
/// \todo Use Asset API for fetching sky resources.
EC_SkyBox::EC_SkyBox(IModule *module) :
    IComponent(module->GetFramework()),
    materialRef(this, "Material", AssetReference("RexSkyBox")), ///< \todo Add "orge://" when AssetAPI can handle it.
    textureRefs(this, "Texture"),
    orientation(this, "Orientation", Quaternion(f32(M_PI/2.0), Vector3df(1.0,0.0,0.0))),
    distance(this, "Distance",50.0),
    drawFirst(this, "Draw first", true)
{
     connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)), SLOT(OnAttributeUpdated(IAttribute*)));

     static AttributeMetadata materialRefMetadata;
     AttributeMetadata::ButtonInfoList materialRefButtons;
     materialRefButtons.push_back(AttributeMetadata::ButtonInfo(materialRef.GetName(), "V", "View"));
     materialRefMetadata.buttons = materialRefButtons;
     materialRef.SetMetadata(&materialRefMetadata);

     // Find out default textures.
     renderer_ = module->GetFramework()->GetServiceManager()->GetService<OgreRenderer::Renderer>();

     StringVector names;
     Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(materialRef.Get().ref.toStdString().c_str());
     if ( materialPtr.get() != 0)
     {
         OgreRenderer::GetTextureNamesFromMaterial(materialPtr, names);
         AssetReferenceList lst;
         if (names.size() == cSkyBoxTextureCount)
         {
            // This code block is not currently working, but if for some reason GetTextureNamesFromMaterialn understands cubic_textures this codeblock is runned
            for(int i = 0; i < cSkyBoxTextureCount; ++i)
                lst.Append(AssetReference(names[i].c_str()));
         }
         else
         {
            // Add default values, hardcoded
            /// HACK use hardcoded-values because ogre textureunit state class cannot find out texture names for cubic_texture type.
            lst.Append(AssetReference(names[0].c_str()));
            lst.Append(AssetReference("rex_sky_back.dds"));
            lst.Append(AssetReference("rex_sky_left.dds"));
            lst.Append(AssetReference("rex_sky_right.dds"));
            lst.Append(AssetReference("rex_sky_top.dds"));
            lst.Append(AssetReference("rex_sky_bot.dds"));
         }

        textureRefs.Set(lst, AttributeChange::LocalOnly);
     }

    // Disable old sky.
    // DisableSky();
     CreateSky();

     lastMaterial_ = materialRef.Get().ref;
     lastOrientation_ = orientation.Get();
     lastDistance_ = distance.Get();
     lastDrawFirst_ = drawFirst.Get();
     lastTextures_ = textureRefs.Get();
}
Exemplo n.º 21
0
void OSystem_Wii::updateScreenResolution() {
	if (_overlayVisible) {
		_currentWidth = _overlayWidth;
		_currentHeight = _overlayHeight;
	} else {
		_currentWidth = _gameWidth;
		_currentHeight = _gameHeight;
	}

	if (_currentWidth > 0)
		_currentXScale = f32(gfx_video_get_width()) / f32(_currentWidth);
	else
		_currentXScale = 1.0;

	if (_currentHeight > 0)
		_currentYScale = f32(gfx_video_get_height()) / f32(_currentHeight);
	else
		_currentYScale = 1.0;

	updateEventScreenResolution();
}
Exemplo n.º 22
0
            Jungle::Jungle(u32 dimension, u32 chunkSize, u32 treeDimension, u8 verticesDetail, ITerrainSceneNode* heightRef, ISceneManager* mgr, s32 id):
                scene::ISceneNode(0, mgr, id)
            {
                //ctor
                Box.reset(core::vector3df(-2000,-2000,-2000));
                Box.addInternalPoint(core::vector3df(2000,2000,2000));

                refNode = heightRef;

                setAutomaticCulling(EAC_OFF);

                //calculating configuration
                CHUNK_SIZE = chunkSize;
                TREE_DIMENSION = treeDimension;
                u32 totalPossibleTreeRooted = dimension / treeDimension;
                WORLD_SIZE = totalPossibleTreeRooted / CHUNK_SIZE;
                CHUNK_RENDER_DIMENSION = f32(dimension) / f32(WORLD_SIZE);
                NUM_VERTICES = verticesDetail;
                normalScale = 500.0f;

                chunks = new JungleChunk*[WORLD_SIZE];
                for(u8 i = 0; i < WORLD_SIZE; i++)
                {
                    chunks[i] = new JungleChunk[WORLD_SIZE];
                }//j

                //set chunks positions
                for(u8 x = 0 ; x < WORLD_SIZE; x ++)
                {
                    for(u8 y = 0 ; y < WORLD_SIZE; y ++)
                    {
                        chunks[x][y].X = x * CHUNK_RENDER_DIMENSION;
                        chunks[x][y].Y = 0;
                        chunks[x][y].Z = y * CHUNK_RENDER_DIMENSION;
                        chunks[x][y].heightRef = heightRef;
                        chunks[x][y].jungle = this;
                        chunks[x][y].setup();
                    }
                }
            }
Exemplo n.º 23
0
void TestScene::tick()
{
	if(time == 1)
	{
		fires[0] = new FireActor(this);
		fires[0]->x = xCam;
		fires[0]->vx = camvel;
		fires[0]->y = -60;
		fires[0]->colorShift = 0;
		actors.push_back(fires[0]);
	}
	
	
	if(time % 5 == 0)
	{
		Particle* star = addParticle1000();
		star->sizePerLife = -(1+rand() % 4);
		if(rand() % 6 == 0)
			star->sizePerLife -= 7+rand() % 4;
		star->vx = camvel.tof5()+star->sizePerLife*17-10;
		star->vy = 0;
		star->vx2 = 0;
		star->vy2 = 0;
		star->x = xCam.tof5()+230*32;
//		star->x = rand() % (192*32) - (192*32/16);
		star->y = rand() % (192*32) - (192*32/2);
		star->nTexture = TEX_DIAMOND;
		star->effect = FX_NOFRICTION;
		
		
		star->r = 150+rand() % 100;
		star->g = 150+rand() % 100;
		star->b = 255;
		star->a = 10+rand() % 21;
	}
	xCam += camvel;
	
	if(fires[0])
	{
//		int ny = sinLerp(time*100) + sinLerp(time*240) + sinLerp(time*174)/2;
//		if(time < 250)
			int ny = sinLerp(time*440)*4;
//		if(time < 150)
//			ny = sinLerp(time*440)*3;
		f32 dy = fires[0]->y-(f32(ny) / (1<<7));
		fires[0]->vy *= 0.7;
		fires[0]->vy -= dy/24;
	}
	
		
	Scene::tick();
}
//! Starts a MD2 animation.
bool CAnimatedMeshSceneNode::setMD2Animation(EMD2_ANIMATION_TYPE anim)
{
    if (!Mesh || Mesh->getMeshType() != EAMT_MD2)
        return false;

    IAnimatedMeshMD2* m = (IAnimatedMeshMD2*)Mesh;

    s32 begin, end, speed;
    m->getFrameLoop(anim, begin, end, speed);

    setAnimationSpeed( f32(speed) );
    setFrameLoop(begin, end);
    return true;
}
Exemplo n.º 25
0
//*****************************************************************************
//
//*****************************************************************************
void DLParser_DumpVtxInfo(u32 address, u32 v0_idx, u32 num_verts)
{
	if (DLDebug_IsActive())
	{
		s8 *pcSrc = (s8 *)(g_pu8RamBase + address);
		s16 *psSrc = (s16 *)(g_pu8RamBase + address);

		for ( u32 idx = v0_idx; idx < v0_idx + num_verts; idx++ )
		{
			f32 x = f32(psSrc[0^0x1]);
			f32 y = f32(psSrc[1^0x1]);
			f32 z = f32(psSrc[2^0x1]);

			u16 wFlags = u16(gRenderer->GetVtxFlags( idx )); //(u16)psSrc[3^0x1];

			u8 a = pcSrc[12^0x3];
			u8 b = pcSrc[13^0x3];
			u8 c = pcSrc[14^0x3];
			u8 d = pcSrc[15^0x3];

			s16 nTU = psSrc[4^0x1];
			s16 nTV = psSrc[5^0x1];

			f32 tu = f32(nTU) * (1.0f / 32.0f);
			f32 tv = f32(nTV) * (1.0f / 32.0f);

			const v4 & t = gRenderer->GetTransformedVtxPos( idx );
			const v4 & p = gRenderer->GetProjectedVtxPos( idx );

			psSrc += 8;			// Increase by 16 bytes
			pcSrc += 16;

			DL_PF("    #%02d Flags: 0x%04x Pos:{% 0.1f,% 0.1f,% 0.1f} Tex:{% 7.2f,% 7.2f} Extra: %02x %02x %02x %02x Tran:{% 0.3f,% 0.3f,% 0.3f,% 0.3f} Proj:{% 6f,% 6f,% 6f,% 6f}",
				idx, wFlags, x, y, z, tu, tv, a, b, c, d, t.x, t.y, t.z, t.w, p.x/p.w, p.y/p.w, p.z/p.w, p.w);
		}
	}
}
Exemplo n.º 26
0
int main(void) {
        f0();
    f1();
    f2();
    f3();
    f4();
    f5();
    f6();
    f7();
    f8();
    f9();
    f10();
    f11();
    f12();
    f13();
    f14();
    f15();
    f16();
    f17();
    f18();
    f19();
    f20();
    f21();
    f22();
    f23();
    f24();
    f25();
    f26();
    f27();
    f28();
    f29();
    f30();
    f31();
    f32();
    f33();
    f34();
    f35();
    f36();
    f37();


    return 0;
}
Exemplo n.º 27
0
//*************************************************************************************
//
//*************************************************************************************
void	IMainMenuScreen::Render()
{
	mpContext->ClearBackground();


	c32		valid_colour( mpContext->GetDefaultTextColour() );
	c32		invalid_colour( 200, 200, 200 );

	f32		min_scale( 0.60f );
	f32		max_scale( 1.0f );

	s32		SCREEN_LEFT = 20;
	s32		SCREEN_RIGHT = SCREEN_WIDTH - 20;

	mpContext->SetFontStyle( CUIContext::FS_HEADING );

	s32		y( TEXT_AREA_TOP + mpContext->GetFontHeight() );

	for( s32 i = -2; i <= 2; ++i )
	{
		EMenuOption		option( AsMenuOption( mCurrentOption + i ) );
		c32				text_col( IsOptionValid( option ) ? valid_colour : invalid_colour );
		const char *	option_text( gMenuOptionNames[ option ] );
		u32				text_width( mpContext->GetTextWidth( option_text ) );

		f32				diff( f32( mCurrentOption + i ) - mCurrentDisplayOption );
		f32				dist( Abs( diff ) );

		s32				centre( ( SCREEN_WIDTH - text_width ) / 2 );
		s32				extreme( diff < 0 ? SCREEN_LEFT : s32( SCREEN_RIGHT - (text_width * min_scale) ) );

		// Interpolate between central and extreme position and centre
		f32				scale( max_scale + (min_scale - max_scale) * dist );
		s32				x( s32( centre + (extreme - centre) * dist ) );

		mpContext->DrawTextScale( x, y, scale, option_text, text_col );
	}

	mpContext->SetFontStyle( CUIContext::FS_REGULAR );

	mOptionComponents[ GetCurrentOption() ]->Render();
}
Exemplo n.º 28
0
// primitive types, by value in, out
void
test1()
{
    printf("\ntesting primitive type functions: fxx(0) ...\n");

    f11(0);
    f12(0);
    f13(0);
    f14(0);
    f15(0);
    f16(0);
    f17(0);
    f18(0);
    f19(0);
    f20(0);
    f21(0);
    f22(0);
    f23(0);
    f24(0);
    f25(0);

    f31(0);
    f32(0);
    f33(0);
    f34(0);
    f35(0);
    f36(0);
    f37(0);
    f38(0);
    f39(0);
    f40(0);
    f41(0);
    f42(0);
    f43(0);
    f44(0);
    f45(0);
}
u32 CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs)
{
    const s32 deltaFrame = core::floor32 ( f32 ( timeMs - BeginFrameTime ) * FramesPerSecond );

    if (Looping)
    {
        const s32 len = EndFrame - StartFrame + 1;
        // play animation looped
        return StartFrame + ( deltaFrame % len );
    }
    else
    {
        // play animation non looped
        s32 frame = StartFrame + deltaFrame;

        if (frame > EndFrame)
        {
            frame = EndFrame;
            if (LoopCallBack)
                LoopCallBack->OnAnimationEnd(this);
        }
        return frame;
    }
}
Exemplo n.º 30
0
//! Set the alignment of the tabs
void CGUITabControl::setTabVerticalAlignment( EGUI_ALIGNMENT alignment )
{
	VerticalAlignment = alignment;

	IGUISkin* skin = Environment->getSkin();
	s32 ButtonSize = 16;
	if (skin)
	{
		ButtonSize = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
		if (ButtonSize > TabHeight)
			ButtonSize = TabHeight;
	}

	TabMaxWidth = s32(f32(ButtonSize) * 2.5f);
	s32 ButtonX = RelativeRect.getWidth() - TabMaxWidth - 1;
	s32 ButtonY = 0;

	if (VerticalAlignment == EGUIA_UPPERLEFT)
	{
		ButtonY = (TabHeight / 2) - (ButtonSize / 2);
		UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
		DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
	}
	else
	{
		ButtonY = RelativeRect.getHeight() - (TabHeight / 2) - (ButtonSize / 2);
		UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
		DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
	}

	UpButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize));
	ButtonX += ButtonSize + 1;
	DownButton->setRelativePosition(core::rect<s32>(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize));

	recalculateScrollBar();
}