• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ryan20fun

Meshes look squished

10 posts in this topic

Hi All.

for some reason the meshes looks to be vertically squashed, the white box if a perfect square.
im using GetClientRect to get the size for the back buffer and for the width and height param for the camera.

here is a pic of it:
[attachment=6574:squished.jpg]

here is the code im using for the camera( its a bit messy, but ill get around to cleaning it up later )
[CODE]
#include "StdAfx.h"
#include <d3dx9.h>
#include "TIPInput_Mouse_Async.h"
#include "TIPInput_Keyboard_Async.h"
#include "TIPVector3.h"
#define PIE D3DX_PI//3.1415926
#define DEG_TO_RAD 0.0174532925
float RadianToDegree( float Radien )
{
return Radien * ( 180 / PIE );
}
float DegreeToRadian( float Degree )
{
return Degree * ( PIE / 180 );
}
class Camera
{
public:
TIP::Physics::TIPVector3 Position;
TIP::Physics::TIPVector3 Target;
TIP::Physics::TIPVector3 Reference;
float aspectRatio;
float nearPlane;
float farPlane;
float fieldOfView;
D3DXMATRIX Projection;
D3DXMATRIX View;
float Yaw;
float Pitch;
TIP::Input::TIPInput_Mouse_Async mStateCashe;
int width, height;
public:
Camera()
{
nearPlane = 1.0f;
farPlane = 1000.0f;
fieldOfView = 45.0f;
Reference.Z = 1.0f;
Target = Reference + Position;
Yaw = 0.0f;
Pitch = 0.0f;
}
void Initialize( int ScreenWidth, int ScreenHeight )
{
width = ScreenWidth;
height = ScreenHeight;
aspectRatio = ScreenWidth / ScreenHeight;
float rad = D3DX_PI / 4;//DegreeToRadian( fieldOfView );
D3DXMatrixPerspectiveFovLH( &Projection, rad, aspectRatio, nearPlane, farPlane );
SetCursorPos( ScreenWidth / 2, ScreenHeight / 2 );
mStateCashe.GetState();
}
void Update( float DeltaTime )
{
TIP::Input::TIPInput_Mouse_Async mouse;
TIP::Input::TIPInput_Keyboard_Async keyboard;
mouse.GetState();
keyboard.GetState();
TIP::Physics::TIPVector3 moveVector;
if ( keyboard.IsKeyDown( 'W' ) )
moveVector.Z += 150 * DeltaTime;
if ( keyboard.IsKeyDown( 'S' ) )
moveVector.Z -= 150 * DeltaTime;
if ( keyboard.IsKeyDown( 'A' ) )
moveVector.X -= 150 * DeltaTime;
if ( keyboard.IsKeyDown( 'D' ) )
moveVector.X += 150 * DeltaTime;
if ( keyboard.IsKeyDown( VK_CONTROL ) )
moveVector.Y -= 150 * DeltaTime;
else if ( keyboard.IsKeyDown( VK_SPACE ) )
moveVector.Y += 150 * DeltaTime;
float mouseX = mouse.State.Position_X - mStateCashe.State.Position_X;
float mouseY = mouse.State.Position_Y - mStateCashe.State.Position_Y;
Pitch += (mouseY * 0.15f) * DeltaTime;
Yaw += (mouseX * 0.15f) * DeltaTime;

if( Pitch < DegreeToRadian( -89.9f ) )
Pitch = DegreeToRadian( -89.9f );
else if( Pitch > DegreeToRadian( 89.9f ) )
Pitch = DegreeToRadian( 89.9f );
SetCursorPos( width / 2, height / 2 );
D3DXMATRIXA16 ViewRotationMatrix, MoveRotationMatrix, rotx, roty;
D3DXMatrixRotationX( &rotx, Pitch );
D3DXMatrixRotationY( &roty, Yaw );
ViewRotationMatrix = rotx * roty;
MoveRotationMatrix = roty;

D3DXVECTOR3 vec( Reference.X, Reference.Y, Reference.Z );
D3DXVECTOR3 transformedCameraReference;
D3DXVec3TransformCoord( &transformedCameraReference, &vec, &ViewRotationMatrix );

D3DXVECTOR3 vec3;
vec.x = moveVector.X;
vec.y = moveVector.Y;
vec.z = moveVector.Z;
D3DXVec3TransformCoord( &vec3, &vec, &MoveRotationMatrix );
Position.X += vec3.x;
Position.Y += vec3.y;
Position.Z += vec3.z;
Target.X = transformedCameraReference.x + Position.X;
Target.Y = transformedCameraReference.y + Position.Y;
Target.Z = transformedCameraReference.z + Position.Z;
D3DXVECTOR3 pos, tar, up;
pos.x = Position.X;
pos.y = Position.Y;
pos.z = Position.Z;
tar.x = Target.X;
tar.y = Target.Y;
tar.z = Target.Z;
up.x = 0;
up.y = 1;
up.z = 0;
D3DXMatrixLookAtLH( &View, &pos, &tar, &up );
}
};
[/CODE]

and here is the rendering code for the meshes:
[CODE]
void Render( IDirect3DDevice9* g_pd3dDevice, TIP::Physics::TIPVector3 Pos, TIP::Physics::TIPVector3 Rot, float Scale )
{
// Set up world matrix
D3DXMATRIXA16 matWorld;
D3DXMATRIXA16 translation;
D3DXMATRIXA16 rotation;
D3DXMATRIXA16 scale;
D3DXMatrixRotationYawPitchRoll( &rotation, Rot.X, Rot.Y, Rot.Z );
D3DXMatrixTranslation( &translation, Pos.X, Pos.Y, Pos.Z );
D3DXMatrixScaling( &scale, Scale, Scale, Scale );
matWorld = rotation * translation * scale;
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i = 0; i < NumMaterials; i++ )
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial( &Materials[i] );
g_pd3dDevice->SetTexture( 0, Textures[i] );
// Draw the mesh subset
Mesh->DrawSubset( i );
}
}
[/CODE]
what am i doing wrong ?
Thanks In Advance.

---edit---
also the window size also seams to affect the way the objects looked.
if the window width and height are the same, then the square box looks square like it is supposed to.
0

Share this post


Link to post
Share on other sites
I think this is your problem

[color=#000088]float[/color][color=#000000] rad [/color][color=#666600]=[/color][color=#000000] D3DX_PI [/color][color=#666600]/[/color][color=#000000] [/color][color=#006666]4[/color][color=#666600];[/color]

try

[color=#000088]float [/color]rad = 0.4f * D3DX_PI
0

Share this post


Link to post
Share on other sites
[quote name='iedoc' timestamp='1325401611' post='4898620']
I think this is your problem

[color=#000088]float[/color][color=#000000] rad [/color][color=#666600]=[/color][color=#000000] D3DX_PI [/color][color=#666600]/[/color][color=#000000] [/color][color=#006666]4[/color][color=#666600];[/color]

try

[color=#000088]float [/color]rad = 0.4f * D3DX_PI
[/quote]
unfortunetly it does not seam to help.

---edit---
when i try to move objects, they have to have a larger amount of movement to visually move, is there a problem with the view matrix ?
0

Share this post


Link to post
Share on other sites
im setting it like this
[code]
RECT size;
ZeroMemory( &size, sizeof( size ) );
GetClientRect( Window.GetHandle(), &size );
camera.Initialize( size.right, size.bottom );
[/code]

i also set the backbuffer width and height to that value.

i also tried using the "camera" code from the "Meshes" tutorial of the SDK and it got the exact same results( box is slightly squached verticall ).

could this be a result of using the Panda 3D exporter of 3ds Max ?
ill try using a box from Blender and see if it has the same results.
0

Share this post


Link to post
Share on other sites
I think i might have found your problem


[color=#000000] matWorld [/color][color=#666600]=[/color][color=#000000] rotation [/color][color=#666600]*[/color][color=#000000] translation [/color][color=#666600]*[/color][color=#000000] scale[/color][color=#666600];[/color]

since the order that you multiply matrices matter, what will happen is that first your rotate, then translate, so that's good (the reverse order will create an orbiting effect), but then you scale your object after you translate it. since the object is not centered around (0,0,0) after you translate it, it will become stretched when you scale it. the order that you do rotations and scaling together don't matter, but the order you do translations and either rotation or scale does matter. try doing this instead:


[color=#000000] matWorld [/color][color=#666600]= scale *[/color][color=#000000] rotation [/color][color=#666600]*[/color][color=#000000] translation[/color][color=#666600];[/color]
1

Share this post


Link to post
Share on other sites
that solved a problem of positioning my objects, but unfortunetly it does not seam to be affecting how the objects look.

can you have a look at the .X meshe to see if that is the problem( as i cannot view it in a another app for verification of the mesh ) ?
0

Share this post


Link to post
Share on other sites
I'm still looking for your problem, but i'll let you know your x file is fine. You can also check x files with the utility in your directx sdk called directx viewer or something
0

Share this post


Link to post
Share on other sites
When you get this problem of stretching, is it after you change your window size? or when you first start the program?

I'm starting to think this has to do with your aspect ratio, where you have width/height
1

Share this post


Link to post
Share on other sites
From initialize():
[source]
aspectRatio = ScreenWidth / ScreenHeight;

[/source]

Both ScreenWidth and ScreenHeight are integers, so you're performing an integer division and the results is thus an integer. That is, your aspect ratio is wrong. Cast the numerator and/or the denominator to a floating point value to perform a floating point division.
1

Share this post


Link to post
Share on other sites
[quote name='iedoc' timestamp='1325428570' post='4898654']
I'm starting to think this has to do with your aspect ratio, where you have width/height
[/quote]
Thank You [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

[quote name='Brother Bob' timestamp='1325429487' post='4898658']
From initialize():
[source]
aspectRatio = ScreenWidth / ScreenHeight;

[/source]

Both ScreenWidth and ScreenHeight are integers, so you're performing an integer division and the results is thus an integer. That is, your aspect ratio is wrong. Cast the numerator and/or the denominator to a floating point value to perform a floating point division.
[/quote]

Thank You [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0