Jump to content

  • Log In with Google      Sign In   
  • Create Account


G-Man9566

Member Since 26 Jun 2007
Offline Last Active Feb 03 2012 08:52 AM

Topics I've Started

UV Mapping Algorithms

03 February 2012 - 01:47 AM

Hi,

Is there anyone who can guide me in the right direction (or article Posted Image ). I want to generate UV mapping coordinates for my objects in code. So I would like to generate Plane, Box, Sphere, Cylinder etc. mapping for my objects in code. I am pretty sure there would be standartd algorithms out there to do this. I implemented my own algorithm for box mapping, but I am getting bad results on "edges" (where one vertex is projecting to one face of the box and the other vertex to the other face).

I included two images, one with the my generated mapping ("Incorrect Mapping.PNG") and one which it should look like and was generated by 3dsMax ("Correct Mapping.PNG").

Thanx in advance.

Backbuffer resolution

01 July 2011 - 07:14 AM

Hi,

When one adjusts a game's screen resolution (you know typically in the game's "Options->Graphics"), is it actually the BackBufferWidth and BackBufferHeight of the D3DPRESENT_PARAMETERS (D3D) for a device, that is being set?

WM_INPUT message not being caught

26 April 2011 - 06:35 AM

Hi,

I read up on MSDN how to implement Raw Input handling. I only want to handle the mouse buttons for now, just to get it working. Now, I've done the following...

/***********
 * Register Mouse as a raw input device
 **/
RAWINPUTDEVICE l_aRawInputDevices[1]; //only one RID will be registered

l_aRawInputDevices[0].usUsagePage = HID_USAGE_PAGE_GENERIC; //0x01
l_aRawInputDevices[0].usUsage = HID_USAGE_GENERIC_MOUSE;  //0x02
l_aRawInputDevices[0].dwFlags = RIDEV_NOLEGACY;   // i've also tried just specifying RIDEV_INPUTSINK 
l_aRawInputDevices[0].hwndTarget = 0/*l_hWindow*/;   // I've tried with and without specifying the window which is applicable

if( RegisterRawInputDevices( l_aRawInputDevices, 1, sizeof(l_aRawInputDevices[0]) ) == false )
{
	System::Windows::Forms::MessageBox::Show( "Could not Register HID" );
}

Now, for our application, we've registered to the Application::Idle event in which we "Run" and handle our Windows Messaging. Something like this....

void Class::AppIdle( Object^ sender, EventArgs^ e )
{
	MSG l_Msg;
	MSG l_MouseMsg;

	while ( !PeekMessage(&l_Msg, 0, 0, 0, 0) ) // No message is recieved
	{
        	....
        	ENGINE->Run(); //updates, culls, draws etc.
	}

	if ( ::PeekMessage( &l_MouseMsg, 0/*this->m_hRenderWindowHandle*/, 0, 0, 0/*PM_REMOVE*/ ) )   // here I've also specified with 
	{                                                         				       //and without the window handle
 		switch( l_MouseMsg.message )
 		{
    		case WM_INPUT: 
    		{
                  	// it does not go in here
                  	System::Diagnostics::Trace::WriteLine( "WM_INPUT" );
                  	break;
        	}
     		}
 	}
}

It does not switch into the WM_INPUT case when I to anything with the mouse (clicking away and moving it around the window). This is how I've been handling mouse inputs thus far (within the same AppIdle funtion) which works well enough (although it does not always catch the button up case - which is the reason I'm trying WM_INPUT)

if ( ::PeekMessage( &l_MouseMsg, this->m_hRenderWindowHandle, 513, 517, 0/*PM_REMOVE*/ ) )
{
	switch( l_MouseMsg.message )
	{
	case WM_LBUTTONDOWN  :
		{
			ENGINEMANAGER->GetInputDevice()->SetMouseButtonDown( 0, true );
			break;
		}
	case WM_LBUTTONUP :
		{
			ENGINEMANAGER->GetInputDevice()->SetMouseButtonDown( 0, false );
			ENGINEMANAGER->GetInputDevice()->SetMouseButtonClicked( 0, true );
			break;
		}
	case WM_RBUTTONUP :
		{
			ENGINEMANAGER->GetInputDevice()->SetMouseButtonDown( 1, false );
			ENGINEMANAGER->GetInputDevice()->SetMouseButtonClicked( 1, true );
			break;
		}
	default :
		{
			break;
		}
	}
}


Any advise what I'm doing wrong that the switch does not catch the WM_INPUT case?

[DX9] DrawPrimitiveUP not taking Tranform and Color into account

18 April 2011 - 07:42 AM

Hi,

Im drawing everything in my scene using effects (ID3DXEffect) and ID3DXMesh::DrawSubset.

There are only one type of object (MeasurementLines) that Im rendering using IDirect3DDevice9::DrawPrimitiveUP. Im drawing these MeasurementLine objects after Im rendering all the others, but I cant seem to set the IDirect3DDevice9::SetTransform and the device does not draw these lines the color that I set them when I create their FVF.

Im probably missing something fundamental, but dont know what it is.

		D3DVertexColor l_aVertexPositionData[2];

		l_aVertexPositionData[0].position.x = this->m_pStartPoint->GetWorldTransform()->GetPosition().x;
		l_aVertexPositionData[0].position.y = this->m_pStartPoint->GetWorldTransform()->GetPosition().y;
		l_aVertexPositionData[0].position.z = this->m_pStartPoint->GetWorldTransform()->GetPosition().z;

		l_aVertexPositionData[1].position.x = this->m_pEndPoint->GetWorldTransform()->GetPosition().x;
		l_aVertexPositionData[1].position.y = this->m_pEndPoint->GetWorldTransform()->GetPosition().y;
		l_aVertexPositionData[1].position.z = this->m_pEndPoint->GetWorldTransform()->GetPosition().z;

		l_aVertexPositionData[0].color = 0xff000000;

		l_aVertexPositionData[1].color = 0xff000000;

		D3DXMATRIX l_d3dmIdentity;

		D3DXMatrixIdentity( &l_d3dmIdentity );

		HRESULT hr;

		ENGINEMANAGER->GetGraphicsDevice()->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE );

		hr = ENGINEMANAGER->GetGraphicsDevice()->SetTransform( D3DTS_WORLD, &l_d3dmIdentity );

		hr = ENGINEMANAGER->GetGraphicsDevice()->SetTransform( D3DTS_VIEW, &D3DCAMERAMANAGER->GetActiveCamera()->GetProjectionMatrix() );

		hr = ENGINEMANAGER->GetGraphicsDevice()->SetTransform( D3DTS_PROJECTION, &D3DCAMERAMANAGER->GetActiveCamera()->GetViewMatrix() );

		ENGINEMANAGER->GetGraphicsDevice()->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );

		hr = ENGINEMANAGER->GetGraphicsDevice()->DrawPrimitiveUP( D3DPT_LINESTRIP, 1, (void *)l_aVertexPositionData, sizeof( D3DVertexColor ) );

So in summary, it draws the line primitive, but does not take the color I specify or the Word transform into account. How do I fix this?

Device not setting color or matrices

29 March 2011 - 12:25 AM

I have a problem where, after I rendered the whole scene using shaders a draw lines which I just use DrawPrimitiveUP, but I can for the life of me not set the Device's matrices and the color that I assign to the line.

Its as if the Device uses the last shader state that it rendered with. Any pointers?

PARTNERS