Ceres629

I've been trying to do this for the past few days asking many questions to get to this seemingly simple goal, but i just run into problems at every step.

In MDX I just created a mesh object,
then:

myMesh = mesh.Box(...)
or myMesh = mesh.Sphere(...)

In XNA I've had to go through making custom vertex formats, manually drawing all the sides of the box, and now even worse it seems I have to manually input the vertex normals and am STILL unsuccesful...i have no idea if i'm expected to do this for a sphere.

This seems too massive a step back for something that is supposed to be superior to MDX, so I clearly have to be missing out on a key point... I realised MDX is being discontinued and i decided to move on to XNA, but I'm considering just going back to MDX or just openGL because for what I need it to to do it seems far better than XNA which although simplifying many of the more complex aspects of MDX, does a complete reverse in some cases complicating things that were so simple in MDX.

All I want to do is just create a lit colored sphere and cube, i'm frustrated that it is so hard in XNA. If someone can point me to some custom classes that just let me draw a cube or sphere to the screen without having to jump through a ton of hoops I will be greatful.


Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Ceres629

After a lot of reading it seems with the exception of writing my own Model class (which will take me far to long) my only hope is to find someone who has written an equivalent MDX Mesh class in XNA, but i haven't found any yet, so I if noone knows of a user made Mesh class for XNA I guess i have no choice but to go back to using MDX.

Is there anyway to suggest this feature in future versions of XNA As much as I like XNA, the lack of a mesh class means for my personal use, i'm far better off using MDX.




Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Kyle_W

Ceres,

XNA does make a number of things easier such as device and resource management, Windows-Xbox360 cross-platform development, modular game development, and game timing. However, you are correct that there are number of things that you can still do easier in MDX than in XNA currently, but XNA will get better over time. There is an official site for making suggestions for future versions of XNA. If you want to see if your suggestion has already been made (so you can vote for it) or if you wish to make a new suggestion, please refer to the following thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=993586&SiteID=1

Note that many users have actually posted their suggestions as replies on the thread, but if you read what the first post says on the thread, you will see that the proper thing to do is to go to the Microsoft Connect site to submit your suggestion.

With regard to your specific question about creating simple cubes and spheres, one option is that you could create them in the Softimage XSI Mod Tool and then export them as X or FBX files so you can then import them into your XNA game as a model. The Mod Tool is great for creating more complex and interesting objects for use in your games as well. The Mod Tool is a feature-restricted free version of Softimage XSI 4.2, and you can get a link to download it here:

http://msdn2.microsoft.com/en-us/xna/bb219594.aspx





Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Ceres629

I downloaded a piece of software called Blender which is very complex but I somehow managed to get it to produce a cube in a .x file.

I attempted to replace the 3D model in the first XNA tutorial that draws a spaceship on the screen with my cube in .x format from Blender.

although the cube was drawn, the lighting was all messed up...

http://illhostit.com/files/d49e3873f3d93d92aaa30ab586072ded/badlighting.jpg

Its a bit hard to see from a still shot but as it rotated it is pretty clear the lighting is messed up... is it a problem with XNA or is it a problem with the model I made I'm not sure...




Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Kyle_W

I'm not sure there is an actual problem at all. If you are using a BasicEffect to render the cube, then the specular highlight will be calculated only per-vertex not per-pixel, which may account for the straight line edges you are seeing in the specular highlight, especially if each side of the cube is composed of a single quad (two triangles). It also appears that Blender is exporting fairly strong values into the BasicEffect for things like DiffuseColor, SpecularColor, and SpecularPower. You could try getting it to export lower values or you could retrieve the BasicEffect on the Model after loading it and try adjusting the values in code. Also, the shape of the specular highlight will look smoother if you divide each side of the cube into a grid of multiple quads. To achieve the finest level of control over the object's appearance, you should use an HLSL Effect instead of a BasicEffect. One thing you can do with an HLSL Effect is calculate the specular highlight per-pixel. ATI's RenderMonkey is an excellent tool for developing an Effect in a GUI environment, and comes with many samples:

http://ati.amd.com/developer/rendermonkey/index.html





Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Ceres629

Is there anyway to get rid of the specular highlight The app i'm trying to create is extremely simple. It probably doesn't even need any lighting come to think of it.

All i simply need is the ability to draw spheres and cubes of different colours, no fancy lighting, no shaders nothing. XNA makes it easy IF you want to do all these things, but if you don't it makes life a living nightmare! I hate being forced to use shaders because i didn't need to understand them to do 3D programming before but XNA forces it on you.... I guess thats the disadvantage of using an API meant for games.

So I guess mainly for these reasons I think its best I use MDX since I don't have to worry aobut complex things to get the job done.

Thanks for all your help though.





Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Kyle_W

I think you can get rid of the specular highlight by setting the BasicEffect.SpecularPower property to zero. If you don't want to have any lighting, leave the call to BasicEffect.EnableDefaultLighting() out of your code. As a side note, you could also create your spheres and cubes for use in your XNA project by using the Managed DirectX Mesh object to create those shapes and then call Mesh.Save() to save the object as an X file.

With regard to learning shaders, writing complex shaders can be difficult, but learning to implement very simple shaders is not too bad. If you learn how to use a very simple HLSL lighting shader you can just keep using that shader if you don't want to learn any more about shaders.

I'm glad to offer help because I've been through what you are going through and I feel your pain. I still have a lot of learning to do myself. As I said, XNA will get better over time. In the course of my learning both Managed DirectX and XNA, I've had many many "this could be so much simpler than it is" moments. There are plenty of places for improvement. I suppose the guys at Microsoft will get around to it all eventually.





Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Kyle_W

I also wanted to mention that a lot of times you can find freeware libraries that have been developed by people in the community to address certain areas of pain. Just dig around on Google... er I meant Windows Live Search.



Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Ceres629

Thank you for all your help, it is indeed frustrating.. after delving into MDX about a year ago and struggling to get a simple 3D app I needed finally working, I now discover a year later that MDX is being phased out and XNA will replace it, and now i can't do basic things again... and even worse to learn how to those basic things is now 10 times harder, maybe the next time i need to create a quick 3D app XNA will be improved .

Indeed you were right about the lighting, there was nothing wrong with it simply the mesh had too few vertices, i created a detailed sphere in blender and the lighting on that was perfect. But surely a cube should have better lighting than that i turned specular lighting off and it still didn't have any effect...

i will take your advice and make an attempt to learn basic shader effects, and hope i can be productive soon enough to finish my project ontime.

*edit*

I figured out the problem with the cube, Blender was exporting the .x file with vertex normal smoothing, once i unchecked that option, the shading was perfectly fine.

Its taken me a while but learning how to export my own models into XNA was annoying initially but I'm getting the hang of it now... and actually prefer it to the old method in MDX i will tackle pixel shaders at a later on ^^







Re: XNA Framework How to get a lit sphere colored sphere/cube in XNA

Derek Nedelman

A few months ago I released a demo that creates both cubes and spheres in memory and lights them with a single directional light. You might find it useful: http://www.gameprojects.com/project/ id=942a7cc022