Changing the walking plane, help!

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

Hey, I am still busily working on my game, and I just changed my character's walking plane from one horizontal slot to be able to move up and down. This change has screwed up one of my two jump methods because now I don't know where the user starts therefore, I don't know where to make his max point or end point. This wouldn't normally be a problem because I could just make some variables to track their position, here's the problem. First off, if I just use it's y position, as declared in the constructer, it always is just the value it was initalized at. Second, if I try to make a variable and equal it to stabNinja.stickPosition.Y, I get some float to int error. Any idea on how to do this? If this helps at all it is my jumpUpdate method.

         public void updateJump()
        {
            //This will carry out the rest of the jump, and can only be called if the user has started jumping
            if (jumping == true)
            {
                //This carries the user up because he has not reached his max height
                if ((atMaxHeight == false) && (stickPosition.Y > maxJump))
                {
                    stickPosition.Y -= jumpY;
                }

                //This tells the method that user has hit the top of his jump
                if (stickPosition.Y == maxJump)
                {
                    atMaxHeight = true;
                }
                
                //This brings the user back down, it is faster than rising
                if (atMaxHeight == true)
                {
                    stickPosition.Y += jumpY + 1;
                }
                //This is for the user has landed, it sets those booleans false so the method does not continue
                if ((atMaxHeight == true) && (stickPosition.Y >= <b>500</b>))
                {
                    atMaxHeight = false;
                    jumping = false;
                }
            }
        }

 

the bolded 500 is a temporary fix so I can still work on stuff.

 

Read more

Filling up the BoneWeightCollections in a custom importer…

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

Hi! I am writing a custom importer, and I have just reached the point where I want to tackle the skinned meshes.

I have a tree of bones. Each bone has a list of weights. Each entry in this list corresponds to the vertex at the same index. I am running this code on a simple 2-poly test object.

This is my current attempt:

1 private IEnumerable<LwoBone> GetBones(LwoBoneCollection lwoBoneCollection)  
2 {  
3     foreach (var bone in lwoBoneCollection)  
4     {  
5         yield return bone;  
6         foreach (var descendant in GetBones(bone.Children))  
7             yield return bone;  
8     }  
9 }  
10  
11 int[ pointIndices = new int[layer.Points.Count];  
12 BoneWeightCollection[ weights = new BoneWeightCollection[layer.Points.Count];  
13  
14 for (int i = 0; i < pointIndices.Length; ++i)  
15 {  
16     Vector3 position = ToVector3(layer.Points[i])  
17     pointIndices[i] = meshBuilder.CreatePosition(position);  
18     weights[pointIndices[i]] = new BoneWeightCollection();  
19     foreach (var bone in GetBones(layer.Bones))  
20         weights[pointIndices[i]].Add(new BoneWeight(bone.Name, (float)  
21             bone.WeightMap.Weights[i]));  
22     }  
23 }  
24  
25 8< snip >8  
26  
27 // Generate mesh  
28 foreach (var part in parts)  
29 {  
30     meshBuilder.SetMaterial(part.Material);  
31     for (int i = part.FirstIndex; i <= part.LastIndex; i++)  
32     {  
33         PolyPoint point = vertices[i];  
34         meshBuilder.SetVertexChannelData(normalChannelIndex, point.SmoothedNormal);  
35         for (int uvIndex = 0; uvIndex < point.UVs.Length; uvIndex++)  
36             meshBuilder.SetVertexChannelData(uvChannelIndices[uvIndex], point.UVs[uvIndex]);  
37         meshBuilder.SetVertexChannelData(weightsChannelIndex, weights[point.VertexIndex]);  
38         meshBuilder.AddTriangleVertex(point.VertexIndex);  
39     }  
40 }  
41  

Unfortunately, all I get is the infamous "has no weights" exception in the processor. I suspect I simply don't know how this data should be added to the mesh builder.

Looking forward to any responses!

Read more

Problem with rendertarget

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

Hi all,

I have a problem with rendertarget…

I have one shader with one passe. This shader allow us to change the Hue and the brighten of the sprite. So to do this, I have created two rendertargets;

one render target to render our sprite normally and one rendertarget to render the effect. So this work but this is the problem :

I would like to have a background (a static background who doesn't change its color even if the hue or brighten of the sprite change) behind the sprite, but if I change the hue or brighten, the background change its color and I won't that… And if I set no background all texture change its color when I change the hue or brighten.

So if I draw the background in rendertarget, its color will change and if I draw the background before the rendertarget it doesn't draw…

I'm confuse…

How can I do this ?

This is the code :

1 GraphicsDevice.Clear(Color.White);
2
3 #region Spell Texture Render Target (Draw normal)  
4 GraphicsDevice.SetRenderTarget(0, m_rtNormal);  
5  
6 if (m_Texture != null)  
7 {  
8       m_SpriteBatch.Begin();  
9  
10       m_SpriteBatch.Draw(m_Texture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 0.62f,  
11                                        SpriteEffects.None, 1f);  
12  
13       m_SpriteBatch.End();  
14 }  
15  
16 GraphicsDevice.SetRenderTarget(0, null);
17 #endregion  
18  
19 #region Change Hue and brighten of the spell texture  
20 GraphicsDevice.SetRenderTarget(0, m_rtHueBrighten);  
21 GraphicsDevice.Clear(Color.White);  
22  
23 m_TintEffect.Parameters[1].SetValue(Constants.IsFirstTexture ? Hue[0] : Hue[1]);  // Hue of the sprite
24 m_TintEffect.Parameters[2].SetValue(1f);                                          // Normal sprite (1.7 for lighten, -1.7 for darken)
25 m_TintEffect.Parameters[3].SetValue(255);                                         // Opacity of the sprite
26  
27 m_TintEffect.Begin();  
28  
29 m_SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);  
30  
31  
32 m_TintEffect.CurrentTechnique.Passes[0].Begin();  
33 m_SpriteBatch.Draw(m_rtNormal.GetTexture(), Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f,  
34                                    SpriteEffects.None, 1f);  
35 m_TintEffect.CurrentTechnique.Passes[0].End();  
36 m_SpriteBatch.End();  
37 m_TintEffect.End();  
38  
39 GraphicsDevice.SetRenderTarget(0, null);
40 #endregion  
41  
42 m_SpriteBatch.Begin();  
43  
44 if (m_Background != null)  
45 {  
46       for (int y = 0; y < Height; y += m_BkgndSize[1])  
47       {  
48           for (int x = 0; x < Width; x += m_BkgndSize[0])  
49           {  
50                m_SpriteBatch.Draw(m_Background, new Vector2(x, y), Color.White);  
51           }  
52       }  
53 }  
54  
55 m_SpriteBatch.Draw(m_rtNormal.GetTexture(), Vector2.Zero, Color.White);  
56 m_SpriteBatch.End(); 

 

Thanks for help

Read more

Texture2D wasn’t tinted, now it is

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

I changed something somewhere in my code and I can't find it. Now all my Texture2Ds are tinted Color.LawnGreen. This wasn't happening earlier today. I must not understand how to use spriteBatch.Draw or something. Can some help a maroon (me) understand why my textures are colored weird now?

The textures are PNGs. They have transparancy of course and looked great earlier. Not sure what I did…

 

1             App.SprBatch.Begin(SpriteBlendMode.AlphaBlend);  
2                 App.SprBatch.Draw(_TerrainTiles, new Vector2(0.0f, 0.0f), Tile(App.TERR_ROCK_1), Color.LawnGreen);  
3                 App.SprBatch.Draw(_TerrainTiles, new Vector2(264.0f, 264.0f), Tile(App.TERR_ROCK_2), Color.LawnGreen);  
4                 //App.SprBatch.Draw(_TerrainTiles, new Vector2(528.0f, 528.0f), Tile(App.TERR_ROCK_3), Color.LawnGreen);  
5                 App.SprBatch.Draw(textr, new Vector2(792.0f, 792.0f), Color.LawnGreen);  
6  

Line 2 and 3 pull rectangles from a big sprite sheet. The image is correct but tinted whatever Color I include in last param.

Line 5 was a test. It reads texture from Content.Load into "textr" and its still tinted the same.

How do I not tint the images? The last param is not optional.

Thank you! :-)

Read more

How do one create a RTS selection box?

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

The tutorials at the XNA Development: Game development for the masses, somehow doesn't work in XNA 3.0, here.

I followed all the instructions in that tutorial. But I don't know how to get past this part:

 

        protected override void LoadGraphicsContent(bool loadAllContent) 
        { 
            if (loadAllContent) 
            { 
                // TODO: Load any ResourceManagementMode.Automatic content 
 
                //Initialize the sprite batch 
                mSpriteBatch = new SpriteBatch(this.graphics.GraphicsDevice); 
                 
                //Create the Content Manager object to load images  
                ContentManager aLoader = new ContentManager(this.Services); 
 
                //Use the Content Manager to load the Dotted Line image into the Texture2D object 
                mDottedLine = aLoader.Load<Texture2D>("DottedLine") as Texture2D; 
            } 
            // TODO: Load any ResourceManagementMode.Manual content 
        } 

Where the "DottedLine" part, VS 2008 can't find the file. I did put the PNG file, DottedLine.png, inside the "Content" folder, but VS still can't find it.

Awaiting your reply…

If there's a way how to create a real-time strategy selection box, I would love to know how.

Read more

Changing the walking plane, help!

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

Hey, I am still busily working on my game, and I just changed my character's walking plane from one horizontal slot to be able to move up and down. This change has screwed up one of my two jump methods because now I don't know where the user starts therefore, I don't know where to make his max point or end point. This wouldn't normally be a problem because I could just make some variables to track their position, here's the problem. First off, if I just use it's y position, as declared in the constructer, it always is just the value it was initalized at. Second, if I try to make a variable and equal it to stabNinja.stickPosition.Y, I get some float to int error. Any idea on how to do this? If this helps at all it is my jumpUpdate method.

         public void updateJump()
        {
            //This will carry out the rest of the jump, and can only be called if the user has started jumping
            if (jumping == true)
            {
                //This carries the user up because he has not reached his max height
                if ((atMaxHeight == false) && (stickPosition.Y > maxJump))
                {
                    stickPosition.Y -= jumpY;
                }

                //This tells the method that user has hit the top of his jump
                if (stickPosition.Y == maxJump)
                {
                    atMaxHeight = true;
                }
                
                //This brings the user back down, it is faster than rising
                if (atMaxHeight == true)
                {
                    stickPosition.Y += jumpY + 1;
                }
                //This is for the user has landed, it sets those booleans false so the method does not continue
                if ((atMaxHeight == true) && (stickPosition.Y >= <b>500</b>))
                {
                    atMaxHeight = false;
                    jumping = false;
                }
            }
        }

 

the bolded 500 is a temporary fix so I can still work on stuff.

 

Read more

Filling up the BoneWeightCollections in a custom importer…

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

Hi! I am writing a custom importer, and I have just reached the point where I want to tackle the skinned meshes.

I have a tree of bones. Each bone has a list of weights. Each entry in this list corresponds to the vertex at the same index. I am running this code on a simple 2-poly test object.

This is my current attempt:

1 private IEnumerable<LwoBone> GetBones(LwoBoneCollection lwoBoneCollection)  
2 {  
3     foreach (var bone in lwoBoneCollection)  
4     {  
5         yield return bone;  
6         foreach (var descendant in GetBones(bone.Children))  
7             yield return bone;  
8     }  
9 }  
10  
11 int[ pointIndices = new int[layer.Points.Count];  
12 BoneWeightCollection[ weights = new BoneWeightCollection[layer.Points.Count];  
13  
14 for (int i = 0; i < pointIndices.Length; ++i)  
15 {  
16     Vector3 position = ToVector3(layer.Points[i])  
17     pointIndices[i] = meshBuilder.CreatePosition(position);  
18     weights[pointIndices[i]] = new BoneWeightCollection();  
19     foreach (var bone in GetBones(layer.Bones))  
20         weights[pointIndices[i]].Add(new BoneWeight(bone.Name, (float)  
21             bone.WeightMap.Weights[i]));  
22     }  
23 }  
24  
25 8< snip >8  
26  
27 // Generate mesh  
28 foreach (var part in parts)  
29 {  
30     meshBuilder.SetMaterial(part.Material);  
31     for (int i = part.FirstIndex; i <= part.LastIndex; i++)  
32     {  
33         PolyPoint point = vertices[i];  
34         meshBuilder.SetVertexChannelData(normalChannelIndex, point.SmoothedNormal);  
35         for (int uvIndex = 0; uvIndex < point.UVs.Length; uvIndex++)  
36             meshBuilder.SetVertexChannelData(uvChannelIndices[uvIndex], point.UVs[uvIndex]);  
37         meshBuilder.SetVertexChannelData(weightsChannelIndex, weights[point.VertexIndex]);  
38         meshBuilder.AddTriangleVertex(point.VertexIndex);  
39     }  
40 }  
41  

Unfortunately, all I get is the infamous "has no weights" exception in the processor. I suspect I simply don't know how this data should be added to the mesh builder.

Looking forward to any responses!

Read more

Problem with rendertarget

August 31, 2008 by admin · Comment
Filed under: Xbox360 News 

Hi all,

I have a problem with rendertarget…

I have one shader with one passe. This shader allow us to change the Hue and the brighten of the sprite. So to do this, I have created two rendertargets;

one render target to render our sprite normally and one rendertarget to render the effect. So this work but this is the problem :

I would like to have a background (a static background who doesn't change its color even if the hue or brighten of the sprite change) behind the sprite, but if I change the hue or brighten, the background change its color and I won't that… And if I set no background all texture change its color when I change the hue or brighten.

So if I draw the background in rendertarget, its color will change and if I draw the background before the rendertarget it doesn't draw…

I'm confuse…

How can I do this ?

This is the code :

1 GraphicsDevice.Clear(Color.White);
2
3 #region Spell Texture Render Target (Draw normal)  
4 GraphicsDevice.SetRenderTarget(0, m_rtNormal);  
5  
6 if (m_Texture != null)  
7 {  
8       m_SpriteBatch.Begin();  
9  
10       m_SpriteBatch.Draw(m_Texture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 0.62f,  
11                                        SpriteEffects.None, 1f);  
12  
13       m_SpriteBatch.End();  
14 }  
15  
16 GraphicsDevice.SetRenderTarget(0, null);
17 #endregion  
18  
19 #region Change Hue and brighten of the spell texture  
20 GraphicsDevice.SetRenderTarget(0, m_rtHueBrighten);  
21 GraphicsDevice.Clear(Color.White);  
22  
23 m_TintEffect.Parameters[1].SetValue(Constants.IsFirstTexture ? Hue[0] : Hue[1]);  // Hue of the sprite
24 m_TintEffect.Parameters[2].SetValue(1f);                                          // Normal sprite (1.7 for lighten, -1.7 for darken)
25 m_TintEffect.Parameters[3].SetValue(255);                                         // Opacity of the sprite
26  
27 m_TintEffect.Begin();  
28  
29 m_SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);  
30  
31  
32 m_TintEffect.CurrentTechnique.Passes[0].Begin();  
33 m_SpriteBatch.Draw(m_rtNormal.GetTexture(), Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f,  
34                                    SpriteEffects.None, 1f);  
35 m_TintEffect.CurrentTechnique.Passes[0].End();  
36 m_SpriteBatch.End();  
37 m_TintEffect.End();  
38  
39 GraphicsDevice.SetRenderTarget(0, null);
40 #endregion  
41  
42 m_SpriteBatch.Begin();  
43  
44 if (m_Background != null)  
45 {  
46       for (int y = 0; y < Height; y += m_BkgndSize[1])  
47       {  
48           for (int x = 0; x < Width; x += m_BkgndSize[0])  
49           {  
50                m_SpriteBatch.Draw(m_Background, new Vector2(x, y), Color.White);  
51           }  
52       }  
53 }  
54  
55 m_SpriteBatch.Draw(m_rtNormal.GetTexture(), Vector2.Zero, Color.White);  
56 m_SpriteBatch.End(); 

 

Thanks for help

Read more

Bottle Rocket (Blu-ray) - Criterion Collection [Blu-ray] (Blu-ray) newly tagged "blu-ray"

August 30, 2008 by admin · Comment
Filed under: Xbox360 News 
Bottle Rocket (Blu-ray) - Criterion Collection [Blu-ray]

Bottle Rocket (Blu-ray) - Criterion Collection [Blu-ray] (Blu-ray)
By Owen Wilson

Buy new: $39.95
$27.95


First tagged “blu-ray” by Jackie Holsmen “J.G.”
Customer tags: wes anderson, criterion collection, perfect, owen wilson, dvd, blu ray, criterion, luke wilson, bottle rocket, blu-ray

Read more

How do one create a RTS selection box?

August 30, 2008 by admin · Comment
Filed under: Xbox360 News 

The tutorials at the XNA Development: Game development for the masses, somehow doesn't work in XNA 3.0, here.

I followed all the instructions in that tutorial. But I don't know how to get past this part:

 

        protected override void LoadGraphicsContent(bool loadAllContent) 
        { 
            if (loadAllContent) 
            { 
                // TODO: Load any ResourceManagementMode.Automatic content 
 
                //Initialize the sprite batch 
                mSpriteBatch = new SpriteBatch(this.graphics.GraphicsDevice); 
                 
                //Create the Content Manager object to load images  
                ContentManager aLoader = new ContentManager(this.Services); 
 
                //Use the Content Manager to load the Dotted Line image into the Texture2D object 
                mDottedLine = aLoader.Load<Texture2D>("DottedLine") as Texture2D; 
            } 
            // TODO: Load any ResourceManagementMode.Manual content 
        } 

Where the "DottedLine" part, VS 2008 can't find the file. I did put the PNG file, DottedLine.png, inside the "Content" folder, but VS still can't find it.

Awaiting your reply…

If there's a way how to create a real-time strategy selection box, I would love to know how.

Read more

Next Page »