• Advertisement

watermelonChris

Member
  • Content count

    62
  • Joined

  • Last visited

Community Reputation

104 Neutral

About watermelonChris

  • Rank
    Member
  1. [quote name='kauna' timestamp='1329736599' post='4914795'] Hi, perhaps it would help if you showed the vertex declaration for VertexPositionColor and vertex shader code too? Best regards! [/quote] The vertex declaration? I'm assuming it's this line (it's the second line in the SetupGrid() method): gridVertices = new VertexPositionColor[lineCount * 4]; As for vertex shader code.. Uhm what where ?
  2. Model artifacts in XNA from blender

    Are they facing the right way in blender? how do I check? My 'bowl' is actually made from 1 'polygon/wall'. I'll try make another!
  3. Hey guys. I'm stumped with this error 'The current vertex declaration does not include all the elements required by the current vertex shader. Normal0 is missing. It is occuring on this line: graphics.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, gridVertices, 0, 6); I've started a projet from scratch to try narrow down where I'm going wrong but no luck. Basically what I'm trying to do is setup a 'grid'. (All points are calculated in the SetupGrid method). All the calculated vertices seem fine coordinate wise. Here's a copy of them either way:[list] [*]+ [0] {Position:{X:-10 Y:0.5 Z:-10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [1] {Position:{X:-10 Y:0.5 Z:10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [2] {Position:{X:-5 Y:0.5 Z:-10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [3] {Position:{X:-5 Y:0.5 Z:10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [4] {Position:{X:0 Y:0.5 Z:-10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [5] {Position:{X:0 Y:0.5 Z:10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [6] {Position:{X:5 Y:0.5 Z:-10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [7] {Position:{X:5 Y:0.5 Z:10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [8] {Position:{X:10 Y:0.5 Z:-10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [9] {Position:{X:10 Y:0.5 Z:10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [10] {Position:{X:-10 Y:0.5 Z:-10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [11] {Position:{X:10 Y:0.5 Z:-10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [12] {Position:{X:-10 Y:0.5 Z:-5} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [13] {Position:{X:10 Y:0.5 Z:-5} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [14] {Position:{X:-10 Y:0.5 Z:0} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [15] {Position:{X:10 Y:0.5 Z:0} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [16] {Position:{X:-10 Y:0.5 Z:5} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [17] {Position:{X:10 Y:0.5 Z:5} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [18] {Position:{X:-10 Y:0.5 Z:10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor + [19] {Position:{X:10 Y:0.5 Z:10} Color:{R:255 G:0 B:0 A:255}} Microsoft.Xna.Framework.Graphics.VertexPositionColor [/list] [code]using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace DelXnaGrideLine { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; BasicEffect effect; VertexPositionColor[] gridVertices; int gridLineCount; private void SetupGrid(int width, int height, int lineCount, float yHeight, Color color) { gridLineCount = lineCount * 2; gridVertices = new VertexPositionColor[lineCount * 4]; int xDiff = width / (lineCount - 1); int zDiff = height / (lineCount - 1); int xStart = -width / 2; int xEnd = width / 2; int zStart = -height / 2; int zEnd = height / 2; for (int x = 0; x < lineCount; x++) { gridVertices[x * 2] = new VertexPositionColor( new Vector3(xStart + (x * xDiff), yHeight, zStart), color); gridVertices[x * 2 + 1] = new VertexPositionColor( new Vector3(xStart + (x * xDiff), yHeight, zEnd), color); } int halfLine = lineCount * 2; for (int z = 0; z < lineCount; z++) { gridVertices[halfLine + z * 2] = new VertexPositionColor( new Vector3(xStart, yHeight, zStart + (z * xDiff)), color); gridVertices[halfLine + z * 2 + 1] = new VertexPositionColor( new Vector3(xEnd, yHeight, zStart + (z * xDiff)), color); bool bob = true; } } public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); effect = new BasicEffect(GraphicsDevice); effect.VertexColorEnabled = true; effect.LightingEnabled = true; SetupGrid(20, 20, 5, 0.5f, Color.Red); } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio; Vector3 cameraPosition = new Vector3(1, 12, 3); Vector3 cameraView = new Vector3(0.5f, 0.5f, 0.5f); effect.View = Matrix.CreateLookAt(cameraPosition, cameraView, Vector3.Up); effect.Projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 1000.0f); effect.World = Matrix.Identity; effect.CurrentTechnique.Passes[0].Apply(); graphics.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>( PrimitiveType.LineList, gridVertices, 0, 6); base.Draw(gameTime); } } } [/code]
  4. Overlapping sprites with transparency

    Nice graphics! Anyway. One possible solution, you generate another 3 'blocks' yet the places where the overlap now you make half the opacity. You could then check when this situation occurs and hence replace the images with the 'half opacity' areas. That's something I quickly thought up. But having it overlap doesn't look bad at all in my oppinion.
  5. Hey guys I'm getting strange artifacts in my model in xna. The only thing I think could be causing it is the single walled 'bowl' the monkey is in. But it's effecting the face so I'm not sure. It seems to be showing 'behind' vertices and hiding the ones infront. A culling issue? Any ideas? Heres my draw code: [code]Matrix[] transforms = new Matrix[monkey.Bones.Count]; float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio; monkey.CopyAbsoluteBoneTransformsTo(transforms); Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); Matrix view = Matrix.CreateLookAt(cameraPosition, cameraView, Vector3.Up); foreach (ModelMesh mesh in monkey.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.View = view; effect.Projection = projection; effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(monkeyPosition); } mesh.Draw(); }[/code]
  6. Some questions about positioning/matricis/rotations

    Thank you for your reply. "All objects have their own world matrix, which translates, rotates, and scales the object relative to all the other objects in the scene." So I need to create a matrix for each model? Where is the monkey's matrix in this example? Is it creating a matrix automatically? In which case if I were to add a second object/model, how would I modify the below? [code]Matrix[] transforms = new Matrix[monkey.Bones.Count]; float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio; monkey.CopyAbsoluteBoneTransformsTo(transforms); Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); Matrix view = Matrix.CreateLookAt(cameraPosition, cameraView, Vector3.Up); foreach (ModelMesh mesh in monkey.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.View = view; effect.Projection = projection; effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(monkeyPosition); } mesh.Draw(); }[/code]
  7. Hey guys... Can someone please explain to me how the 'world matrix' relates to objects, I understand that a matrix is a equation/formula for translating/rotating/scaling operations. However, a model does not have a 'rotation' vector as far as I can see, so what is the matrix acting/translating on? Wouldeach object/model have it's own world matrix? When you have a model you would like to rotate, should one keep a 'rotationX/Y/Z' variable in radion/degrees? How is the rotation 'state' stored? Second question, I've encountred times when positioning my camera that if I have say the camera position vector3 set as (0, 5, 0), It won't display anytihng on screen. However if I add just a tiny increment to the x/z component the models will show on screen? Why does this happen? Thank you!
  8. XNA Access variables from base class in game component

    Thanks I'll give that a go.
  9. XNA Access variables from base class in game component

    [quote name='Tsus' timestamp='1320612471' post='4881162'] Aloha, You plan to access some member variables of the Game (Microsoft.Xna.Framework.Game) from within a GameComponent, right? There is a property called "Game" at each GameComponent, see [url="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gamecomponent_members%28v=xnagamestudio.40%29.aspx"]here[/url]. That should do the trick. [/quote] Yes, I'd like to access public/private variables of my Game class. I can't seem to access it via Game.speed or game.speed ?
  10. using a dualshock 2 via USB in a C++ program

    I think you need an external library for this. Which probably will be DirectX (DirectInput).
  11. Hey guys. Can someone please inform me how I should be accessing variables from the base game class in a game component? Or should I be passing it via the game component's constructor?
  12. XNA Color in spritebatch

    I've found some code that 'ghosts' an object/sprite. If anyone is interested: http://bobtacoindustries.com/developers/utils/ (It's near the bottom). I've just got one line that I don't get [code]spriteBatch.Draw(previousSceneRenderTarget, Vector2.Zero, new Color(blendAmount, blendAmount, blendAmount, blendAmount));[/code] It's the color part. I don't get what the Color parameter in Draw() does? A colour tint? If we had the blendAmount at 128, it would create a gray colour with half transparency? Why is the white/gray/black ish component needed? The 'trails' left behind the object are in colour just so you know.
  13. XNA General Help

    Hey man, re-welcome to the world of programming . I'd suggest getting more comfortable with XNA before trying to make something a bit complex, it also doesn't help that XNA 4.0 is allot different from 3.0 Anyway there is a 'plane shooter' tutorial to follow on here: [url="http://create.msdn.com/en-US/education/tutorial/2dgame/getting_started"]http://create.msdn.c...getting_started[/url] It's not 3D though. I would really recommend a book though I found this one quite good: [url="http://www.amazon.co.uk/XNA-Game-Studio-4-0-Programming/dp/0672333457/ref=sr_1_1?ie=UTF8&qid=1314280205&sr=8-1"]http://www.amazon.co...14280205&sr=8-1[/url] I'm still pretty much a beginner though, but hoped that helped. Oh and there is a 3D one over here: http://msdn.microsoft.com/en-us/library/bb203897%28v=XNAGameStudio.31%29.aspx But it's written for XNA 3.1.
  14. Why are they not two separate sub categories? They are hardly similar, mainly use a different language. So why keep them as one?
  15. Apply effect to entire screen XNA - flash effect

    [quote name='EJH' timestamp='1314205795' post='4853284'] The simplest way for full screen texture is probably: - a SpriteBatch to draw the "flash" texture - additive blend mode - draw the texture inside rectangle placed at 0,0 and scaled to backbuffer width/height - if you are using layering, put it at the highest layer - scale the color down over time, to fade it out Use the appropriate call from here, which explains the variables you will want to use: [url="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw.aspx"]http://msdn.microsof...batch.draw.aspx[/url] [/quote] And how should I do it so that the 'flash' texture is of a screenshot earlier? By screenshot I mean dynamically created.
  • Advertisement