Skip navigation
Help

John Grden

warning: Creating default object from empty value in /var/www/vhosts/sayforward.com/subdomains/recorder/httpdocs/modules/taxonomy/taxonomy.pages.inc on line 33.


Well, people often wonder why I tweet so little and why there are such long stretches in between.  The answer is simple enough:  I work.  Well, it’s more complicated than that, I work, I’m headcoach for my son’s football team, my daughter is in both soccer AND volley ball and I’m involved in all of them in some way or another.  That, and I just came off of a really nice game project that took 7 months of my life, and I can’t seem to do social network stuff while working and still be productive.  I don’t know how you all do it!  Anyway, I’d been wanting to do SOMETHING of a blog post just to get back into contributing to the Unity community, and so when I came off this current project, it was my turn to post something on the IR5 blog – YAY!

So, since Unite 11 is starting today and I’d promised to do a demo on this back in 09′ while speaking at Unite 09, I figured it was time to make good on my promise.  I’ve finally put it all together in a very simple, yet flushed out, demo of how I did dog fighting in The Trench Run.

Check out the post, files and demo over at infrared5.com

Enjoy!

0
Your rating: None

Well, I finally came up with a fix for this issue and thought to archive it.  Basically, the issue is that when you have textfields in a Sprite that you use for a material source for Papervision3D, you want to be able to set focus to those text fields.  Without them being on stage, however, it doesn’t work to say “stage.focus = myTextField”.

So, very simply, all you have to do is add the textfield to the stage, then use stage.focus = myTextField, then re-add back to your Sprite.  Bingo, you have focus in your TextField.  Now, I should say, that i’ve seen it work with just using stage.focus = myTextField, but in this particular situation, adding it to the stage first, then setting focus, then adding it back worked.  So give it a whirl either way.

example:

stage.addChild(myTextField);
stage.focus = myTextField;
this.addChild(myTextField);

Bam! done.  As long as you’re redrawing your material so that you can see what you’re typing ( bitmapMaterial.drawBitmap()), it’ll work just fine.

Tabbing is controlled easily with:


protected function handleKeyUp(e:KeyboardEvent):void
{
if( e.keyCode == 9 ) // tab
{
if( currentField == username )
changeToPassword();
else if( currentField == password )
changeToUsername();
}
}

hope that helps someone!

0
Your rating: None

If you haven’t seen it yet, Andy Zupko just released QuadTree for Papervision3D! He also released a more indepth look at using the new features on his blog. A big huge thanks to the Away3D team for their code and brilliance!  Andy was able to port it over to work with Papervision3D rather well and we’ve added some features that I think everyone will want to take advantage of.

So, what is QuadTree?  Well, in simple terms, its corrective z sorting for a 3D scene.  Say wha?  In other words, when you have 2 triangles who’s size is bigger than the distance between them, you will sometimes see sorting issues depending on the angle the camera is to the triangles.

It makes this:

Look like this:

How do I use it?

Now, this is very easy to use with Papervision3D.  Instead of creating a BasicRenderEngine, you’d now use the new QuadrantRenderEngine object instead:

var renderer:QuadrantRenderEngine = new QuadrantRenderEngine(QuadrantRenderEngine.CORRECT_Z_FILTER);

You’ll notice that there’s one argument about which type of filter to use.  On the sample I’ve created, I used the CORRECT_Z_FILTER which is the faster filter of the 3 options.  It simply takes care of z sorting of triangles.

Two new features added for speed

There’s also 2 other options worth mentioning.  One is the ability to tell QuadTree that any particular DO3D is not to be tested on each render (DisplayObject3D.testQuad:Boolean=true).  The default setting is true, but you can set it to false.  The second option is the maxLevel setting.  This controls the regions of the QuadTree.  Having less does NOT mean better performance.   You have to find a nice balance between the # of tri’s you have and how many regions gives you the best bang for the buck.

You might be asking yourself “why would I only want certain objects to be tested for z sorting fixes?”.  Well, the example I’ve created shows you just a instance that you *would* choose to be very picky about what QuadTree does and doesn’t test on.  This example is using the 3D object I’d made for my Mom’s site.  When you first load the sample, it is *not* including the big white mass in the middle (under the panels) in the QuadTree testing.  To activate it, hit the “s” key on the keyboard, and you’ll notice a decrease in performance.  In this particular type of demo, not testing the biggest object in the scene pays off as the panels above it are still corrected.  That’s a substantial savings.

Also, if you want to see how maxLevel affects performance, use the Q and A buttons to increase and decrease the maxLevel.  As I said earlier, a lower number does not equal better performance.  You just have to find a nice middle ground.  The default value, btw, is 4 and my demo seemed to run better set to 3.

Try it out here

My point, all along, is proven true ;)

Now, this all leads me to a point that I’ve been making since this topic and request for corrective z sorting came up a long time ago.  My point has been:  If you have the 3D model, fix the sorting yourself - its FAR faster performance-wize than QuadTree could ever be.  And my example here proves my point.

In the pictures below, I have the original version of my 3D object, and then a new version with the Panels much closer to the surface of the main structure.  The only difference between the 2 visually, is JUST that:  the panels are simply closer to the main structure.

Original:

The new QuadTree enhanced version:

When you run my sample, just hit “T” to switch between the QuadTree enhanced version and my original model.  You’ll see a huge difference in performance.  Yes, there are still some sorting issues in my model, but I could very easily go in and split the triangles by hand to fix those minor issues.  And I’d still have a very fast presentation.  While I would agree that having the panels closer to the main object looks a bit nicer, it’s not “nice enough” to justify the CPU/performance.

Now don’t go and take this as “John thinks QuadTree is useless” - I don’t think that, but I do think it’s uses are very confined given the speed we all live with in Flash 3D.  It’s awesome to see it working, and I would love to see good samples of it in production for sure, but if speed is what you need, you’ll likely end up fixing your sorting issues by hand in a good editor.  Of course, I haven’t talked about triangles colliding, which is something QuadTree deals with as well.  But for more information on that, head over to Andy’s blog for a full explanation ;)

Conclusion

Corrective Z sorting is a very cool feature to have indeed and, btw, the most requested.  But so was shaders before they came out.  Now ask yourself, “how much do I use shaders these days?”  I’d venture a guess that your answer is hardly ever - if ever.  I think we’ll see more need for QuadTree than shaders, but I don’t think that QuadTree is the miracle pill we’ll all be able to leverage very often to fix our sorting issues.  That will most likely STILL fall on the hands of the 3D modeler 95% of the time I would bet.

      

0
Your rating: None

*UPDATE*
Apparently adobe scheduled maintenance this saturday during the scheduled time for the course (which blows tremendously -they could have asked if anyone was doing something during those hours) I guess it could be argued that no time is a good time, but I'd argue back that midnight would be 90% better option I'm willing to bet... Just sayin'

Anyway, we ARE going to reschedule it asap (like in the next week or 2), and RMI is extending the viewable recording of the session to 2 months for the inconvenience to the students. Sorry for the hassle guys

I'm sorry I'm late on announcing this, I've been super busy with this current client and trying to get everything else done for the course has just consumed all motor skills and brain cells ;(

I'm taking a break from traveling for a while, so RMI has set me up with some on-line course time and this weekend (saturday), I'm going to pouring over the Winterwonder Land application and talking about optimization techniques for Papervision and the flash Player in general.

In the course files, I'm including nearly all the demo's I used for the classes I taught in person as well as the source for Winterwonder Land's animation engine etc.

If you're interested, you can sign up over at RMI's site:

http://www.richmediainstitute.com/node/142

Hope to see you there!

0
Your rating: None

What turned out to be just something to finally scratch a strict typing itch i'd had with tweening has no become and full blown side project. Not only did Moses get me started, but Graeme Asher and John Lindquist fueled the fire as well. Graeme's been working on Tween3DCamera and John's been helping me add some other properties like scale/scaleX/scaleY/scaleZ to the property types as well as a small refactor.

If you've tried Go3D lately, you'll notice that I had put static property methods (yeah kinda weird name, but that's what they do ) in Go3D.as, but have now moved them to Value.as in the properties directory. It seemed to make alot more sense with what their function was, and Go3D.as has been deleted for now since it serves no purpose.

check out the project here:
http://code.google.com/p/goplayground/wiki/JohnGrden

svn:
http://goplayground.googlecode.com/svn/trunk/JohnGrden/GO3D

One thing I added just today was the ability to pass a tweenTarget for a 3D object. If you look at the code samples below, you can now just pass a target and it's position and rotation will be used to tween to. You can also use constants to just tween to position or just rotation. You can also pass custom properties for it to use with the target. The swf demo I've posted in the playground basically tells the Cylinder object to use the properties of the orange sphere.

PLAIN TEXT
Actionscript:

  1. protected function tweenAll(e:Event=null):void
  2. {
  3.     resettargetObject();
  4.     tween = new Tween3D(targetObject, [Value.tweenTarget(middleObject)], duration, Easing.easeOutElastic);
  5.     tween.start();
  6. }
  7.  
  8. protected function tweenXYZ(e:Event=null):void
  9. {
  10.     resettargetObject();
  11.     tween = new Tween3D(targetObject, [Value.tweenTarget(middleObject, Value.XYZ)], duration, Easing.easeOutElastic);
  12.     tween.start();
  13. }
  14.        
  15. protected function tweenCustom(e:Event=null):void
  16. {
  17.     resettargetObject();
  18.     tween = new Tween3D(targetObject, [Value.tweenTarget(middleObject, [Value.X, Value.Y])], duration, Easing.easeOutElastic);
  19.     tween.start();
  20. }
  21.  
  22. protected function tweenRandom(e:Event=null):void
  23. {
  24.     tween = new Tween3D(targetObject, [Value.x(getRandom()), Value.y(getRandom()*.5), Value.z(getRandom())], duration, Easing.easeOutElastic);
  25.     tween.start();
  26. }

Value.tweenTarget() returns an array of Go3DProperty objects that Tween3D expects to get to do the tween. It's basically a convenient, yet strictly typed way of doing things. I'd say we're having as much fun as untyped objects at this point - Even more probably ;)

Note:
I'll be teaching on Go3D at the Toronto class in 2 weeks, and if you haven't signed up yet, I seriously suggest getting out there asap - seats are filling up

Now, the reason I say we need base 3D classes for all 3D engines to use is because in a situation where I want to open this up for Sandy3D or Away3D or any other 3D engine that uses x/y/z/rotationX/Y/Z/scaleX/Y/Z, I'd have to write specific classes tailored to their api and object types.

We need to have one set of common 3D classes that define the atom level of a 3D object with the main 10 properties:

x, y, z, rotationX/Y/Z, scale, scaleX/Y/Z

So, I'm going to be starting such an effort and see how that pans out ;) It makes too much sense especially when you consider any project that has to work with a 3D engine, but isn't integrated with the code base. ASCollada being one, and Go3D being another.

I'd love to hear people's thoughts on this matter.

0
Your rating: None