# Axiverse

Member

769

367 Neutral

• Rank

• Role
Programmer
• Interests
Programming

## Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. ## Calculate the amount of torque impulse needed to get to a certain orientation.

I've been looking more into PIDs, however I'm not sure where to start learning how PIDs are combined in automation. For example, we have both the turning mechanism as well as the acceleration - both affecting how we arrive at our goal but independent on each other. I can implement some logic which attenuates the acceleration by the difference between the heading and the target angle, but I wouldn't know how to extrapolate this if more actuators were involved. I'm sure this is an existing problem, however I don't know what the field is called or what to look for.
2. ## Calculate the amount of torque impulse needed to get to a certain orientation.

Yes, ideally, I would both use angular forces to accelerate and then decelerate. However I feel like figuring out the total angular impulse would be the first step, then I could try and use that to figure out how to accelerate and decelerate angularly to stop at the target orientation. Thanks for the keywords. I've since found these, which look promising. I'll try to read up on them in the morning. https://engineering.stackexchange.com/questions/13960/using-a-pid-to-control-rotation https://www.researchgate.net/publication/322015472_FPGA_based_angular_stabilization_of_a_quadcopter
3. ## Calculate the amount of torque impulse needed to get to a certain orientation.

I’m programming some steering behaviors in 3D and am a little lost on figuring out how to figure out the necessarily torque impulse necessary to match a target orientation. Ive been looking at some boids steering code and it seems like often the orientation is dependent on velocity. I’m trying to implement a space simulation so I want to do steering based on rotational thrust. I’ve tried finding the difference between the two orientations (q2 * q1.inverse()) and then converting that to ruler angles. However I’m not sure that’s completely the same thing. Doing this also leads to some spinning out of control so I haven’t figured out how to try to go to the nearest target and then be able to stop.
4. ## [solved] How to apply local torque to an axis?

Hmm, it seems like the angular velocity is stored in local space in my code. The culprit line was in the integratetransform function. I'm calculating angular position like: angularPosition = (angularPosition * deltaOrientation).Normal(); Whereas bullet has: btQuaternion predictedOrn = dorn * orn0;
5. ## [solved] How to apply local torque to an axis?

Yes. I'm really trying to convert local space torque into global space torque. The code is as follows. AngularPosition (quat).Transform rotates the localTorque by the orientation of the body, which seems to be wrong. /// <summary> /// Applies a torque impulse on the body. Will only cause any angular changes. /// </summary> /// <param name="torque"></param> public void ApplyTorqueImpulse(Vector3 torque) { angularVelocity = angularVelocity + Matrix3.Transform(inverseInertiaTensorWorld, torque) * angularFactor; } public void ApplyLocalTorqueImpulse(Vector3 localTorque) { // This is wrong? ApplyTorqueImpulse(AngularPosition.Transform(localTorque)); } This post seems to suggest that I can just rotate the localTorque vector by the orientation and it should work, however I'm not seeing this to be the case. https://answers.unrealengine.com/questions/495309/applying-torque-in-local-space-on-a-physics-driven.html Full Source: Body https://github.com/AxiverseCode/Axiverse/blob/master/Source/Libraries/Axiverse.Physics/Body.cs Math: https://github.com/AxiverseCode/Axiverse/tree/master/Source/Libraries/Axiverse.Mathematics/Core
6. ## [solved] How to apply local torque to an axis?

I'm writing a physics engine based on bullet. For a body, the angular velocity is stored as a vec3, which is the normalized axis of rotation scaled by the angle. To add global torque, you simply add to this vec3. However, I want to add torque based on the body's local frame of reference. I was wondering how to approach this. The approach that I think is viable is. torquequat = Convert vec3 torque into quaternion. localtorquequat = Convert localTorque into quaternion. globaltorquequat = Multiply localTorque by the inverse of the angular position. combinedtorquequat = torquequat * angularposition.inverse() * localtorquequat. decompose into axis angle and scale axis by angle. This feels incredibly involved for adding a local torque. Are there better alternatives?
7. ## Upload buffer timing - when can they be overwritten?

I'm wondering when upload buffers are copied into the GPU. Basically I want to pool buffers and want to know when I can reuse and write new data into the buffers.
8. ## Open Source Direct3D 12 Game Engine?

@237cookies I'm currently working on building DirectX12 game engine as well, possibly a bit further along rendering 3D models as well as having 2D UI. I'm looking work co-working buddies or collaborators, and would be happy to chat if you're interested. I generally find that it's more motivating if you have others that you can talk to who are working towards similar goals. I've been looking at a lot of game engines, many have abstracted the hardware layer (DX/GL) from the core of the engine itself. For open source Xenko is the one that I've been looking at. DirectX12 samples has their MiniEngine (https://github.com/Microsoft/DirectX-Graphics-Samples/tree/master/MiniEngine) and Unreal engine 4 is open source (you just have to register on their website). In relation to this, I recently posted:
9. ## Game Engine & Server Project / Space Sim like Eve

Hey Everyone, I'm looking for people who would be interested in working on a hobby game engine and server. I'm looking to build a game engine in order to get a good end to end understanding of all the components as well as building a distributed entity-component-system backend as well (think SpatialOS). I'm wondering if there are other proficient developers who are also interested in understanding and building this system from scratch, learning and building on the best practices from existing game engines. I'm open to collaborating on the same engine as well as people working together, but on their own engines as well. I'm open to the general engine being open source as well as possibly providing some compensation depending on the circumstances. In conjunction with the engine, I'm also aiming to build a lightweight space econ/battle simulation game much in the style of Eve Online. I would like this to be developed into release game, though that would be further in the future. My background: I've been in the game dev community for quite a while now, with a pretty broad range of knowledge. During the day I'm an engineer at Google, having worked on large projects at Amazon and Microsoft as well in the past. So experience in large scale systems and projects as well. I have decent background in building scalable and distributed systems as well. Technology stack: C# DirectX 12 via SharpDX Protobuf & GRPC for network Current progress: I have a working renderer which renders obj models via a (primitive) scene graph. There 2D UI framework which is built on top of Direct2D using DirectX11 interoperability layer. Next steps include flushing out the UI system as well as implementing deferred rendering, physics, etc. Interested? I'm partly gauging interest at this point. If you're interested, please let me know what your background and skillsets are as well as what particular areas you're interested in. Thank you! Aaron
10. ## Need Help Choosing Art Style

I agree that the bottom one looks more polished. However I think that's because you only use black for line art in the top screen. I think if you played with the colors in the line art, it could look quite good. Look around at other examples, you'll see that usually it's a dark color, but there are cases where the line art can be a very light color against a dark background, etc. It also can be utilized to give the art more character as well. If you can get that to work, I'd say go with the top, otherwise bottom.
11. ## Spaceship Autopilot to face direction ignoring roll.

So, I've found that PID systems solves for what I'm trying to do. This thread seems to be a pretty good starting point. I'm still trying to figure out do velocity as I'm shooting through the target at max velocity at the moment. https://forum.unity.com/threads/spaceship-control-using-pid-controllers.191755/
12. ## Spaceship Autopilot to face direction ignoring roll.

I'm working on a spaceship simulation and am working on implementing autopilot. Setting the right torque in order to make the ship's heading in the right direction has been tricky. The parts I'm not sure about are how to properly translate the quaternion difference to torque and how to do it ignoring the roll of the ship. When I set the target to a identity quaternion, it seems to align just fine, but anything else, and it goes haywire. The simulation starts with a random quaternion normalized. The steps I'm currently taking are: Compute the target heading (forward is unit Y, I want it to point to unit X, I get {[ 0, 0, -0.7071068, 0.7071068 ]} in xyzw) Compute the delta orientation (I don't know how to tell it to ignore roll or choose the closet roll with this rotation). Covert it to euler. Subtract the current velocity from the euler velocity, The euler velocity is the target we are aiming for. Apply it as torque. Quaternion target = Quaternion.FromVectors(Vector3.UnitY, Vector3.UnitX); //Quaternion.Identity; Quaternion current = Entity.AngularPosition; Quaternion deltaOrientation = target * current.Inverse(); Vector3 euler = Quaternion.ToEuler(deltaOrientation); Vector3 difference = euler - Entity.AngularVelocity; //Quaternion deltaVelocity = deltaOrientation * Quaternion.FromEuler(Entity.AngularVelocity).Inverse(); //difference = Quaternion.ToEuler(deltaOrientation); //Entity.AngularVelocity = new Vector3(); Entity.ResetForces(); Entity.ApplyTorque(difference); // Primary thrusters var heading = Entity.AngularPosition.Transform(Vector3.UnitY); Entity.ApplyCentralForce(heading); base.Step(delta); Console.WriteLine(\$"\tNavigating {euler}\n\tHeading {heading}"); The integration code is based on bullet physics. I think that the angularVelocity is convertable to euler rotation, but I'm not sure. Also generally euler is clamped, which doesn't work here. But since the equations I've come across all seem to expect the clamp, I don't know if it works correctly with unclamped values. float angle = angularVelocity.Length(); Vector3 axis; if (angle < 0.001f) { // use Taylor's expansions of sync function axis = angularVelocity * (0.5f * delta - (delta * delta * delta) * 0.020833333333f) * angle * angle; } else { axis = angularVelocity * ((float)Math.Sin(0.5f * angle * delta) / angle); } Quaternion deltaOrientation = new Quaternion(axis, (float)Math.Cos(0.5f * angle * delta)); angularPosition = angularPosition * deltaOrientation; angularPosition = angularPosition.Normalize();
13. ## D3D12 default to logrithmic depth buffer?

I was trying to debug some zfighting issues in my d3d_12. I was using a depth stencil with the D32_FLOAT format, my camera was set to perspective with near being 0.0001f and far being 20.0f. The camera was 5 units away and the 3d model in question was approximately 1 unit deep. I was experiencing z-fighting issues which I found strange since the camera range was so narrow. When I used the graphics debugger, I found that the depth buffer only used values in the range of 0.9999+ - 1, which seems like a really narrow range given how the camera was set up. Changing the near to 0.01f fixed the z-fighting issues, but the z-buffer is still only utilizing 0.998-1. I thought that depth buffers were linear by default, have they change to logarithmic by default or how is it calculated?

I've gotten pretty far with earth rendering as in the attached picture. I'm looking into rendering stars. I really like how the stars are rendered in elite dangerous but I have no clue how to start working towards this. Has anyone worked on something similar that can give me some pointers on where to start?
15. ## Cutting polygons by a grid.

I'm trying to cut polygons into smaller polygons constrained by a grid. I'm wondering if there's a fast way to do this other than normal poly-poly clipping because I'm dealing with a large amount of points on a comsumer's computer (via javascript).   The application is that I want to cut country boundries by longitude and latitude lines before tessellating them so they don't get clipped by the sphere that they will be matted on. If I don't do this then large triangles will go inside the sphere.