Results 1 to 2 of 2
  1. #1
    ntKid's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Posts
    9
    Reputation
    10
    Thanks
    86

    Raidez World to Screen

    W2S for new PW/Frogster game Raiderz.
    https://raiderz.perfectworld.com/

    If this is usefull for you please credit me and mpgh.net

    Code:
    std::vector< D3DXVECTOR3 > m_ModelInfo;
    
    HRESULT GetVertexPosition( LPDIRECT3DDEVICE9 lpDevice, D3DXVECTOR3& lpWorldPosition )
    {
    	HRESULT Eax = E_UNEXPECTED;
    
    	LPDIRECT3DINDEXBUFFER9 dwIndexData = NULL;
    
    	if( SUCCEEDED( lpDevice->GetIndices( &dwIndexData ) ) )
    	{
    		PVOID dwIndex = NULL;
    
    		if( SUCCEEDED( dwIndexData->Lock( 0, 0, &dwIndex, D3DLOCK_READONLY ) ) )
    		{
    			LPDIRECT3DVERTEXBUFFER9 dwStreamData = NULL;
    
    			UINT dwOffsetInBytes = NULL, dwStride = NULL; 
    
    			if( SUCCEEDED( lpDevice->GetStreamSource( 0, &dwStreamData, &dwOffsetInBytes, &dwStride ) ) )
    			{
    				PVOID dwData = NULL;
    
    				if( SUCCEEDED( dwStreamData->Lock( 0, 0, &dwData, D3DLOCK_READONLY ) ) )
    				{
    					Eax = NO_ERROR;
    
    					lpWorldPosition.x = ( ( PFLOAT )dwData )[ 0 ];
    					lpWorldPosition.y = ( ( PFLOAT )dwData )[ 1 ];
    					lpWorldPosition.z = ( ( PFLOAT )dwData )[ 2 ];
    
    					dwStreamData->Unlock( );
    				}
    				dwStreamData->Release( );
    			}
    			dwIndexData->Unlock( );	
    		}
    		dwIndexData->Release( );
    	}
    
    	return Eax;
    }
    
    VOID AddDeviceModel( LPDIRECT3DDEVICE9 lpDevice )
    {
    	D3DXVECTOR3 dwWorldPosition( 0, 0, 0 );
    
    	if( FAILED( GetVertexPosition( lpDevice, dwWorldPosition ) ) )
    		return;
    
    	D3DVIEWPORT9 dwViewPort;
    
    	ZeroMemory( &dwViewPort, sizeof( D3DVIEWPORT9 ) );
    
    	if( FAILED( lpDevice->GetViewport( &dwViewPort ) ) )
    		return;
    
    	D3DXMATRIX dwWorldViewProj;
    
    	ZeroMemory( &dwWorldViewProj, sizeof( D3DVIEWPORT9 ) );
    
    	if( FAILED( lpDevice->GetVertexShaderConstantF( 216, ( PFLOAT )&dwWorldViewProj, 4 ) ) )
    		return;
    
    	if( D3DXMatrixTranspose( &dwWorldViewProj, &dwWorldViewProj ) == NULL )
    		return;
    
    	D3DXVECTOR3 dwScreenPos( 0, 0, 0 );
    
    	if( D3DXVec3TransformCoord( &dwScreenPos, &dwWorldPosition, &dwWorldViewProj ) )
    	{
    		dwScreenPos.x = ( dwScreenPos.x + 1.0f ) * dwViewPort.Width * 0.5f + dwViewPort.X;
    		dwScreenPos.y = ( 1.0f - dwScreenPos.y ) * dwViewPort.Height * 0.5f + dwViewPort.Y;
    		dwScreenPos.z = ( dwScreenPos.z + 1.0f ) * 0.5f;
    		
    		m_ModelInfo.push_back( dwScreenPos );
    	}
    }
    Example:
    Code:
    VOID PrintPosition( LPDIRECT3DDEVICE9 lpDevice )
    {
    	if( lpDevice )
    	{
    		if( pFontManager )
    		{
    			for( INT i = 0; i < m_ModelInfo.size( ); i++ )
    			{
    				pFontManager->OnDraw( NULL, ( INT )m_ModelInfo[ i ].x, ( INT )m_ModelInfo[ i ].y, NULL, NULL, "LA", DT_NOCLIP, D3DCOLOR_ARGB( 255, 255, 255 ,255 ) );
    			}	
    		}
    	}
    }
    
    HRESULT __stdcall myEndScene( LPDIRECT3DDEVICE9 Device )
    {
    	PrintPosition( Device );
    
    	m_ModelInfo.clear( );
    
    	return pEndScene( Device );
    }
    
    HRESULT __stdcall myDrawIndexedPrimitive( LPDIRECT3DDEVICE9 Device, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount )
    {
    	if( pTextureManager->GetActiveTextureId( ) == 0x9CDE3DBB || pTextureManager->GetActiveTextureId( ) == 0xFDA64A00 )
    	{
    		AddDeviceModel( Device );//W2S + Store ScreenPos
    	}			
    	return pDrawIndexedPrimitive( Device, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount );
    }

  2. The Following User Says Thank You to ntKid For This Useful Post:

    gnsv (08-21-2012)

  3. #2
          ( ° ͜ʖ͡°)╭∩╮
    Former Staff
    MarkHC's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    127.0.0.1
    Posts
    2,750
    Reputation
    66
    Thanks
    14,529
    My Mood
    Angelic
    Good to see people sharing this kinda stuff. +Rep


    CoD Minion from 09/19/2012 to 01/10/2013

Similar Threads

  1. What is World To Screen?
    By u.A.v.A in forum Coders Lounge
    Replies: 3
    Last Post: 05-25-2012, 11:09 AM
  2. World 2 Screen?
    By Xlilzoosk8rX in forum Combat Arms Coding Help & Discussion
    Replies: 30
    Last Post: 10-01-2010, 12:06 PM
  3. Replies: 10
    Last Post: 08-13-2010, 09:51 PM
  4. Hacking world of warcraft? & a noob question
    By arsholio in forum General Game Hacking
    Replies: 9
    Last Post: 04-08-2006, 01:55 PM
  5. World jump day
    By -Avenger- in forum General
    Replies: 4
    Last Post: 01-14-2006, 08:28 AM