TwelvestoneFlash

PV3D, interactivity, and container


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
baron ruhstoff
 
2009-01-22

I've hit a roadblock trying to set the buttonMode for a given object. Here's where I'm at so far (very simplified):

var container:Sprite = getSimplePrimitive().container; container.buttonMode = true;

I'm getting a 1009 for container. Any ideas what might be going on?

Also, it seems like there are few extra hoops through which one must jump to get interactivity in Papervision. What's the thinking behind this? It's not that I mind at all - just trying to get a handle on the big picture.

// edit: running Papervision3D Public Beta 2.0 - Great White (December 3rd, 2008)

pyrogen
 
2009-01-22

you need to set the viewport to interactive.

viewport = new Viewport3D(1200, 600, false, true, true, true);

Then set your material's interactive property to true.

        var planeM:ColorMaterial = new ColorMaterial( 0x000000 )            
        planeM.interactive = true;

        var yourPlane:Plane = new Plane( recordM , 445, 500 , 2, 2 );

        yourPlane.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, mousePressHandler);
        yourPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, mouseOverHandler);
        yourPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, mouseOutHandler);

then in the mouseOverHandler and mouseOutHandler, set the viewport.buttonMode to true and false respectively.

public function mouseOutHandler( ev:InteractiveScene3DEvent ) :void {

        viewport.buttonMode = false;

}

public function mouseOverHandler( ev:InteractiveScene3DEvent ) :void {

        viewport.buttonMode = true;

}

that should do it

baron ruhstoff
 
2009-01-22

You, sir, are a gentleman and a scholar.

baron ruhstoff
 
2009-01-22

What's up with this mysterious container object? People seem to like using it to handle mouse events (specifically, in conjunction with a dictionary), but I can't create a situation where it is defined. The reason I ask is now that I've moved on to handling mouse events, I'm struggling wrapping my head around InteractiveScene3DEvent. What's the relationship between InteractiveScene3DEvent.displayObject3D and InteractiveScene3DEvent.sprite? Why does the documentation suck so much assneckhard? Why are we here? What does it all mean?

pyrogen
 
2009-01-22

container is a property you can set to have each primative or dipalyObject have its own container, it really slows shit down though performance wise.

better off using the method i delineated.

also, primatives have the extra property, which you can use to pass id and crap so one can retrieve them from the event:InteractiveScene3DEvent

/// plane init shit

var planeM:ColorMaterial = new ColorMaterial( 0x000000 )
planeM.interactive = true;

        var yourPlane = new Plane( recordM , 445, 500 , 2, 2 );
            yourPlane.extra = { id:0 };
        yourPlane.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, mousePressHandler);
        yourPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, mouseOverHandler);
        yourPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, mouseOutHandler);

public function mouseOutHandler( ev:InteractiveScene3DEvent ) :void { var id:Number = ev.target.extra.id viewport.buttonMode = false;

}

pyrogen
 
2009-01-23

InteractiveScene3DEvent returns displayObject3D and sprite. InteractiveScene3DEvent.displayObject3D is the object that generated the event, and sprite is the overlay container that actually captured the

event.

soooo

you can do this:

public function mouseOutHandler( ev:InteractiveScene3DEvent ) :void { var id:Number = ev.target.extra.id viewport.buttonMode = false; trace( ev.displayObject3D.name ) // disaplyObject3D trace( ev.sprite ) // say you have filters on the viewport or what ever

}

pyrogen
 
2009-01-23

heh did not mean to sound snarky k

i kinda went into geek mode.

hope that helps.

JLM
 
2009-01-23

pyrogen I think you missed out some stuff, although I may not be completely up to date.

This link explain the effects branchhttp://blog.zupko.info/?p=129

Basically early versions of papervision used separate sprites for each plane in a scene, but this was slow to render so all the triangles are now sorted and drawn in a single sprite.

The effects branch brought back some aspect of the early version allowing you to use layers (specify a sprite to render some of the scene in a layer ( viewportlayer )) or set a plane to useOwnContainer to true ( render triangles for plane is its own sprite). But using effects structures is heavy and uses over head as does useOwnContainer.

Now the advantage of use own container is effectively that the plane can be treated as a MovieClip button, there is no fancy calculations needed and you can get the pointy hand easily.

However papervision does have a virtual mouse which simulates mouse over etc.., this also adds overhead, so you need to set both the plane interactive (a rollover detectable ) and the whole of papervison interactive (runs virtual mouse ) for it to work. The reason it is not automtically on is that to do the rollover/down detection it needs to loop through all interative elements durring the render cycle and detect the 2D coordinates for a hit and then sort the hits by depth to find the actual one. Now gaps between triangles can miss a hit and getting the handcursor working has been issues for me in the past along with the depth, so it can be rather unreliable.

The virtual mouse actually maps standard movieclip mouse events of your movie plane so you don't need to use the special InteractiveScene3DEvent stuff you can

just use regular mouse events

and listen to the 2d MovieClips hidden on stage that are used for the MovieMaterial.

For instance my first as3 project with a friend we used the virtual mouse on this http collon slash slash w w w dot milknosugar dot co dot uk slash equens slash

before effects was merged into pv, we did not need to use the InteractiveScene3DEvent directly.

pyrogen
 
2009-01-23

my understanding is that:

InteractiveScene3DEvent

is less over head than:

useOwnContainer

MovieMaterials also carry more over head than BitmapMaterials. Moving around bitmap data is less processing that moving around a lot of clips. The only clip would be your viewport.

are you saying otherwise?

I believe the way i am doing it is the preferred manner, but if i am wrong could you clearly state why?

yeah it's rough when it is not documented as well as it could be

Cheers k

JLM
 
2009-01-23

pyrogen

useOwnContainer is heavy, but it is more reliable and allows rollover effects. I actually use hit areas above papervision when its very critical.

MovieMaterial is more suitable than BitmapMaterials for interactive planes as you can map the events of various parts of the plane and have the plane auto update in the normal way, in effect you can ignore that you are in 3D and this is a very powerfull abstraction and will result in much clearer code.

One of the most important things with papervision is to treat it as an element or view of a project, try to abstract structures away from papervision rather than trying to build everything inside papervision.

It is very much down to what you are doing, you can't say this is the way to do it we need to understand a bit about whats happening and try different approaches, you can for instance get a picture with text below to render better if you render them in different planes as bitmap materials, as you can tweak the tiling and more importantly edges of planes don't distort much and you don't want the edge of a picture to distort.

If speed is a real issue for a button you can actually pre calculate the bitmapData yourself (put them in an array) for the roll over and swap the bitmap of the material at runtime, if you want to render alpha rather than useOwnCantainer you can calculate the alpha and store so that next time you don't have to calculate you just swap out an array.

Stuff like starting and stopping render.. can be important for skipping over bad render frames or frames that are slow to render due to acute angles, so I am not sure there is 'a' way its always a balance between speed and keeping the code clear and abstract enough to allow changes.

If you are not using a layer or container and you are not letting a movie material update then there is no difference in render between a BitmapMaterial and a MovieMaterial they both wrap a precalculated bitmap, so if you can use standard events on your sprite seems MovieMaterial is a much better option, although if its really critical testing is worthwhlie.

pyrogen
 
2009-01-23

JLM

It seemed to me that your earlier contention was that useOwnContainer was more effecient than InteractiveScene3DEvent approach, and it seems we both agree that that is not always true.

JLM
 
2009-01-23

Sorry not always good at being clear in words with my thoughts, the main aspect that I felt you had not covered in relation to interactive materials was using movie material

The virtual mouse actually maps standard movieclip mouse events of your movie plane so you don't need to use the special InteractiveScene3DEvent stuff you can

just use regular mouse events

(I am inclined to treat InteractiveScene3DEvent as a behind the scenes event.)

But interactive materials use a virtual mouse that has to do a lot of heavy work behind the scenes its a clever hack and if a client flags a bug in relation to it you may well be fucked, so its important to understand the alternatives and how they work (and for anyone not having read the effects link and know the history; layers and useOwnContainer is confusing) at the very least to educate clients about what might be possible, I guess I went into so much detail because I have had problems with virtual mouse, maybe others won't have difficult client requests k

But yes I agree interactive materials are often better, I just prefer to use them differently.

pyrogen
 
2009-01-23

definitely.

we should all try to post a papervision tip or question every week k

JLM
 
2009-01-23

I am looking at haXe at moment so far Sandy is the best supported 3D library so I intend to look at that more in near future rather that pv, my friend is interested in away so I may end up using all! Need to learn some 3d package as my collada knowledge is limited. Not managed to get any 12stoners into haXe ( so i can pick there brains ) yet, but I am trying, pyrogen why not try some haxe?

baron ruhstoff
 
2009-01-23

This has been really helpful, guys. Hopefully I can go through in more detail over the weekend.

Thanks!

pyrogen
 
2009-01-25

what kind haXe be used for commercially? Or is it just for fun?

I have been playing with FMS3 and red5 a bit lately, fun stuff.

pyrogen
 
2009-01-25

ah very cool

http://haxe.org/doc/intro

I will look into a bit more.

wet_boots
 
2009-02-08

Hi, this is really useful - thanks or the explanation - there's surprisingly little info around on this.

How would you go about detecting a releaseOutside after a press? I'm guessing you have to listen to something like the stage but i see there's an InteractiveScene3DEvent.OBJECT_RELEASE_OUTSIDE event, thing is I can't figure out how to use it (i'm trying to do a drag and drop).

Any help appreciated ta.

JLM
 
2009-02-09

did you try a button underneath pv?

wet_boots
 
2009-02-09

I ended up just listening to the stage as per usual like:http://www.kirupa.com/forum/showpost.php?p=1948182&postcount=204

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

PV3D, interactivity, and container