bd->WS
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/07/2010 at 03:04, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11
Platform: Mac OSX ;
Language(s) : C++ ;---------
HelloI am getting some strange values when trying to convert mouse position from world space to screen space in
Bool MyObject::MoveHandle(PluginObject *op, PluginObject *undo, const Matrix &tm, LONG hit_id, LONG qualifier) { ... bd->WS(tm.off); ... }
it all works well until the camera is in front of the world center (0,0,0), as soon as the camera goes trough center (so the center is behind camera) the return of WS skyrocket to very high numbers.
Anyone know how to get pass this?
Thanks
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 01:13, xxxxxxxx wrote:
I suspect that tm is not in world space.
Also tm.off might be an offset to the original position of the handle. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 01:28, xxxxxxxx wrote:
As Michael said tm is not in world space.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 05:48, xxxxxxxx wrote:
What is then the correct way to get screen coordinates in MoveHandle, basically I only need the movement and this is the code I use atm
Bool MyObject::MoveHandle(PluginObject *op, PluginObject *undo, const Matrix &tm, LONG hit_id, LONG qualifier) { BaseDocument *doc = GetActiveDocument(); BaseDraw *bd = doc->GetActiveBaseDraw(); if(mouseClick) { // save where you clicked in 2D storeTM = bd->WS(tm.off); mouseClick = FALSE; } Vector moveTM = bd->WS(tm.off); //move in 2D Vector translate = moveTM - storeTM; //final move ...
The object is in center of the world anyway, so tm is in world space no?
Or is it WS simply the wrong way to get this?Thanks
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 06:25, xxxxxxxx wrote:
the documentation says:
tm = The amount the handle has been moved by the user
So tm is already the translation matrix (not sure in which space it is defined, might be the object space or world space, the docs don´t say anything about it. Rotate your object and check the result to find out). Simply use tm.off for your translate value and do something with it.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 06:27, xxxxxxxx wrote:
Well I need the translation in screen values not in 3D.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 06:38, xxxxxxxx wrote:
If you know in which space the translation is defined and where your handle is then you can easily calculate the world space position and convert it.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 06:50, xxxxxxxx wrote:
Ok tested with rotating the object, so the translation matrix is in object space.
Since tm.off always starts from 0,0,0 and object is at 0,0,0 this basically is world space or isn't it.
The problem is still with WS and world center being behind the camera as far as I can see.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 07:37, xxxxxxxx wrote:
The translation matrix is in local space of the handle itself, so basically an offset.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 08:47, xxxxxxxx wrote:
so is bd->WS the right way to convert this offset to 2D screen coordinates?
or is there a simple alternative to get 2D screen coordinates of the mouse while moving a handle, since I am hitting a wall with this?thanks.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 09:09, xxxxxxxx wrote:
WS( worldspace(handleposition + translation offset) )
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/07/2010 at 10:35, xxxxxxxx wrote:
Thanks for all the tips, it finally works with this code, and translating the matrix in front of camera at all times so it cant fail.
BaseDocument *doc = GetActiveDocument(); BaseDraw *bd = doc->GetActiveBaseDraw(); BaseObject* camera; if(bd->GetSceneCamera(doc) != NULL) camera = bd->GetSceneCamera(doc); else camera = bd->GetEditorCamera(); Matrix camMg = camera->GetMg(); Vector camZ = Vector(0,0,1000) * camMg; if(mouseClick) { storeTM = bd->WS(tm.off+camZ); mouseClick = FALSE; } Vector moveTM = bd->WS(tm.off+camZ); Vector translate = (moveTM - storeTM);
I doubt anyone will need something like this again, but here it is
Thanks again!