rifter1818 Posted June 22, 2004 Posted June 22, 2004 Ok this is a simple one, i want to use LeftHanded CC View CamPos 0,0,-100 CamTar 0,0,0 CamUp 0,1,0 Now how do i get my projection matric such that (on a 1024x768 resolution) 0,0,0 in the world is the center of the screen -512, 384 ,0 is top left of screen 512, 384 ,0 is top right of screen -512, -384,0 is bottom left of screen 512 , -384,0 is bottom right of screen Really simple question but i really dont know how to fine tune my projection matrix (at least i think thats what i need to modify) And before you as the question yes i know about transformed Vertices and all that.... Thanks in advance Quote
ThePentiumGuy Posted June 22, 2004 Posted June 22, 2004 Ok this is a simple one, i want to use LeftHanded CC View CamPos 0,0,-100 CamTar 0,0,0 CamUp 0,1,0 Now how do i get my projection matric such that (on a 1024x768 resolution) 0,0,0 in the world is the center of the screen -512, 384 ,0 is top left of screen 512, 384 ,0 is top right of screen -512, -384,0 is bottom left of screen 512 , -384,0 is bottom right of screen Really simple question but i really dont know how to fine tune my projection matrix (at least i think thats what i need to modify) And before you as the question yes i know about transformed Vertices and all that.... Thanks in advance im not too sure if you want to use a projection matrix for that.. d3ddev.transform.view = OrthoLH(1024,768, znearplane,zfarplane) would do what you're asking OrthoOffCenterLH would specify the bounds like (IIRC): (left , right, bottom, top, znear,zfar) like what you're asking for. (and with the arguments that you provided, the center = 0,0,0 but OrthoLH would make your 'center point' 0,0,0 its basically: left = -width/2 right = width/2 top = -height/2 bottom = height/2 isnt the LookAt matrix masinly for 3d games? here's my tip in 2d: i transform the world, and set the view = orthoLH in 3d: i dont worry aobut my center point, so my view = LookAt, and projection = ..(crap i completely forgot lol - its like PerspectiveFOVLH or something) pent Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
rifter1818 Posted June 22, 2004 Author Posted June 22, 2004 Thanks Pent I was just so used to 3d myself that id forgotten the finer points of view/projection/all that stuff. Thanks. Quote
rifter1818 Posted June 22, 2004 Author Posted June 22, 2004 (edited) Are you sure? d3d.Dev.Transform.View = Matrix.OrthoOffCenterLH(-512,512,-384,384,-50,0); d3d.Dev.Transform.Projection = Matrix.PerspectiveLH(1024,768,-50,0); Seems a little redundant to have Projection and View so simular and doesnt set campos,camtar,camup anywhere?! Edit After Testing doesnt seem to work, btw which Matrix makes it 10x larger in x,y? Matrix.Scaling(10,10,1) Matrix.Scaling(1/10,1/10,1) Never Mind Problem was my cull mode Thanks Pent. Edited June 22, 2004 by rifter1818 Quote
ThePentiumGuy Posted June 22, 2004 Posted June 22, 2004 you're doing 3d right? hmm, ok, to set the center point to 0,0,0 - you'd have to set the camTarget to 0,0,0.. beucase that point will be the center of the screen so just do d3ddev.transform.view = matrix.lookatlh(campos, new vector3(0,0,0), new vector3(0,1,0) d3ddev.transform.projection = matrix.perspectiveFOVLH( math.pi/4, 1, -50,0) 'math.pi / 4 is 45 degrees - so you can see "45 degrees around you", the "1" represents the Aspect Ratio: most TV's use 16:9 which is widescreen (just type in 1.777 to get 16:9) im not sure what PerspectiveLH is though i beleive taht matrix.scaling (10,10,1) makes it 10x larger :) pent Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
ThePentiumGuy Posted June 23, 2004 Posted June 23, 2004 just wanna make a quick comment: i dont think my reply was very clear lol u said u want to makethe center point (0,0,0). in order to do that, just set the cameraTarget (0,0,0). becuase the cameraTarget is what you're looking at, and that point is the center of the screen also, the greater the aspect ratio, the wider the objects will seem to appear pent Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.