0

I am trying to manipulate a 3D object with gestures. In order to accomplish my task I need to implement some custom GesturesRecognizer.

I am subclassing UIGestureRecognizer to detect the gestures.

What I need to do is to access the vertices of the 3D object, which is drawn on the screen. I have this data in my ViewController class. Say, I want to know the normal of the facet use r is touching.

Although, I can try to access ViewController from the View which will be connected to the Custom Gesture by some means, I dont think, this is a good way to access the object.

My question here is...

Is it ok to make an instance variable of some struct holding vertex/normal information of a 3D object in View controller.

If not what would be the best way to store such information to render objects.

Another thing I want to ask here is

Is it a good way to access View Controller from Custom Gesture through the view it is connected to?

Kindly suggest me the best way handle my problem.

Sagar Ranglani
  • 5,491
  • 4
  • 34
  • 47

1 Answers1

0

Can't you set up and handle the gesture recognizer in view controller's code instead of view's code? That would enable you to access view controller's data in an easy and clear way.

And regarding vertex/normal struct, have you considered creating a model (data source) for your view and keeping that kind of data over there? That would seem a sane solution from MVC point of view.

ayoy
  • 3,835
  • 19
  • 20
  • Thank you for responding. As I would need many gestureRecognizers, I Actually, subclassed the UIGestureRecognizer Class to recognize the gesture and I am handling the gesture in View-Controller. After I define the custom gestureRecognizer class, I attach this gestureRecognizer to the view (in view-controller code) and then I can access the view in Gesture Reognizer class using [self view]. Since I need to the information of view-controller in the custom gestureRecognizer (subclass of UIGestureRecognizer) I dont know what is the best way to do that. – Sagar Ranglani Oct 22 '11 at 05:22
  • For the second case, I have a Shape class which has functions to read mesh data files (obj files in specific) and can store Vertex/Normal/TexCoord data in it. I made a ivar of this class in view-Controller class and sent msgs to read files from view-controller methods. Since the object of this class is allocated in View-Controller I can access its data from View-controller and render what I want. It seems it may not be good solution from MVC point of view. I wish to know the best way to do this. Thanks a ton. – Sagar Ranglani Oct 22 '11 at 05:32