Mixed static/dynamic animations in Unity3D >=5.0 - animation

Is it possible to combine animations created within the unity editor with scripted animation, e.g. I want a camera to rotate 90 degrees on Y axis and move to a point V in the duration of 3 seconds. Everything but the target point vector V should be animated statically, but the vector V should be given at runtime through a script.
Is something like this possible?

Related

ThreeJS flip reversed X axis (left handed coordinate system)

I'm trying to create this 3D tile system world merged from smaller 3D objects - in order create these we use another application made in Unity which loads all small 3D assets separate and may be used to create your new model. Upon saving these model files there will be a JSON file created which contains all scales, positions, rotation etc. of all used 3D models.
We have decided to use this system of 'North, East, South, West' to make sure everything will look good in production. However now when we're trying to render these same JSON files in ThreeJS we have noticed the X axis is reversed compared to the Unity application that we're using .
What we want is this:
North is increasing Z value (north and south are fine)
East is increasing X value
West is decreasing X value
At the moment this is what's going wrong in ThreeJS:
East is decreasing X value
West is increasing X value
What we already have tried is this:
mirror / flip the camera view
when a coordinate drops below 0 we make it absolute (-10 will be 10)
when a coordinate is above 0 we make it negative (10 will be -10)
But nothing of the above had the desired effect. Reversing the coordinates with code brings other problems when it comes to scaled, rotated objects that are smaller or larger than 1x1x1 size. Ideally would be that we don't have to change our coordinates and that still can be used as a solid reference by changing the direction of the X axis from the left side to the right side of 0,0,0
Currently ThreeJS uses the 'right handed coordinate system' and what we desire is a left handed coordinate system. Is this something that is possible to configure within ThreeJS?
Anyone an idea what i can try except flipping all X coordinates?
It's not something you can configure in three.js or Unity. Different file formats typically have a notional coordinate system built into them. GLTF, for example, is represented in a right-handed coordinate system. It's the responsibility of the format importers and exporters to handle the conversion -- this is what the builtin three.js importers do.
I would suggest using an existing format such as GLTF to represent your scene (there is an existing Unity exporter available and an importer available for three.js).
Or if you'd like to retain control over your own file format you can do the left to right handed coordinate system conversion yourself either at export from Unity or import to three.js. Looking at your image it looks like you'll want to multiple all of the X values by -1.0 to get them to look the same. You'll want to save your rotations as quaternions, as well, to avoid rotation order differences.
Of course you could always just scale the whole scene by -1.0 on X but that may make it difficult to work with other parts of three.js.
I would consider to apply a (-1, 1, 1) scale to the root of your "Unity exported scene", this way you can still keep the other part of your scene unchanged.
obj3d.scale.set(-1, 1, 1);

Constrain scene navigation in AFrame

I am building an application in AFrame and I want to constrain the viewers movement, that is I want to limit where the camera can go in the scene. For example I have a a-plane that is the floor and I want the camera to stop moving when it reaches 0 on the Z axis to stop the camera from going through the floor or stop again if it reaches 20 on Z axis. I also wish to limit the movement in x,y directions. There are no obstacles in the scene besides the a-plane. Is creating a navigation mesh my only option or is there an easier way to constrain movement? Thanks!
I don't know of built in tools to do this, but you could do it with programming (this sounds pretty easy). You could create a custom component, attached to the camera, with a tick handler, that records the position of the camera in world space and stores in in a variable (camPosPrevFrame). Then create a function to test if the current position is outside of the bounds. If so, set the camera coordinate on the axis that has exceeded its limit, to the previously recorded boundary (camPosPrevFrame). If you are simply testing whether the camera is on one side of an orthagonal plane (say the world space xy plane), that is pretty simple math (camera.getWorldPosition.x>someAmount). If you have a more complex situation, there are ways to test if a point is on either side of any arbitrary plane (it involves the dot product).

Solve z-Up exported collada file from blender in OpenGL

I export models from Blender to Collada with animation. As it is known, Blender is a right-handed system so its up axis is z and OpenGL ES2 is Y-Up.
For static meshes I can rotate the object around x axis for 90° degrees but when I apply the rotation to the frame's matrix, it has unexpected results.
So how can I do this?
To Rotate an Object:
To rotate the object manually, make sure you select the object (normally by right-clicking the object). Then simply press "R" on your keyboard and move the mouse and see the object rotate accordingly. You might realize you have limitation on how it rotates; press "R" again and now you will see the object rotating freely depending on how you move your mouse.
If you want to rotate the object around the x-axis by 90 degrees, then once again select the object, press "R" on your keyboard (R is for Rotate), then press "X" on your keyboard (X is for X-axis), then type in 90 on your numpad, and finally hit "Enter". You will see your object rotate by 90 degree along the X-axis.
To Rotate an Entire Scene:
Select all parent objects
Move 3D cursor to 0,0,0
Rotate around cursor: global X axis, -90 deg
Apply rotation
Continue with the usual export
The correct way to handle this problem is to do the rotation as part of the export since the point of an export would be to take a correctly oriented Blender object and produce a correctly oriented Unity object. You should be performing the rotation before anything else. The application of the rotation should come before any translation in the actual frame.
More detail on this can be found at the following thread: https://blenderartists.org/forum/archive/index.php/t-255246.html

Animation rotation in unity3D is not as accurate as it in maya

I have a turn on spot animation that actually turns the player 61 degrees in maya. But when import the animation to unity and apply it to a animator controller to control a character, it turns the character 56 degrees. Why the turn angles are different?
Maya and some other 3D packages export their models with Z-axis faces upward. Standard scripts in Unity assume the Y-axis represents up in your world axis. It is better to fix the rotation in Unity than to modify the scripts to make things fit.
How do I fix the rotation of an imported model?
The same problem refers to orientation in Unity:
Rotation and Orientation in Unity
See also Euler vs Quaternion and The order of transformation in Maya.

3Ds Max CAT animation

In character animation toolkit: I've created an animation in the absolute layer. How can I set rotation keyframes for the whole character?
Example: In my abs layer, I have created a dancing animation. Apart from this, I would like my character to be rotating around its own axis too. However when I select the whole character and try to rotate it, limbs don't rotate around character's axis, but rather around their own axes.
In CATMotion layer, it could be done by choosing a path node, but how can I achieve the same effect in the abs animation layer?
The tool I was looking for is called a transform gizmo

Resources