Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Well, The only way i figured to move a sprite (stored in a vertexbuffer), is to dispose the buffer and create a new one with new vertices... This sound really inefficent, but i've seen lots'a things with direct3d that didnt sound efficent...

 

Any suggestions??

 

EDIT: it did effect my framerate while moving one object. I lost about 4-8 of 150 FPS... This is no real problem, but if it should move 100 objects??

 

--Loffen

Edited by Loffen
Erutangis a si tahw
Posted

Nono man :).

This is not how you move the sprite. There is something called World Transformations. In order to move the sprite, you must move the WORLD.

 

For example, if the sprite is at 0,0,0.

 

dxDevice.Transform.World = Matrix.transformation(2,0,0) would move the sprite over 2 units to the rihgt.

 

dxDevice.Transform.World = Matrix.Multiply(dxDevice.Transform.World, Matrix.Translation(2,0,0)) would move the sprite 2 units to the right - each time the line gets executed. (If you put it in the render loop, it will move 2 units each frame)

 

The first line dxDevice.Transform.World = Matrix.transformation(2,0,0) will only move the world to that point. No matter how many times you execute it, it will only move it to the right once... err its confusing - but experimenting with the code should help you understand.

 

"In order to move the sprite, you must move the WORLD." - heh,

I'm 100% sure the next question you will ask is: "If I have to move the WORLD to move 1 character, how do I move 2 characters if they wish to go in opposite directions?"

-There's a post on the forum which i answered, just search for it :).

 

-The Pentium Guy

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

Posted

Err, I realized that the post title was "Associating Matrix with Shape" - so it might have been hard to search. But anyways, here's the thread link:

 

http://www.xtremedotnettalk.com/showthread.php?t=87596

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...