• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

Koga73

Member Since 04 Mar 2009
Offline Last Active Mar 07 2013 10:20 PM

translate point set distance towards quaternion

10 December 2012 - 03:26 PM

Hi,
I'm new to quaternions and want to use the resulting rotation matrix to translate a point a towards the quaternion given a set distance.

Without using quaternions or matrices I would do something like this:

public static function calcVector(angle:Number, distance:Number = 1):Vector2D {
var vec:Vector2D = new Vector2D();
vec.x = Math.sin(90 - angle) * distance;
vec.y = Math.sin(angle) * distance;

return vec;
}

How do I mimic this functionality using the quaternions resulting rotation matrix as my "angle" parameter?
Assuming the starting point is at (0, 0, 0) and I have a rotation matrix from a quaternion how do I translate the starting point towards the quaternion with a set distance of say 10 units?
I would like to keep everything in the form of vectors, quaternions, and matrices.

Thanks for the help!

UV Mapping fundamentals

01 September 2011 - 01:30 PM

Hi,

I want to know the math behind how a texture is mapped to a plane using UV coordinates... I've looked online quite a bit but can't seem to find anything about the actual math and logic of how this is done outside of a graphics engine such as OpenGL.

Thanks

sync issues

31 May 2010 - 02:48 AM

Hey,
The game I'm working on is a real-time multiplayer flash game. It uses smart fox server to allow clients to communicate. The game does not run on the server, but rather on the clients and the server just serves as a form of communication between the players. This works for the most part, however I am having sync issues and need to get them worked out. I want to redo the sync system and here is what I am thinking:

-One player "hosts" game.
-Player logs in their game timers sync up
-Whenever a keystroke or action is performed that action is sent through the host to all other players
-When an event is received by another player it is placed into a queue
-When the game time on the local machine hits the time stamp specified on the event in the queue the event fires
-After the event fires the game timer stops and does not start back up until another event is received

Will I have any problems with this? I figured I'd stop the game timer between events because otherwise if an event is received and the local game timer is already past the time stamp, what would I do? And also, concerning overclocked machines... their game timer will be running faster than normal. How will this effect syncing?

Thanks

calc velocity on inclined plane with friction

02 May 2010 - 12:36 PM

Hey, so in a 2d physics engine I have an inclined plane with a frictional value. Along with a "player" that has a mass. The player object will have an initial x and y velocity and hit an inclined plane that has a slope (theta) along with a friction coefficient. 1. How do I calculate the new speed using the initial speed, mass, gravity, friction coefficient of slope, and angle of slope for both the x and y directions over a period of time (delta). (This must work even if the slope is 0°) 2. How does acceleration factor in? You must accelerate down the slope, how is this calculated. Any help is appreciated! Thanks

Reference To Pointer help

04 March 2009 - 05:39 AM

Hey, I'm fairly new to C++ and am having some trouble with the following. I am trying to pass a reference of a class to a function and have that function assign the reference to a pointer. I can't seem to get it to work though.
```
//The pointer I want to assign
Texture *_texture;

//Constructor prototype
Tile(float x, float y, Texture &texture);
};
```
```//The constructor
Tile::Tile(float x, float y, Texture &texture) {
_x = x;
_y = y;
_texture = &texture;
}
```
And, where I am passing in the texture
```void TileMap::setTileMap(){
for (unsigned int i = 0; i < MAP_SQUARE; i++){
for (unsigned int j = 0; j < MAP_SQUARE; j++){
_tiles[(i * MAP_SQUARE) + j] = new Tile(i * Tile::WIDTH, j * Tile::HEIGHT, Texture::_textures[0]);
}
}
}
```
```//In the texture header file
static Texture *_textures[1];
```

PARTNERS