Tag Info

New answers tagged

0

A transformation matrix has two functions: It can move and rotate a vector. We need one vector that we transform a little. Let's call it positionRelativeToA. We can transform this vector to the global world coordinates as follows: Vector positionAbsolute = positionRelativeToA * transformA; Of course, we can do the same with B: Vector positionAbsolute = ...


1

If you're using a tilemap, this transition is fairly easy to do. You will probably already have some sort of camera class. The thing is you only move the camera when the player reaches the edge. Suppose your screen is 20 tiles wide and 10 high, the camera shows 0, 0 to 19,9. If the character reaches the border of tile 19-20 set the camera to a 'transition ...


1

This is a floating point issue and yes, you will get artifacts at very large values. The reason is because as the size of the value to the left of the decimal in a floating point number increases, you lose precision on the right side (and vice versa). The fix is to change your point of origin so that your offset positions are always within an acceptable ...


0

So just to answer my own old question. I had already done what I was asking for in my prototype, and found my solution when looking back in my git repository. Only thing missing from the previous code was the division by 2 of the position in the transform Vector. public Vector2 Worldposition(Vector2 position) { float ViewportWidth = 720; float ...


0

In order to do this you need to simulate inertia. This is how I would recommend doing it: class Ship { public Vector2 Pos; //Current ship position public Vector2 Vel; //Store current velocity as a vector public float Rot; //What direction the ship is facing in radians public float Accel; //Maximum acceleration public float MaxSpeed; ...


0

Okay so the answer was rather simple, should've thought about it earlier, in order to give a correct origin you'll need to get the world coordinates for it through your original view matrix's transformation. transform2 = Matrix.CreateTranslation(0, 0, 0) * (rotation * Matrix.CreateScale(new Vector3(1, 0.75f, 0)) * ...


1

For future reference: I solved this problem by mirroring everything over the local waterheight instead of a plane. I rendered all that using the standard camera.


1

If anyone could offer any ideas as to 'force' the game to complete the animation first before continuing I would be really greatful. It looks like you haven't implemented any way to tell if the animation is complete. You are using a shooting flag that appears to be a bit confused about it's purpose. The shooting flag gets set when the user clicks the ...


0

Could you post your update loop? I don't immediately see something wrong with the code you posted which causes this behavior so it is possible the problem is somewhere else in your code. Usually you would do something like this when programming a simple physics engine in your game: 1. Update positions of the objects based on their velocity 2. Check for ...


1

After another hour of researching and trying I finally solved the problem. As Shiro suspected it was not the rendering code that causes the problem. I tried it with models from which I know they worked for other projects and they were drawn just fine. So I began to search for issues with the lamp model itself. With the current Blender exporter, there is no ...


0

The return value of ShowDialog is set by altering the value of Form.DialogResult. To ensure that the correct result is set, override the form's OnClosing invocator or hook its Closing event and set it there.


3

1. Creating textured model in Blender First, add a new texture by going to texture panel on the right. Select type "Image or Movie", click "Open" and locate your texture file. Then, move your mouse to the 3d view, press Tab to select the default cube, then press "U" and select Unwrap. Go to UV Image Editor: and select the texture: At this point, the ...


0

I guess it's something wrong with your normal buffer. Render out the normal buffer to screen and make sure it's in view space. (or world if the depth is so)


0

So basically what you want to do is check to see what the scroll position is after a key is pressed, and with an if else statement, check to see whether you should move the background or the character. For example: if (CurrentKeyboardState.IsKeyDown(keys.Right)) { if (BackgroundXPosScroll < BackgroundTexture.Width - CurrentScreenLength - ...


0

It may just be that the sound is not done playing, and you are continually asking it to resume. This could potentially create a delay, depending on your logic. You may want to add a few lines to see if solves your problem: public void Play(SFX effect) { if(!Muted) { switch(effect) { case SFX.ButtonTap: ...


0

I think I know what is wrong. It seems like some of faces in your model have one side. Try to open your model in blender, match three vertices that makes some triangle you cant see and use ctrl + N (in edit mode as far as I remember). It should flip your face, so it would be visible. When I had that that problem I did that with every single face, but there ...


0

I'm not sure what causes this problem completely, but I think that some blender models are just plain not supported well in XNA and the FBX format. This has happened to me before, and my solution was to export the model as STL, upload it to here: https://netfabb.azurewebsites.net/ and import it back into blender and export as FBX. The only downside is that ...


0

Looks like a export setting. Make sure the model is triangulated on export or prior. Also I assume your draw call is set to indices with individual triangles? Might be worth checking if you get TriangleStrips exported.


2

You could draw this using a multiply blendstate. BlendState multiplyblend = new BlendState(); multiplyblend.ColorBlendFunction = BlendFunction.Add; multiplyblend.ColorSourceBlend = Blend.DestinationColor; multiplyblend.ColorDestinationBlend = Blend.Zero; Create a bitmap of a white circle in a black background (mask). The white is the part of the shield ...


0

You only have to find the intersection point in your LineIntersectsLine method. Add something like this last: Vector2 t0 = l1p2 - l1p1; Vector2 t1 = l2p2 - l2p1; Vector2 t2 = l2p1 - l1p1; float dotDPerp = t0.X * t1.Y - t0.Y * d.X; float t = (t2.X * t1.Y - t2.Y * t1.X) / dotDPerp; Vector2 intersection = l1p1 + t * t0;


3

You can do this via masking on the cpu if you prefer to not use shaders yet. You'll need these resources: Spaceship texture (no shield visible, left) Shield texture (only the shield visible, needs to fit the ship, middle) Empty editable Texture (pixmap) that you can draw onto (same size as shield texture, right) Point of impact You can draw your ship ...


0

An easy way to do this would be to use transformation matrices. So you need to define a transformation matrix like so. Matrix transform = Matrix.Identity; Then to create the transformations do something like this but with your values in there. transform = Matrix.CreateTranslation(X, Y, 0f) * Matrix.CreateRotationZ(rotationInRadians), ...


1

XNA's update and draw methods do in fact happen in a single thread. In order to utilize other threads on the machine, or do long running calculations across multiple frames you can utilize C#'s asynchronous function calls. The basic idea is, you start a calculation by invoking an asynchronous function, this function will execute in a new context on the ...


1

First, your entire map needs to be loaded (all "rooms/zones") like a single image. Next, you have a viewport that displays the Zone your in, say 0,0 to 50,50. next, you set collision to if player collides with zoneWallRight start a render loop that will render the map scroll in that direction. (move the view port x,y) at least, this is how I would do it. ...


0

You can draw the polygons easily, if you attach the DebugView from farseer, in your physics simulation. If this is not what you want, you will need to write your own renderer, which is not going to be a trivial task. You could also extend the DebugView from the Farseer library, seeing as it is open source.



Top 50 recent answers are included