Jump to content
XCOMUFO & Xenocide

Converting Models To Xna


SupSuper

Recommended Posts

I figure this is better off in its own topic.

 

Couldn't get the "click on an x-net entry to show respective model" working though so I'll leave that to dteviot.

In theory, it's simple.

Each entry in xnet.xml has a element, with the name of the model.

In practice, at the moment, it's a bit more complicated.

  • xnet.xml is autogenerated from a data file, so if you decide to update xnet.xml, you also need to update the source file. http://svn.projectxenocide.com/assets/Creative Text Department/XNet/xnetCtFiles.xml
  • The names in the file are currently the locations of the models in the C++ tree. I'd suggest moving the models into separate directories. (e.g. Craft, Facilities, Aliens, Weapons, etc.)
  • Because there's only one 3D model at the moment, XNetEntry.ExtractModel() has code to ignore any model other than the stun launcher. This will need to be removed.
  • The model files are somewhat large. So to keep the downloads small, I've left the models that do export out.
  • Someone might want to look at the files for the aircraft missiles. FOr a simple shape, the files are huge.

Yeah I tried editing the code myself but I couldn't get the code to not load missing models so I dropped it. We might also consider having our own copies of the XML files instead of trying to keep them compatible with both C++ and C# branches. After all, it's pretty unlikely that the files will still work on the C++ branch after all the changing is done, and that way we can optimize them for the C# branch (and finally include them in the project).

 

Anyways here's all the Blender-format models and respective textures (only the basic textures since I dunno how to add the specular/bump/etc), converted and tested: http://supsuper.wurmz.net/stuff/Models.zip

- Assault Rifle

(Avalanche model doesn't have the texture properly set in the Blender file, and I don't know how to fix it)

- Grenade

- Smoke Grenade

- Stingray

- Stun Launcher

- XCAP Cannon

- XCAP Laser

- XCAP Missile

- XCAPS Hover GAIA

- XCAPS Hover Plasma

- XC-1

- XC-33

Link to comment
Share on other sites

I have had a hard time converting models to .x however, I found out XNA also supports FBX and 3d max and maya have great tools to export to FBX, I have tested this (barracks.fbx replaced stunlauncher) and took it well..

 

Also nice that FBX holds textures inside of them insted of having to include them, I will convert all 3d max models and maya models soon.

base.jpg

Edited by Darkhomb
Link to comment
Share on other sites

Anyways here's all the Blender-format models and respective textures (only the basic textures since I dunno how to add the specular/bump/etc), converted and tested:

 

Probably because .x doesn't support specular and bump maps. Only a diffuse map.

 

I have had a hard time converting models to .x however, I found out XNA also supports FBX and 3d max and maya have great tools to export to FBX, I have tested this (barracks.fbx replaced stunlauncher) and took it well..

 

Also nice that FBX holds textures inside of them insted of having to include them, I will convert all 3d max models and maya models soon.

And I've been told that FBX doesn't support animations. That said, for most of the models: facility, weapon, equipement, etc. there isn't an animation anyway.

Edited by dteviot
Link to comment
Share on other sites

Anyways here's all the Blender-format models and respective textures (only the basic textures since I dunno how to add the specular/bump/etc), converted and tested:

 

Probably because .x doesn't support specular and bump maps. Only a diffuse map.

 

I have had a hard time converting models to .x however, I found out XNA also supports FBX and 3d max and maya have great tools to export to FBX, I have tested this (barracks.fbx replaced stunlauncher) and took it well..

 

Also nice that FBX holds textures inside of them insted of having to include them, I will convert all 3d max models and maya models soon.

And I've been told that FBX doesn't support animations. That said, for most of the models: facility, weapon, equipement, etc. there isn't an animation anyway.

 

http://usa.autodesk.com/adsk/servlet/index...&id=8224901

 

FBX Converter

This free, downloadable utility lets you convert OBJ, DXF, and other 3DS files to the FBX file format, and vice versa. This means you can transfer your entertainment, design, or visualization project data from one 3D application to another ? including any professional 3D animation package.

Link to comment
Share on other sites

Anyways here's all the Blender-format models and respective textures (only the basic textures since I dunno how to add the specular/bump/etc), converted and tested:

 

Probably because .x doesn't support specular and bump maps. Only a diffuse map.

Oh well, my only other option was converting to .fbx and those always rendered textureless for some reason. Edited by SupSuper
Link to comment
Share on other sites

Thanks sup, got them all working in xnet... hopfully in the future we will be able to use the spec and bump maps.

 

Might have to edit some of the models because not all of them are centered or on the right axis.. but looking good wish more of the facilities were textured...

 

Shinzon come back!

 

 

edit typo

Edited by Darkhomb
Link to comment
Share on other sites

Thanks

 

I can convert the male armor mesh and female armor mesh as well but I don't think there is a need yet until battlescape comes in play

I want to get the probe ufo converted but it uses an animated texture (.avi) and we can't use that yet it is a very cool effect though

Edited by Darkhomb
Link to comment
Share on other sites

Thanks

 

I can convert the male armor mesh and female armor mesh as well but I don't think there is a need yet until battlescape comes in play

I want to get the probe ufo converted but it uses an animated texture (.avi) and we can't use that yet it is a very cool effect though

I am quite positive that animated texture wont be available as it can hog the videocard, what we can do it take a look at the effect and try to create a shader that looks like that ;)

 

Greetings

Red Knight

Link to comment
Share on other sites

http://rapidshare.com/files/53885514/test2.zip.html

 

 

quick render, if you cant view it ill post an uncompressed version but thats 120 meg

*Snif memories :'(*

Very nice render darkhomb ^_^

 

That's much better than the first video, the one with the UFO taking off was also impressive :D, unfortunately I can't find them anywhere, they may be uploaded on the FTP server

Link to comment
Share on other sites

http://rapidshare.com/files/53885514/test2.zip.html

 

 

quick render, if you cant view it ill post an uncompressed version but thats 120 meg

*Snif memories :'(*

Very nice render darkhomb ^_^

 

That's much better than the first video, the one with the UFO taking off was also impressive :D, unfortunately I can't find them anywhere, they may be uploaded on the FTP server

 

Rapishare ALWAYS tells me "You have reached the download-limit for free-users. Want to download more? Pay!"

I never downloaded one thing there I know about. Sniff.

Link to comment
Share on other sites

http://rapidshare.com/files/53885514/test2.zip.html

 

 

quick render, if you cant view it ill post an uncompressed version but thats 120 meg

Thanks Darkhomb. I agree with kafros, it does look nice.

And I agree with RK, the effect it can probably be done with a shader.

Just don't ask me how.

Maybe the same way waves in water are done?

Link to comment
Share on other sites

Probe doesn't work for me:

Warning 1 Mipmapped texture will not work on all graphics cards. This image is sized 100x200, but many cards do not support mipmapped textures that are not a power of two in size. D:\XenocideSVN\xna\Xenocide\Content\Models\Craft\Alien\Probe.fbm\omh2_0002.jpg Xenocide

Warning 2 Mipmapped texture will not work on all graphics cards. This image is sized 200x200, but many cards do not support mipmapped textures that are not a power of two in size. D:\XenocideSVN\xna\Xenocide\Content\Models\Craft\Alien\Probe.fbm\blueshift.jpg Xenocide

I guess I have one of those graphics cards. Edited by SupSuper
Link to comment
Share on other sites

  • 2 weeks later...

Not having much luck importing the non-Blender models. When it does succeed, only the model gets imported and I don't know how to put the texture in.

 

I also updated the camera for the current X-Net models. I left the crafts and xcaps at a "top" view since I couldn't come up with a fancy perspective for them (ala X-Com).

Link to comment
Share on other sites

Not having much luck importing the non-Blender models. When it does succeed, only the model gets imported and I don't know how to put the texture in.

 

 

What are you using to import them, and which models? keep in mind many do not have textures yet. Almost all facilities do not, I have already exported the barracks/research/laser pistol/laser rifle/probe ship (I fixed the texture but I haven't reexported it yet. When I get back from ohio I will)

Link to comment
Share on other sites

Added. I put the facilities in a separate folder so as to not break the Baseview.

 

Although the facilities are so big they don't even fit in X-Net. :|

 

 

must be something with the new camera code.. i haven't changed the barracks and it used to work a while back just fine...

 

edit.. maybe the scaling code doesn't work correctly, i change the scale manually and it works fine.

 

hmm now the origins are off.. I'm looking into it

 

Edit 2, Think i figured out the problems with origins, there are multiple meshes in the facilities, for example the bench in the barracks, so it uses that for the origin, and the server for the research... is there a way to set the origin to the center of the whole thing?

Edited by Darkhomb
Link to comment
Share on other sites

Added. I put the facilities in a separate folder so as to not break the Baseview.

 

Although the facilities are so big they don't even fit in X-Net. :|

 

 

must be something with the new camera code.. i haven't changed the barracks and it used to work a while back just fine...

 

edit.. maybe the scaling code doesn't work correctly, i change the scale manually and it works fine.

 

hmm now the origins are off.. I'm looking into it

 

Edit 2, Think i figured out the problems with origins, there are multiple meshes in the facilities, for example the bench in the barracks, so it uses that for the origin, and the server for the research... is there a way to set the origin to the center of the whole thing?

Yes, but we may need a custom content processor to handle it. Have a hunt around the XNA forums, on the topic "extracting a bounding box from a mesh"

Link to comment
Share on other sites

There are a lot of tasks where using Custom Content Processors is the way to go instead of putting the loading code in game. So that is probably one of those. You can bind the effects files, the creation of the mesh bounding box, and maybe a couple of other things that may be needed like the floor level so you can create a custom terrain and just use that precalculated information to level down or up the terrain given the house profile.

 

Greetings

Red Knight

Link to comment
Share on other sites

There are a lot of tasks where using Custom Content Processors is the way to go instead of putting the loading code in game. So that is probably one of those. You can bind the effects files, the creation of the mesh bounding box, and maybe a couple of other things that may be needed like the floor level so you can create a custom terrain and just use that precalculated information to level down or up the terrain given the house profile.

 

Greetings

Red Knight

Some links on Creating Bounding Boxes from Models.

 

This one's got a bit about applying bone matrixes to meshparts.

http://forums.xna.com/thread/21468.aspx

 

Getting the vertices from a model. (Both the model itself, and via a ModelProcessor.)

http://forums.xna.com/thread/19266.aspx

 

Has links to Setting up Model Processor

http://forums.xna.com/thread/8856.aspx

Link to comment
Share on other sites

Some links on Creating Bounding Boxes from Models.

 

This one's got a bit about applying bone matrixes to meshparts.

http://forums.xna.com/thread/21468.aspx

 

Getting the vertices from a model. (Both the model itself, and via a ModelProcessor.)

http://forums.xna.com/thread/19266.aspx

 

Has links to Setting up Model Processor

http://forums.xna.com/thread/8856.aspx

 

Possible alternate solution, a custom model.

http://forums.xna.com/thread/25698.aspx

Link to comment
Share on other sites

Some links on Creating Bounding Boxes from Models.

 

This one's got a bit about applying bone matrixes to meshparts.

http://forums.xna.com/thread/21468.aspx

 

Getting the vertices from a model. (Both the model itself, and via a ModelProcessor.)

http://forums.xna.com/thread/19266.aspx

 

Has links to Setting up Model Processor

http://forums.xna.com/thread/8856.aspx

 

Possible alternate solution, a custom model.

http://forums.xna.com/thread/25698.aspx

 

 

Just as a side note, the approach I am taking with the battlescape will actually completely divorce the battlescape from the graphics engine. So I wouldn't be able to take advantage of bounding boxes and so on. It would be pretty cool for line of site. However, I think tightly binding the game rules to the graphics engine is a poor design. If we needed to wring every once of performance out of the engine, then maybe. But for a turn based game, I don't think this will be an issue.

 

-D

Link to comment
Share on other sites

Be careful, cause if you do that you will end up doing duplicated work. Besides more code = more mantainance = more work. If I where you I would try to decouple things that make sense, but Bounding Boxes and all those Math oriented common style is out of the question. There is no plans to move out of XNA so using them is pretty safe.

 

Moreover, the way to go is adding special custom processors that your program can understand, if adding an special Battlescape processor that would create special objects to be used in the battlescape only, there is no reason why you shouldnt do it. Having everything preprocessed and in binary form has 2 very clear advantages, you have typesafety and it is as fast as it can get.

 

Greetings

Red Knight

Link to comment
Share on other sites

Be careful, cause if you do that you will end up doing duplicated work. Besides more code = more mantainance = more work. If I where you I would try to decouple things that make sense, but Bounding Boxes and all those Math oriented common style is out of the question. There is no plans to move out of XNA so using them is pretty safe.

 

Moreover, the way to go is adding special custom processors that your program can understand, if adding an special Battlescape processor that would create special objects to be used in the battlescape only, there is no reason why you shouldnt do it. Having everything preprocessed and in binary form has 2 very clear advantages, you have typesafety and it is as fast as it can get.

 

Greetings

Red Knight

 

Your clearly experienced with code and quite smart. We have some serious differences in style.

 

If duplicating work means ending up with a good loosely coupled design, then I am all for it. I have an almost working battlescape, it doesn't have a lick of graphics code in it. The graphics engine should be able to be pretty simple. Just query each box on the battlescape for whats in it and draw that. Add some callbacks for weapons fire and sounds, and I think we have something workable and maintainable.

 

Less code != easier maintence. Consider obfuscated C as an extreme example. Work for clear, maintainable code will leave you with more code than ignoring it in most cases.

 

"but [decoupling] Bounding Boxes and all those Math oriented common style is out of the question."

 

I don't agree at all. If I can solve those problems simply with a loosely coupled design, whats the problem? I mean, sure it would be nice to be able to use the bounding boxes and some of the other visualizations of the battlescape. But I don't think those benifits are worth the cost of so tighly coupling all the game mechanics to the graphics engine.

 

Tell me more about the "custom processors". I don't know what that would even look like. I do web services and discreet simulations. I am weak on graphics. (Thus my tendency to want to put them in a black box and let someone else worry about them.) But I think you graphics guy kind of have a hammer and you looking at all the game problems like they are nails. I look at this problem and I see the need for a simulation with an interface the graphics engine can understand. Not a graphics engine with game rules built into it.

 

-D

Edited by SaintD
Link to comment
Share on other sites

You deserve a better response but am already late :) so I have to go. So quick reply is better than nothing.

 

Less code != easier maintence. Consider obfuscated C as an extreme example. Work for clear, maintainable code will leave you with more code than ignoring it in most cases.
You are true about it, always remember that I despise ofuscated bad code :) So in equal code quality less code == less mantainance :)

 

I don't agree at all. If I can solve those problems simply with a loosely coupled design, whats the problem? I mean, sure it would be nice to be able to use the bounding boxes and some of the other visualizations of the battlescape. But I don't think those benifits are worth the cost of so tighly coupling all the game mechanics to the graphics engine.
True, but you can create loosely compled designs using common concepts. If concepts are similar then coupling is minimal, and the code binding is small as nothing ;)

 

Tell me more about the "custom processors". I don't know what that would even look like. I do web services and discreet simulations. I am weak on graphics. (Thus my tendency to want to put them in a black box and let someone else worry about them.) But I think you graphics guy kind of have a hammer and you looking at all the game problems like they are nails. I look at this problem and I see the need for a simulation with an interface the graphics engine can understand. Not a graphics engine with game rules built into it.
Those are Content Pipeline, take a look to the documentation about it. There are a couple of pretty interesting examples like a HeightField Processor in creators.xna.com. Just contact me by MSN if you want to talk about it.

 

Greetings

Red Knight

Link to comment
Share on other sites

You deserve a better response but am already late :) so I have to go. So quick reply is better than nothing.

 

I haven't had a chance to do any more work on the battlescape stuff. Hopefully I can get something usable finished up next week before I run out of time.

 

Thanks for the reply. After reading this one and the one before, I don't think we are that far off anymore. I think one you see my design in action it will make total sense to you.

 

I want the following.

  • ecapsulate the game "rules" so the 3d engine is indepentant of them
  • create a one way mapping where the 3d engine consults the rules object (and gets callbacks from it) but the rules don't care at all about the 3d engine.
  • solve the few collision and placement problems in the game with simple cartesien math, rather than hooking into the 3d engine. (Line of site is the big one).

The rules object considers the battlescape to be like a stack of blocks. It keeps track of the objects in the blocks and the walls around them. The graphics engine can then look at each block as a (possible) set of models to draw.

 

I have two problems I would love a little help with.

 

1. Line of site. Given:

Vector3[] blocks = new Vector3[20,20,5];

blocks = fillBlocks(); //files blocks in with whole numbers that indicate the position in 3d grid. 0,0,0 is the northwest most block on the bottom. 19,19,5 is the topmost block in the southeast corner.

 

 

enum WallFacing

{

north,south,east,west,up,down

}

 

struct Wall

{

Vector3 location; //the center of the block, always whole numbers

WallFacing facing;

}

 

private Wall[] LineOfSite(Vector3 origin, Vector3 end)

{

//returns an array of wall structs indicating ALL the edges the line traverses in 3d.

}

 

 

2. PathFinding

a function that given a start and end will find the shortest path (around obstacles) from a to b.

This one is a lot more complicated to set up. The battlescape code has a list of "solid" walls, ramps and untraversable obstacles in 3d.

 

This is going to be one of the biggest problems to solve. XCOM cheats buy stopping when you cross certain terrain boundarries. (a good thing too or I would misclick move a lot more men).

Link to comment
Share on other sites

×
×
  • Create New...