Tuesday, January 29, 2008

Grass


The last weeks have been really productive for Ember. I've closed most of the bugs reported in the bug tracker and also managed to add some new features. One that I've been needing for some time was a teleport function for admin mode. Previously when you were logged in as admin you had to move just as a regular person, which could take some time when you wanted to go to a different area of the map. But now there's a nifty "teleport here" option available when you click on the world, which will instantly transport you to the clicked location. It was very easy to implement, no more than 30 minutes work.
Another thing that has been bugging me for a while was that when you entered and exited building your orientation would be messed up. I initially assumed that there was something wrong with how the server sent updates to the client, but after some thorough testing I found that it was solely a client issue. The problem was that when the user controls the avatar and walks through the world, Ember ignores orientation and position updates sent for the avatar. This is to avoid the issue on lagging connections where the avatar continuously will snap back to a previous position, as sent from the server. When the avatar stops moving it will be adjusted to the data sent from the server however.
The problem here was then when the avatar moves into a house and changes it's container, it needs to be have it's orientation updated relative to the orientation of the new container. And this new orientation is correctly sent from the server, however not as I incorrectly assumed in the onLocationChanged event, but in the subsequent onMoved event. But if the user is moving the avatar Ember ignores the onMoved event and the old orientation will be used instead, resulting in the avatar looking in the completely wrong direction. The solution was to change the functionality so that the onMoved event would be honoured by Ember for the avatar even when the user was moving it, if it occurred right after a onLocationChanged event. This fixed the problem, something which I think has been in Ember for some years now.

A new feature I've been working on this week is support for a better foliage system. I've so far used a home grown system which uses static geometry, but it has some problems and I didn't want to put much effort into it since there are other third party components for Ogre which does it all much better. Especially the Paged Geometry plugin shows real promise. So the last couple of days I've worked on integrating that into Ember, throwing out my own solution. It's a very good library, excellent in both design and documentation. So far I've had no problems getting it integrated, but I think I need to do some alterations to it in order to support the demands of Ember, especially the dynamic nature of the terrain. So far I've focused on getting the grass to work, but the idea is to also use if for the trees and other objects that are both numerous and fairly static. This will hopefully bring the ability to display really vast forests.
Post a Comment