Slam 3D drawing
can you provide some tutorial or sample project about how is this done?
https://www.youtube.com/watch?v=kSJFm7_pFA0
Hello.
Thanks for your interest in MAXST SDK.
Sorry that we don't have a plane to open the SLAM technology which you watched so far.
Thanks.
John,
MAXST Support Team
ok, than could you tell me how can i place object on specific area?
like in the center of camera, when i place one object it is in center, but if i move camera and place other object, it is is on the same place as previous object.
Hello.
The position where I placed a small block in the movie was calculated using the current camera position.
You can get the current camera position by transforming a pose matrix of "trackable.getPoseMatrix()".
The following function gets a pose as an input and returns the position in front of the current camera.
private fun getDrawablePos(pose: FloatArray): Point3f { val Rt = floatArrayOf(pose[0], pose[1], pose[2], pose[4], pose[5], pose[6], pose[8], pose[9], pose[10]) val T = floatArrayOf(pose[12], pose[13], pose[14]) val cx = -(Rt[0] * T[0] + Rt[1] * T[1] + Rt[2] * T[2]) val cy = -(Rt[3] * T[0] + Rt[4] * T[1] + Rt[5] * T[2]) val cz = -(Rt[6] * T[0] + Rt[7] * T[1] + Rt[8] * T[2]) val dx = Rt[2] val dy = Rt[5] val dz = Rt[8] val dist = 0.5f return Point3f(cx + dist * dx, cy + dist * dy, cz + dist * dz) }
John,
MAXST Support Team
do you have alternative code for unity in c#? if no, what is pose? is it matrix4x4? or should i convert getPose() matrix to array?
I did that
Matrix4x4 pose = Matrix4x4.Translate(getDrawablePos(track.GetPose())) * Matrix4x4.Translate(touchSumPositions[i]);
but objects are following camera movement, how can i "attach" them to InstantTrackable?
Hello.
If you want to place a virtual cube at (0, 0.3, 0) in world coordinate, kindly refer to the following code.
Vector4 Xw = new Vector4(0,0.3f, 0,1);
Vector4 Xc = poseMatrix * Xw;
transform.position = Xc;// MatrixUtils.PositionFromMatrix(poseMatrix);
transform.rotation = MatrixUtils.QuaternionFromMatrix(poseMatrix);
transform.localScale = MatrixUtils.ScaleFromMatrix(poseMatrix);
And you can refer to the world coordinate system of instant tracker via the "Instant Tracker" section of the (link https://developer.maxst.com/MD/doc/unity/coordi).
If you want to get the current camera position in world coordinate, kindly refere to the following unity code.
Vector3 getCameraPos(Matrix4x4 pose)
{
float[] Rt = { pose.m00, pose.m10, pose.m20,
pose.m01, pose.m11, pose.m21,
pose.m02, pose.m12, pose.m22};
float[] T = { pose.m03, pose.m13, pose.m23 };
float cx = -(Rt[0] * T[0] + Rt[1] * T[1] + Rt[2] * T[2]);
float cy = -(Rt[3] * T[0] + Rt[4] * T[1] + Rt[5] * T[2]);
float cz = -(Rt[6] * T[0] + Rt[7] * T[1] + Rt[8] * T[2]);
return new Vector3(cx, cy, cz);
}
John,
MAXST Support Team
thank you, and could you also tell me how do you drag and drop objects like in this video?
https://www.youtube.com/watch?v=E9xA9WEl2As
i mean, how do you put object where your finger is?
Hello.
You can find several unity examples including a touch event in the linke (https://developer.maxst.com/MD/doc/unity/sample).
Unfortunately, some examples might not work as the unity version rise.
(And they were made by the previous MAXST SDK.)
Among examples, ExtraInstantTrackerBrush provides you with a hint for drag and drop.
If the example do not work, refer to ExtraInstantTrackerBrush.cs.
Thanks.
John,
MAXST Support Team
GetWorldPositionFromScreenCoordinate is not working
the object, who's position is GetWorldPositionFromScreenCoordinate seems to have problems, when i move camera, it is not staying in one place, it moves a little bit. is there any better way? or am i doing something wrong?
Could you let me know MAXST SDK version which you are using?
i am using 4.0.0 version
Hello.
Sorry for the late reply due to Korean national holiday.
I'm not sure what your problem is exactly.
We've just corrected and uploaded all sample apps which I introduced.
I'd like you to test ExtraInstantTrackerBrush app and check whether the problem occur again.
(Sample apps do not include our SDK so you need to import MAXST Unity SDK into sample apps.)
Thanks.
John,
MAXST Support Team