Multiple textures within a shader

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

Hey, everyone. Having a bit of trouble here.

I'm trying to draw two textures using a single shader, instead of having to use two separate ones. I was under the impression I could change internal shader parameters using the CommitChanges method. Here's my code:

            spriteBatch.End(); 
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); 
            HP.Begin(); 
            foreach (EffectPass pass in HP.CurrentTechnique.Passes) 
            { 
                pass.Begin(); 
 
                HP.Parameters["green"].SetValue(1); 
                HP.Parameters["health"].SetValue((float) pseudoPlayerHealth / playerMaxHP); 
                HP.CommitChanges(); 
                 
                spriteBatch.Draw(Sphere, new Vector2(300, 400), null, Color.White); 
 
                HP.Parameters["green"].SetValue(0); 
                HP.Parameters["health"].SetValue((float)pseudoFoeHealth / foeMaxHP); 
                HP.CommitChanges(); 
                 
                spriteBatch.Draw(Sphere, new Vector2(800, 400), null, Color.White); 
 
                pass.End(); 
            } 
 
            spriteBatch.End(); 
            HP.End(); 
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);  

But, alas, both textures are drawn exactly the same, using the second pair of values for both. The shader handles both green == 0 and green == 1 cases fine when they're done separately.

What's going on?

Multiple textures within a shader

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

Hey, everyone. Having a bit of trouble here.

I'm trying to draw two textures using a single shader, instead of having to use two separate ones. I was under the impression I could change internal shader parameters using the CommitChanges method. Here's my code:

            spriteBatch.End(); 
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); 
            HP.Begin(); 
            foreach (EffectPass pass in HP.CurrentTechnique.Passes) 
            { 
                pass.Begin(); 
 
                HP.Parameters["green"].SetValue(1); 
                HP.Parameters["health"].SetValue((float) pseudoPlayerHealth / playerMaxHP); 
                HP.CommitChanges(); 
                 
                spriteBatch.Draw(Sphere, new Vector2(300, 400), null, Color.White); 
 
                HP.Parameters["green"].SetValue(0); 
                HP.Parameters["health"].SetValue((float)pseudoFoeHealth / foeMaxHP); 
                HP.CommitChanges(); 
                 
                spriteBatch.Draw(Sphere, new Vector2(800, 400), null, Color.White); 
 
                pass.End(); 
            } 
 
            spriteBatch.End(); 
            HP.End(); 
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);  

But, alas, both textures are drawn exactly the same, using the second pair of values for both. The shader handles both green == 0 and green == 1 cases fine when they're done separately.

What's going on?

Celebration (MP3 Download) newly tagged "blu-ray"

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 
Celebration

Celebration (MP3 Download)
By Madonna

Buy new: $0.99
Customer Rating: 5.0

First tagged “blu-ray” by Porfie Medina “Porfie Jr. Medina”
Customer tags: music(2), blu-ray(2), the, madonna celebration new song pop greatest hits, mtv, celebration, most successful female recording artist, porfie, madonna, madonna celebration, dvd

PhysX and TriangleMesh

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

I write next code:

            ModelMesh mesh = model.Meshes[0];

            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            int countTr = mesh.MeshParts[0].PrimitiveCount;
            int countVert = mesh.MeshParts[0].NumVertices;// / 3;
            int countInd = countTr;// *3;

            Vector3[] vertices = new Vector3[countVert];
            int[] indices = new int[countInd];

            mesh.VertexBuffer.GetData(vertices);
            mesh.IndexBuffer.GetData(indices);

            TriangleMeshDescription triangleMeshDesc = new TriangleMeshDescription();
                triangleMeshDesc.TriangleCount = countTr;
                triangleMeshDesc.VertexCount = countVert;

                triangleMeshDesc.AllocateTriangles(triangleMeshDesc.TriangleCount);
                triangleMeshDesc.AllocateVertices(triangleMeshDesc.VertexCount);

                triangleMeshDesc.TriangleStream.SetData(indices);
                triangleMeshDesc.VerticesStream.SetData(vertices);

            MemoryStream s = new MemoryStream();

            Cooking.InitializeCooking();
            Cooking.CookTriangleMesh(triangleMeshDesc, s);
            Cooking.CloseCooking();

            s.Position = 0;
            TriangleMesh triangleMesh = core.CreateTriangleMesh(s);

            TriangleMeshShapeDescription triangleMeshShapeDesc = new TriangleMeshShapeDescription()
            {
                TriangleMesh = triangleMesh,
                Flags = ShapeFlag.Visualization
            };

            ActorDescription actorDesc = new ActorDescription()
            {
                BodyDescription = new BodyDescription(10.0f),
                GlobalPose = Matrix.CreateTranslation(0, 0, 0),
                Shapes = { triangleMeshShapeDesc }
            };

            actorDesc.Shapes.Add(triangleMeshShapeDesc);
            actor = scene.CreateActor(actorDesc);

but here

Cooking.CookTriangleMesh(triangleMeshDesc, s);

Error: Attempt of reading or record in the protected memory.

Sorry, I not freely speak on English. (i'm from Russia)

Help me!

‘We Were De-Splendored’

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 
Posted By:Jane Wells

1ad2d_madoff_ruth.thumb We Were De-Splendored

As the trustee representing victims of Bernard Madoff seek tens of millions of dollars more from his wife, Ruth, Madoff victim Nancy Barrie-Chivian tries to, well, at least laugh a little in the face of despair.   4408c_more-bullet We Were De-Splendored Read More
Sectors:Media

Advice on Octree and collision with Model Mesh

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

Hi Guys!

I need some advice and some pointing in the right direction.
I have a model that I am using as terrain. I can't use heightmaps. I would like to implement collision detection with said model. I saw an article on Ziggyware XNA Splitting Octree Sample With 3D Collision Response which worked amazingly well! So I thought I would try to implement something like that (although Ziggys is pretty hard to get my head round).
I have used the TrianglePoint content pipeline to attached the vertex information in tags to the model at build time. I also create a bounding box around the mesh. Now comes the bit were I am getting a little confused.
I need to implement a simple octree. What I am planning on doing is first getting the vertex information from the tag of the model and creating a poly structure to hold every polygon.
public struct Poly 
   public Vector3[] verts; 
   public Poly(Vector3 v1, Vector3 v2, Vector3 v3) 
   { 
        verts = new Vector3[3]; 
        verts[0] = v1; 
        verts[1] = v2; 
        verts[2] = v3; 
   } 

I loop through the vertices 3 at a time creating a List<Poly> of polygons.
Now comes to distributing the octree. I thought you would first check each nodes containingPoly list and if its greater than the maxPoly, split the node. Next I need to determine what polygons are in this node. As every node has a bounding box I was thinking of checking if the bounding box contains a polygon however I have no idea how to do this. 
What I want is determine what polys are inside the node, remove them from the nodes poly list and add them to the child nodes containingPoly list. Any clues how I could do this? Also, in Ziggys article, any poly that overlaps two nodes he splits. Is that really necessary? I thought you could just add the poly to both nodes lists. Not the most efficient way but simplier? 
Am I kind of on the right track?? Any idea how I can determine if a poly struct is contained within the nodes bounding box?
Thanks.

Advice on Octree and collision with Model Mesh

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

Hi Guys!

I need some advice and some pointing in the right direction.
I have a model that I am using as terrain. I can't use heightmaps. I would like to implement collision detection with said model. I saw an article on Ziggyware XNA Splitting Octree Sample With 3D Collision Response which worked amazingly well! So I thought I would try to implement something like that (although Ziggys is pretty hard to get my head round).
I have used the TrianglePoint content pipeline to attached the vertex information in tags to the model at build time. I also create a bounding box around the mesh. Now comes the bit were I am getting a little confused.
I need to implement a simple octree. What I am planning on doing is first getting the vertex information from the tag of the model and creating a poly structure to hold every polygon.
public struct Poly 
   public Vector3[] verts; 
   public Poly(Vector3 v1, Vector3 v2, Vector3 v3) 
   { 
        verts = new Vector3[3]; 
        verts[0] = v1; 
        verts[1] = v2; 
        verts[2] = v3; 
   } 

I loop through the vertices 3 at a time creating a List<Poly> of polygons.
Now comes to distributing the octree. I thought you would first check each nodes containingPoly list and if its greater than the maxPoly, split the node. Next I need to determine what polygons are in this node. As every node has a bounding box I was thinking of checking if the bounding box contains a polygon however I have no idea how to do this. 
What I want is determine what polys are inside the node, remove them from the nodes poly list and add them to the child nodes containingPoly list. Any clues how I could do this? Also, in Ziggys article, any poly that overlaps two nodes he splits. Is that really necessary? I thought you could just add the poly to both nodes lists. Not the most efficient way but simplier? 
Am I kind of on the right track?? Any idea how I can determine if a poly struct is contained within the nodes bounding box?
Thanks.

separate calls to DrawUserIndexedPrimitives ignoring depth information

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

Hello,

I have a series of triangles and lines in indexed vertex buffers that I am drawing. I want the line to be in front of some triangles, but behind others.

To do this, I made sure to specify that it's z-coordinate was between the z-coordinates of the respective triangles. I am rendering using an Orthographic projection.

Here's my drawing code (it is very like the code used in the drawing primitives example):

            device.VertexDeclaration = vertexDeclaration; 
            basicEffect.Begin(); 
            basicEffect.CurrentTechnique.Passes[0].Begin(); 
 
            // Draw whatever the user wanted us to draw 
            device.DrawUserIndexedPrimitives<VertexPositionColor>( 
                PrimitiveType.TriangleList, triangleVertices, 0, triangleVertices.Length, 
                triangleIndices, 0, trianglesAdded); 
 
            device.DrawUserIndexedPrimitives<VertexPositionColor>( 
                PrimitiveType.LineList, lineVertices, 0, lineVertices.Length, 
                lineIndices, 0, linesAdded); 
 
 
            // and then tell basic effect that we're done. 
            basicEffect.CurrentTechnique.Passes[0].End(); 
            basicEffect.End(); 

As it is, the line is always visible on top. When I exchange the two calls to DrawUserIndexedPrimitives, the line becomes hidden behind all the triangles.

How can I fix this?

separate calls to DrawUserIndexedPrimitives ignoring depth information

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

Hello,

I have a series of triangles and lines in indexed vertex buffers that I am drawing. I want the line to be in front of some triangles, but behind others.

To do this, I made sure to specify that it's z-coordinate was between the z-coordinates of the respective triangles. I am rendering using an Orthographic projection.

Here's my drawing code (it is very like the code used in the drawing primitives example):

            device.VertexDeclaration = vertexDeclaration; 
            basicEffect.Begin(); 
            basicEffect.CurrentTechnique.Passes[0].Begin(); 
 
            // Draw whatever the user wanted us to draw 
            device.DrawUserIndexedPrimitives<VertexPositionColor>( 
                PrimitiveType.TriangleList, triangleVertices, 0, triangleVertices.Length, 
                triangleIndices, 0, trianglesAdded); 
 
            device.DrawUserIndexedPrimitives<VertexPositionColor>( 
                PrimitiveType.LineList, lineVertices, 0, lineVertices.Length, 
                lineIndices, 0, linesAdded); 
 
 
            // and then tell basic effect that we're done. 
            basicEffect.CurrentTechnique.Passes[0].End(); 
            basicEffect.End(); 

As it is, the line is always visible on top. When I exchange the two calls to DrawUserIndexedPrimitives, the line becomes hidden behind all the triangles.

How can I fix this?

CodePlex Daily Summary for Friday, July 31, 2009

July 31, 2009 by admin · Comment
Filed under: Xbox360 News 

CodePlex Daily Summary for Friday, July 31, 2009

New Projects

  • DoLines: It is great idea
  • Legend Fakes: A dynamic fake framework. * Easier semantics, all fake objects are just that - fakes - the use of the fakes determines whether they're mocks or st…
  • ManaObject: Learning environment for object oriented programming. Written in C# .NET 3.5, IDE based on Visual Studio 2008 Shell.
  • nPress: nPress is a "port" of WordPress in asp.net Mvc (c#).
  • OneDAL: Simple framework for Data Access Layer. Developed in C#. It is simple, but has high performance. Providing you with strong typed object.
  • Secure Fields: Secure Fields is a solution design to allow the user to set some permission on a list field.
  • SharePoint Solution and Packaging Guidance: WSPSolution is the SharePoint Solution and Packaging Guidance project. The project recommends standards for: building SharePoint solutions in Visu…
  • Silverlight / WPF - Multi Touch: Silverlight / WPF custom controls to enable multi touch gestures and features.
  • Sports Schedule: This DotNetNuke module allows you to display a schedule of sports. Site admin can add and remove sports, tournaments and actual sporting events. Id…
  • SQLSTAT2005: SQLSTAT2005 is a data collection and a data warehouse service based on SQL Server 2005 DMV and DMF performance views and functions. This product wi…
  • StyleCop for CodeRush: Implementation of Micrsoft's StyleCop for Devexpress CodeRush.

New Releases

Most Popular Projects

Most Active Projects

Next Page »