Uberman Posted March 23, 2012 Share Posted March 23, 2012 Some years ago (for the original Sony PSP, to show you how long ago) I wrote some raw 3D code using that platform's SDK. The code allowed the user to "walk" a cube around a grid. The cube could be "walked" by using the arrow keys; pressing left caused the cube to roll over to the left, up caused it to roll away from the user, etc. I never did anything with this code, I just wrote it basically to see if I could, and it involved a lot of management and shifting of the object's pivot point to create the illusion. I'm thinking of doing something similar in the test program I writing with Leadwerks. I cannot see any abstracted management of an Entity's pivot point in the Leadwerks SDK, so I am assuming I'll have to do some direct matrix programming to achieve the same effect. However, Leadwerks provides something new that I've not had access to before: a physics engine. I'm not sure what approach, then, would be better in programming the effect, that of using the physics engine to cause the object to "fall over" as though it were walking, or if I should just animate the motion by hand as I did on the PSP. I would imagine I'd have greater control over the movement of the object by doing manual animation, but I'd have less complicated code if I somehow employed the physics engine to move the object. In the physics approach, I imagine I'd have some kind of hidden collision object that would "knock over" the Entity, like an invisible finger pushing over a brick, while the user holds down a key. I don't know if that would be the most elegant approach, though, and perhaps some combination of manual animation and physics might be better (e.g., manually animate until the object crosses a gravitation threshold and the let the physics engine take over). Would anybody have any opinions or insights about what might be the best approach in this situation? Quote Link to comment Share on other sites More sharing options...
Uberman Posted March 24, 2012 Author Share Posted March 24, 2012 Ah, I see that I could probably use a Pivot instead of having to resort to matrix manipulation. However, it still begs the question whether using the physics engine might be the more (or less) elegant approach. Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted March 24, 2012 Share Posted March 24, 2012 For something as controlled as that, where the movement is required to be exact, I would manipulate it directly. Physics engines are great but not really intended for fine control more for emulated physics behavior where the interaction of forces and momentum would otherwise make it difficult to control in a believable way. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Uberman Posted March 24, 2012 Author Share Posted March 24, 2012 I suspected as much, but just wanted a second opinion on the topic. Thanks. Quote Link to comment Share on other sites More sharing options...
paramecij Posted March 25, 2012 Share Posted March 25, 2012 Why not try and do both? Since you said it's for a test program, it would be good exercise. If I understand the "walk" correctly, you could get away with LE's rotation and translation commands only, if used on a pivot that you re-position when necessary. But by directly manipulating the matrix you could do it a bit faster. The pure physics approach probably wouldn't work that well in more complex scenarios (could be wrong), but for a cube on a plane you could start by manipulating the torque and velocity. Best from both worlds would be if you use a physics body for movement and collision with terrain/objects and you animate the mesh manually (that's basically how most games do their characters, just that in your case the character is a cube) Quote Link to comment Share on other sites More sharing options...
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.
Note: Your post will require moderator approval before it will be visible.