Notifications
Clear all

[Closed] Viewport

Would it be possible to display a viewport inside of a rollout? My goal would be to make a type of “mini map” to display where you are in the scene from a top view.

Can someone tell me if this is possible. I would assume i would have to somehow get my position of the perspective camera. and use that matrix to point either the top view, or a camera the script creates where i am looking.

Thoughts.

If not clear, let me know.

7 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Alternatively, you can do what Combustion and Fusion do – display a simplified view where each node is displayed as a rectangle the size of the bounding box and the color of the wireframe, then draw a border for the current view. Should be enough schematics to get an idea where you are and how you are moving. Of course, snapshotting a large version of the top view and drawing in it would be much easier…

actually it doesn’t seem like i can edit/use the view ports with maxscript…so what about taking a small rendering with the topview camera with script, storing it in code…and then moving a square around the rendered image that relates to my position in the scene?

Hi Hobbs

I´ve got and idea reading your post.
You can replicate the viewport on a rollout, but you can´t control the viewport from the rollout.

unregisterRedrawViewsCallback xView

rollout test “Duplicated Viewport”
(
bitmap xBitmap “” width:350 height:300
)
createDialog test 370 320

fn xView =
(
test.xBitmap.bitmap = (gw.getViewportDib())
)

registerRedrawViewsCallback xView

Thanks…this will help me along my way…I definately have to start reading up on registering and unregistering.

Mabe you can.

  • make a rollout and a ImgTag

  • cam1 = camera from top

  • cam2 = camera from perspective

  • myTopView = “render scene with cam1”

  • set tag.bitmap = myTopView

  • get width and height from you scene. (bouding box)

  • newPos = (use a function to translate “tag click point” to scene position)

  • move cam2 to newPos

set one of view windows to top view . when click in the rollout bmp controller . it can select the object for u . maxium any view port will not affect the script . it works .

 rollout vptlan "top viewport: [email="http://forums.cgsociety.org/haibo.lan@gmail.com"]haibo.lan@gmail.com[/email]" 
(
-- var define -- 
local curVpt = viewport.activeviewport 
-- interface define -- 
bitmap bmplan "" 
-- fn define -- 
fn activeTopVpt  = 
(
local vptnum = viewport.numviews 
for i in 1 to vptnum do 
 (
 viewport.activeviewport = i 
 if viewport.gettype() == #view_top  do exit 
 )
) -- end fn . active top vpt .
--------------------
fn resumeCurVpt = try( viewport.activeviewport = curVpt )catch() 
--------------------
fn loadVpt =
(
local thesize = getviewsize() 
vptlan.width = thesize.x + 20
vptlan.height = thesize.y + 20 
bmplan.width = thesize.x
bmplan.height = thesize.y 
bmplan.bitmap = gw.getviewportdib() 
)
--------------------
on vptlan open do 
( activetopvpt() ; loadvpt() ; resumecurvpt() ) 
--------------------
on vptlan lbuttonup arg do 
(
activetopvpt() ;loadvpt() 
arg -= bmplan.pos 
if arg.x >0.0 and arg.x< bmplan.width and \
arg.y>0.0 and arg.y <bmplan.height do 
 (
 local theRay = mapscreentoworldray arg 
 local theobjs = for i in geometry where (intersectray i theRay)!=undefined collect i 
 select theobjs
 )
redrawviews() ; loadvpt() ;resumecurvpt()
)
--------------------
) 
createdialog vptlan  

Nice…you have all given me alot of ideas to work with…thank you . I’m going to start working on this as soon as i get some free time from work.