Re: MVC roles of objects in pattern
Re: MVC roles of objects in pattern
- Subject: Re: MVC roles of objects in pattern
- From: "ad veloper" <email@hidden>
- Date: Fri, 5 Oct 2007 18:52:55 +0100
> In my understanding of MVC, your view should only communicate with
> controller object(s).
That's my understanding, too.
> Thus, it should not have an instance of Camera
> (a model object. It is a model object, right?) So, mouse events
> should be captured by a controller object. The controller should
> update your model object (reposition coordinates of the world or
> objects or whatever), then another controller object (or the same
> one) will update the view using the data in your model.
>
> Did that answer any of your questions?
>
Very helpful, thanks.
In /Developer/Examples/OpenGL/Cocoa/GLSLEditorSample we find the
following snippet from GLSLView.h
typedef struct {
GLdouble x,y,z;
} recVec;
typedef struct {
recVec viewPos; // View position
recVec viewDir; // View direction vector
recVec viewUp; // View up direction
recVec rotPoint; // Point to rotate about
GLdouble aperture; // pContextInfo->camera aperture
GLint viewWidth, viewHeight; // current window/screen height and width
} recCamera;
I have put Class wrappers around these 2 structs and then manage an
array of them in my controller class, which kind of shifts them out of
the View side of things. However, as my view is in the business of
handling mouse events and updating the camera's coordinates, it seems
logical to me that the best kind of object to bind the arrays selected
object to is an instance of camera in the View.
You see, what I really want to do is animate between camera objects.
So my plan was to leave the View with its Camera instance, and then
when the selectionIndex changes in the controller, trigger an
animation that handles transitions between the 2 objects, i.e. the
(view) Camera moves to new Camera (model).
In the case I've outlined it seems that without the bound array, one
still has a functioning View, managing an array of cameras is
something the View is almost unaware of - a bonus, so to speak.
That's not to say that what I've just said doesn't smell fishy to me,
because it does! I'm just playing Devil's advocate to my own
ignorance.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden