Jump to content
Chris Chris

ImageProp Autorotation

Recommended Posts

Hello,

I would like to add autorotate behaviour to my custom object in Vectorworks. This billboard effect rotates the object around the up-axis to always face the object towards the camera like the build-in Image Prop. 
https://app-help.vectorworks.net/2020/eng/index.htm#t=VW2020_Guide%2FTextures%2FCreating_image_prop_objects.htm

A solution would be to create an ImageProp and attach the geometry inside it. I use a VWMeshCreator to pass the constructed mesh to Vectorworks.

 

EObjectEvent XXX_EventSink::Recalculate()
{
VWParametricObj paramObj(fhObject);
MCObjectHandle mcObject = gSDK->CreateImageProp(
    /*const TXString&   propName*/        TXString("propName"),
    /*InternalIndex     textureRef,*/    0,
    /*WorldCoord        height,*/        100,
    /*WorldCoord        width,*/        100,
    /*bool              enforceImageAspectRatio,*/ false,
    /*bool              crossedPlanes,*/    false,
    /*bool              createPlugin,*/        true,
    /*bool              autoRotate,*/        true,
    /*bool              createSymbol*/        true);
gSDK->AddObjectToContainer(mcObject, fhObject);
    
VWMeshCreator meshCreator;
[...]
const TMCObjectHandlesSTLArray& mcObjectArray = meshCreator.GetGeneratedMeshes();
gSDK->AddObjectToContainer(mcObjectArray[0], mcObject);
}

 

My question is why is the ImageProp not created and the geometry rotating? 
I am new to Vectorworks and spend some days to read through the docs and SDK.

 

Kind Regards,
Chris

Share this post


Link to post

It’s hard to tell from the example. Does the mesh show up in the PIO? FYI, not every object needs to get added to the PIO container explicitly, though symbols and other PIOs do. 
 

it could be as simple as calling a reset on the image prop after creation. 
 

A couple strategies to help you troubleshoot:

make a copy of the PIO in the drawing and then “convert to group”. You can then look at each element that the PIO creates. 
 

Also see the earlier thread on examining the document tree for info on Debug List View

Share this post


Link to post

Hi Joshua,

 

Thanks for the answer. The mesh itself always show up. The Image Prop is never appearing in the viewport or in the Debug List View, also without adding it to the container or with calling reset. 

 

Kind Regards,

Chris

 

Share this post


Link to post

A few things to look at. Likely the CreateImageProp call is returning a NULL handle, as some of the options may not be working as expected:

- InternalIndex is 0 — this needs to refer to a texture resource, so this will definitely fail

- You're creating a symbol, so if the call succeeds, VW will create a "red" symbol for the image prop with every reset event.

 

A larger issues is that this command will take a number of steps to convert a texture to an image prop, and doing this inside the reset event will go through those procedures every time the object redraws, going you lots of copies of the texture. First, check to see if the texture "propName Prop Texture" already exists.

 

You have a couple of options. One is to create the image prop in the profile group, and then copy to the main container on reset. Create / delete and re-create the image prop in the profile group when you need to update the image.

 

The other is to create the image prop as a PIO with CreateCustomObject(). The texture just applies to the PIO. You can either manually code the texture creation, or only run CreateImageProp() if the texture doesn't already exist.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...