how did u do the 3D for the lil guy? did you render it in FLASH??!?! If not, then how did you get the proper scaling and stuff (like how did you make him smaller and **** when he gets further and position in the 3D plane.
Printable View
how did u do the 3D for the lil guy? did you render it in FLASH??!?! If not, then how did you get the proper scaling and stuff (like how did you make him smaller and **** when he gets further and position in the 3D plane.
i modelled him using swift3d and then animated a 360 degree spin (120 frames, which explains the bandwidth) i used the flash samuri calculation to convert 3d points to 2d.
for the trees AND the dude i did was this ;
//
// Note
I good deal of this deals with the mini-map you see at the top right-hand corner of the stage. it is important to remember that even though it is scaled down, the co-ordinates used will be as though it were scaled to 100%.
//
// Position and scaling
//
i took the (x,y) pos for the object from the map[See rotation] (which in 3d is the x,z). now coz the ground is flat, and everything sits on the ground, the 3d y position will always be the same (note that the center of all the object mc's is at the bottom).
i just guestimated where the camera would be which determines the y position. the higher the camera lower y value. i think i set my y value to -80.
now i have an x,y,z value for where the object meets the ground. i can use the flash samauri method to convert that x,y,z value to a 2d x,y value.
i then gave each object a height (have a look in the elvis and tree mc and you'll see a height=value statement). i subtracted the height value from the 3d y position which gives a 3d y point for the top of the object (the x and z values are the same). using flash samauri i converted that to a 2d point.
now i can calculate the height of the object (on the stage) by subtracting the top 2d y pos from the bottom 2d y pos. i then set the _height of the object to that value and set _xscale to equal _yscale which matintains the aspect ratio of the object (flash will automatically calculate the _yscale of an object when you set the _height).
Finally, because the scene seems to be flattened out i had to scale the resulting x,y co-ordinates to fit the screen. i'm not sure why i need to do this but i multiplied the y value by 10 and the x value by 1 (i know i don't need to do the x calculation but i figured i may have to multiply it by something other than one in the future). this gives me a 10:1 aspect ratio.
//
// Rotation
//
Now the flash samauri method will only work when the camera is at right angles to the scene. this presents a problem when the car turns and thus puts the scene at another angle to the camera.
to solve this problem i convert the x,y co-ordinates from the map to the camera (car in the map).
the map is a mini-map (scaled down to 10%), notice how the car moves around the map and is rotated according to the keyboard.
so to convert a point on the map to a co-ordinate that is at right angles to the camera i use map.localToGlobal(point) to convert the map point to stage co-ordinates and then use map.car.globalToLocal(point) to convert the stage point to the car's co-ordinates and wala i now have an (x,y) pos that is at right angles to the camera.
you could do exactly the same thing by using the car as the center and applying some trig to the point but i think the localtoglobal is easier and quicker.
//
// Angle to camera (of Elvis)
//
I'm still not sure i got the angle to camera right but the basic principle is this. using the opponent mc within the map i take a point that is directly behind and a point that is directly in front of the opponent.
i then convert these points to the (car/camera) using the method described above.
i then calculate the angle between these two points and scale it to the number of frames in my elvis mc (120). So the angle range will be 0-360 and the frame range will be (1-120). the calculation is roughly;
frame = int(angle * 120 / 360). a bit of extra code makes a zero result 1.
hope this helps
blink
Flash samurai 3d to 2d calculation;
http://www.macromedia.com/devnet/mx/...murai_ch2.html
which is basically this;
(Don't try and understand why it works just know that it worksCode:D = 400;
// calculate the perspective ratio
// the D value is actually the view planes distance from the camera
// have a look at the "3D for dummies" tutorial (here at fk) for an explanation of the view plane
perspective_ratio = D / (D + z);
// calculate position of point on computer screen
perspective_x = x * perspective_ratio;
perspective_y = y * perspective_ratio;
funny how the samurai guy was a senior in high school when he wrote that. But I recall the proof for 3d to 2d was in some Friend of ED book. oh well.
This is getting so cool!! I was trying to look for the maze engine on this site that strille did, or the raycasting engine, but I can't seem to find it, can someone point to it for me. thanks. Almost like MarioKarts!!!
Strille's raycasting v1: http://www.flashkit.com/movies/3D/En...6852/index.php
Strille's raycasting v2: http://www.flashkit.com/movies/3D/En...8022/index.php
Or his cool website (see his links)
Whoa!! You totally overkilled that question, but thanks! Im sure it'll help others who will want to learn.:D:D
I just wasnt sure of the method you were using.
Personally, I spent a lot of time trying to figure out the 3D to 2D thing on my own. I came up with 2 formulas (one for findig a point's X value, one for the Y value). Now this need only apply to vector 3D mind you... wait a minute, you could actually use this technique for images that you want to 3D afy (by simply interpretting 2 opposite corners of the image as points and messing with the heigh and width accordingly).
I'm sure your technique works better, but here's my formulas (they are for points):
_x = (atan(x/z)+endAngleofRangeofView)/degreesofViewSpan
_y = (atan(y/z)+endAngleofRangeofView)/degreesofViewSpan
seems pretty simple, but it took me about 2 months (not very focused, but still:D) for me to figure these out.
Unfortunately, this is only theory I have worked out on paper, so it may not actually work;)
I still gotta check out that Samuri thing. Please tell me if there are any flaws in my theory (the theory is based on the human eye, the cone like range of view it has, and I EUREKA!ed when I plotted that out (a plane at a time) for someone looking down a hallway:D:D)
jide: i'll have a go at using you algorythm in the game. it looks interesting.
this is a just-for-fun post. i added a player dude "pete the pirate" (that thing sticking outta his face is a knife). i also change the individual tree to clumps of trees, i think it kinna makes it look a bit more crowded. the fps took a little bit of a hit but i expected that.
its a massive 470k now and i would expect it to be 700-800k when finished unless i can figure out some more graphics optimization.
http://www.nlc.net.au/~oceana/games/loader.html (with preloader)
anyways have fun!
blink
ps: the code is a mess right now so i won't bother posting it. gimme a day or so and i'll clean it up and add the other dude (sarg) and then i'll post it.
wow .. that was real cool :) .. great work.
nice pirate :)
u need to move the 'thepic' movieclip (the one with the instance name 'pic' from my code) up about 8 pixels from the center point of pic (the movieclip that gets attached), this will mean that the road will rotate from under the pirate, rather than from behind him :)
if u have a look at my original link u'll see what I mean :)
also have u changed the way the trees move? they seem to jump when I let go of left or right. dirty!
hi,
your sample is really good and very interesting !
Would you like to publish it here ? >> www.gotoandplay.it
we are gathering developers and passionates to exchange their ideas and game prototypes etc ...
your work is really educational !
Drop me a line if you're interested.
bye
Lapo
[email protected]
wow guys that is absolutly AWESOME:D i wish... well i could wish all day but thats awesome:D
blink: he he - im a cockroach in toad land;) boy did i have fun on both thursdays at skool:D:D:D:D he he - neway stuff skool!!! IM ON HOLIDAYS:D:D:D
percy: your right about the trees percy, it's a stupid mistake i made before posting. i'll have a look at the rotation point too.
leight: mabey us canetoads will get a little dignity back in origin 3
lapo73: sounds interesting]
vont: thanks
ok !Quote:
lapo73: sounds interesting
let me know if you wish to publish it on my site.
bye
Lapo
[email protected]
i found a bug guys... turn the fog on and off and that elvis guy goes up in the air for a lil bit infront of you:S
blink: yes joey johns is a mighty fine player:D go the banana kick:D:D:D he he didnt u love it when kennedy smashed price was it??? neway ill stop spaming this amazing thread now!!! GO THE BLUES:D:D:D whitewash them toads;)
i need a little help here.
i tried what percy said to change the pivot point and it didn't work (i'm using strille's code) so i'm prolly doin something wrong.
i created a test .fla so you guys could have a look and see what you can do.
i basically want to be able to move the pivot point from the bottom center of the screen to somewhere else.
http://www.nlc.net.au/~oceana/games/pivot.html (27k)
http://www.nlc.net.au/~oceana/games/pivot.zip
thanks in advance for the help.
blink
leight: i think kennedy will do time for that, but i'm sure that won't bother him. bronco's go around tonight so mabey i'll get a little back. re the fog, i'm workin on that now.
But what the heck are those endAngleofRangeofView and degreesofViewSpan variables? Can you make picture of this system?Quote:
Originally posted by jide
Personally, I spent a lot of time trying to figure out the 3D to 2D thing on my own. I came up with 2 formulas (one for findig a point's X value, one for the Y value). Now this need only apply to vector 3D mind you... wait a minute, you could actually use this technique for images that you want to 3D afy (by simply interpretting 2 opposite corners of the image as points and messing with the heigh and width accordingly).
I'm sure your technique works better, but here's my formulas (they are for points):
_x = (atan(x/z)+endAngleofRangeofView)/degreesofViewSpan
_y = (atan(y/z)+endAngleofRangeofView)/degreesofViewSpan
i... i just lied, so have edited my post....
Think about your eyes. You can't see behind you can you? The view span is how "widely" you can see. Your actual view span can be calculated quite easily. Just mark the left most and right most point you can see, and calculate the degrees between them using trig.
Here is an example of a view range would be this (the degrees of view range for this one would be about 45 degrees):
The end of view range is simply the rightest side. I also used a projector as an analogy to help me try to understand it.Code:\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
eyes
Think about how u would go about placing the x's at the top to the
of the diagram bottom while still being proportional, and still fitting within the view range. You kinda have to think of it in terms of arcs. If you moved along the arc, the z value would remain constant, and the angle in relation to the eye would change. I'll try to whip something up in paint later, cuz im sure this is very confusing to you because Im not that good at explaining things in english :D
I cant keep my eyes off this thread...but dont have time to read all the posts. And its all open-source too - someday I'll rip apart that engine :)
Geeze.. It sure is beautiful. Mbenney, don't you wish we had've jumped on it and done this first? We would get all the credit :D Nice job Percy, you beat me to the punch on this, I was going to do it this summer when I had some (large amounts) of free time.
Oh yeah, by the way, hills are actually not that much harder, you just need to at a height map, and then increased the height of the strips... Ok, it's sort of hard to explain... get Top Gear 2 and run it in 400% view, you'll see what I mean.
HOLY CRAP!!!
HOW COULD I'VE MISSED THIS THREATH!!! FINALY SOMETHING GREAT AND I DIDN'T SEE IT!!!... oh wait... caps was on :p
I like all this stuff here peeps!!! I haven't read all of it, but I will soon...
Could somone plz explain everything like the alogrithems and stuff (if it's not yet explained cuz then I'll find it myself when I go read it :p)
Good stuff... keep it coming :D
I've updated my version once more: Added some parallax to the sky and tried using mipmapping to reduce the aliasing hear the horizon. The mipmapping needs a bit more tweaking, because right now it doesn't add much.
http://hem.passagen.se/strille/works...z_mapping.html
heh, yeah it was certainly something on my todo list but im glad someone else has done it... we all have something to learn
strille,
that parallex sky is fantastic!
what's mipmapping?
i had a problem with setting the pivot and i kinna got a solution but changing the initial position of the "stripe" mc from 400-180 to 400-250. this changed the whole perspective ratio so i'm re-aligning it now. am i just wonderin if i'm doin the right thing here or not?
thanks
blink
now I'm assuming that if we just make the image into a movieclip and make it animate, then it would work with the raytracing now, right? could make some cool stuff.
guys... this is taking flash gaming to the next level!!! wait for me guys!!! im still on the level behind you!!!
you could really make an awesome game outa all this when the engine is perfect!!!
absolutly amazing!!!
'04 edit: i really was an idiot back then ('02) :p
So, does anybody know if this is the way Nintendo did it on their SNES ( mode 7 )
Where did the idea for this engine come from?
In 3D, it's a trick for texture optimization : you are using different textures size and quality for the rendered object is more or less far : a detailled texture for close objects, and a smaller, less detailled for far objects ...Quote:
Originally posted by BlinkOk
strille,
what's mipmapping?
Though it could be something else, but in the same spirit, in the case of that engine ...
I would guess so ...Quote:
Originally posted by ClydeTheGlyde
So, does anybody know if this is the way Nintendo did it on their SNES ( mode 7 )
(http://www.taswegian.com/TwoHeaded/mode7.html for a simple explanation of what is mode 7)
Hey all, I'm a regular on Bit-101 and Were-Here.
I made a really huge level map (3000 x 4000), and it seems Flash cannot handle a JPG that big. It literally chops off a large part of the image when I publish and try racing around. I did some testing and Flash was able to handle the image when I resized it to 81% of the original size. Likewise, I manually cut the image in half in Photoshop, then placed both halves next to each other, and Flash was able to handle it then also, but at a price - the frame rate took a fairly noticeable hit.
I was just curious if anyone knew any workarounds for getting huge images as a map without affecting the performance much.
Marshall
luxregina explained the idea, but I've made a small flash movie that hopefully shows why mipmapping can be a usefull thing:Quote:
what's mipmapping?
http://hem.passagen.se/strille/works...ipmapping.html
I've removed a movie clip depth from PercyPea's original code, that is, the image is in a movie clip (symbol: movepic) and that movie clip is in another (symbol: strip), and that's it. You may have to add another clip in between and move that.... will look into that.Quote:
i had a problem with setting the pivot and i kinna got a solution but changing the initial position of the "stripe" mc from 400-180 to 400-250. this changed the whole perspective ratio so i'm re-aligning it now. am i just wonderin if i'm doin the right thing here or not?
looks like you guys have some fans :D
http://www.drunkfoundation.com/forum...showtopic=3678
I had the same problem about a wheek ago, I made a realy huge grassfield for my ISO game, I stored in a MC and attached that MC on stage, but when tested the game I only saw a small cut out of it...Quote:
Originally posted by marshdabeachy
I made a really huge level map (3000 x 4000), and it seems Flash cannot handle a JPG that big. It literally chops off a large part of the image when I publish...
After some testing, I found out that it had something to do with the position of the image withing the attached MC...
At first I had my image centered... But when I put the X position of the image at 0, Flash did load it!?...
So it might have something to do with the image going out of the far left border!?... It's still weird though :(
:confused::doughnut::cow:
Did you tried having it an external file, loaded like a dynamic image ???Quote:
I had that bug too, and i always found not so logical, random solutions ...
Though, i must say that Flash ain't no Director, and that working with huge images is not the proper way for it : isn't there any repetition in your map so you could go tilebased ? or having an actionscript repeteted background on which you spawn objects (trees, road borders etc ... ?)
How it works:
When i first saw this, and after i got over the initial shock :p, i thought it would be really complicated. But for those who are thinking they do not/will not understand, it'll all become clear if you do this: ( using strille's version with strip adjustment controls )
> set top and bottom strip heights to roughly the same, at about 20-30-ish
> set your "z" scale to about 5 ( i noticed strille's latest one has replaced this with mipmapping, but if you can find the earlier version, it helps visualise what is going on. )
Then the algorithms etc will suddenly seem to make sense :D So simple this idea, am amazed i've not seen something like this before.
Paralax and mipmapping looking mighty fine so far though, keep up the great work guys, this is one of the most interesting, and original threads in a while.
I just tried adjusting it to that, and now it works. :rolleyes: Thanks for the help SaphuA.Quote:
Originally posted by SaphuA
At first I had my image centered... But when I put the X position of the image at 0, Flash did load it!?...
And luxregina... I am loading in an external SWF that contains the JPG. I figured if I was going to start making this a real game, I might as well do the basic stuff first. Nobody in their right mind would include every map file in the same SWF.
And like I said earlier... just having 2 images took a big hit on the frame rate. I don't think tiling would work.
My mistake : i realized too late that you might be talking about the engine of this thread ... i was thinking about a top view racing track that you were scrolling ...Quote:
Originally posted by marshdabeachy
And like I said earlier... just having 2 images took a big hit on the frame rate. I don't think tiling would work.
I can't even keep up with this thread. The mipmapping explanation was great strive. Can someone also explain parrallax skys please? I switch it on and switch it off a few times, I notice a slight changed, but I don't quite get the difference. I need to drastically improve my actionscript skills so I can join in.
the parrallax thingee is where the top of the sky, moves faster than the sky at the horizon.
Strictly speaking though.... when you turn you wouldnt get a parrallax effect. You'd only get that if you were 'strafing' left or right..... i... :shhh:
tis very nice effect though :)
paralax scrolling is where objects which are closer to the object move faster then the foreground objects. eg builings , trees , sky and mountian's :) excellent work btw guys im really impressed.
Yes, that's true. But it looks cooler :) Actually, my first intention was to use the parallax effect to just make the clouds constantly move due to wind.Quote:
Strictly speaking though.... when you turn you wouldnt get a parrallax effect. You'd only get that if you were 'strafing' left or right