[Ves] Rotate 3D object to the specifeid angles [iOS]

shamsudheen shamsutk87 at gmail.com
Thu Feb 7 19:43:51 EST 2013


Hi Pat,

This one rotated fine on Y-axis

   vesKiwiPolyDataRepresentation* polyDataRepresentation =  self->renderer.app->getKiwiPolyDataRepresentation(0);
     
    vesSharedPtr<vesActor> vesActor = polyDataRepresentation->actor();
 
    vesVector3f center = vesActor->center();
    
    vesVector4f angleAxis;
    
    angleAxis[0] = center[0];
    angleAxis[1] = 1;
    angleAxis[2] = center[2];
    angleAxis[3] = angle * (M_PI/180.0);
    
    vesActor->setRotation(angleAxis);


Then

> I have called
> 
>         [self->glView disableRendering];
          [self->glView resetView];
>         [self.glView setDiffrentAngle:30];
>         [self->glView enableRendering];




Thanks for you all effective responds.



On Feb 7, 2013, at 5:05 PM, shamsudheen wrote:

> Hi Pat,
> 
> Thanks again,
> 
> As per your replies, I have wrote the code in vesKiwiViewerApp to retrieve vesKiwiPolyDataRepresentation
> 
> The code is
> 
> vesKiwiPolyDataRepresentation* vesKiwiViewerApp::getKiwiPolyDataRepresentation(int itemIndex)
> {
>     return dynamic_cast<vesKiwiPolyDataRepresentation*>(this->Internal->DataRepresentations[itemIndex]);
> }
> 
> 
> and I have wrote the code in EAGLView class as 
> 
> -(void)setDiffrentAngle:(float)angle
> {
>     vesKiwiPolyDataRepresentation* polyDataRepresentation =  self->renderer.app->getKiwiPolyDataRepresentation(0);
>     
>     vesSharedPtr<vesActor> vesActor = polyDataRepresentation->actor();
>     
>     vesVector3f center = vesActor->center();
>    
>     vesVector4f angleAxis;
>     
>     angleAxis[0] = center[0];
>     angleAxis[1] = center[1];
>     angleAxis[2] = center[2];
>     angleAxis[3] = angle * (M_PI/180.0);
>     
>     vesActor->setRotation(angleAxis);
>     
> }
> 
> then I have called
> 
>         [self->glView disableRendering];
>         [self.glView setDiffrentAngle:30];
>         [self->glView enableRendering];
> 
> 
> 
> The changes are not effecting the 3D mode now on the screen.How could I update the angle changes on 3D object ? 
> 
> 
> First I would like to know about my implemntation.is it looks perfect ? after apply the code, if I rotate the 3D modal through hand, it seems zoomed in.
> 
> Any help on this is appreciated.
> 
> 
> 
> 
> On Feb 6, 2013, at 4:25 AM, Pat Marion wrote:
> 
>> The version of vesKiwiViewerApp in the master branch doesn't provide a way to access the representations that are loaded via the loadDataset(filename) method.  You could modify vesKiwiViewerApp to provide an accessor to the internal representations, or implement your own data loading method.  If you grab the version from the stage/kiwi-update branch then you'll find an accessor method dataRepresentations() that returns the list of reps, but there isn't a mapping from filename to representation object, that logic would be up to you to implement.  I highly recommend deriving your own app class based on vesKiwiViewerApp and implement your own data loading methods so that you have full control over your models, the loadDataset(filename) is useful for a basic app, but once you do something more advanced you definitely want to write your own app class.
>> 
>> Pat
>> 
>> 
>> 
>> On Wed, Feb 6, 2013 at 8:13 PM, shamsudheen <shamsutk87 at gmail.com> wrote:
>> Thanks again for the quick reply .
>> 
>> I think , this is what you mentioned.
>> 
>> vesSharedPtr<vesActor> actor = vesKiwiPolyDataRepresentationPtr.actor();
>> actor->setRotation(angleAxis);
>> 
>> However now I'm unable to get vesKiwiPolyDataRepresentation pointer.
>> 
>> I have just used   bool loadDataset(const std::string& filename); method to load my 3D file.this is a vesKiwiViewerApp.h class method.
>> 
>> How can I get the vesKiwiPolyDataRepresentation  pointer ? could you please help on this.
>> 
>> Thanks again for the quick ,professional and effective responds.
>> 
>> 
>> On Feb 6, 2013, at 3:19 AM, Pat Marion wrote:
>> 
>>> Instead of adjusting the camera, you should set a transform on the vesActor object associated with your model.
>>> 
>>> You can access the vesActor from the vesKiwiPolyDataRepresentation for your model, if you are using that class in your app.
>>> 
>>> For example code, please see the implementation of vesKiwiDataRepresentation::setTransformOnActor().
>>> 
>>> Pat
>>> 
>>> On Wed, Feb 6, 2013 at 7:10 PM, shamsudheen <shamsutk87 at gmail.com> wrote:
>>> Hi All,
>>> 
>>> I have successfully built the VES/Kiwi and have rendered one 3D obj  in to my iPad application from a .obj file.
>>> 
>>> Im using vesKiwiViewerApp in my application.The Gestures are working and the 3D model is rotating well.
>>> 
>>> Now I would like to rotate my 3D modal/object through programmatically.
>>> 
>>> I have  to rotate my 3D object to the following angles,, 30º,60º,90º,120º,150º,180º,210º,240º,270º,300º,330º,360º
>>> 
>>> So I have wrote the code as below to rotate the  3D object in to 30º
>>> 
>>>     vesVector3f cameraPosition (30, 0, 1);
>>>     self->renderer.app->setCameraPosition(cameraPosition);
>>> 
>>> Its rotated.However not exactly to the 30º and the 3D model is zoomed out.
>>> 
>>> My screen size is (400, 400).So the console window displayed the following when 3D model renderes
>>> 
>>> resize(400, 399)
>>> x:0.000000 y:0.000000 z:-1.000000
>>> x:0.000000 y:0.000000 z:-439.917145
>>> 
>>> So I have set the camera position as 
>>>  
>>>     vesVector3f cameraPosition (30, 0,-439.917145);
>>>     self->renderer.app->setCameraPosition(cameraPosition);
>>> 
>>> Now the zoom is correct and the 3D model is rotated.However not exactly to 30.
>>> 
>>> My target is to rotate the object in different angles.how can achieve this?
>>> 
>>> Is it possible to access the rendered 3D object and set the positions instead of using the camera ?
>>> 
>>> Any help on this is appreciated.
>>> 
>>> Thanks
>>> 
>>>  
>>> 
>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ves/attachments/20130207/61d39dd0/attachment-0001.html>


More information about the Ves mailing list