How To Make 3d Wireframes - A Flash Actionscript tutorial

free web hosting
Open Discussion > CONTRIBUTE > Tutorials

How To Make 3d Wireframes - A Flash Actionscript tutorial

Tsunami
Ok to start off this tutorial, i would like to ask you to make a blank flash movie and set the stage to have a width of 600 and a height of 400.

Now when the movie loads, we need to set some variables so lets start off by setting the origin

QUOTE
origin = new Object();
origin.x = 300;
origin.y = 200;




What this does, is it defines the origin to be an object with physical properties such as X and Y coordinates and it then sets those coodinates to 300 and 200, which is the center of the movie. Now we want to set what is called the 'focalLength'.

QUOTE
focalLength = 500;


What the focal length does, is it helps to define how much z will offset the object. The higher the number, the smaller the offset. We dont want it to be too big, but not too small so we will set it at 500 for the time being.

Every figure whether it be 2 or 3 demensions has to have some coordinates, so lets go ahead and define the coordinates for our box shall we:


QUOTE
boxpoints = [
Make3D(50, -50, -50),
Make3D(150, -50, -50),
Make3D(150, -50, 50),
Make3D(50, -50, 50),
Make3D(50, 50, -50),
Make3D(150, 50, -50),
Make3D(150, 50, 50),
Make3D(50, 50, 50)
];



Make3D is a function that we will define a little later on, but what matters now is what is inside it. inside each function call there are 3 numbers, representing x, y, and z. these coordinates will make a box 100 x 100 x 100 at a little less than center. Now i know your eager to make the function Make3d so lets get to it:

QUOTE

function Make3D(x,y,z) {
var point = new Object();
point.x = x;
point.y = y;
point.z = z;
return point;
}

I know its not quite what you expected BUT this is a very important part. What it does is takes those 3 coordinates and assigns them to an object. Just like with the origin this object has X and Y values, but this one also has a Z value. Then it returns the point object back to the array.


and then we should make an empty movie clip to store it in:

QUOTE
this.createEmptyMovieClip("box",1);



Ok were done with the easy part. Now comes the a lil harder but still pretty easy. I say this because it would be EXTREMELY difficult to draw a 3d object without it. In computer land, they dont have a Z plane like we do in the real world. All they have is X and Y. So what we have to do is make a function that will convert 2d coordinates to 3d by offsetting the X and Y values. I know its sounds like gibberish but bear with me... lets take a look at the function:

QUOTE
function convert3d(pointIn3D) {
var pointIn2D = new Object();
var scaleRatio = focalLength/(focalLength + pointIn3D.z);
pointIn2D.x = pointIn3D.x * scaleRatio;
pointIn2D.y = pointIn3D.y * scaleRatio;
return pointIn2D;
}




see that wasnt that hard, what this does is when passed in a 3d point (which was originally made by Make3d() wink.gif ) it takes the Z value and along with the focalLength, makes a Scale Ratio. it multiplies the X and Y Values by the scale ratio and returns the new point. beleve it or not... thats all the math involved ^.^.

now we have to draw it. But these coordinates are just the virtual coordinates because we still have to make each point relative to the origin... Lets look at the code:


QUOTE
function draw3d(item) {
//Make Real Points ^.^
var realpoints = new Array();
for (i=0; i < boxpoints.length; i++) {
var itemPoint = boxpoints[i];
realpoints[i] = convert3d(itemPoint);
realpoints[i].x += origin.x;
realpoints[i].y += origin.y;
}
// draw
item.clear();
item.lineStyle(2,0x000fff,25);
//bottom
item.moveTo(realpoints[0].x, realpoints[0].y);
item.lineTo(realpoints[1].x, realpoints[1].y);
item.lineTo(realpoints[2].x, realpoints[2].y);
item.lineTo(realpoints[3].x, realpoints[3].y);
item.lineTo(realpoints[0].x, realpoints[0].y);
//top
item.moveTo(realpoints[4].x, realpoints[4].y);
item.lineTo(realpoints[5].x, realpoints[5].y);
item.lineTo(realpoints[6].x, realpoints[6].y);
item.lineTo(realpoints[7].x, realpoints[7].y);
item.lineTo(realpoints[4].x, realpoints[4].y);
// connecting bottom and top
item.moveTo(realpoints[0].x, realpoints[0].y);
item.lineTo(realpoints[4].x, realpoints[4].y);
item.moveTo(realpoints[1].x, realpoints[1].y);
item.lineTo(realpoints[5].x, realpoints[5].y);
item.moveTo(realpoints[2].x, realpoints[2].y);
item.lineTo(realpoints[6].x, realpoints[6].y);
item.moveTo(realpoints[3].x, realpoints[3].y);
item.lineTo(realpoints[7].x, realpoints[7].y);
}



all we do to convert it to real coordinates is add the origin x and y to the point. Then we draw it by first clearing everything inside the movie clip, setting the line style then drawing the points. I wont get into the details about the moveTo and lineTo functions but what happens next is it draws the bottom. Then it draws the top.


now we need to make sure it does this on every frame, so in the onenterframe command you would put:

QUOTE
draw3d(box);




And your done! feel free to edit the coordinates and such to make new figures once you get the hang of it ^.^

 

 

 


Reply

iGuest
I made your code a little more bareable, and added the left and right keys for fun. just cut and past the following into actionscript.

var origin:Object = new Object();
origin.x = 300;
origin.y = 200;
var focalLength:Number =100;
Key.addListener(this);
var key = Key.getCode();
this.onKeyDown = function() {
var code:Number = Key.getCode();
switch(code) {
case Key.LEFT:

focalLength+=1;
draw3d(box);
break;
case Key.RIGHT:

focalLength-=1;
draw3d(box);
break;

}
}
var boxpoints:Array = [Make3D(50, -50, -50), Make3D(150, -50, -50), Make3D(150, -50, 50), Make3D(50, -50, 50), Make3D(50, 50, -50), Make3D(150, 50, -50), Make3D(150, 50, 50), Make3D(50, 50, 50)];
function Make3D(x1:Number, y1:Number, z1:Number) {
var point:Object = new Object();
point.x = x1;
point.y = y1;
point.z = z1;
return point;
}
this.createEmptyMovieClip("box", 1);
function convert3d(pointIn3D:Object) {
var pointIn2D:Object = new Object();
var scaleRatio:Number = focalLength/(focalLength+pointIn3D.z);
pointIn2D.x = pointIn3D.x*scaleRatio;
pointIn2D.y = pointIn3D.y*scaleRatio;
return pointIn2D;
}
function draw3d(item) {
//Make Real Points ^.^
var realpoints:Array = new Array();
for (I=0; I<boxpoints.length; I++) {
var itemPoint:Object = boxpoints[I];
realpoints[I] = convert3d(itemPoint);
realpoints[I].x += origin.x;
realpoints[I].y += origin.y;
}
// draw
item.clear();
item.lineStyle(to, 0x000fff, 25);
//bottom
item.moveTo(realpoints[0].x, realpoints[0].y);
item.lineTo(realpoints[1].x, realpoints[1].y);
item.lineTo(realpoints[to].x, realpoints[to].y);
item.lineTo(realpoints[3].x, realpoints[3].y);
item.lineTo(realpoints[0].x, realpoints[0].y);
//top
item.moveTo(realpoints[4].x, realpoints[4].y);
item.lineTo(realpoints[5].x, realpoints[5].y);
item.lineTo(realpoints[6].x, realpoints[6].y);
item.lineTo(realpoints[7].x, realpoints[7].y);
item.lineTo(realpoints[4].x, realpoints[4].y);
// connecting bottom and top
item.moveTo(realpoints[0].x, realpoints[0].y);
item.lineTo(realpoints[4].x, realpoints[4].y);
item.moveTo(realpoints[1].x, realpoints[1].y);
item.lineTo(realpoints[5].x, realpoints[5].y);
item.moveTo(realpoints[to].x, realpoints[to].y);
item.lineTo(realpoints[6].x, realpoints[6].y);
item.moveTo(realpoints[3].x, realpoints[3].y);
item.lineTo(realpoints[7].x, realpoints[7].y);
}
draw3d(box);

-Aaren

 

 

 


Reply

dukenemesis
Thanks for that Tsunami/Trap FeedBacker. biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. 3d wireframe - 3.58 hr back. (2)
  2. flash wireframe as2 - 6.21 hr back. (1)
  3. actionscript 3d wireframe - 26.39 hr back. (1)
  4. wireframe buildings in flash - 30.59 hr back. (1)
  5. how to make wireframes - 37.03 hr back. (1)
  6. actionscript text moving on z-plane - 49.91 hr back. (1)
  7. create wire frames for drawing characters - 54.80 hr back. (1)
  8. 3d wireframe example - 56.01 hr back. (2)
  9. flash wireframe box - 84.67 hr back. (1)
  10. how to make 3d numbers - 91.17 hr back. (1)
  11. actionscript math wireframe - 104.51 hr back. (1)
  12. 3d wireframe movies - 168.88 hr back. (1)
  13. "coordinates to 3d" - 203.45 hr back. (1)
  14. make wireframes - 238.29 hr back. (1)
Similar Topics

Keywords : make, 3d, wireframes, flash, actionscript

  1. Adding Flash Music Player To Home/any Page
    How-to (put any song you want!!!) (4)
  2. Load A Another Swf Movie Into Flash Player.
    During Execution. (0)
    Load a another swf movie into Flash player. Create an empty flash document as you like. Save and
    publish it. Create a 2nd flash document as you like. Save and publish it. Note: Both are in same
    directory. Open a first empty flash document. Select the first frame and Press F9. Copy the code
    below and paste it. loadMovie("Your 2nd flash file name .swf", this); Save and run it.....
  3. Digital Time
    Create a Digital Time in flash. (2)
    Digital Time 1.Create a Text Field and Create set them instance name = “time”. 2.Select the first
    Frame. 3.Press F9 and Copy Code Below and paste it. CODE _root.onEnterFrame =
    function() {     var time:Date = new Date();     hour =
    (time.getHours()<=12) ? time.getHours() :
    (time.getHours()-12);     hour = (hour<10) ? ["0"+hour]
    : hour;     second = time.getSeconds();     second = (second<10) ?
    ["0"+second] : second;     Minutes....
  4. 3d Landscape In Swishmax (flash)
    some syntax differences but basically same as flash (1)
    OK! this tutorial is inspired by a game at addictinggames.com... im not sure how many of you
    have played it but here it is: God's Playing Field Its a cute little game... but when i first
    played it i though HOW DOES IT DO THAT!!! and by that i mean dot he 3d with the mouse
    and then today i finally got around to making it... I used one of the oldest tricks in the book...
    so lets educate you a lil about flash... Flash does not support 3D directly, you have to find some
    way to make your own. You could develop some complicated system for which you co....
  5. Flashing Your Motherboard's Bios
    How to flash a BIOS (10)
    Hello Everyone, Let me start with reintroducing myself into this forum. My name is Michael Odo. A
    Nigerian and one of the previous most active members of this great online community. Well, I know
    that I have been off from here for quite a very long time due to some hard times but, I am back now
    and in full force . Back to the topic of my discussion . BIOS means Basic Input/Output System .
    It is a software embedded into your motherboard and which controls everything on your system.
    Flashing the BIOS is quite a risky affair and you are better adviced not to try t....
  6. Using An Actionscript In Flash For Loops
    (0)
    QUOTE When you are dealing with a lot of data, you without a doubt will run into the need to use
    loops. Lets say you would want to attach a movieClip to the stage. If its just a few clips it
    won't form a problem, but what if you wanted to attach a lot more clips? It would be impossible
    to set them up piece by piece. It would take hours of coding the same code over and over again and
    that redundancy is something you could really do without, not even talking about the time you are
    loosing. This is where loops come into action. We have a few different ones to our d....
  7. Making Interactive Cds With Flash
    My second flash tutorial for Beginners (2)
    Im back again with what i think it would be an interesting tutorial for all of you guys who wants to
    take flash out of the web and make really cool interactive CDS. First of all if all of you are
    thinking right now: "this dude is wrong for making interactive cds you have to use macromedia
    Director", well you are right macromedia director it's used to build interactive cds and dvds
    among other things, but you can also make interactive cds with Flash, the thing is: if you want to
    make a simple interactive CD you can totally do it with flash, of course Director brings ....
  8. Loading Movies Technique In Flash
    (4)
    What is loading movies technique? Well for example if you are buildin a 7 section website fully
    flash animated, the whole site is flash, one option is to make the 7 sections in the same movie, but
    the result will be a huge movie, that will take a lot of time to load, and probably the user wont
    stay that long to wait. The other option is to make one main movie and 7 other movies one for every
    section and then load does movies dinamically into the main movie, in that case the user its gonna
    load the main movie and then just load the section hes gonna navigate. Now lets get....
  9. Tweening In Flash Mx
    Simple tutorial for biginners. (10)
    In this tutorial you will learn how to tween in Flash MX. Motion Tween 1. Create a new
    document in flash. Any size will do. 2. Create any shape or object - just not a Flash UI. 3. On
    the time line right click on the time when you want it to stop moving. right click on a frame and
    click Insert keyframe. 4. Select it, you can use the black picture of a cursor in the toolbox
    (Arrow Tool (v)) 5. With the new Keyframe selected move the object where you want it to move it.
    6. Select the to keyframes with shift. 7. Right click and press Create Motion Tween. 8. Pr....
  10. How To Format Your Flash Disk/ Diskettes
    Formatting your flash or diskette (6)
    Now sometime your flash disk or diskette might have corrupt data, don't worrry just format it.
    follow these simple steps: 1. Double click "My Computer" on your desktop. It opens a window with
    all the available disks. 2. Right-click, your "Removable Disk" or "3 1/2 Floppy" 3. Then click
    "Format" it would bring out a window 4. you can either choose "Quick Format" option to make the
    formatting faster. 5. then click the format buttooon. it formats the drive. When it finishes it
    show you the "format complete" dialog, click "ok" and it is done. you have a formatted d....
  11. Loadsound Flash Mx
    streaming (0)
    I've asked this question in another section but i figure it belongs here. Would like to know if
    it's possible to loop streaming music using loadsound. I've managed to do it by creating a
    movie that loops but i was wondering if there was another way? round.trap17.com....
  12. Flash Movie Loads...
    (4)
    Im making a full flash website... For those flash freaks... I used LoadMovieNum to call the a
    movie1. And then movie1 has submovie1. Submovie1 has subs too... (e.g.sub1) How can i load sub1
    retaining the movie1 & submovie1!? and the is there a way? or is it just one loading of movie at
    a time?? =)....
  13. Flash Tutorials
    (7)
    I have been looking for a complete tutorial on how to do flash. I have found a few but they only
    teach you how to do 1 or 2 certain things. I need one that shows excatly step by step how do do
    everything. If anyone out there knows where to find one like that please let me know. Im not
    looking to learn it overnite i am looking for a long term tutorial that i can work at my own pace.
    Tahnks in advance!....
  14. Flash / Multimedia
    tutorials (1)
    Building a flash site ---------------------------------------- Kirupa.com - Building a complete
    site hyd-designs.com - PHP Nuke and Flash Animating 3D logo with Swift3D
    ---------------------------------------- http://flashmove.com/fsug/session/s...xpress/demo.htm
    Prototypes ---------------------------------------- http://proto.layer51.com/ A huge list of
    resources links ---------------------------------------- http://www.stranger.per.sg/ FLASH
    TUTORIAL LINKS ---------------------------------------- whatdoiknow.org - Flash Presentatio....

    1. Looking for make, 3d, wireframes, flash, actionscript

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for make, 3d, wireframes, flash, actionscript

*MORE FROM TRAP17.COM*
advertisement



How To Make 3d Wireframes - A Flash Actionscript tutorial



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE