Viewport Drawing Methods - gw.hPolygon, gw.hPolyline etc..

Become a member of the CGSociety

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

Thread Tools Search this Thread Display Modes
  12 December 2004
Question Viewport Drawing Methods - gw.hPolygon, gw.hPolyline etc..

Hi. I have some questions regarding those GW. functions described in Viewport Drawing Methods. First - I can't figure out, why example showed in that chapter doesn’t work correctly. Here's the code:

-- Draw some primitives 
gw.hPolyline #([300,50,16], [300,200,8], [450,250,4]) true 
gw.hPolygon #([200,100,16], [280,100,8], [250,200,4]) \ 
#(red, blue, green) \ 
#([1.0,.5,0], [0.5,0.5,0], [0,0,0.5]) 
gw.hTriStrip #([50,50,0], [175,100,0], [25,100,0], [150,250,0]) \ 
#(red, blue, green, white) \ 
#([1.0,.5,0], [0.5,0.5,0], [0,0,0.5], [0.5,1,0]) 
-- Update the viewports 
gw.enlargeUpdateRect #whole 

This should draw 3 figures – Polyline, Polygon and TriStrip (not actually sure what TriStrip is). However it draws only hPolyline. After hour of experiments I found out that after switching video driver to Software mode hPolygon figure is finally drawn, but hTriStrip is not. So where's the catch?

Second question – How can I clear all previously drawn fiures during drawing of another figure? I am trying to make something similar to Render Region frame, not so complicated of course, it will be a simple rectangle without fill, with top left corner in the point of first click and bottom right corner in the point of mouse cursor. This rectangle should redraw when mouse moves, however all I can do is either leave previously drawn rectangle and add new ones and create a mess, or complecely clear specified region using gw.clearScreen <Box2>, so there will be only flat color. But I need to see objects below frame! Of course I can include completeredraw() command but it is so slow that it makes no sence to use those fast GW functions.. There should be a way to erase drawn figure but leave underlying viewport image

Here is the simple loop that draws a line with moving second point. How to erase old line without using completeredraw() and at the same time not loose viewport cotents?

mypoint1 = [50,80,0] 
mypoint2 = [200,200,0] 
for i = 1 to 200 do 
gw.wPolyline #([mypoint1.x,mypoint1.y,10], [mypoint2.x,mypoint2.y+i,10]) true  
gw.enlargeUpdateRect #whole   

Thanks in advance.

Last edited by C00PER : 12 December 2004 at 02:56 PM.
  12 December 2004
Originally Posted by C00PER: gw.hTriStrip #([50,50,0], [175,100,0], [25,100,0], [150,250,0]) \
#(red, blue, green, white) \
#([1.0,.5,0], [0.5,0.5,0], [0,0,0.5], [0.5,1,0])

This feature has been disabled for some unknown reason.
There is no workaround except for drawing full polygons instead.

Quote: Second question How can I clear all previously drawn fiures during drawing of another figure?

As far as I can tell, you cannot erase a line, you have to update the view.
If you are using DualPlanes, you can flag all objects as background and then the redraws should theoretically just swap the background plane's DIB content, effectively drawing only your polylines on top of a bitmap...
I have not tested this though.

MAXScript Reference > Frequently Asked Questions > How To Make It Faster:

Use the 'flagForeground' node viewport state method.

The 3ds max graphics pipeline can use a dual plane technique for speeding up viewport redraws. When only few objects are changing, the graphics subsystem can take a snapshot of the viewport DIB bitmap showing only the non-changing objects which are flagged as background. After that, the graphics pipeline evaluates only the changing objects and draws on top of the background bitmap. These objects are internally flagged as foreground.
The flagForeground method controls the disposition of scene nodes in the viewport foreground/background planes, so you can influence interactive performance on a node. Nodes placed in the foreground plane are redrawn individually and so interactive changes to them through spinners in scripted rollout panels are much faster.
  12 December 2004
Thanks for the reply, Bobo. Unfortunaly this flagForeground method can't help me in any way. Or maybe I am just doing something wrong.. As far as I understand, this should be used to speedup redrawing of nodes that are changed by script, and I do not change any nodes.. I am manipulating completely different system.

However, I found a way of efficient use of the completeredraw() command. I create a simple counter in the function that updates rectangle. When it reaches say 10 it calls completeredraw() command and then resets itself, so it redraws every tenth cycle.. I think that’s pretty enough at this moment. Thank you.
  12 December 2004
Hey! I guess I found simple and genius way to update ONLY a drawn frame There is a nodeInvalRect <node> command which specifies a node that should be redrawn with RedrawViews command. If you didn’t call a nodeInvalRect <node> before RedrawViews, it will redraw nothing… Guess what we supply as a node for invalidation? Our camera haha! And it works! 10 times faster than completeredraw()! However I noticed that it works well only when camera is selected…..But what if we are looking through perspective view, not camera hmm.. maybe creating of temporary dummy aligned to camera center will help.

edit: Just tried this trick with dummy, aligned to (inverse (getviewtm())) and it works.. Speedup is dramatic and viewport contents are not lost. Cool! I guess this method shoud be included in Maxscript reference in How to make it faster haha now back to my script..

Last edited by C00PER : 12 December 2004 at 05:52 AM.
  01 January 2006
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
Society of Digital Artists

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

All times are GMT. The time now is 09:48 AM.

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