Tag Info

New answers tagged

0

Extensive research on matrix math is often quoted and, probably, gets mostly ignored. You might read and read and read and still never get it. The important thing is that XNA/DirectX/video cards DO get it. Rather than learning how and why they work, you need to learn how and when to use them. In graphic programming, Matrices are primarily used to move ...


0

I also use SpriteBatch to render 2D "hitboxes"; supply values for "_" variables. Rectangle rectangle = _absoluteBounds; if (_drawBorder) { SpriteBatch.Draw(WhiteTexture, rectangle, null, _borderColor, _rotation, Vector2.Zero, SpriteEffects.None, 0.0f); rectangle.Inflate(-2, -2); //<=== border thickness } if (_texture == null) ...


1

I believe all you need for this is some ambient lighting (light that is allways there, even in the dark parts), and a diffuse light. Instead of enabling default lighting, call cubeEffect.LightingEnabled = true; cubeEffect.AmbientLightColor = new Vector3( 0.3f, 0.3f, 0.3f ); cubeEffect.DirectionalLight0.Enabled = true; ...


1

You need a directional lighting. Also disable specular lighting if you want screen position not to matter. This type of directional lighting is achieved by: float lighting = saturate(dot(normal,lightDirection)); But you can enable it in a BasicEffect, too. If you want speculars gone, turn down the material's specular intensity to zero (you can also do it ...


1

This is because the sprite batch hijacks the graphics device's states when you use it. You need to cache them before using the sprite batch and then restore them afterwards. (Or you can set them directly afterwards without caching if you know the ones you want to use.) // cache device states var blendState = GraphicsDevice.BlendState; var depthStencilState ...


0

For: why "width = 2" looks like 80 pixels instead of 2? Pixels are gone in 3d space, but you still use them in your UI canvas. Your distances are in "units". How large something looks depends on if you put the camera 1 unit away from the object or 20, 100, etc.


0

Changes when it was structs were not propagating because things were passed by value rather than reference. This meant that the face culling wasn't applying, and all blocks had all faces culled unless they were freshly-placed. I opted to stick with classes for now, but that was the issue.


0

Try change default Facing value from none to something else. If this value is established for all the blocks you get it just does not change where it should. Perhaps you pass a block as a parameter and change its value Facing inside the method.


0

Please say for what are this variables? public NewPlayer player; public List<NewPlayer> players = new List<NewPlayer>(); And why are you drawing both player an players, but not only players? If I only got the player variable, it draw everything fine, but if I add one player at the list, it doesnt draw any player. Is there anything ...


2

What you want is a skew matrix. XNA has no built-in mechanism for creating one. Fortunately we can write our own: Matrix CreateSkewX(float angle) { Matrix skew = Matrix.Identity; skew.M12 = (float)Math.Tan((double)angle); return skew; } Matrix CreateSkewY(float angle) { Matrix skew = Matrix.Identity; skew.M21 = ...


-1

If you really need to skew image you can write your shader for it. It's got solution if when you need deform image in any non-standard way.


0

You could draw it in 3d. Actually rotate it around the "up" axis. What's actually quite ironic though, is that you're already showing how it could also be done: You could split your sprite in strips vertically, drawing them at a small y offset from eachother. Note however that this skews the sprite, rather than actually rotating it. Not knowing if that's ...


0

Never done anything like that, but as an sugestion: what about the to draw the circle with gradient on each point between lighting parts? This will make the edges smooth, that might not be very much like a real lightning, but no ragged edges.


0

I've had some trouble with this myself. I've never actually found a perfect way to do it, but a* pathfinding with Jump point search should make it possible. Take a look at this: http://gamedevelopment.tutsplus.com/tutorials/how-to-speed-up-a-pathfinding-with-the-jump-point-search-algorithm--gamedev-5818


0

I Googled extensively yesterday and today screwing around with a similar issue. It turns out that, when using SpriteBatch with a custom effect that samples from textures, you must explicitly asign the textures to a register other than 0. effect.Parameters["WorkingTexture"].SetValue(WorkingTexture); SpriteBatch assigns this texture to register 0 ...


0

Expanding Shiro's comment: You could increase the speed the game updates to a higher fixed rate (as long as you know beforehand it can handle that FPS). While this isn't really SOLVING your problem it will at least reduce it's effect. You could either set the FPS to a specific amount: this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 200.0f); //Where ...


0

What you describe here is often called z-fighting, and is a product of the fact that the items have exactly the same depth. Now, while iterating objects to draw, you could check if you've already drawn an object close to it that it might overlap with. You could then set the depthbias of your graphicsdevice's rasterizerstate to make sure they don't flicker. ...


0

Assuming you're using a custom server written in C# with Visual Studio and you have access to the source... Open Visual Studio, and go to your server project Right mouse click on 'References' and then left click 'Add Reference' Switch to the .NET tab, and scroll down to find 'Microsoft.Xnz.Framework' Select it and then click on OK Add 'using ...


0

I guess I found out the problem. Its not the model or camera that is not rotating, the problem is with the terrain. As the only thing I draw is model and terrain, I was basing my vision on the terrain, but when I log the position, its rotating the model and keeping it in the same position, wich is the correct thing to do, so its yaw is correct, the problem ...


0

I'm want to clarify about this line in your camera Update method campos = Vector3.Transform(campos, Matrix.CreateFromQuaternion(player.rotation)); As I can understand you rotate camera with your model. If so you cannot not see rotation. Did you have any other objects in scene to determine that model realy rotated or not? Please add some screenshots with ...


1

Since I misunderstood your question and your camera seems not to be working correctly here is a minimal solution for what you want to achive. (Note this is a bare bones example which uses only what you need) class FollowCamera { public Vector3 offset; public MeshTransform target; public Matrix view; public Matrix projection; public ...


-1

Not a pro at these things but try changing effect.World = transforms[mesh.ParentBone.Index] * worldMatrix; to... effect.World = worldMatrix * transforms[mesh.ParentBone.Index];


1

If I understand right what you are trying to move the camera backwards and upwards relative to the player model. However, in the Z-axis direction XNA ago, that is, you need to set Z coord 100 instead of -100. Or you can do like that: Vector3 thirdPersonReference = Vectro3.Up * 100 + Vector3.Backward * 100; Vector3.Backward has value (0, 0, 1), abd ...


0

You're already using bone transforms. I suggest you read up on bone animation in blender. You can create a chain of bones that represent arms, holding the bat, and animating that in blender. Then just export the model, including the animations, and you can use the bone animation you made yourself. Download blender and follow this tutorial: ...


1

I recently attempted this very thing and the question and answer here got me through it - How can I acheive a smooth 2D lighting effect?. I'll explain it for you though: What this method does is instead of 'tinting' your tiles directly, it draws that 'tinting' color to a new texture (called the LightMap), scaled down to 1 pixel for each tile. Then you draw ...


1

You draw the lighting values into a small gray scale (or color) texture with 1 texel per map tile, enable interpolation, then sample this interpolated texture to tint your tiles. This will smooth out the lighting. Note: doing per-vertex interpolation rather than texture sampling will cause to interpolate over the 2 triangles that makes up the quad and ...


1

Okay, you've done the right thing. To get smooth lighting, all that's necessary is to have a separate brightness for each tile vertex rather than each tile. Then, render the tiles using a series of textured quads. The brightness of each vertex is just the average of the brightness of its neighboring tiles. However, you are using XNA, so in order to do this, ...


1

What you are looking for is called ribbon trail. While a particle trail does the job as well there are a few problems with using particles: missing particles at high speed gpu overdraw effect limited to particle settings However if this effect fits your game better then here is a good tutorial: World of Goo Cursor This porblems were the reason i ...


0

You were right about checking it before it collides but the handling collision algorithm you code will not solve it. As it doesn't handle all the case that can occur. Lets say that the player comes and grounded on the top of the platform. Yes the case of: if(Position.Y < OtherObject.Position.Y){verticalPoint = OtherObject.Position.Y - BoundRect.Height;} ...


2

One wav for the whole scene can turn into a big headache if you want to alter the scene later, even a minor one. And if any of the players have a problem during the playback (memory, CPU, bug...etc), the rest of the audio will be asynchronous. Players will skip the scene or close the game without you knowing about that. Which will throw away all your ...


0

Like in your original post, you have one boolean that is set to true only when you change state. like when you click some button in menu. on part where you change CurrentGameState set also stateChanged to true. and this code will be exectuted only once in your update funciton. if(stateChanged){ MediaPlayer.Stop(); switch (CurrentGameState) { ...


0

I have looked into your code and I could see some wrong procedures ( I think , I might be wrong though ) but I will try to look more into it to see what are its problems . However , since your main goal is to stop the rectangles from intersecting each other , I have another way that works well ( mostly ) and I think is more efficient than your algorithm . ( ...


0

You can try allocating an array of pixels composing a bitmap of each getRGB() values of each individual pixel. Than compare the values with an if statement as the borders of the tile are a separate color value than that of what the tile represents(water, sand, grass). That for a basic isometric grid. Or you can have two layers of the map itself. One layer ...


0

Most issues relating to the graphics devices and the SpriteBatch should be fixed in the development branch of the Github repository. If you compile the project, which is very easy, you can use that dll instead of the normal one (or whatever the Mac equivalent of a dll is). In addition, we are very close to porting Monogame to the Xamarin iOS Unified API, ...


2

If the triangle strips, while being disconnected, are all sharing the same material (shaders, textures, shader constants) then you can join them together with a degenerate triangle. Since degenerate triangles have zero area they should not show up. The only case they would is if you are drawing wireframe. You make a degenerate triangle by defining the two ...


4

You could use polygons, or you could do a quick and dirty hack and just get a political map like this one: . Then, pick a unique color for each country and flood fill it in paint or photoshop. Then, you have a simple file that just has the mapping of countries/provinces to particular colors. Just something like this: # Country, #Unique RGB color ...


0

You call the player's Update() function 3 times per Main.Update(), where you probably want to call it only once. Calling it 3 times will presumably attempt to move the player 3 times per frame, only doing a collision test with a single object for each of these three movements, so that each subsequent Update() can move through the previous obstacles in the ...


0

Since it wasn't mentioned in the question (nor the answers) -- the original, and best Game State Management class can be downloaded and learned from here - http://xbox.create.msdn.com/en-US/education/catalog/sample/game_state_management It's applicable in both XNA 4.0 and MonoGame 3.2, Enjoy.


2

Because textures are unmanaged resources, you can not garbage collect them like most objects. Use a ContentManager for this task instead. Once you want to release the textures of a content manager, you should call Unload(); like this: Texture2D apple = Content.Load<Texture2D>("apple"); //Content is the default Content manager //... //When you don't ...


1

AFTER READING EDIT: You cannot change how fast the game will do it's draw calls. What happens is that on a fixed timestep your game will attempt to do one update and one draw call at a steady rate (usually 60fps). If it cannot keep that up for whatever reason then it will lag. On a non-fixed timestep your game will run as fast as it possibly can and you ...


2

This animation is likely a bunch of different colored sprites moving or fading in to follow the path of the trail. Look up particle systems. They let you control many sprites/objects at once easily with a set of rules to define their movement. For this example, you can start with a white circle moving in pre-defined path. Using trigonometric functions is a ...


0

So, you draw all on the render target and after calling gd.SetRenderTarget(null) you need draw your render target on the screen. gd.SetRenderTarget(target); // ... drawing on the render target ... gd.SetRenderTarget(null); // now draw on the screen ... sb.Begin(); sb.Draw(target, Vector2.Zero, Color.White); // ... your rended target sb.End();


3

BoundingBox provides several Contains (MSDN) methods that return ContainmentType (MSDN). To test if an object is outside your bounding box, test for ContainmentType.Disjoint.


2

You need to invert the logic of the test not the box itself. The bounding box can only describe a box. Whether that is a rectangular solid in space or a rectangular hole in infinite space is up to the test performed.


0

All you need to do is first create a mesh and then distort it. Create a mesh that's just a strip of triangles. Texture the mesh using your terrain texture. Deform each vertex of the mesh by using perlin noise. What I mean exactly is this: // Deform a 3D vertex by noise vertex.position.y += Perlin(vertex.position.x, vertex.position.y, vertex.position.z); ...


2

Your question title explicitly states "thousand of quads". That is really not a lot of geometry. I would have to say that unless you expect millions, or are targeting mobile, I suggest going with simple batching to reduce draw calls. It is easiest to implement and should do the job admirably. If you really do need more geometry, read on... Since Monogame ...


1

I am not 100% sure about the Monogame implementation. But, in XNA, what you are seeing is the correct behaviour. One would expect Monogame to be faithful to the XNA implementation. The reason this behaviour exists is that on some devices (Xbox 360, WinPhone) the operations for saving and restoring a backbuffer are slow. So the default is to clear a render ...


0

Do your draw calls for each vertex buffer you set, with the corresponding number of primitives as the third parameter in DrawPrimitives. Calling GraphicsDevice.SetVertexBuffer two times will replace the first vertex buffer. Your draw function should look similar to this: public override void Draw(GameTime gameTime) { basicEffect.World = world; ...



Top 50 recent answers are included