Archive for the ‘ 3D ’ Category

 
Sunday, November 30th, 2008

Yep, i made my submission to 25lines contest just few days ago (right in time :) ), so (as Sakri did some days before me) I’m publishing my code. It’s an easy terrain generator…

Actually, I think it can be somehow improved both in lines of code and actual performances, so feel free to edit or tell me “you’d better to do that this other way…” :)

What’s going on is:

  • generate a shape filled with a gradient to create a reference color for differents “height”
  • generate a perlinNoise everyframe for dataprovider use
  • detect each perlinNoise pixel depth according with its main channel value (blue in this case..)
  • generating a vector of Bitmaps to be employed in the view
?View Code ACTIONSCRIPT
/**
 * 25-Line ActionScript Contest Entry
 *
 * Project: Random Terrain 3D Generator
 * Author:  Piergiorgio Niero (aka pigiuz) piergiorgio.niero[at]gmail.com
 * Date:    11/24/08
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
 
// 3 free lines! Alter the parameters of the following lines or remove them.
// Do not substitute other code for the three lines in this section
[SWF(width=800, height=800, backgroundColor=0xffffff, frameRate=24)]
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
// 25 lines begins here!
var _bd:BitmapData = new BitmapData(50,50,false,0x0000FF);
var _points:Array = new Array(new Point());
var _vxCont:Sprite = Sprite(addChild(new Sprite));
_vxCont.x = _vxCont.y = 400;
var _vexels:Vector. = new Vector.((2500),true);
var _hMap:BitmapData = new BitmapData(255,1,false);
var _gradient:Shape = new Shape();
_gradient.graphics.beginGradientFill( GradientType.LINEAR,new Array( 0x4267F9, 0xF9EAB0, 0x9EF07D, 0x8DF273, 0x9D5E1E, 0xFFFFFF ),new Array( 1, 1, 1, 1, 1, 1 ),new Array( 90, 105, 110, 120, 145, 185 ),new Matrix(0.2456396484375,0,0,0.0006103524625,127.5,.5));
_gradient.graphics.drawRect(0,0,255,1);
_hMap.draw(_gradient);
addEventListener(Event.ENTER_FRAME,generatePerlinNoise);
function generatePerlinNoise(e:Event=null):void{
	_bd.perlinNoise(25,25,1,0,false,true,4,false,_points);
	Point(_points[0]).y+=1;
	for(var v:uint=0;v<(2500);v++){
		_vexels[v] = (_vexels[v]==null)?generateVoxel(v):_vexels[v];
		_vexels[v].y = Math.pow((_bd.getPixel(v%50,Math.floor((v/50))) & 0xFF)/255*6,3)*24*.24;
		_vxCont.rotationX = mouseY*.1;
		_vxCont.rotationY = (_vxCont.rotationY-(90/stage.stageWidth*(mouseX-stage.stageWidth)+45))*.5;
		_vexels[v].bitmapData.floodFill(0,0,_hMap.getPixel(255-(_bd.getPixel(v%50,Math.floor((v/50))) & 0xFF),0));}}
function generateVoxel(v:uint):Bitmap{
	var b:Bitmap = new Bitmap(new BitmapData(24*.5,24*.5,false,0x000000),"auto",false);
	b.x = v%50*24-(_bd.width*24*.5);
	b.z = Math.floor((v/50))*24-(_bd.height*24*.5);
	return Bitmap(_vxCont.addChild(b));}
// 25 lines ends here!
 
enjoy ;)

 
Monday, October 6th, 2008

I’m digging into MMOs, now testing papervision2 cow model (unfortunately i’m not a modeler, but i’m a pretty good thief :) ) and put it on my testing stage…here’s the result…40 COWS! quite good uh? :)

cows! :D

Let me know how it runs on your machines ;)

Stay tuned :)

 
Friday, October 3rd, 2008

Here is my very first test on MMOs with Papervision3D on Flash Player 10 (needed to watch properly).

pv3d_isometric_01

here’s the link http://www.flashfuck.it/test/pv3d_isometry_01/

this is just the beginning…it has to be tuned and refined but, yes, it can be done ;)

PS: I stolen the model somewhere on the web…please if it is yours don’t offend yourself, i stole it because it’s good ;) (anyway let me know so i can put your name somewhere :) )

 
Thursday, July 3rd, 2008

It’s PaperKing time!!!¬† :D

A new contest has been lauched by pv3d guys. Just make an opensource “something” using Papervision3D framework and submit!

Deadline is 15th August…then a new PaperKing will sit on his 3D Throne :D

Get here for more information :D

stay tuned ;)

 
Thursday, June 26th, 2008

I just moved to my fresh new country  and started studing for my new job :)

I’m trying to get a usual “virtual world” scene (such as second life’s) using (possibly free and open) as3 3D frameworks, so my first choice has been papervision3D.

Unfortunately I’m not a 3D modeler so I had to get models from the web, anyway google sketchup warehouse is a very good resource to collect DAEs (but remember they may be not parsable by ascollada).
For the human model I’ve just “stolen” a walking girl from 3Dflasho.
…and here’s what I got combining the 2 models: a girl walking in a stadium. (girl is automatically walking forward, just use left and right arrows to make her turn)

pv3dstadium.jpg

(note: textures are about 7 mb and the whole swf is very cpu intensive) 

Take a look to the profiler, you can notice that framerate is very low even on a very good machine (i had a value range from 12 to 18 with everything loaded and 26\28 for the girl only on a macbookpro 2.4ghz and flash player 9.0.124 debug).

Next steps for me are:

1) try the same models on Away3D and maybe on Alternativa

2) search for better models (expecially for the stadium which generates too many culling issues on the ground)

3) have a mana potion

I hope to get good news from papervision and away3d mailing lists about flash 10 implementations, expecially about both engines’ drawing speed..in the while I’m going on with my tests :D

Here’s two big interviews. Guys from “Papervision Daily” and “Dreaming in Flash” (be sure to have both links among your bookmarks ) had the good idea to take an interview from Ralph Hauwert (from Papervision3D core team) and Rob Bateman (from Away3D core team).
Both interviews are about what’s next to new Astro features and what kind of benefits is PixelBender (AIF) giving to their engines.

I highly suggest to take a look to those interviews, just to be aware of what’s going on :)

here’s the links:

..and here’s the little summary:

  1. Features such as native 3D APIs won’t affect both engines because they’re based on drawing triangles (skewing)
  2. Otherwise, new drawing APIs will strongly improve both engines performances, vectors of drawTriangle instruction will replace arrays of very long drawing instructions
  3. PixelBender will enhace shaders’ performances, Ralph talks about 10 times faster… Both are quite sure this technology will be used on shaders.
  4. Both are assuming it would be great (but not a priority) to implement vector render (as Five3D already does)

stay tuned,

byez

 
Monday, June 2nd, 2008

I just found a very good tutorial by Senocular able to clarify every (or at least many) doubt and misunderstanding about practices to bring 3D effects in Flash.¬† Here’s the link http://www.kirupa.com/developer/actionscript/3dindex.htm

I don’t know if someone would be interested in this kind of experiments, there are many good projects that make 3D approach easier than build your own engine. However even if Papervision or Away3D let us make 3D content (..oh, i forgot to add flash 10 to this list :D ) I think it’s always better to understand what’s going on behind the scenes to better comprehend what’s the magic made of :)

 
Sunday, June 1st, 2008

June is starting from two big hot news for flash 3D fans and devs:

ist2_5320460_calendar_june.jpg

  1. Papervision team merged Great White and Effects branches, now effects are considered “stable” (as a beta can be :) ) and they’ve been included in the project core. There’s a plenty of synthax and logic changes but the result is pretty awesome, so update your working copy from great white svn and visit Zupko’s blog to keep you up to date. Note for devs: From now on “effects” branch on svn is to be considered deprecated.
  2. Alternativa Platform is ready to try!!!!! From Russia with love, this cutting edge 3D project finally is available for download and test. The major interest for me is to try out a 3d engine already cooked for flash player 10. Anyway keep calm your blood, whilst Alternativa is a really kickin ass project it’s not free nor open, so if you’re already planning to build up something that will be commercial you have to send some roubles there in Russia :D

…no doubts about this is a good way to begin summer time :D