how to get mouse drag direction in unity - unity3d

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.

Related

Shader is not working properly in my 2d game

I was looking for doing a sprite wave like water on a lake/ocean, i found a tutorial on internet, but it was for a 3d game, i applied the tutorial but the shader is moving the sprite in the Z axis, so the wave effect is not notizable from 2d view, but in 3d view it looks fine, it's a 2d game so i need it to move in the correct direcction, this is my first shader so i don't understand it so much.
Use a x=0, y=1, z=0 vector instead of the Normal Vector node.
That will make the wave motion go in the "upward" direction on the object instead of the "outward" direction.

ARKit - Resize object along particular direction

I want to resize an object along a specific direction in ARKit.
For example, there is a cube on a detected plane and I want to be able to resize the cube in X direction, Y direction and Z direction respectively. Does anyone know how to do this? Thanks.

How to transform a non-planar surface on a plane using a pair of 2D and 3D control points?

I have a set of control point pairs. One part of the pair is in world coordinates (3D). The other one is in pixel corrdinates of the image (2D).
My goal is to transform a surface you can see in this image onto a flat plane. The problem is that the surface is not perfectly flat, it kinda looks like a ribbon. Otherwise I could have used OpenCV's getPerspectiveTransform() or Matlab's fitgeotrans().
I know that I can use OpenCV's solvePnP() or Matlab's estimateWorldCameraPose() to get the pose of the camera. The camera matrix is known and the image is rectified. But what is the next step then? How can I transform my ribbon shaped surface onto a flat plane, i.e. get an orthographic top view? That is the step, I'm stuck on.

compute pitch, roll and yaw movement of an object in Matlab

I am currently working, with Matlab, on a 3D simulator whose aim is to move an object (currently it's just a simple circle) in space (using plot3).
Although it's easy to compute a trajectory without any rotation of my object, I do not manage to rotate my object around its own axis. Indeed, I have computed the 3 well-known rotation matrix but it (of course) rotate my object (represented by a set of points) around the axis of my figure (in the "world" system).
For example, the center of inertia of my object (currently the center of my circle) is I whose coordinates are (Xi,Yi,Zi). Thus, I suppose that I need to define an additional system for my object to be able to rotate my object about these 3 new axis composing such a system...
I would like something like:
[X2,Y2,Z2]=Mat*[X1,Y1,Z1] where [X1,Y1,Z1] is the coordinates of a point of my object before the rotation, [X2,Y2,Z2] the coordinates after the rotation and Mat the matrix I am looking for. Of course, the center of inertia must be unchanged whichever the rotation (yaw and/or pitch or/and roll)
However I have no idea about the way to compute such a matrix. The link below summarizes my wish.
Drawing of my problem

How can I project a group of points in 3D space onto a 2D plane in Matlab?

I'm making an animation in Matlab: I have 15 dots moving around in a 3D space. Their XYZ co-ordinates and movement are taken from motion-capture data. I need to show how the dots are moving from the perspective of an observer "in front" of the motion. What I'm trying right now is to create a 2D plane and to move it towards the dots so that they end up "projected" onto it. However, it's not a standard X-Y or Y-Z plane, so I'm having trouble figuring out how to make this work.
How can I make this plane do what I want - or is there another way I should be trying?
What you're aiming for is basically implementing an ideal pinhole camera, where the pinhole becomes a point in space. Each of your 3D points plus the "pinhole" defines a line in 3D space, which intersects with your projection plane at some point. It looks somewhat like this:
x_1 and y_1 should have the same length, i.e. 1, so "x" in 3D space is defined as x = o_1 + a * x_1 + b * y_1. In your 2D projection, a and b become your coordinates for plotting.