SDK:Planar Graphics

From Vectorworks Developer
Revision as of 15:39, 12 August 2013 by Root (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

.SDK|SDK ..SDK:Types|SDK Types ..SDK:Using the SDK|Using the SDK ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

By Vladislav Stanev

What's that

Planar graphics is the ability of 2D objects (line, rectangle and so on) to be represented and rendered in 3D. Each 2D object has 'Plane' properly on the Object Info Pane that describes on what plane in 2D object is located and that determines its location in 3D space.

There are two planes:

  • Screen plane -- the plane that is always oriented toward the user. A 2D object on that plane will always be in plan toward the user;
  • Layer plane -- the plane of the layer. A 2D object always sticks to its layer plane when rendered in 3D.

This system works exactly the same for 2D parametric objects only. 3D and Hybrid objects will not have that option available. This means that 2D parametrics allow the user to control where the parametric will be rendered: on the screen plane or layer.

Vectorworks automatically controls this so normally a parametric plug-in developer doesn't have to do anything.

Tools

A plug-in tool can control the view it requires by the tool's resources.

The second option in the TDef resource have been updated. Its new meaning is to determine if the tool will require screen plane to be activated with the tool activation. This would mean that this is 2D only tool.

Specifying 'needsScreenPlane' will put the screen plane active when activating the tool. 'doesntNeedScreenPlane' will not put the screen plane. No one of the option will change the view (rotate nor go to plan or 3D).

2D Tools

Here is an example of 2D tool -- that will create 2D geometry.

resource 'TDef' (128, "Tool") {
  /* pickAndUpdate, disablePickUpdate */        pickAndUpdate,
  /* doesntNeedScreenPlane, needsScreenPlane */ needsScreenPlane,
  /* doesntNeed3DView, needs3DView */           doesntNeed3DView,
  /* use2DCursor, use3DCursor */                use2DCursor,
  ...


3D Tools

Here is an example of 3D tool -- that will create 3D geometry.

resource 'TDef' (128, "Tool") {
  /* pickAndUpdate, disablePickUpdate */        pickAndUpdate,
  /* doesntNeedScreenPlane, needsScreenPlane */ doesntNeedScreenPlane,
  /* doesntNeed3DView, needs3DView */           needs3DView,
  /* use2DCursor, use3DCursor */                use3DCursor,
  ...


Hybrid Tools

Here is an example of Hybrid tool -- that will create Hybrid geometry.

resource 'TDef' (128, "Tool") {
  /* pickAndUpdate, disablePickUpdate */        pickAndUpdate,
  /* doesntNeedScreenPlane, needsScreenPlane */ doesntNeedScreenPlane,
  /* doesntNeed3DView, needs3DView */           doesntNeed3DView,
  /* use2DCursor, use3DCursor */                use2DCursor,
  ...

Note that 'use2DCursor' is set. Normally 3D only tool will require 3D cursor, so this should be 'use3DCursor'

However, for hybrid tool this depends on the view. So, initially we have 'use2DCursor' but the code should determine the cursor upon kToolDoSetup event: by using VCOM:VectorWorks:ISDK::SetCursorByView.

Also, it's goold practice for hybrid tools to set up the WorkingPlane properly with call to VCOM:VectorWorks:ISDK::SetWPHybridTool.

Here is example of the kToolDoSetup event of the main function of a hybrid tool. kToolGenericStateChange event is required for when the tool is active and the view changes. The tool must put up the correct cursor.

case kToolDoSetup: {
  ...
  bool bRestore = (message1 == kSetupSetdownPauseRestoreFlag);
  gSDK->SetWPHybridTool( bRestore );
  gSDK->SetCursorByView();
} break;

case kToolGenericStateChange: {
  ...
  gSDK->SetCursorByView();
} break;

Parametric Objects

Vectorworks handles the planar graphics for the parametric objects by default. Vectorworks 2010 doesn't allow mixing planar objects with 3D or non planar (screen) ones.

However, there is simple control over that.

There is new object variable ovPlanarObjIsSrceen.

  • ISDK::GetProgramVariable will return boolean if the specified object is planar or screen. Non 2D objects will be reported as screen objects;
  • ISDK::SetProgramVariable will assign screen plane to a 2D object if passed 'true'; otherwise it will make planar object on the current container (the layer or the parametric object itself)


See also