Object space to Monitor space.

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  10 October 2009
Object space to Monitor space.

So I can get the 2D coordinates of an object in the viewport, but I would like to get it on the monitor instead. So that I can draw in monitor space where and object is.

Any one know how to go about that?
__________________
Paul Neale
http://paulneale.com
 
  10 October 2009
There might be a "cleaner" way, but how about using mouse.pos (mouse position relative to viewport) and mouse.screenpos (mouse position relative to screen) to find the difference between the two coordinate systems?
__________________
MatManager - take control of your materials
Teacup - online material sharing inside 3D Studio
 
  10 October 2009
I am not 100% sure i got what you are looking for. Monitor vs. Viewport space as in monitor space beeing the whole screen res and viewport beeing bound to the viewport position and size ?
 
  10 October 2009
I can't use the mouse. And yes I want to convert the position of an object in a viewport to where it is relative to the over all monitor, Not a viewport. I can get the viewport space without a problem but I want to know where on the monitor is has been drawn.
__________________
Paul Neale
http://paulneale.com
 
  10 October 2009
I was wondering if I could go down this sort of road, this doesn't work though.

dnControl=dotNetClass "system.windows.forms.control"
maxHwnds=(windows.getChildrenHWND #max)
for i = 1 to maxHwnds.count do
(
	hWnd=dnControl.FromChildHandle (dotNetObject "System.IntPtr" maxHwnds[i][1])
	if hWnd!=undefined do print hWnd
)
__________________
Paul Neale
http://paulneale.com
 
  10 October 2009
Originally Posted by PEN: I can't use the mouse.


Why not? All you need to do is subtract mouse.pos from mouse.position and then add the result you get to the viewport coordinates to "translate" them to monitor space. Of course math has never been my strong point so I might be overlooking something.
__________________
MatManager - take control of your materials
Teacup - online material sharing inside 3D Studio
 
  10 October 2009
Paul, Marco has the correct solution. This has been talked about before, see this thread:
http://forums.cgsociety.org/showthr...p?f=98&t=592854
you even posted to it!
 
  10 October 2009
Great minds think alike
__________________
MatManager - take control of your materials
Teacup - online material sharing inside 3D Studio

Last edited by MarcoBrunetta : 10 October 2009 at 02:24 AM.
 
  10 October 2009
Ah ya, I see how it works. Sorry but when I read mouse I'm thinking, I don't care where the mouse is as I might not even be over that viewport at the time. But of course it doesn't matter.

Well done. Thanks for the link to the thread, my searches turned up nothing at all and I don't think that I ever followed that thread to the end when it was originally posted.
__________________
Paul Neale
http://paulneale.com
 
  10 October 2009
I'm just testing out the method outlined in the other thread mentioned above. It is working for me, but not consistently. More often than not I am getting the rollout I am creating to be displayed at the bottom centre of my monitor, right on line with the task bar. [527,975] to be exact. The correct results should return [665,668], which does happen from time to time. I formatted out a breakdown of values and discovered that the inconsistency is coming from the gw.transpoint call and the mouse position values are fine. Does anybody know why this is happening?

EDIT: This is happening in Max 2010. Just jumped to test in 2008 and so far have not had the issue. Will keep testing.

EDIT2: Just ran into it in 2008.

Last edited by Mathieson : 10 October 2009 at 02:44 PM.
 
  10 October 2009
maybe you're not setting the gw transform to the identity matrix before calling gw.transpoint by using:
gw.setTransform (matrix3 1)
also i seem to remember that gw.wTranspoint worked better that gw.transpoint, dont remember why.
 
  10 October 2009
Cool, seems like that was it. Working now. Thanks!
 
  10 October 2009
on a side note I noticed a thing with viewport.getviewportDIB the other day - on 32bit max 2010 this worked fine, yet on 64bit yielded a blank bitmap. Using gw.getViewportDib() worked on both platforms. meh.
__________________
Regards,
Pete

Read my technical blog - lonerobot.net
 
  10 October 2009
I'm seen the same thing Pete, 2009 and 2010 were not working in one of my old tools. Noticed that I was using viewport and not gw.
__________________
Paul Neale
http://paulneale.com
 
  10 October 2009
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 11:45 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.