Page 1 of 1

Adding new characters

PostPosted: Wed Apr 09, 2008 4:54 am
by multiverseuser
hello,

I was wondering how to add new characters to the server?
How do clients get this new characters?

A little background on the main python modules would be nice.

thanks,

Re: Adding new characters

PostPosted: Wed Apr 09, 2008 5:20 am
by SirGolan
So, the little demo world that gets created when you use the -i argument to starting the server is all defined in mv3d.server.worldgen. However, that SetupAssets.py file the server downloaded (located in Extern/Group0/ServerSide/SetupAssets.py) defines a bunch of assets. There is one list of assets that are used as player models in there. If you add something to that, it'll be randomly used as a player model in the game.

Creating assets in code is tricky. Basically, you have to tell it that the texture map assets are required by the material, which is required by the mesh file. In addition, the skeleton file is also required by the mesh file. That way it'll load everything hierarchically. Your best bet is to copy one of the other player model asset definitions.

If you locally change SetupAssets.py, it should be fine-- it doesn't currently check to make sure that your version is the same as the one on my server.

To go into things a little further, all assets can have dependencies which must be downloaded before the asset downloads. There are many types of assets. The ones you'll want to concern yourself with for now are probably in the mv3d.resource.ogre3d file. Those specify assets having to do with Ogre such as models, materials and so on. URL asset types are able to be downloaded via http or ftp. Local asset types are expected to live on the user's system already.

Re: Adding new characters

PostPosted: Thu Apr 10, 2008 6:44 am
by multiverseuser
Thanks,

I cleaned up the code for the swordman because it was a little confusing with all the female references.

Code: Select all
        d = newURLImageAsset(ag,
            self.baseUrl + u"Materials/Textures/armored_swordman.tga", u"armored_swordman.tga", u"Body Texture")
        d.addCallback(lambda tta: newURLOgreMaterialAsset(ag,
            self.baseUrl + u"Materials/Scripts/armored_swordman.material", u"",
            u"armored_swordman.material", u"swordman Material", [tta]))
        d2 = newURLFileAsset(ag,
            self.baseUrl + u"Models/armored_swordman.skeleton",
            u"armored_swordman.skeleton", u"swordman Skeleton")
        g = gatherResults([d, d2])
        g.addCallback(lambda res: newURLOgreMeshAsset(ag,
            self.baseUrl + u"Models/armored_swordman.mesh", u"", u"swordman Mesh", [res[0], res[1]]))

        g.addCallback(lambda s: self.playerassets.append({u"models":[s], u"scale":(0.02,  0.02, 0.02)}))


I also added this code for the ninja. It looks good. The mesh needs some tweaking to make it stand
in solid ground. I will use the meshmagic tool to change the offset

Code: Select all
               
        d = newURLImageAsset(ag,
            self.baseUrl + u"Materials/Textures/ninja2.jpg", u"ninja2.jpg", u"Ninja Texture")
        d.addCallback(lambda tta: newURLOgreMaterialAsset(ag,
            self.baseUrl + u"Materials/Scripts/ninja2.material", u"", u"ninja2.material", u"Ninja2 Material", [tta]))
        d2 = newURLFileAsset(ag,
            self.baseUrl + u"Models/ninja2.skeleton", u"ninja2.skeleton", u"Ninja2 Skeleton")
        g = gatherResults([d, d2])
        g.addCallback(lambda res: newURLOgreMeshAsset(ag,
            self.baseUrl + u"Models/ninja2.mesh", u"", u"Ninja2 Mesh", [res[0], res[1]]))

        g.addCallback(lambda s: self.playerassets.append({u"models":[s], u"scale":(0.02,  0.02, 0.02)}))



I didn't have time to work with ninja mesh. I will post the new ninja2 files.

PS I renamed the JPEG and updated the .material files.
I could never remember the name!

Re: Adding new characters

PostPosted: Thu Apr 10, 2008 4:22 pm
by SirGolan
That looks great! As soon as you have the character's feet on the ground, can point me to an updated zip file with all the stuff on it and I'll add it in. It'll be good to have one mesh that I know I can distribute. As I mentioned before, the license on the armored swordsman is a bit unclear.

Thanks,

Mike

Re: Adding new characters

PostPosted: Thu Apr 17, 2008 6:32 am
by multiverseuser
Hello,

I read somewhere that the server loads randomly assets. I have only experienced
the swordman. I'm would like to load more than one mesh.
I would like to test the swordman with the ninjas and robots.

How can I do this?

thanks

Re: Adding new characters

PostPosted: Thu Apr 17, 2008 6:46 am
by SirGolan
If you add the code you pasted above to the SetupAssets.py file, it should choose the ninja every once in a while. For best results increase the number after -n in the server command line. That specifies the number of PCs to create.

Re: Adding new characters

PostPosted: Thu Apr 17, 2008 6:48 am
by SirGolan
By the way, if you re-download SetupAssets.py, it should have this code in it.