# Insdeath

Member

7

100 Neutral

• Rank
Newbie
1. ## 3D Rotation problem

Thanks for the response. I think I have figured out some things about the quaternion now. However, I would like to - at any given time - extract the rotation axis and angle from this quaternion. Is the following assumption correct? Rotation axis (vector) = (quaternion.x; quaternion.y; quaternion.z); Angle = quaternion.w;
2. ## Online RTS with a persistent world - a basic design issue

Very good point. Then I assume it's best to do the following: At server startup, execute any events that would have been executed during the server downtime, such as unit training, building construction, resource gathering, battles, ..., based on the start time and duration. Thank you very much for your help, I think I can manage my project on my own now. I was unsure about whether my basic design was good or not. Thing is, if my basic design is bad and I base everything off that, then at some point I may have to throw away all my current code and start all over again. I'd prefer not to have that happen
3. ## 3D Rotation problem

Hello everyone! I am currently working on a game which involves moving (and rotating) objects in 3D-space. I have heard (read) a great deal about using Quaternions to represent and calculate rotations in 3D-space. However, after googling for hours I still don't understand at all how they work, let alone how I could use them to represent/calculate rotations. Can anyone point me in the right direction? Maybe some (pseudo)code as to how to work with a quaternion, or a site/tutorial/example where a quaternion is used. All I have read so far are theoretical concepts which I don't understand at all. I know vectors, matrixes and complex numbers, but I still don't understand how this stuff works. Thanks! [EDIT]: I just came across this article on gamedev.net: Do we really need quaternions? In short, it says you might be better off using an axis/angle approach than by using a quaternion. However, I actually tried this, but the problem with that is that I can't manage to make proper calculations. Say I have this: - Current direction vector: (1; 1; 0) - Rotation axis: the x-axis - Rotation speed: 1 radian per second (Location is of no concern to the calculations, since that doesn't change with a rotation) Code example: rotation of the object around the x-axis: double ry = direction.y * Math.cos(rotation) - direction.z * Math.sin(rotation); double rz = direction.y * Math.sin(rotation) + direction.z * Math.cos(rotation); direction.y = ry; direction.z = rz; After one second, this would mean: direction = (1; 0,54; 0,84) So this calculation works. However, I can only calculate the direction when the object rotates around the x-, y- or z-axis. Does anyone know how I can apply this kind of calculations when trying to rotate around ANY axis in 3D-space? For example: the axis (-1; 1; 0).
4. ## Online RTS with a persistent world - a basic design issue

An example of an event is the following: A building is being constructed. I create an event for this which I place in a priorityqueue. This queue handles so-called timed events for me (events which I give a starting time and an execution time). Let's say the building starts being constructed at sept 28, 4PM GMT. The construction takes 20 minutes. So we save that information in the database. However, if the server were to crash in the middle of this event, and is only rebooted say an hour later, then how do I make sure the server doesn't suddenly think the building is already constructed at the moment it reboots? It will think the construction has been finished, based on the starting time and the time it takes to build. I probably need a special frame of reference for this. Maybe an internal clock in the server which only runs when the server runs, and everything is calibrated according to that clock? Thanks for the information about transactions, I'm looking up how exactly those work and I will make sure to integrate this into the server. [EDIT] Someone who works with me and who is responsible for all database-related issues said he knows about transactions and how they work. So we have that
5. ## Online RTS with a persistent world - a basic design issue

Thanks for your quick response. So apparently, there doesn't seem to be any specific, 'special' approach for this kind of games, just following my gut instinct then Concerning the database, what do you mean exactly by Transactions vs Events? I would present Events as following: it has a starting point (the current time in milliseconds as obtained from System.currentTimeMillis()) and the time it takes to complete/start the event (also in milliseconds). However, say the server is down for about one hour, how do I then make sure my event still works properly and isn't desynchronized with the rest of the world data? I'm not exactly sure as to what Transactions are...