Game Development Community

T2DShape3D DSQ xbox problem

by David Horn · in Torque X 2D · 07/14/2009 (10:31 am) · 9 replies

I am loading in a T2DShape3D object and trying to load in a dsq file containing an idle animation called "stand"

It works fine on the PC, but not on the xbox. the model is there, but the animation is completely ignored.

here is my code

T2DShape3D shape = new T2DShape3D();
            shape.Name = "Player";
            String _shapeFile = @"data/shapes/testguy.dts";
            if (File.Exists(_shapeFile))
            {
                FileStream fs = new FileStream(_shapeFile, FileMode.Open, FileAccess.Read);
                ShapeReader reader = new ShapeReader();
                Shape dtsshape = reader.ReadShape(fs);
                fs.Close();
                FileInfo fi = new FileInfo(_shapeFile);
                dtsshape.FilePath = fi.DirectoryName; 
                dtsshape.FilePath = dtsshape.FilePath.Replace(TorqueEngineComponent.Instance.ExecutableDirectory + @"", string.Empty);
                shape.Shape = dtsshape;


            }
            else
            {
                Assert.Fatal(false, string.Format("Specified shape file not found: {0}", _shapeFile));
            }
   
            shape.ShapeScale = new Microsoft.Xna.Framework.Vector3(6);       
            shape.SetPosition(Vector2.Zero, true);
            shape.Rotation2 = new Vector3((float)(Math.PI * 50) / 180, (float)(Math.PI * 90) / 180, (float)(Math.PI * 90) / 180);
            Vector2 p = new Vector2(21.0f, 20.0f);
            shape.Position = p;
     
            shape.Layer = 0;

            String ani = @"data/animations/stand.dsq";

            String aniName = "stand";
            shape.LoadSequence(ani, aniName);  
            shape.AddThread("stand", "stand", true);
           

            TorqueObjectDatabase.Instance.Register(shape);
            shape.SetSequence("stand", "stand", 0.0f);

Please, can anyone help?

#1
07/14/2009 (11:04 am)
I'm going to make the assumption that you need to load up the DSQ file as read only just like how your loaded your DTS file.

If you have the torqueX 2D source code you could probably change it in the engine.

Nice work around for the DTS file loading btw. It'll fix one issue I have with T2DShape3D.

If you want to see if it's a read only file issue, set a break point where the dsq is loaded up and debug on the 360. It should throw an exception when it gets loaded.
#2
07/14/2009 (12:28 pm)
2 questions, David. Thanks for responding btw. Glad this code could help you out.

1. There is something in that ShapeReader called ImportSequence, but I don't know whow to use it. Would I need to use a different FileStream for every dsq animation? or is there some way to load all of them when I instantiate the dts shape somewhere near line 13? any sample code would be tremendous.

2. stupid question, but... debug on xbox? you can debug on xbox?
#3
07/14/2009 (2:07 pm)
1) Haven't looked at the shapereader but I'll take a look when I get home.

2) Just set a break point in your code, and right click on the xbox 360 project within your solution and click debug. Of course make sure your xbox 360 is on and the creators club app is running.

It'll deploy your game and begin running it till it hits the break point. The 360 only allows read only from data unless you setup a special file, for saving etc. The exception that gets thrown by trying to access files for read/write though is swallowed by your app and allows it to keep running.
#4
07/14/2009 (4:21 pm)
1. That would be appreciated - I've tried a couple ways and nothing works.

2. Wow - I just tried that - works like a charm! very useful - thanks!
#5
07/15/2009 (2:07 am)
I tried looking at how to load dsq manually but I'm as in the dark as you are about it. With the source code it'd be easy.

But anyways, just to make sure the problem is from not opening the file with read only access. Debug your game and if you see System.UnauthorizedAccessException in the output then that's your problem.

Oh and on line 12 you have a tiny mistake in your source code

dtsshape.FilePath = dtsshape.FilePath.Replace(TorqueEngineComponent.Instance.ExecutableDirectory + @"\", string.Empty);
#6
07/15/2009 (2:29 am)
Hey David do you happen to know the best way of cloning a T2DShape3D. Does the clone() function work correctly?

The way I currently have mine, it has to open the DTS file every time the model clones itself, and that is a big slowdown on the 360.
#7
07/15/2009 (6:28 am)
Couple things.

1, thanks for the correction

2, I didn end up getting it to work late last night.

here is the code if you need it, this is the revised if statement in the above code...

if (File.Exists(_shapeFile))
            {
                FileStream fs = new FileStream(_shapeFile, FileMode.Open, FileAccess.Read);
                ShapeReader reader = new ShapeReader();
                Shape dtsshape = reader.ReadShape(fs);
                fs.Close();
                fs = new FileStream(@"data/animations/stand.dsq", FileMode.Open, FileAccess.Read);
                Shape dsq = reader.ImportSequence(fs);
                
                FileInfo fi = new FileInfo(_shapeFile);
                dtsshape.FilePath = fi.DirectoryName;
                // remove executable directory so that path is relative to it   
                dtsshape.FilePath = dtsshape.FilePath.Replace(TorqueEngineComponent.Instance.ExecutableDirectory + @"", string.Empty);  
                shape.Shape = dtsshape;
                

            }



finally, no I've never tried to clone. I'm making a wrestling game. Right now, I'm concentrating on the "create-a-wrestler" feature. Once I get into gameplay, I'll probably not use the clone feature. I'll just make new T2DShape3D like I've done above. Just give them different names. I do know that they do have to be decently low poly. hopefully I won't run into problems with several wrestlers on-screen at once.
#8
07/15/2009 (8:16 am)
Well they don't have to be as low poly as you might think. I use the robot from the FPS demo example for testing. My laptop PC easily handles 30+ of them on screen with animation and collision with each other.

I'm currently trying to test how the 360 will handle but whenever it has to read the DTS file to create a new model there's about a one second pause incurred.

Also for T2DShape3D objects their Layer property is a little picky. Like a layer 3 may overlap a layer 0, but a layer 0 may overlap a layer 5. Very odd stuff.

I've found that a good layer gap will yield good results.
#9
07/15/2009 (10:21 am)
That's good to know, because all of my wrestlers will be on one layer with the Y value determining the order.

Now I'm getting strange results while changing the material. I have a face, which I can change to other textures without problem. However I do the smae process on something else like the chest, and all of a sudden, it completely erases the UV map.

I'd love it if GG would add a little to these T2DShape3D classes. lighting, bug fixes, etc.