Ther axis of Imported FBX from 3ds Max into Uity 3D is not matching because of which object is not moving desired direction - unity3d

I have created 3d model in 3DS Max and imported in Unity 3D.
In Unity 3D i m moving object in -Z axis direction.
While exporting object from 3ds max axis are x0, y0, z0 and in FBX settings y-axis up.
When model imported in the Unity 3D object appear as rotated in x-axis 90 degree
code is working fine its moving the object in -z zxis but object is rotated in X90.
And when I rotate my FBX object in required position then object is moving downwards in -y axis direction.

Hey I just figured out the problem.
In 3DS MAX, change the pivot point of the object then export.
First, Y - axis was facing Front view and Z - axis top [image 1]
Rotate X - Axis with 90 degree
Now Y - axis id pointing top and Z - axis is pointing back [image 2]

You can use this very useful max script
http://www.strichnet.com/improving-the-fbx-workflow-between-3ds-max-and-unity3d/
or my tweaked version (ui fix, success alert disabled)
https://yadi.sk/d/HKMDxakf3a3zHq
may not work with animation and rigged models
example of settings

Related

Unity Rotate Sphere To Point Directly Upwards Based On Child Point

I've got a 3d sphere which I've been able to plot a point on using longitude and latitude thanks to some work of another developer I've found online. I think I understand what its doing.
What I need to do now is rotate my planet so the point is always at the top most point (ie the north pole) but I'm not sure how to do this. I'm probably missing some important fundamentals here so I'm hoping the answer can assist in my future learning.
Here's an image showing what I have - The blue line is a line coming from the longitude and latitude I have plotted and I need to rotate the planet so that line is basically pointing directly upwards.
https://ibb.co/2y24FxS
If anyone is able to advise it'd be very much appreciated.
If I'm not mistaken, Unity uses a coordinate system where the y-axis points up.
If the point on your sphere was in the xy-plane, you'd just have to determine the angle between the radius-vector (starts in the center of the sphere, ends on the point in question) and the y-axis, and than rotate by that amount around the z-axis, so that the radius vector becomes vertical. But your point is at an arbitrary location in 3D space - see the image below. So one way to go about it is to first bring the point to the xy-plane, then continue from there.
Calculate the radius vector, which is just r = x-sphereCenter. Make a copy of it, set y to zero, so that you have (x, 0, z) - which is just the projection of the vector r on the horizontal xz-plane - let's call the copy rXZ.
Determine the signed angle between the x-axis and rXZ (use Vector3.SignedAngle(xAxis, rXZ, yAxis), see docs), and create a rotation matrix M1 that rotates the sphere in the opposite direction around the vertical (negate the angle). This should place your point in the xy-plane.
Now determine the angle between r and the y-axis (Vector3.SignedAngle(r, yAxis, zAxis)), and create a new rotation matrix M2 that rotates by that angle around the zAxis. (I think for this second one, the simpler Vector3.Angle will work as well.)
So, what you want now is to combine the two matrices (by multiplying them) into a single transform (I'm assuming this is a transformation in the local coordinate system of the sphere, where (0, 0, 0) is the sphere's center). If I'm not mistaken, Unity uses column-major matrices, so the multiplication order should be M = M2 * M1 (the rightmost matrix is applied first).
Reorient your globe using M as a local transform, and it should bring your point to the top. You can also create M3 = M1.inverse, and then do M = M3 * M2 * M1, to preserve the original angular offset from the xy-plane.
Check for edge cases, such as r already being vertical (pointing straight up, or straight down).

how to get mouse drag direction in unity

Hello guys I am building a 3D game that player can reshape something like slime with dragging it. the shaping part is alright and I do not have a problem with it.
I use mesh manipulation for shaping my object and I move all vertices within a specific radius of clicked position. but my vertices are moving toward its normal vector I figured that out I can move vertices toward mouse drag vector by just changing normal vectors.
so, here is my question how can I get mouse drag vector so I can change my normal vector to that?
also the player can rotate around X And Y Axis on my object and this makes this problem a little more difficult.
because for example if I see my object from this angle (270,0,0) if players drag mouse to right and down my object should Stretch to its -x Axis and -z Axis.

Rotate an image around x or y axis in Matlab

If a camera is looking at say 6 evenly spaced dots in the real world it would look like the image below if the camera is looking at the image straight on with no rotation in the x, y or z axis
The z-axis is perpendicular to the image sensor so rotation around the z-axis is simple, it's just a tilt of the image. If I were to rotate the camera (or objects being looked at) around the x axis (if the x-axis is up down) the rows and columns will no longer be parallel and would project off to a vanishing point, like this.
What I would like to do is take a 2 dimensional image of say, dots, and be able to apply different rotations around the x,y and z axes independently. I've experimented with reading my image in Matlab and multiplying by a rotation matrix, or even a full camera matrix but I can't figure out how to take a 2D image, simulate rotating it around the x axis and then saving that back to an image. So that my original grid of dots would look like the bottom image with lines going off to a vanishing point. I've seen some examples using imwarp but I didn't see how I can set the angle of rotation. I'm working on camera calibration so I really want to be able to specify an angle of rotation around each axis.
Thanks for any help.

Orientation problem from inertial module LSM9DS1 Arduino

I am working on a project where i have to determine position and rotation of an IoT object with accelerometer, gyroscope and magnetometer. The goal is to show this object in a Unity3D virtual world.
To do this, i have an Arduino Nano 33 BLE that include a LSM9DS1 as inertial module.
So, i started to determine the rotation of my object. This link was very usefull : http://gilles.thebault.free.fr/spip.php?article32
That's the line for get the Y axis :
angle=0.98*(angle+float(gy)0.01/131) + 0.02atan2((double)ax,(double)az)*180/PI;
With this one, i can get X, Y and Z angles. When i try one by one axis orientation, all axis rotation are fine. The problem is when i use 2 axis or more at same time. For example, i use only X and Y axis. When i turn only X axis of 90°, Y axis turn of 90° too. This video will explain more accurately than words : https://www.youtube.com/watch?v=IeuIuEcjUBc&feature=youtu.be
I searched lot of things to fix it but now, i have no more idea. Can anyone guide me?

Change 3D view in matlab

I would like to change the view of a 3D plot in matlab such that the y-axis points upward and the z-axis points to left. For example, consider the following plot:
Here the x-axis points forward, the y-axis points to the right and the z-axis points upward.
I would like to have the y-axis points upward and the z-axis points to the left instead. I tried to rotate the plot (using the figure window toolbar rotate button) but I could not get it to work. (It should just be a simple 90 degrees rotation about the x-axis)
Code to generate the plot:
membrane
view(100,50)
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
grid on
Try using view. I don't have MATLAB available so I can't test it, but I think it can do what you want.
Example from the documentation:
Set the view along the y-axis, with the x-axis extending horizontally
and the z-axis extending vertically in the figure.
view([0 0]);
EDIT:
Try using three inputs to the view function. I can't experiment myself, but you should be able to do it if you choose the right values here.
From documentation:
view([x,y,z]) sets the view direction to the Cartesian coordinates x,
y, and z. The magnitude of (x,y,z) is ignored.
EDIT 2:
Check out camroll. I think camroll(90) (possibly in combination with view) will work.
From documentation:
camroll(dtheta) rotates the camera around the camera viewing axis by
the amounts specified in dtheta (in degrees). The viewing axis is the
line passing through the camera position and the camera target.
This was posted a while ago, but in case someone else is looking for ways to set y-axis as the vertical one here is a possible fix.
Manually: In the command window type cameratoolbar('show') which will open an interactive toolbar in your plot from which you could change the view. One of the options is to set a principle axis to x, y, or z.
Or in you script you could use cameratoolbar('SetCoordSys',coordsys) command which sets the principal axis of the camera motion. coordsys can be: x, y, z, or none.
http://uk.mathworks.com/help/matlab/ref/cameratoolbar.html