Spinning an object

Technical discussions
Post Reply
JM_
Posts: 6
Joined: Tue Aug 27, 2013 7:10 am

Spinning an object

Post by JM_ »

Hi
I saw the http://www.dynoinsight.com/phpBB3/viewt ... p?f=2&t=29 thread about an animation example. Correct me if I'm wrong I think I saw in help that one can have series of 'viewpoints' and a time to animate between each point. However, what we were hoping to do is give the user a couple buttons, rotate left and rotate right. As long as they hold the buttons down the object will rotate. Does the animation method have a loop method in it in case the user holds the button down for longer then there are viewpoints in the array? Also does it also have a method that we could cancel the animation in the event the user releases the button. We were hoping for a couple things, 1) Two models to rotate precisely at the same time, giving the appearance that they are the same model. 2) Rotating that more closely (smoothly) represents the rotation you get when dragging the model around with the mouse.
Thanks
JM

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Spinning an object

Post by nickz »

Hi JM_

For spinning the viewpoints array will be probably bit cumbersome. They are designed to avoid sudden jumps in view when switching viewpoints, so they are more suitable for very short non-continuous animations.

The View Point sample Sample Explorer > View > View Point or C:\Projects\KernelCAD_4_3\Samples\NET\C#\ViewPoint project shows how to code spinning of view. It is good to look at first. You would need to add timer for animation.

Animation of spinning view is also implemented in Rotation sample. See it in Sample Explorer > View > Rotation. There is only C++ code unfortunately. You can open it in Visual Studio: C:\Projects\KernelCAD_4_3\Samples\VC\Rotation. It should be pretty clear.

Synchronisation of the views can be done using the Eye frame. In the View Point example it is accessed in OnFormLoad(). The frame is fully controllable in code. You can copy eye frame of one control to another and rotate it around y axis by 180 degrees to have the view from the opposite side.

Nick

JM_
Posts: 6
Joined: Tue Aug 27, 2013 7:10 am

Re: Spinning an object

Post by JM_ »

I'm sorry I'm getting confused, I originally used the ViewPoint sample project as the guide to build the rotation in the CadTester project I sent. I don't really see the differences in the two projects unless you are indicating to use
_iViewFrame.Rotate() Instead of _iViewFrame.RotateStd(), the Viewpoint project has a radio button to toggle between the two whereas the cadtester project always uses RotateStd(). You mentioned eye frame and Iyou're your documentation referencing the BirdsEye project for manipulating the eye frame, is this what you meant instead of the ViewFrame project? (B.T.W. I don't see the Birds Eye project in the sample explorer, the C# project doesn't have a prebuilt .exe, and it has a missing reference to AxBIRDEYELib.AxBirdEye preventing it from being built)

Regards,
JM

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Spinning an object

Post by nickz »

Yes these are the samples included in the KC installation. I think once you get the concept of eye frame everything should be easy. Keep in mind that there can be bugs, which can be making everything confusing.

Essentially a view point is a box in 3D aligned to some axes. These axes are called the eye frame. What is displayed on the screen is the view from the front side of the box. What is outside is clipped out. Increasing its size means including more into the scene, so it is zooming out. When you rotate and translate the eye frame you are rotating/translating the box so scene appears rotating/panning

Nick

JM_
Posts: 6
Joined: Tue Aug 27, 2013 7:10 am

Re: Spinning an object

Post by JM_ »

Thank you, Nick
Our observation is that the rotation method via the buttons (demonstrated in the sample project) isn't as smooth as we would like to see it. When we use the internal KernCad mouse drag, i.e. if you run the sample project -> left click and hold on the object -> drag around so the object is spinning. This is the performance we are looking for, the object smoothly rotates following the mouse cursor but we want to do it with the button GUI. Is this possible to obtain or improve upon our existing code. If so how does the code in our sample project have to change to attain the performance.
JM

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Spinning an object

Post by nickz »

Sorry, JM_ about the confusion

I have mentioned Rotation only because there is Animate button. C# does not have examples with view animation.

We should also remove reference to the bird's eye example. It got lost on the way few years ago as it was considered non-essential. We need to rewrite it more efficiently. It was a great demo of what I wrote in the paragraph about eye frame.

Here it is:
http://www.dynoinsight.com/Prod/KernelC ... 4_3143.exe

I recommend having a look at the sample. Sample Explorer > View > Birds eye. The product is small. It can be installed simultaneously with 4.3. You need only to execute "Update Component Registration" in Start menu to activate one or the other.

Nick

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Spinning an object

Post by nickz »

JM,
What I was explaining above, particularly with the Birds Eye demo, is how to control the view point completely on low level. For example,

if you need to display the other model from the opposite side synchronous on every rotate you need to copy eye frame of the left control to the eye frame of the right one and rotate it by 180. This would make viewpoints exactly opposite at any moment.

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Spinning an object

Post by nickz »

To copy one eye frame to another Query IFrame2 from IFrame of Eye frame of the second control and call Copy() like
iFrame2_second.Copy(iFrame_first)

You can also use IFrame3.GetAxis/Setaxis etc, but this should be the same

I recommend creating a quick new test or modify any KC sample to try it first.

You probably won’t need it, just for completeness: If you need to synch zoom too ILook.Get/SetView Volume allows copying sizes of the viewing volume (the box in the birds eye demo) so this gives complete control

Cheers
Nick

Post Reply