Graphics Reference
In-Depth Information
void UWB _ WindowHandler::WorldToDevice( float wcx, float wcy, int &dcx, int &dcy) const {
.
GetDeviceSize(dcW, dcH); // dcW/dcH are the width/height of the drawing device
center = m _ WCWindow.GetCenter(); // center of the WCWindow
// Equation 10.13
dcx = (m _ WCWindow.Width() / 2.0f) + ((dcW/m _ WCWindow.Width()) * (-center.x + wcx));
dcy = (m _ WCWindow.Height()/ 2.0f) + ((dcH/m _ WCWindow.Height()) * (-center.y + wcy));
void UWB _ WindowHandler::DeviceToWorld( int dcx, int dcy, float &wcx, float &wcy) const
.
GetDeviceSize(dcW, dcH); // dcW/dcH are the width/height of the drawing device
vec3 center = m _ WCWindow.GetCenter(); // center of the WCWindow
// Equation 10.19
Source file.
uwbgl _ WindowHandler3.cpp
file in the Common Files/Win-
dowHandler subfolder of the
UWBGL _ D3D _ Lib10 project.
wcx = center.x + ((m _ WCWindow.Width()/dcW) * (dcx - (dcW/2.0f)));
wcy = center.y + ((m _ WCWindow.Height()/dcH) * (dcy - (dcH/2.0f)));
Listing 10.8. The WindowHandler transform and draw functions.
class UWBD3D _ WindowHandler : public UWB _ WindowHandler {
.
virtual void LoadW2NDCXform() const ; // Computes and loads VIEW matrix with M w 2 n
.
void UWBD3D _ WindowHandler::LoadW2NDCXform() const
Source file.
uwbgl _ D3DWindowHandler4.h
/.cpp files in the D3D Files/
WindowHandler folder of the
UWBGL _ D3D _ Lib10 project.
// center of the m _ WCWindow
cy wc )
vec3 center = m _ WCWindow.GetCenter();
// T ( cx wc ,− cy wc )
D3DXMatrixTranslation(&toPlace, -center.x, -center.y);
// S (
(
cx wc ,
2
H wc )
D3DXMatrixScaling(&toSize, 2.0f/m _ WCWindow.Width(), 2.0f/m _ WCWindow.Height());
// M w 2 n = T ( cx wc ,− cy wc ) S (
2
W wc ,
2
H wc )
D3DXMatrixMultiply(&world2ndc, &toPlace, &toSize);
// M V M w 2 n
m _ pD3DDevice->SetTransform(D3DTS _ VIEW, &world2ndc);
.
2
W wc ,
Listing 10.9. The LoadW2NDCXform() functions.
Search WWH ::




Custom Search