MV3D Development Blog

November 25, 2007

Let’s all sing the refactoring song…

Filed under: Uncategorized — SirGolan @ 8:48 pm

But first, a bit of coolness.. My trac server is misbehaving, so I just looked at the server it runs on to see why. While looking, I noticed that an MV3D server was running on it (it’s the dev mv3d server), and after logging in, it seems it’s been running for 112 days. That’s just under the 133 days since the machine was last rebooted (probably because of the power outage that was longer than the run time on my UPS). Anyway, pretty cool. Now that I think of it, it’s not like it’s just been sitting there unused. For quite some time, I was connecting to it to test the performance of the client. It isn’t even barely compatible with the client now though because I reorganized SVN today… A lot. However, I just connected to it from my old desktop which has a very old version of MV3D running on it. Yay for things that keep running without crashing. It doesn’t surprise me that it’s still up and running, just mostly makes me happy to know that MV3D’s server is that stable.

In any case, I finished the refactoring of objects to use bodies. I didn’t do the beach ball, but it’s like 20 lines of code (and probably doesn’t deserve to be its own object type even), so I’ll do it some other time. That’s one ticket down (if trac was working).

Then I took some time to work cleaning up the SVN repository. Originally, there wasn’t a trunk, it was just mv3d, branches, and tags. Now there is a trunk, and mv3d is inside the trunk. The reason this is important is because this way, if some other package has a server module, it won’t conflict with MV3D. I also renamed all the top level directories to use lowercase and most of the second level ones as well. There’s still some more SVN moving around to do since I think the util directory is a little vague and could be better named or split up or something. Currently, it has everything that isn’t specific to either the server or the client. I made the choice early on to separate client and server code so that the client can ship without any of the server code, and the server can run without the client code. However, the util module is the common ground between them.

I’m not sure what’s next. Probably making normal config files for server and client. For the client, I’ve been thinking that adding an auto-login/character picker option to the config file would save me some clicks when testing. Also moving the Ogre config stuff in there would remove another click.

After that is Axiom integration. If I’m quick about the config file, I may get to start that tonight. So, with that, it’s off to config file land!

November 23, 2007

Nevow + Axiom = Fun

Filed under: Uncategorized — SirGolan @ 4:35 pm

I’ve made a lot of progress with the photography website. I figured out how to make an admin interface that is password protected in Nevow using portals (which I have prior experience using in MV3D).

So now, I have a front page of the website that has the javascript slideshow on it, and an admin interface that allows you to modify which images get put in the slideshow and what order they’re in. It is pretty cool and works well though the admin interface is pretty simple. It lets you add photos by entering the url and display order. Then you can select them in a list and move them up/down or delete them.

My ultimate goal here is to allow Corey to upload photos to the app and then use PIL to resize them (and maybe even add a watermark if I get fancy). I’ll make a few sizes, but one will be slideshow sized so that he’ll be able to select any photos from his site to put on the slideshow.

My sister and Corey came by for the holiday, so I got a chance to talk to him more about what he wants out of the website.

Now, though, it’s MV3D time. And time to convert the terrain to use bodies.

November 18, 2007

Nevow fun

Filed under: Uncategorized — SirGolan @ 12:11 pm

I finally got to spend some time yesterday working on the photography website. Admittedly, part of my motivation is that I’m also writing a site in Nevow for work that is due on Monday, so I’m trying to learn it as quick as possible. If anyone has a link to some good / up to date documentation, that would be cool. I’ve mostly had to learn from the source & examples with a fair amount of guessing going on.

I still haven’t really integrated the site with Axiom yet, but at the moment, it does have an index page right now. I was able to find this javascript that does all I want as far as slide shows go. I just need to hook that into Nevow/Axiom so that Corey can choose what images go there.

Something I’m finding confusing is how the tags work in the xml templates. This could be because the only other template engine I’ve ever used was one that I wrote, and it had a whole programming language you could use in the templates. Anyway, for a while, I thought you could only put the nevow: tags in div tags. I finally figured out that it can be any tag.

The other thing that’s confusing me is forms. I’m looking at the examples that use formless, and I pretty much don’t understand how they could actually work. So, that probably means copying them and messing with them until they break and figuring out how they work that way. I’ve also never used anything to create and parse web forms other than the library I wrote for it.

Anyway, today is housework, building a computer, and hopefully finding time for MV3D. No pretty screenshots. I got bipeds working again, though there is one little issue, but I think that’s more related to how bodies work than anything. I’ve moved on to moving the water object over. That’s also a little bit tricky since it was probably the only object that still talked directly to Ogre. It’ll still have to do that to an extent because it uses render to texture, and I haven’t yet thought of a good way to wrap that in a non-renderer specific way. Next is wrapping up the object refactoring with terrains. I’m hoping I can do some huge cleanup there since they are (I think) one of the things that cause the client to freeze while it is logging in to the server. I bounced the mesh generation to its own thread, but that didn’t seem to help, so either the terrain is bombing out PB when it gets transferred because of the height data (I moved to a array(”f”).tostring() hoping to solve that), or I don’t know what the issue is. Anyway, hopefully I’ll work on that today. Then there’s actually one more object to change to use bodies, and that’s the beach ball. The beach ball should be more fun now that I added a “kick” command. It should also be incredibly simple to convert since it’s just the same as the box except the collider and mesh.

November 15, 2007

Issues

Filed under: Uncategorized — SirGolan @ 10:41 am

So, my initial new style object using a body is finished. The server side is 80 lines of non-shared code. The client side is 0. Since it’s just a physical object that has no special other qualities, all the client side code is shared. In fact, I suspect most objects will share the client side code. The only differences will be things that have more complex physics like bipeds or cars. The reason for this is that in order to make things move smoothly on the client, I need to mirror the physics there.

Speaking of bipeds.. They are pretty hard to simulate in physics engines. I’ve probably talked about it previously here, but I do it by creating a capsule (pill shaped object) for the body that is attached to a non-physical object for the head. Every update, the capsule is set to stand on end. At this point, you could walk around– kinda. However, you’d basically be dragging your ass along the floor. Simulating feet in a realistic way is very complicated, and I feel is getting way too crazy for a MMORPG. Instead, I cheat. I cast a ray down from the bottom of the capsule and check where it hits something. If it hits something in range of the length of the character’s feet, I push up on the capsule. This way, it floats in the air. When you encounter stairs, as long as they are below the bottom of the capsule, the player will appear to walk up them. Otherwise, they are “too high” and it will just bump into them. Anyway, this is a fairly common approach and works well. It’s when you get into simulating virtual knees that bend when you land hard that gets tricky. Also, if the player is standing on something that is moving, he should move with it. I had all but the last part working well before, but copy/pasting it and then doing a little refactoring seems to have broken it. The specific problem now is that the ray cast results are used to determine if the player is on the ground, however, it keeps bobbing up too high to register the ray cast and then falling back down. So, hopefully I can come up with a good solution to this. I also need to add the part about moving the player if the object he’s standing on moves.

Now, those aren’t really the issues I’m talking about. Here they are:

The first one is disturbing. I have no idea what happened. All of a sudden, there was an ogre head on the horizon. I turned around to get a closer look and it was gone. The second one is just confusing. I re-built the female model, but now, the torso is facing the wrong way. :)
Speaking of rebuilding models. I’ve a) gotten very good at applying skeletons to models in 3ds max, and b) FINALLY FINALLY found a 3DS Max->Ogre exporter that works. Ok, so there’s another one that works, but it takes a few days to get a model right. This one, it’s right on the first try. With the other one, you’ll get a properly exported mesh, but when you play an animation, it distorts the heck out of it because the bones are in completely the wrong position. Anyway, I found some simple free 3d models out there and was able to properly export one of them:

Just got to get the biped working again, change the terrain and water objects to use bodies, and then, I think it’s on to Axiom.

November 9, 2007

Get some candy in your eye.

Filed under: Uncategorized — SirGolan @ 5:53 pm

I took a break from bodies to add some eye candy. Bodies are 99% working. They seem to have issues when they are in an octree node that gets split though. Have to check that out. Also have to make a method to limit how fast they update based on something or other.

First up, a lot of objects that use bodies. 2000 to be exact.
Pretty reflections at night Trees, grass, and water. Not too bad for FPS, but not very good either.
Walking through the forest. Trees and water at sunset
A whole lotta trees Too many?

So… This stuff isn’t too impressive because I basically shoe-horned in this Python-Ogre demo. And for some reason, you get pretty clouds in the demo, but I don’t get them. Anyway, this isn’t done in a client server way at all. It’s just attached to the client side of the terrains. Making it into something that comes from the server probably won’t be incredibly hard. The trees will also need integration with physics since you can walk through them right now. There are other optimizations I can do I’m sure to get things going faster– especially tweaking the settings of the tree plugin.

Right now, I need to get back to the server side of things and make bodies work better. Something I really need is an easy way to write unit tests that involve a client and server. I spent a lot of time going back and forth with Bodies making them work when transferred from a server. I more or less had this working before, but it was pretty kludgey (Ogre would get initialized and everything). It would have been nice to be able to write unit tests for the issues that came up.

Anyway, better get back to doing some non eye-candy stuff.

November 8, 2007

Preview

Filed under: Uncategorized — SirGolan @ 6:52 pm

So, I almost have my example Box object that uses bodies going. It works ok, but it sends updates way too often, client side Physics may be not working (hard to tell since it sends updates so often :) ), and you don’t see it in its initial position until it moves. But I took a short break to give you the following pretty picture:

I should have some trees and grass to go along with that soon.

Also, I forget if I mentioned, but I saw that the Python-Ogre guys made wrappers for libnoise. This is very cool because even though MV3D already has a pretty good noise generator, this one is in C++ and therefore will be quite a bit faster. I suspect the new sky plugin uses it for real time clouds (which you can’t see in the screenshot because they are broken for some reason).

November 6, 2007

Linux? No waaay.

Filed under: Uncategorized — SirGolan @ 7:22 pm

Way.

Someone was nice enough to build and package Python-Ogre on Linux. So, now I can run the client there again. Maybe I’ll even package up Python-Ogre + MV3D on Linux if enough people would be interested in such a thing. However, MV3D’s svn trunk is a bit messed right now. Combinator on Windows lied to me when it said I was working in a branch (seriously, it seemed to work and even created MV3D/branches/branchname and put files there, but their .svn/entries points to trunk :(, and I only found out after totally screwing with everything). Yes, I could revert it and try again, but I’ve almost got it fixed.

Anyway, the whole point of this post is the screenshot:

Otherwise, I’m continuing to fix the stuff I broke. That mostly means ripping out my hacky cooperator-ish code and replacing it with real cooperators. Unfortunately, the old code causes Python to crash on Windows, so it has been a little hard to debug. And very odd since MV3D’s server never crashes. It’s a stack overflow that is causing the issue, so increasing the stack size a bit (like on Linux) should get me a maximum recursion depth reached error in Python rather than a crash. But anyway, I know why it’s caused, it’s just finding all the places that cause it and fixing them.

Edit: Trunk fixed… or at least I can log in and walk around now. There may be other issues hiding out.

November 5, 2007

Hello Axiom World

Filed under: Uncategorized — SirGolan @ 12:34 am

So first, I took a look at some more Nevow stuff, and it seems like it should be pretty easy to work with. I didn’t expect otherwise, but you never know.

I just finished writing up a basic data model for the photography website. It was pretty easy. In order to test it, I created some unit tests that store and retrieve things. I figured out how to do various types of relations such as one to many, and many to many. All in all, it’s pretty straight forward and should do the job very well. The next step here is to integrate it with Nevow and then make an admin interface to create data.

The big question is: can I use it on MV3D? I think for 90% of the data, it would be fine. The other 10% is the stuff that changes 20x per second like object position, rotation, and velocities. I have no idea how I’d store that stuff in Axiom as I wouldn’t want to save it to disk so often. Once a minute is probably fine. Maybe there is some sort of parameter I can set for that. I’m definitely open to any ideas here.

As far as other MV3D stuff goes, the new version of Python-Ogre includes a bunch of kick-ass addons such as a really nice dynamic sky, and paged geometry. The paged geometry is what will allow me to have forests with tens of thousands of trees in them (no really, this can display hundreds of thousands of trees on screen without breaking a sweat). There’s also now a kick-ass water texture/shader in the Python-Ogre demos that I can use. Now if I only wrote a nice tree generator that could be used with the paged geometry.

For things that I’ve done, well, I’m creating a base object that uses bodies. It is < 200 lines of code, which is a good sign. I also refactored out a lot of stuff related to object views and figured out how that whole mess will work with bodies and visual objects. Basically, items (objects, areas, realms, etc) in MV3D can be Viewable. Something that is viewable has a sister view class that contains only the attributes that are needed for the client. The reasoning for this is that you don't want the client knowing everything the server knows about an object. That leads to cheating. Right now, viewable objects that don't use bodies update position and rotation of their views all the time. This isn't slow, but it could become so. Instead, with bodies, I've decided that the body level and below is all public data that the client can know about. So, an object and its view share a reference to a body (or more than one). The body can have visual objects attached to it, which become models and such on the client. On the client side, the body updates the position/rotation of its visual objects as needed based on client side physics and updates from the server. It seems to make a lot of sense to me, but we'll see how it works soon enough.

On the subject of portals, it actually looks like I can do some render to texture work in order to support smaller portals visually. Basically, I should be able to create a flat object and render whatever is behind the portal to it. It is theoretically possible to only render to it when it is visible to save some cpu cycles.

The next step here of course is getting a working object using bodies on the server and client. But first, housework.

Edit: Persistence Thoughts
Right now, bodies don’t actually have a member variable called “position” or anything. They just get/set that information directly in the physics engine. Maybe I could define position/rotation/velocities as Axiom attributes and then once a minute start up a coiterator that goes through all the items on the server and calls a method on them that would cause the bodies to do something like self.position = self.odeBody.getPosition(). Does that seem like a reasonable solution? I don’t know Axiom nearly well enough to say if that would be fast and not dumb.

November 2, 2007

So simple, it must be right!

Filed under: Uncategorized — SirGolan @ 2:03 pm

I just figured out how to handle collisions between areas with separate coordinate systems. Give gateways their own physics space. Whenever a body gets near the gateway, it adds colliders in that space. After checking collisions in the area, all the bodies in the gateway space are translated through the gateway, and then the gateway space is checked for collisions against the gateway’s destination area. Then just translate the bodies back out of the gateway afterward. They’ll have all the correct collision info generated, and it should be a pretty quick collision detection. Changing the positions and back is a little annoying, but I really think this is the absolute best way to handle it.

November 1, 2007

Hello Nevow Web

Filed under: Uncategorized — SirGolan @ 7:53 pm

So, it took under 30 minutes for me to follow the tutorial for hello world here. Would have been much faster, but that is a fairly outdated tutorial. Mostly the issue is that twistd has changed a lot. Here’s what I ended up with for the twistd plugin code if anyone is interested:


from zope.interface import implements

from twisted.plugin import IPlugin
from twisted.application.service import IServiceMaker
from twisted.application import internet
from twisted.python.usage import Options

from nevow import appserver

import helloworld

class HelloOptions(Options):
    """
    Command-line options for the web server.
    """

    optParameters = [
        ('config-file', 'c', None, 'The file to load configuration from.'), ]

class HelloWorldPlugin(object):
    """
    The plugin that starts the website
    """
    implements(IServiceMaker, IPlugin)
    tapname = "helloworld"
    description = "hello website"
    options = HelloOptions

    def makeService(self, options):
        self.site = appserver.NevowSite(helloworld.HelloWorld())
        self.webServer = internet.TCPServer(8080, self.site)

        return self.webServer

thePlugin = HelloWorldPlugin()

With that finished, it’s off to the ‘hello Axiom-world’. But first, some MV3D stuff.

I’ve been doing a lot of refactoring, reformatting, and re-testing of code. I started changing things up so that instead of inheriting from something like odeObject in order to be an object in a 3D environment that has a physical representation, I’m adding Body classes that handle physical and visual representations. This way, those can just get sent to the client as they will have no data in them that the client should not see.

Right now, there is a FastObject3D class that you can inherit from that basically aggregates its position updates and queues them for all objects going to a connection. The queue will drop updates if there are too many, and updates sent to the client are thinned down by a few factors such as distance between the PC and the object that is moving. This was a direct result of the load testing I did a while back with thousands of objects. The load ended up not being the physics engine once I got things straightened out there, but instead, it was in serializing all the updates to send them down the wire. I’m thinking that I’ll move FastObject3D’s logic to the Body classes more or less, and then add some extras to it. One thing I’d like to do to make user experience better is whenever there is a position/rotation update that is significantly different from what the position/rotation is on the client, the client will average that in over a few frames to make it less jerky. I’ve put in some thinking on a related subject of “the client is usually right about where he’s looking,” but I’m still not ready to make a decision on that one yet. The other thing I may add in if I get really fancy is to have the update queue send info to clients/other servers over UDP as just a stream of bytes. That could speed it up even more. Though right now, I don’t really have speed or bandwidth problems, so that would be a premature optimization, imho.

One more thing to mention about the Body classes. They need to handle collisions between objects in adjacent areas that have different coordinate systems. To explain, MV3D has areas, which don’t have a size or a position (except OctreeArea since Octrees require it). You can connect areas with gateways, and one thing you can do with gateways is specify a translation or rotation for any object that passes through the gateway. This is absolutely essential since MV3D uses floats instead of fixed point. Without it, as you got further away from (0,0,0), the accuracy of the physics will get worse because of how floating point numbers work. Anyway, now there is no need to extend things very far from (0,0,0). Just make a gateway at (0,0,10000) that goes to (0,0,0) in its destination. Anyway, this brings about an interesting challenge when an object is on the border between two areas that are in different coordinate systems. The physics engine only understands one coordinate system. Currently, only Bipeds can handle collisions between areas in different coordinate systems. They do it by creating duplicate physics bodies in each area near their position. This works, but is not very efficient and also causes some strange artifacts when passing between areas. It’s not efficient because the “main” body has to update the sub bodies positions every frame. I’ve tried just adding colliders in the other areas, but that doesn’t hold up if the object rotates (because they act like two objects connected by a very long pole). The same thing if I create two bodies and use a joint to keep them in sync. Basically, I’m not sure how best to handle this, and it is fairly important. I need to figure this out before I can move on basically, but at least with Bodies, it’ll be all kept in the same place.

What’s next after I get all of that working? I’ll have to yank out 90% of all the currently created objects’ code and replace it with Bodies. That will be fun. Then, well I think I want to create a new object using Bodies to see if it is sufficiently painless. I’m thinking of making a sword object that is modular and is derived from three models so that I can make a random sword generator (after making multiple blades, hilts, and guards). From there, I’d like to do some more load testing, some refining of the world editing tools, and lots of other things. I really need to get v0.4 out the door though, so I’ll have to draw the line somewhere.

All these changes have been taking a while to make because other than not having much time to work on them, I’m also reformatting modules that use the old formatting style, switching all unit tests to trial, adding unit test coverage where there is none, and refactoring quite a bit. More later.

Powered by WordPress