PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: Tipz on April 27, 2009, 02:14:45



Title: Papervision and MVC
Post by: Tipz on April 27, 2009, 02:14:45
Hi guys am planning on using puremvc on my next papervision project. Whats the best way to implement papervision with multicore. Does each of the facade have its own Viewport3D or just the 3d objects? Also whats the best way to control the camera across all facades.

any help would be appreciated
cheers


Title: Re: Papervision and MVC
Post by: puremvc on April 27, 2009, 05:37:09
This will really depend a lot on what you're doing in each module. If all the rendering takes place in one module, then you don't have a problem coordinating the camara amoungst them.

We'll need to understand more about your intended architecture.

-=Cliff>


Title: Re: Papervision and MVC
Post by: Tipz on April 27, 2009, 09:03:40
Thanks for the quick reply Cliff. I must tell you i love coding using the pureMVC framework. Made my life so much easier.

Ok about the papervision project. It is a flash website, am using flashdevelop and Flex SDK to develop it. Here is what am planning to to.  There is going to be an intro logo in 3d on clicking the logo more 3d objects would be added to the scene. Each object would represent for eg: "services", "contact" etc... On clicking these objects some events would take place.

I would like to have the main facade as the background and keep each object as its own facade. Then here is my confusion how do i add all these objects to one 3d scene.

Cheers


Title: Re: Papervision and MVC
Post by: meekgeek on April 29, 2009, 10:13:35
I too would like to know how to best develop something like this.

My company and I just completed a project similar to this.  I love this framework and used the Alternativa Platform.  The issue with this is that all of the 3d engines out there are so closely tied to the stage.  I would like to find something out there better suited for the framework.

My solution was kind of messy but it worked for now.  I basically placed most of my 3d code in the main module class, which extends “PipeAwareModule.”  The Mediator that mediates that class can then register other mediators to mediate parts of the engine if you need to.

Anyway, like I said, don’t think this is the best solution but it worked for me.



Title: Re: Papervision and MVC
Post by: puremvc on May 02, 2009, 09:56:25
Check out the way the Modularity demo has a shell that allows modules to add components to a canvas owned by the app. To do so it exposes an interface that the modules call to add or remove a visual component.

You could have a module that owns the 3D scene and allow other modules to add objects to the scene that way.

You could also follow the path of PipeWorks, where instead modules calling interface methods on each other, they request components be manufactured and exported using messages. So a module that generates Spheres could receive a request for a sphere of a certain radius and number of points, say. It would create the sphere (possibly registering a mediator for it) and export it via a message on a pipe leading to a module that takes the sphere and places it in the scene.

Why might the sphere need a mediator? Because you might also send notifications to the sphere module that says turn on shading for a given sphere or all spheres.

In your case the module may generate the various 3d menu objects, which you want mediators to be listening for and sending out messages (or making interface calls) to other modules to make things happen.

-=Cliff>


Title: Re: Papervision and MVC
Post by: Tipz on May 13, 2009, 10:13:40
Thanks for your reply Cliff. I tried the module way am able to add and remove 3d objects that way. The problem arises when i want to control the camera. I want to have access to this one camera that is created in the shell. What is the best way for other modules to have access to this? I was thinking of having a global variable with the camera, but not sure if this is the way forward. Any suggestions?

Cheers


Title: Re: Papervision and MVC
Post by: puremvc on May 13, 2009, 11:19:38
Why not have a camara module that you send messages to when you want it to do something? Can you explain why you need to grab access to the camara everywhere?

-=Cliff>


Title: Re: Papervision and MVC
Post by: Tipz on May 13, 2009, 11:39:03
Thanks for the quick reply. May be i dont get the concept as am not a seasoned programmer, thanks for your patience. Here is my problem. Say i create 3 modules (what i mean by modules is having its own facade) each being a 3d object. When i add the first module to the widgitshell using the interface, i would like to make some camera movements, like wise for the other two modules. So if i had access to the camera within each of the modules i could control it.  This way each of the modules have its own camera movement.

Cheers
Tipz


Title: Re: Papervision and MVC
Post by: puremvc on May 14, 2009, 05:41:48
But then each of the modules necessarily needs to be able to drive the camara, and thus you'll spread a lot of the same logic around the app.

Consider the distribution of responsibility on a movie set. There's one camaraman, and lots of actors to shoot. The actors don't trouble themselves with making sure the camara's pointed at their good side. That's the job of the director who's looking over the camaraman's shoulder and at the set. The director gives queues to the camaraman as well as the actors.

This may seem a bit tangential, but building an OOP app is often analagous to building a specialized team of people, because you're taking the work to be done and imbuing various classes with various roles and responsibilities.

In a company where people 'wear lots of hats', often it means that not much thought has been given to distribution of responsibility, and people often don't know who to go to for what. In a company where people have clearly assigned roles and responsibilities, you always know who to go to for what.

So back to your modules. What if there was a director module and a camaraman module, and the director was the one that actually placed the actors on the stage and coordinated their appearance with camaraman to make sure the camara was pointed the right direction when they entered?

-=Cliff>


Title: Re: Papervision and MVC
Post by: Tipz on May 14, 2009, 10:03:56
Thanks for that i now understand the concept.

This is how i see it.
1. Using widgitshell as my papervision base class i can add and remove other modules (3d objects) through the iwidgit interface.
2. If i use widgitshell as my papervision base class i would need to use this papervsion method
:
renderer.renderScene(default_scene, default_camera, viewport); which runs on enterframe event, to render the 3dscene.
3. Now if i have the camera as a module do i pass the camera through the iwidgit interface to be rendered?
4. How would the widgitshell pass information about modules being added, to the camera, so the camera could make appropriate movements?
5. Is there a way the modules could communicate with each other?

when you say module, do you mean a package with its own facade?

Cheers


Title: Re: Papervision and MVC
Post by: Jason MacDonald on May 14, 2009, 10:28:21
5. Is there a way the modules could communicate with each other?


You can use an interface, the Pipes Utility (http://trac.puremvc.org/Utility_AS3_MultiCore_Pipes) or Fabrication (http://forums.puremvc.org/index.php?board=63.0).


Title: Re: Papervision and MVC
Post by: Tipz on May 14, 2009, 12:16:48
Thanks for your reply mate, i am from a designer background no programming knowledge what so ever. Started getting my head around as3 and was beginning to get my head around PureMVC, now i need to learn plumbing and fabricating  :o. Is it ever gonna stop... :'(.

Had a look at Fabrication, its really interesting, never knew it existed. Would you say using Fabrication is better than just pureMVC multicore and pipeworks?

Cheers


Title: Re: Papervision and MVC
Post by: Jason MacDonald on May 14, 2009, 01:50:24
Thanks for your reply mate, i am from a designer background no programming knowledge what so ever. Started getting my head around as3 and was beginning to get my head around PureMVC, now i need to learn plumbing and fabricating  :o. Is it ever gonna stop... :'(.

Had a look at Fabrication, its really interesting, never knew it existed. Would you say using Fabrication is better than just pureMVC multicore and pipeworks?

Cheers

It's easier to get going with Fabrication, in my opinion. But Fabrication is, at it's heart, a wrapper to simplify the use of Multi-core and Pipes. It still uses pipes and multi-core to accomplish it's communication between modules, it just helps you avoid doing the nitty-gritty part of hooking-up and managing the pipes between modules.

If you are the type of person who likes to really understand how the plumping (pun not intended) works, then try using Pipes with Multi-core on their own. If you just wanna get going fast, and write a little less boiler plate code in the process, use Fabrication (it also has some additional features).


Title: Re: Papervision and MVC
Post by: Tipz on May 15, 2009, 12:12:33
Thanks for your reply Jason. Does using Fabrication in any way divert from the mvc framework.


Title: Re: Papervision and MVC
Post by: Jason MacDonald on May 15, 2009, 05:56:21
Thanks for your reply Jason. Does using Fabrication in any way divert from the mvc framework.

No. It's just an extension built on top of PureMVC to making communication with modules simpler. Underneath it's still PMVC and Pipes.


Title: Re: Papervision and MVC
Post by: puremvc on May 15, 2009, 07:44:00
Yes, by module, I mean a loaded SWF or Flex Module with its own Facade. When referring to either the shell or a module interchangably I say 'core'.

Cores can communicate using interfaces or pipes. See the PipeWorks MultiCore demo and the Pipes Utility to see how pipe communications work.
For a real world app, you can also check out the Sea of Arrows site, which uses pipes to allow the shell to talk to the playlist module and the playlist module to communicate with the visuals module. The shell provides the main layout and plumbs the cores. Then it asks the playlist module to manufacture large and small versions of the playlist selector and the track selector. Inside the playlist module, when a track is played, the playlist module asks the visuals module to manufacure a spectrum analyzer to  display while the track plays. (I'm extending the visuals module to create other types of visuals per track, which is why its a separate core).

http://seaofarrows.com

http://seaofarrows.com/srcview

-=Cliff>


Title: Re: Papervision and MVC
Post by: taymless on May 18, 2009, 02:08:59
Hi there,

I've been following this thread for the last few days and I finally got my account approved, yeah :).

In the first place I should say, that my post will not answer any of the questions here, instead I will ask some questions regarding the same topic. If someone thinks this is the wrong place for that, let me know so I can create a new thread for this.

I am also considering PureMVC for my next PV3D project and have been asking myself how the abstraction would work. Unfortunately Tipz already had an idea, so I would really love to know how that would work.

I just couldn't solve the question how I would seperate the PV3D "scene" from my objects.

In my application I will have an overview of different objects, which you can select. Lets say these are different categories.
Depending on which category you clicked, a new scene, the innerview, would appear. In this innerview I'd also have different objects which can be clicked. Doing that would show a detailed view of that object, but staying in the innerview.

I would seperate all the innerviews in individual swfs. Which would obviously lead to the MultiCore version of pmvc and the module-approach you've been talking about.

I just don't seem to unterstand how the overview and the innerview would be combined and how I would apply the MVC-pattern on the PV3D-structure.

Based on your ideas I would create a module for the overview, having it's own facade and his own pv3d-objects (scene, renderer, etc.) and a module for each innerview.

Should I create a Mediator for the "3DView" which would include the scene/viewport/renderer/camera?
Would an object (e.g. a cube) be a VC with it's own Mediator?

Antoher big question is, would pmvc have a bad influence on my performance, considering that pv3d is very weak in that matter?

Hope my english is pretty much understandable and the questions don't seem as confused as I am ;)


Title: Re: Papervision and MVC
Post by: puremvc on May 18, 2009, 06:58:43
I don't believ PureMVC will slow down your demo relative to say a brute force approach. And yes, I imagine your scene objects being view components, tended by mediators. This allows you to send, say, a TWIRL notification and have a number of mediators respond causing their objects to do a little piroette on the stage, for instance.

-=Cliff>


Title: Re: Papervision and MVC
Post by: taymless on May 18, 2009, 08:57:09
Well, that's kind of a relieve to hear that I wasn't that far away from getting it ;).

I worked on a first idea how the structure would look like and I'd really love some feedback.

(http://blaupause.eu/file/overview.jpg)

I'm still not sure if I'm on the right way, so let me know if there's a major misunderstanding on my side.

Thanks so far.


Title: Re: Papervision and MVC
Post by: Tipz on May 18, 2009, 11:51:34
Thanks for all your input guys. Am now trying out a demo using fabricate. If i succeed i will post on how i went about it, if not i will be back  ;D


Title: Re: Papervision and MVC
Post by: puremvc on May 18, 2009, 12:57:05
@taymless this looks like a reasonable setup to me.

-=Cliff>


Title: Re: Papervision and MVC
Post by: taymless on May 19, 2009, 12:36:45
Thanks Cliff, I think I'm getting closer to what it should be. Now I only need to weigh up, if it's smart to try something new like pmvc in the project for my bachelor thesis.

If I screw this up, it would be a load of time to recover, considering I only got the next 11 weeks for programming and writing the thesis.

Still, thanks for your help so far. If I keep working with pmvc on this project, I will clearly have to come back for more questions and will also document some of the results I've got.


Title: Re: Papervision and MVC
Post by: puremvc on May 19, 2009, 08:58:26
Feel free to ask away! I'm here to help, and lots of others are as well.

It looks to me like you've got the gist of the PureMVC approach. If you've got eleven weeks to work on this, I believe you'll do fine.

Again, don't hesitate to post, but do make sure you've read the PureMVC docs, they'll help you out a lot and might actually help you make your decision about sticking with PureMVC for the project.

-=Cliff>