Zulbaric

Hi i have used some of the code from the SkyBoxDemo tutorial to make a skybox in my game. I adapted the code to run with my game but when i debug the game i cannot see the skybox and my model following camera flips round to face the front of the model insted of the back and The Ship model turns weird colors! 



Re: XNA Game Studio Express Invisible Skybox

Joel Martinez

you say this happens only when you debug the game does it not happen when in release mode, or are you saying that it only happens if you hit a break point and step through the code in debug mode





Re: XNA Game Studio Express Invisible Skybox

Zulbaric

I mean it happens when i play the game :) (sorry for the confusion)



Re: XNA Game Studio Express Invisible Skybox

Pocketmnky

Show us the code where you set your effect.View and effect.Projection matricies. The ships model being changed different colors is probably a renderState being set strangely somewhere else in you code and isn't being returned to it's original value




Re: XNA Game Studio Express Invisible Skybox

Zulbaric

my old Projection and veiw matrices were;

effect.View = Matrix.CreateLookAt(cameraPosition, modelPosition, Vector3.Up);

effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),

aspectRatio, 1.0f, 100000.0f);

but they wern't working out. I couldn't get the matrices to work any other way though





Re: XNA Game Studio Express Invisible Skybox

Mike36

Hi Zulbaric:

Your code looks like it's from the SkySphereDemo and EarthOrbitDemo that I created awhile ago. At the time, I didn't have the understanding of world coordinates and object coordinates that I do now, and that may be affecting your game. I'd suggest you take a look at this forum topic: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1212376&SiteID=1. If you're using the camera manager from the demo, the camera looks down the world's Z axis, so -Z is into the monitor. +X is towards the right, +Y is up.

The demo assumes (well, it should assume) that with the above orientation of the camera, the ship's nose is pointed towards the right, the ship's top is pointed at the top of the screen, and the ship's right wing is pointed at you. At the time, I didn't know how the .X processor works- it basically assumes that models coming in use the left-handed coordinate system and it flips the vertices around. I use Caligari trueSpace 7.11 to create my models, and based on my experiments, to get the model oriented the way I want, the model's +X axis points towards its tail, its +Y axis points towards its right wing, and its +Z axis points towards its top. If I do that, and then export the model using left-handed coordinates, then it appears the way I want.

If you go to http://www.spellflight.com/GameModes/EarthOrbitDemo.zip you'll find the latest demo code. skysphere.x, planet.x, and spacecraft.x models all oriented properly according to the above conventions, and you can use the following controls to orient the ship:

W: pitch up.

S: pitch down.

A: yaw left, unless left-shift key is down. In that case, roll left.

D: yaw right, unless left-shift key is down. In that case, roll right.

Also, be sure to reset your render states. I had to change the render states in order to get the textures to look right. Hope this helps.





Re: XNA Game Studio Express Invisible Skybox

Zulbaric

This helped alot thankyou so much, but i still have 2 more dilemas,

one, The star field is only the size of my ship and two, the ship isnt inside the skybox its infront of it, Please have you got any ideas that will bring me back to sanity :)

 





Re: XNA Game Studio Express Invisible Skybox

Mike36

To answer your first question, just before I draw the starfield, I set these properties:

graphics.GraphicsDevice.RenderState.DepthBufferEnable = false;
graphics.GraphicsDevice.RenderState.CullMode = CullMode.None;

That will let me draw the starfield rather large (it is 40 meters in size). When I get ready to draw the model, I set DepthBufferEnable=true and CullMode=CullCounterClockwiseFace. If your drawing code is like the demo, then the ship appears in front of the sphere because the game's draw method is designed to draw the sphere first.

Don't forget to move the sphere to the same location as your camera, if you move your camera around.





Re: XNA Game Studio Express Invisible Skybox

Zulbaric

Wahoo it semi works :) now i am accually inside the sky box and when i turn the star moves but i cant move 360 degrees and my turning system is now messes up when i turn one way it turns for a bit but then starts moving back the other way basically it works exepect for the movment qualities of my ship :( i need to be able to move anywhere in the skysphere other wise my game is ruined also the skyspere just randomly turns without me telling it to!! :( Please help!!! p.s thanks for all the posts so far)

 





Re: XNA Game Studio Express Invisible Skybox

Mike36

I'm trying to understand what you want to accomplish in your code. It looks like you want the camera to follow behind the ship, have the ship move around, and watch the sky sphere rotate as you fly left and right. Is that right



Re: XNA Game Studio Express Invisible Skybox

Zulbaric

That is correct



Re: XNA Game Studio Express Invisible Skybox

Mike36

Well, then you probably want to create a 3rd person camera and have it follow your ship around. For an example, see http://www.spellflight.com/GameModels/GameTest.zip. This is based on your game1.cs file you posted. I modified it a bit to perform the steps described in http://msdn2.microsoft.com/en-us/library/bb203909.aspx. One thing I did differently is modified the skysphere code to let it handle drawing. You might want to check out the changes. Wasn't sure why you pulled the code out of skysphere.cs, unless you couldn't get it to work due to the namespace name (Dreamland) in the class file. Note that I added "using Dreamlad;" to the top of your file. I can also see that I have the wrong default texture on the sky sphere...

Hope this helps.

-Mike





Re: XNA Game Studio Express Invisible Skybox

Zulbaric

Thankyou Everyone who has posted on this topic everyone has been much help now everything works fine!! One last thing though :( To get the feel of moving forward, would scaling the sky box depending on where you are give the wanted illusion

 

Once again thanks all for your time





Re: XNA Game Studio Express Invisible Skybox

Mike36

You wouldn't necessarily have to scale the sky box. You could just move it towards the player a bit as you pour on the speed (and maybe move the camera back a bit as it tries to catch up), then move it back in place as you let off the gas. I originally made the sky sphere thinking space is big, really really big, and you won't see much movement. But it's a game, not reality... have to remind myself that sometimes.

-Mike





Re: XNA Game Studio Express Invisible Skybox

Zulbaric

but wouldnt moving the skysphere make everything go wrong, If the skyphere is always located where the modelPosition is then to alter the skyspheres location you would have to do a sum on the model position vecter which would change were the model is and most likeley dissapear the skybox. Is there an easier way than this :D

-Thanks-