Tag Info

New answers tagged

0

There are lots of simple functions to realize those curves. http://www.wolframalpha.com/input/?i=%28x^2%29*40+-+%28x%2F8%29+%2B+200 This one grows in a smooth curve since I used x^1.5 http://www.wolframalpha.com/input/?i=%28x^1.5%29*5+-+%28x%2F9%29+%2B+200 Play around with the values.


2

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

You might be using a net-like structure, where each gear knows about all gears it is in contact with. When you need to apply a rotation, you pick a master gear that you start with and recursively rotate all its neighbors. If you want an algorithm to find a master gear - there's really none. You just pick gears that has only one neighbor and choose one of ...


1

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

Yes, there are many performance implications to consider even when two objects share the same amount of geometry. Fragments that fail a Z-buffer test will not invoke fragment shaders. The amount of screen-space that the objects occupy will impact performance, as fill-rate is a big deal especially on mobile devices. If you have large triangles that are ...


3

Fly along circular arcs You start at x1, moving in the direction v1 and want to end up at x2 facing in v2, then the shortest path (assuming a finite turning radius, which realistically should be proportional to the square of the velocity) takes you along an arc of radius r1around m1, followed by a straight line segment and then another arc of radius ...


1

I would add some AI (artificial intelligence) checks. A first thing to do would be to check if the distance to travel, in comparison with the distance to the enemy makes sense to apply the Bezier curves. For example, you could make the weight (i.e.: distance from the end point to the control point of the Bezier curve) depend on the distance travelled and the ...


3

First of all: most computer trigonometric functions takes radians as input. Even if the code worked, I am 99% sure it will not rotate by 90 degrees. So if it is that case, try changing it to pi/2. Secondly, if you would rotate by not-multiply of 90 degrees - the code would still produce axis-aligned rectangle (bounding box), NOT rotated rectangle as you ...


1

historically billboards matrix just copy the camera view matrix, and replace the last row with their own world position. the scale can be world-fixed if you want trees or hard stuff. But it can also be screen-fixed for halo effects, in which case you need to scale using the euclidian distance. this can be done in the vertex shader rather than on CPU as an ...


0

Overview So the algorithm is a simple fill algorithm that first finds the number of blocks needed to adequately cover the diagonal. Then it walks along this diagonal is block long increments. At each increment the fill algorithm branches out at both right angles and adds blocks so long as the center is within the box. Also just walked though this with a ...


1

To get the rotated sprites coordinate simply call the getVertices() method. For example: sprite.getVertices()[SpriteBatch.X2] Gets you the X coordinates of the top left corner. The same call but replacing X<number> with Y<number> gets you the Y coordinate. The corner numbers go like this: 2-3 | | 1-4


0

Rectangles are convex polygons which makes this very easy. To test whether a point lies within a convex polygon, check that it lies on the same "side" of all the edges of the polygon. Sketch this out to see how this is only possible if the point is inside. Here's the SO question for this: ...


1

You then have the centers of the BB without having to know the size of it, if your game needs to know the centers more often than the top left then that is preferable. Storing the half vectors is to simplify retrieving the left/right and bottom/top vectors center-halfHeight provides the bottom and center+halfHeight provides the top. Granted all it does is ...


1

Get the object's Normal as vector (X,Y,Z). I guess that will be (0,0,1) in your case. Construct rotation matrix from your angles (e.g. euler-to-matrix or any other "Euler to Matrix" instructions that suit you). Order of rotations is important. Multiply your Normal with Rotation matrix


2

Your code is only sampling the corner texels, so is only valid for a 2x2 filter. Sample all the texels within your filter shape to achieve correct results.


2

Rather than use the legacy D3DXMath, consider using DirectXMath instead Plus you get all the source in the header. This computes the matrix as a row-major, right-handed matrix: inline XMMATRIX XMMatrixOrthographicOffCenterRH ( float ViewLeft, float ViewRight, float ViewBottom, float ViewTop, float NearZ, float FarZ ) { ...


4

The D3DX function D3DXMatrixOrthoOffCenterRH constructs an orthographic projection matrix based on the top/left/right/bottom coordinates of the view volume. Per the documentation, the formula used is: 2/(r-l) 0 0 0 0 2/(t-b) 0 0 0 0 1/(zn-zf) 0 (l+r)/(l-r) (t+b)/(b-t) zn/(zn-zf) ...


0

This seems to get the job done, special thanks to a forum member Entity for this answer: core::vector3df(sin(core::degToRad(rot.Y)), -sin(core::degToRad(rot.X)), cos(core::degToRad(rot.Y))).normalize();


1

You can do the trig functions yourself if you want, but it's a lot easier to use a rotation matrix. In the background it will do the exact same sin/cos stuff, but it's already programmed for you, so why redo it? I'm not too familiar with Irrlicht (or C++), but adapting some code I found on their forums, it'll probably look something like this: ...


0

It is actually very simple, I have this exact thing in my game. I will solve it in a pseudo code manner. Obtain the coordinates of the gun that is firing. var gunPosition; Obtain the coordinates of the target. var targetPosition; Subtract the targetPosition FROM the gunPosition and store it in a new variable. var difference; Now you can either compute the ...


0

Try: position + directon. The method here is called raycasting. IT can be used in various ways. (cannonPosition & cannonDirection are vector2's) Like. vector2 bulletPosition = cannonPosition + cannonDirection * i Just. do: float bulletSpeed = 0.5f; float shootRange = Gun.getShootDistance(); /*(EG: 100)*/ float gravityConstant = 0.1f; float gravity ...


-3

Calculate the angle between the origin of the shot and the mouse position with the arctan2 function.


-1

Without screenshots or an idea about where the origin and target are, and what kind of coordinates you're registering for your mouse, it's really just blind guessing on my side. I think your problem is here: float dirLength= (float) Math.sqrt(dirX*dirX + dirY*dirY); dirX=dirX/dirLength; dirY=dirY/dirLength; You're using distance between ...


2

Say the object is 10 meters above ground. Assume that our dt (delta t) is 1 second. The object goes to the height of 9 meters at the end of the first iteration Here lies your problem. It is true that the velocity at the end of the first iteration is 1 m.s¯¹. However during that time the object has not travelled 1 m. In fact, since the acceleration is ...


1

You may run into trouble if you're writing an algorithm which requires that you compute an optimized position. For example, let's say you had a set of objects, and you were trying to compute the position with the smallest total distance from all of the objects. Just for a concrete example, say we're trying to power three buildings, and we want to figure ...


1

I know this is a pretty late reply but I just thought I should throw it out here for anyone with similar questions. I did econ major undergrad in UC Berkeley too. But after I finish, I wish I did a technical/science/math major because Economics is very general. You have to go to PhD to really make it worth it. Unless, you're planning on going to graduate ...



Top 50 recent answers are included