tracking head rotation in c# with only using a camera - unity3d

Im curious how you would find how you would find how much someones head rotated using only a camera in c#. I dont know where to start with this so thats why im bringing it up on here.

If I'm understanding this correctly, there would be no simple way of telling how much a head has rotated in unity only using a camera. The only method I could think of would be some OR (optical recognition). My best recommendation would be looking into the rigging of the character to be able to tell, as that has the direct rotational, scaling, and positional values in reference to the character.
Example: This characters bone #3 (which isn't the head, but doesn't directly matter) has been rotated 100 degrees along the X, and -90 degrees along the Z.

Related

Adding up quaternions in a child to parent style

I have been struggling with some rotations maths for a feature on my project.
I am bassicly using a gyroscope input from a phone and combining a touch input in order to recreate the same behaviour as the youtube 360 video player input. (Using Unity)
So in other words im trying to add the touch input (only rotation on the X and Y Axis) to the gyroscope free to rotate in all angles.
I tried building 2 quaternion, one for the gyro and one quaternion with the touch input. If i start up the app and stay looking at the same direction with the phone, both are adding up fine, but if i change my phone orientation in the Y axis and start using the touch input up and down becomes the roll instead of the yaw.
I tried changing the quaternion addition order but it did not fix my issue.
After playing around with a minimal setup in Unity, i figured what i need to do is recreate the same relation a child and parent object have regarding rotation.
Sorry for the lack of capture and screenshots im trying to find the best way to document the issue.
Thanks

RealityKit AR Directions

Is it possible to make like an AR GPS type thing using RealityKit? Kind of like the lines that appear on the road in Watch Dogs.
I’m having an issue figuring out how to place objects in the correct direction. For example, I’m trying to make a line that goes straight towards the north pole, so you’d have to point your camera in that direction on the ground to see the line. Is this possible? My entity is always placed wherever the camera is pointed at. How do I place it in a predetermined position?
I learned a lot about that kind of thing from working through these examples on GitHub:
https://github.com/vasile/ARKit-CompassRose
https://github.com/ProjectDent/ARKit-CoreLocation
Neither is very recent, but all the concepts are there.

How to rotate an object to point along a vector Unity3D

Hi I have been searching google for some time now with no avail. I was wondering if there was some function or easy way to make an object rotate so it is pointing along a certain vector (in this case, pointing the same way it is moving, but I would like to know generally how to do this with any Vector3) in Unity? I know it is possible to rotate an object using a Vector3 holding EulerAngles, but that is not what I'm looking for, since the object will not point in the direction of that Vector in 3D space.
I believe you should be able to use either Transform.LookAt or Quaternion.LookRotation to accomplish your goal.
Additionally, here is a link to a good Unity answers post where they use Quaternion.LookRotation to get a character to face the position it's moving based on its vertical and horizontal movement input.
transform.forward = velocity.normalized;
Hope that helps =)

Animate a Stick Figure with Cocos2d, images vs. drawing?

I saw this question on a Cocos2d forum, and I would really like to see the answer, I'm assuming its more likely to get answered here:
I was wondering what would be the best method to go about animating a stick figure running, walking, etc.
I need to have a wide and flexible range of motion, so prefer to actually animate multiple lines rather than create premade images and flip through them.
Would I use rotation or use trigonometry to figure coordinates from the angle of the moving extremities?
Any advice, direction or code snippets would be really appreciated!
You could set your own anchor points for each sprite to animate with the rotation- that way you could rotate an arm from the end of the arm just by using rotate instead of doing a lot of complicated math. Setting the anchor point also allows you to translate the sprite along that point instead of its center. Anchorpoint tutorial.
However, I think that it might be easier just to create a lot of images of the stick figure doing all of the actions. I think that n game does this and their character has a lot of animations.

Iphone OpengGL ES: detecting clicks on a primitive

I have created a 3d environment full of 3D cubes, does anyone have any idea how you would detect a touch on one of these Cubes. I thinking if I could get the cubes screen position (coords start from bottom left) then it would be pretty easy
UPDATE:
I added the function -(CGPoint)getScreenCoorOfPoint:(IMPoint3D)_point3D which seems to give me my items position in the world but the bit I am now stuck on is:
I have objects that have a position
I have my position in the world (gluLookAt eye[0], eye[1], eye[2])
and then I have where I tapped on the screen
How do I join all this up, its the last thing in my way to archiving greatness!!!!
Look up OpenGL picking on Google. There are two main methods to accomplish this, I recommend you use the second one described at OpenGL.org as it does not involve rendering anything offscreen:
[…] involves shooting a pick ray through the mouse location and testing for intersections with the currently displayed objects. OpenGL doesn't test for ray intersections, but you'll need to interact with OpenGL to generate the pick ray.
Also see this question for some discussion on the matter:
Screen-to-World coordinate conversion in OpenGLES an easy task?