PDA

View Full Version : Mesh Matrix wth...



Memphis
23-03-2009, 06:05 PM
ok i've run into another wall.... i wasnt sure which section to post this so i posted here. ok since working on my 3d engine, i have always loaded static meshes (.x)

all works perfect, .... until now... now i want to move meshes around in my 'world' and i have no idea how todo it. or at least i know it is something todo with the matrix local or something. but thats all i know. so..

for my world i use this. which allows me to move my camera around in my world (.x) map/model



procedure TEngine.SetupViewCam;
var
matView: TD3DMatrix;
begin
D3DXMatrixLookAtLH(matView, Cam.Position, Cam.Direction, Cam.vUpVec);
ResMan.DX_Device.SetTransform(D3DTS_VIEW, matView);
D3DXMatrixPerspectiveFovLH(matView, D3DX_PI/4, Cam.ViewAspect, 0.1, 4000.0);
ResMan.DX_Device.SetTransform(D3DTS_PROJECTION, matView);
end;


which is called each once before a frame render / after processing mouse/keyboard input.

now i want to load a mesh of lets say a ball or a box. and would like to move it around. how would i go about this? :o

hope someone understands and can help. thanks,

chronozphere
23-03-2009, 07:21 PM
You should make a "world matrix" and apply it using Device.SetTransform(D3DTS_WORLD, Your_World_Matrix).

For example:



D3DXMatrixTranslation(MyWrldMat, 100, 0, 0);
Device.SetTransform(D3DTS_WORLD, MyWrldMat);

//Draw your translated mesh now

D3DXMatrixRotateY(MyWrldMat, 0.5 * Pi);
Device.SetTransform(D3DTS_WORLD, MyWrldMat);

//Draw another model that will be rotated 90 degrees about the Y Axis

D3DXMatrixScaling(MyWrldMat, 2, 2, 2);
Device.SetTransform(D3DTS_WORLD, MyWrldMat);

//Draw another model that will appear two times as big as the original


It's actually very simple. ;)
Take a look at the following pages:

http://msdn.microsoft.com/en-us/library/bb205367(VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb205359(VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb205363(VS.85).aspx

Etc... Also usefull:

http://www.drunkenhyena.com/pages/projects/d3d8/d3d_lesson4.php
http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B5.aspx
http://msdn.microsoft.com/en-us/library/bb206269(VS.85).aspx

Etc... google is your friend. :)

noeska
23-03-2009, 08:56 PM
And not to forget clootie's site: http://www.clootie.ru/

Memphis
24-03-2009, 11:34 AM
google is your friend. :)


google is not my friend ... lol.. i have mensioned in other posts why, which i won't bother to repeat but....

http://www.pascalgamedevelopment.com/forum/index.php?topic=5667.msg45886;topicseen#new

this is a clue, i like this forum and community, so i'd like to be regged on a forum that stays active for a change :)

anyways i will check those links and thanks for example, i think i understand now.