Tag Info

New answers tagged

1

If you have the rotation matrix, I think the the easier is to get the cos between the normals and forget the vertex position. Vector3 VectorUp = Vector3.UnitY; // Now get the VectorUp from world coordinates to the rotated space Matrix inverted = matrix.Invert(RotationMatrix); Vector3 RotatedVector = Vectro3.TransformNormal(VectorUp, inverted ); Vector3 ...


1

Last time I was looking at benchmarks for this (quite some time ago), Texture2D.FromStream was actually faster than Content.Load<Texture2D>. The overwhelmingly slowest part of the process, it turns out, is transferring data from disk. When using Texture2D.FromStream, you can load a PNG or JPEG file. These file formats use image-specific data ...


0

Not a significant one, though this depends a lot on what you're trying to achieve. Keep in mind that Texture2D.FromStream() returns a default format of SurfaceFormat.Color /w non-premultiplied alpha data, whereas with the pipeline you have full control over what you want to do with the texture. The distinguishing feature between the two is flexibility as ...


0

You can calculate the orientations that the die will fall on, then test the current orientation against a pre-computed list of orientations to get the number.


1

Vertices are stored in memory using local coordinates. So no vertex has a "currentPosition," they're always positioned according to their offset from their original origin. In the "world," they are displayed according to some transformation: scale and rotation about their local origin, then translation with respect to the world origin. With the exception of ...


0

There are lots of simple functions to realize those curves. (x^2)*40 - (x/8) + 200 This one grows in a smooth curve since I used x^1.5: (x^1.5)*5 - (x/9) + 200 Play around with the values.


4

Long ago I did the math for different growth functions for an RPG (that I didnĀ“t use in the end). I was playing around with five basic growth curves, as show below. The curves are: Red: Exponential. Grows slowly at the beginning, very fast at the end. Blue: Quadratic. Average growth curve. Black: Linear. Green: Flipped quadratic. Grows more slowly with ...


0

Where did 0.035f come from? I believe your mistake comes from doing (temp%32)/32. If you take a look at it closely, you see that you get values in range 0..31, but you divide it by 32, which gives resulting values from 0 to 0.98675 (0 to 247 in RGB) Correct code would be like so: float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0 { float ...


2

You could use a logarithmic function: Example function: double increment = Math.Log(level + 1); Example output: Level 1 increment: 0.693147180559945 Level 2 increment: 1.09861228866811 Level 3 increment: 1.38629436111989 Level 4 increment: 1.6094379124341 Level 5 increment: 1.79175946922805 Level 6 increment: ...


0

Since these are possible solutions I figured why not ... HP in my experience has always been something that increases very slowly, XP required for next level tends to be the big exponential. I would go with your second example or you could try reducing the 1.17 in your pow call to something like 1.02 for a more gradual increase. You could also consider ...


2

The answer to this question here should help explain how to use the GetData function. Basically, the data is stored in the return array from the GetData call is formed by reading the 2D texture from left to right, top to bottom, transforming it as follows: AAAA BBBB => AAAABBBBCCCCDDDD CCCC DDDD To determine where a given pixel in the 1D array is, we ...


1

Though Fault's comment is correct, what I usually do is to store the rotation and translation and then recreate the view matrix when required. (Full article here). The gist of the idea is: (btw the type of camera you are creating is often referred to as an Arc-Ball camera.) public class ArcBallCamera { public ArcBallCamera(float aspectRation, ...


2

Unfortunately Monogame cannot (yet) generate XNB files so you will need to use the original content builder from XNA 4.0. You can use the libraries from https://msxna.codeplex.com/releases to install XNA on Visual Studio 2012 or 2013, so that you can use it with Windows 8.1.


1

What you want to do is test how far the rectangle can move in a direction, then change it. For example: desiredX += speedX * timeSinceLastUpdate; desiredY += speedY * timeSinceLastUpdate; desiredRect = new Rectangle(desiredX, desiredY, width, weight); intersect = Rectangle.Intersect(desiredRect, collider); collisionWidth = intersect.Width; collisionHeight ...


1

Look again at your else/ifs: regardless of key combination pressed, only ONE direction is saved, because you override them. (the last of them in code) if left/right direction is pressed collision from the other side(right/left) is always assumed. (if (direction == Direction.Right) => move player to left side regardless where he is) quick fix: add another ...


1

You can use Texture2D.GetData() to copy texture pixel data to a Color[] in XNA. Texture2D texture=Content.Load<Texture2D>("asd"); Color[] tcolor=new Color[texture.Width*texture.Height]; texture.GetData<Color>(tcolor); After you have your Color array, you can do whatever you want with it, for example you could change certain colored pixels to ...


1

Perspective shadow maps like that are usually not used to shadow the whole scene, but for a single lamp or flashlight. If you want to shadow the whole scene, You probably don't want to use perspestive shadow maps, but rather orthographic ones (I guess you want shadows from the sun?). When you are creating an othographic matrix (MSDN) you specify its ...


1

Lets see what you're trying to do : you're trying to check if 1 entity collides with N other entities, but I suppose those collide as well. Basically (if I understood you right) you`re trying to do N*N comparisons every frame, or even N. You should, first and foremost, switch your data structure. Use a quadtree, with that, you will have a complexity of ...


4

You should be using layers. That is you have a naked character sprite. On top of that you add layers for hair, armor, gear, weapons. Depending on your actual game, you might do that in generic form, or split in parts or even add skeletal system. For example in Diablo 2 character was split into parts that were combined: Here's another example of ...


3

So as a warning I'm quite rusty with regards to shaders, but lets take a look at the BasicEffect's source code and see how Microsoft did it. Overview of the shader pipeline. Most interesting bits below. For a fog shader BasicEffect utilizes the below 2 components. A vertex shader performs per-vertex processing such as transformations, skinning, vertex ...


0

I read this and thought it would be a fun exercise this morning, so I decided to write this for fun. The implementation is pretty simple, keep adding lines at the end of each other until the last line is outside of the viewable area. The following code will draw a line infinitely going right. As an added optimization, the lines on the left side of the ...


0

You need to convert your cursor position into world position: Vector2 adjustedPosition = Vector2.Transform(touchCollection[0].Position, Matrix.Invert(camera.View)); Then your direction would be: direction = adjustedPosition - toolPos;


3

Keep in mind I had this problem over 2 years ago and I have since moved onto Unity 3D. This is more of a conclusion than a solution. The main problem was that moving the bones did not move the mesh. I used Cinema 4D to model and rig the model and exported as fbx. There are many fbx export options in C4D and I tried many variants with no success. Here are ...


3

This is essentially simple trigonometry. Assuming the center of the screen is your origin (i.e. (0, 0)), then it's pretty straightforward: x = length * sin(angle); y = length * cos(angle); Just insert the proper numbers and you end up with your vertex coordinates.


1

How do I disable texture filtering for sprite scaling in XNA 4.0? This looks like it might be a solution for you. It seems the textures are being sample in such a way that when one pixel on the screen lies between two texture pixels, it's interpolating the colours. You can change it so it uses the closest pixel colour instead. This will look blocky, but ...


2

What you have now is essentially: screenPosition.X -= velocity * 1.0; screenPosition.Y -= velocity * 0.0; You need to explicitly add a Direction variable which is a 2D vector (you are dealing with 2D, right?). Direction = (1.0, 0.0); You might be already seeing my lead. You need to scale Velocity by Direction and add to your Position like so: ...


0

What I would to is set a key to show the hit box. I tend to use F1 and that way when I hit the F1 key all my hit boxes show up as red. In order to get that to work you would create a 1x1 blank texture and : In LoadContent: content.Load<Texture2D>(@"1x1");//or replace 1x1 with where you put the image In Update: KeyboardState ...


1

If you want to continue to draw a line off screen, you need to continually update your code with a point that's off screen. This means that your nextVector method should take the current position of the camera, plus half the screen width plus some buffer amount. Then, whenever your camera moves the buffer amount in the x direction, you update the next ...


0

According to the reference page for GraphicsDevice.DrawPrimitives(), it can throw one of two exceptions - ArgumentOutOfRangeException and InvalidOperationException - and only the former has anything to do with primitiveCount. When you say the error only says "primitiveCount", that's must be the exception's description, while the type is ...


0

I'm not familiar with MonoGame. Have you thought about drawing your parallax background at a reduced resolution to a render texture? Scale the finished render texture up to the original size and render it to the screen. If you create the render texture at half the width and height of the original, you need to overdraw and blend only 25% of the fragments in ...


2

So, first of all, for anyone coming here from search reading your title, I'll answer how to "Cancel a SpriteBatch I've started drawing": Basically: You can't. A SpriteBatch acts like a list of sprites, and that gets send out to the GPU when you call End (or immediately with SpriteSortMode.Immediate). But, unlike a List, there's no Clear method or similar to ...


0

Yes, you can implement your own content manager. http://romsteady.blogspot.com.es/2011/07/use-zip-files-to-hold-your-xna-content.html public class ZipContentManager : ContentManager { private ZipFile zipFile = null; public ZipContentManager(IServiceProvider services, string zipFile) : base(services, "") { this.zipFile = new ZipFile(zipFile); ...



Top 50 recent answers are included