![]() |
3d
1 Attachment(s)
Hi =)
Well this week I made 2 scripts.. I would like to improve them more before show them here, but this week and the next I will not have time.. Hope you people like them.. |
WOW! damn great dude! you rocks!
|
Very nice, especially the "fire" like yellow effect.
|
Your math is good. The script is isn't formatted well and not very efficient. I still don't understand why you choose to lay your scripts out that way but whatever :O
|
Quote:
pretty sweet stuff. |
Nice effect, hideous coding. And the sphere's a little unoriginal, don't you think? :-p
|
Please post screenshots for those of us who can't run Graal levels.
|
Truely amazing. Mind commenting that code? :O
|
Quote:
For me it runs faster then 20fps.. but maybe just the script runs faster, the render is 20fps.. I dont know.. If it really shows faster then 20fps its a good technique =) |
Nifty, as well. :)
|
2 Attachment(s)
Very nice.
Quote:
|
NICE WORK, very original (pokes kaimetsu) har har
|
Very nice work. I wish I could do stuff like that.
|
Wow, nice. Good job. Too bad I can't understand it because it's far beyond my level.
|
Quote:
|
The lighting on the particle script isnt that accurate.
Graal should only run on 20fps, 1/20 = 0.05 as in the smallest timeout or sleep you can do. whee. Shame its not a perfect sphere, Master Storm or someone showed me a sphere which was much MUCH more efficient than both kai's and this one, it was maybe 30 lines of code? didnt skip at all, etc. |
Quote:
Envy is the way of the fool, something that many people in Graal should learn. Like XXIII centuries ago Socrates showed the smart guy is the one that knows how much things needs to learn. I can agree that are billion people better then me.. better then anyone when programming, but a message like "Hi... your script is fun" or something like that would be great.. like you said your message, I feel like my week making the scripts were nothing.. |
Quote:
|
Quote:
Quote:
|
Quote:
|
I think Kai should strike back with an even greater 3d object.
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Mine was a balloon and not a sphere (The script aslso contains a diablo hehe), and is different from Kai's and Amon-Ra's examples in that mine is shape independant, and works much like a proper 3d engine, in that you just weed co-ordinate polygons and normals, It is because mine is shape independant that it uses showpoly2, as whiilst working out what polygons are hidden when you have a shape like a sphere is easy, it becoms much more difficult when you are making shapes such as carrots and tables, especially when the drawing code is independant of the data.
For those intrigued, mine uses a tensor which is manipulated and polygons drawn from that as necessary. And um.. mines rather efficient, but can probably be tweaked, and weighs it at 169 lines, including setting the definitions for the balloon shape, although its probably only 130-140 commands, as i put in a lot of spacing for clarity. Added: I just saw what Amon had put about using 3d studio max to get the vertexes and this is how mine works, with the drawing not relying on the data being a certain type of shape. I'd still rather use showpoly2 than go through every single possible situation (2 sided polygons, clipped, obfuscation etc..). Amon's excample is very good, and I agree somewhat with what he says about Kai misdirecting the thread. |
That's pretty awesome, but it seems to lag up at about 500 vertex, see if you can get it to run smoother with more vertex and then let's start skinning. :whatever:
It's not torque, but it's progress. ;) |
Quote:
=) I will comment other so.. the commands are the keys: 1,2,3 or 4 PHP Code:
By parts =) We will make Stars coming to our Eyes when we press the key '1' ok? We can rotate things in 3D world.. like a Caracter you can rotate it to left or to right.. or rotate the whole world to make the Camera moviments.. its pretty easy.. This par will make the rotate moviments.. PHP Code:
When creating the script it will set some values.. 'Total' means how many stars we will draw on the screen.. so we will make their positions.. In 2D world you normally use (X,Y) right? showimg 30,door.png,20,20; So its 20 blocks from left and 20 from top right? In 3D world you have to use Z.. Try to look at your window.. do you see a tree out there? You can say from your eyes its 200 points from left and 20 from top.. But you cant get it.. couse its far.. It has a big Z.. and your arms size isnt bigger then its Z.. thats why you cant get it.. So 3D worls use (X,Y,Z) But graal doesnt have a function like: showimg3d index,name,x,y,z; right? So we have to make a 3D position be in a 2D world.. There are many ways to do that.. I know better 2 ways.. Left Hand and Right Hand Left hand.. Bigger value of Z... near the screen it is.. Right hand.. Bigger value of Z.. more far from screen it is.. Its pretty easy to imagine how 3D world works in a 2D screen.. X is to the right.. how you know.. Y is to down.. how you know.. Z make the things be smaller.. Bigger Z in Left hand way.. Bigger in the screen it is.. because its near your.. Like you can see a Big mountain.. and the mointain is some times bigger then your eyes. But its far.. So its smaller.. has a big Z value in Right hand way.. and a Small Z value in Left hand.. easy huh? ;) So we will make an array so each star has it own (X,Y,Z) X for me is XX Y for me is YY Z for me is ZZ ok? PHP Code:
PHP Code:
My LENS is "lente", couse Im brazillian ;) PHP Code:
Lets make the moviment.. It gets each Star.. So get a new value for each cordinate.. SX is equal the star position LESS our Camera position.. What that means? Later we just change 'camz', 'camy' and 'camx' positions and fantastic things happenes.. PHP Code:
Do you know “SOHCAHTOA” ? Strange word? We use the same word in Brazil, and I found a person using the same word in an american site, so probably you should know it ;) SOH-CAH-TOA means: SOH = Sin(Theta) = Opposite/Hypoteneuse CAH = Cos(Theta) = Adjacent/Hypoteneuse TOA = Tan(Theta) = Take a wild guess. ;) You remeber a triangule right? Not sure how this triangle is called in English.. but in Brazil we call it “Retangule Triangule” | \ a |_ \ b | .|_\ c B its our Hypoteneuse.. And what will be Opposite or Adjacent you have to imagine an angle.. a^b = c is the Opposite and ‘a’ is Adjacent.. ‘b’ is always Hypoteneuse.. We will never (ops.. almost never) use this but Its always good to know: Tan(a) = Sin(a)/Cos(a) Sec(a) = 1/Cos(a) Csc(a) = 1/Sin(a) Cot(a) = 1/Tan(a) = Cos(a)/Sin(a) Do you know PI? ;) Pi means 180 degree... Some centuries ago they used GRADOS.. Like 90 degree was 100 grados.. So 360 degree was 400 grados.. But this things dont care, just stupid nerds like me know that.. Ok.. Pi value is.. 3.1425926535.. A japanese guy found like 4000 number after ‘3’.. and the funny part is noone number is the same o.O like 11, 22, 33... If Pi is 180 degree.. and its 3.1415.. How much is 360 degree (or the whole circule) ? 2* 3.1415 =PPP ohh.. smart guy.. I will try to explain 2D rotations.. so we use those in 3D rotaions.. x' = x*cos(Theta) - y*sin(Theta) y' = y*cos(Theta) + x*sin(Theta) WTF? Lol... wait XD Imagine a Circule.. and cut it in 4 pieces.. Like 4 piecies of a Pizza (hmm.. pizza =(~~~ ).. The center of our pizza is (0,0) I said 2D remember? ;) How can we find a tomato on the pizza position from the center? O.O If we use a line.. from the center to the tomato we have a RADIOS. ^_^ This radios (not sure how its the English word.. Radius? .. hmm try to understand it. Sorry my English ).. Well.. this radius is our Hypoteneuse.. Make a tringule from the center to the tomato position.. where one site of the Triangle is where you cut the pizza with the knife.. The other is a line directly from the center to the line (Hypoteneuse) the last is the height from where we cut the pizza making 90 degrees.. Use SOH-CAH-TOA... so we know that: sin(theta)=tomatoy/r_or_Hypoteneuse cos(theta)=tomatox/r_or_Hypoteneuse Difficult? Dont care too much with this right now ok? With time things will be easier.. I promise.. Lets play a litlle bit more with that.. Multiplying both sides by r... r(Sin(Theta) = y/r)r r(Cos(Theta) = x/r)r = r*(Sin(Theta) = y r*(Cos(Theta) = x = EQ. 1 x = r * cos(Theta) EQ. 1-1 y = r * sin(Theta) These 2 equations.. Alot of people on Graal knows.. and now should know from where they come ;)) Since on a unit circle r = 1 then x = 1 * cos(Theta) y = 1 * sin(Theta) or EQ. 2 x = cos(Theta) EQ. 2-1 y = sin(Theta) To change from polar to cartesian: r = Sqr(x^2 + y^2) Theta = (y/x); X needs to be different then 0 WTF is a polar cartesian? We used in our pizza.. Dont care too much about that ;) Ok.. now its less difficult to understand the Rotate 2D: x' = x*cos(Theta) - y*sin(Theta) y' = y*cos(Theta) + x*sin(Theta) I said before remember? |
Remember these equations?
EQ. 1 x = r * cos(Theta) EQ. 1-1 y = r * sin(Theta) Legend: P = Phi T = Theta Phii + Theta = is the total angle.. From the center of the pizza to the tomato. Alitlle bit dificult to undestand.. Just read dont care if you dont understand for now.. One day that will make sence and you back here and read again.. I hope Graal 3D will not come so fast, so Im not writing all this for nothing =PPP Cosine Identity: EQ. 3 Cos(P+T)= Cos(P)*Cos(T)-Sin(P)*Sin(T) Sine Identity: EQ. 3-1 Sin(P+T)= Sin(P)*Cos(T)+Cos(P)*Sin(T) Let (P+T) = Theta(Just one angle)... EQ. 1 becomes: x = r * cos(P+T) EQ. 1-1 y = r * sin(P+T) Then by substitution from EQ 1 and 1-1 EQ. 1 becomes: x' = r * (Cos(P)*Cos(T)-Sin(P)*Sin(T)) EQ. 1-1 becomes: y' = r * (Sin(P)*Cos(T)+Cos(P)*Sin(T)) Distributing r: x' = r*Cos(P)*Cos(T) - r*Sin(P)*Sin(T) y' = r*Sin(P)*Cos(T) + r*Cos(P)*Sin(T) And looking back at EQ's 1 and 1-1: Let P = Theta... x = r * cos(P) y = r * sin(P) Then by substitution: x' = x * Cos(T) - y * Sin(T) y' = y * Cos(T) + x * Sin(T) That's how you prove the 2d rotation formula. =)) Final equations: Newx=oldx*Cos(Theta) - oldy*Sin(Theta) Newy=oldy*Cos(Theta) + oldx*Sin(Theta) Ok.. Why I explained 2D rotation first? Couse for 3D rotation you have 3 equations.. 1st) rotate in X 2nd) rotate in Y 3rd) rotate in Z o.O If you know the 2D rotaion its pretty easy.. you just let the Cordinate you want to change equal. And rotate the others.. Very logic.. Rotation on the Z NewY = y*cos(Thetax) - z*sin(Thetax) NewZ = z*cos(Thetax) + y*sin(Thetax) y = NewY z = NewZ Rotation on the Y NewZ = z*cos(Thetay) - x*sin(Thetay) NewX = x*cos(Thetay) + z*sin(Thetay) x = NewX Rotation on the Z NewX = x*cos(Thetaz) - y*sin(Thetaz) NewY = y*cos(Thetaz) + x*sin(Thetaz) Rotatedx = NewX Rotatedy = NewY Rotatedz = NewZ :P easy huh? Your near to make any 3D thing in Graal 2D You also needs to learn Cull mode.. Not used in these stars but used in my poly script =) Whats Cull mode? You make a caracter.. graal shouldnt lose time drawing the part of caracter thats not visible.. We can use normals for that.. normals come from the center of each triangle.. Why triangle? Couse when can model anything with triangles.. Sherek 2 caracters where made all by triangles.. ;) any 3D thing is made by triangles.. To find a center of a trinagle is pretty easy.. you have 3 vertex right? x1,y1,x2,y2,x3 and y3? The center is: Xcenter = (x1+x2+x3)/3; Ycenter = (y1+y2+y3)/3; You can use it in all 2d poly.. All Vertexes dived by number of vertexs. For the light I used in my poly.. is just get the mouse distance for each Triangle (or face).. and how near it is.. more light.. or bigger R,G,B value.. In my poly script I just count the mouse position when its near the poly.. Maybe for this reason someone posted here he didnt like my Light way.. But if I didnt do that.. noone would see the poly when the mouse is too far.. Backing to script.. Everything I showed up.. I use in this part.. From that we can make a fast 3*3 Rotation matrix There the letters “c” in front each thing means “cos()” Letter s in front each thing means “sin()” X axis xx = cy*cz xy = sx*sy*cz - cx*sz xz = cx*sy*cz + sx*sz Y axis yx = cy*sz yy = cx*cz + sx*sy*sz yz = -sx*cz + cx*sy*sz Z axis zx = -sy zy = sx*cy zz = cx*cy Difficult when you see the first time.. But it becomes pretty easy when you use it alot.. I promise.. I fell free to make other kinds of rotation when I learned this.. PHP Code:
Distancia is out “distance”.. My scripts always in portuguese ;) Distance from star is our LENS less its Z distance.. When using Right Hand or Left hand its different.. If Distance is bigger then 0.. or its in out LENs we draw.. Meux means “myx” =P Learning portuguese huh? Lol... Center of the screen plus LENS multiplicate for position.. I said alot on top.. But to change 3D to 2D you just have to divide X and Y for Z =P new_x = x/z new_y = y/z where Z is the distance.. I used my LENS in this distance.. PHP Code:
PHP Code:
Is the position is bigger the LENS we lost it.. lest put again in other screen position.. If its not.. We add Z.. so it comes for our eyes.. PHP Code:
And the timeout to repeat what is not in “created” part.. PHP Code:
It turns on/off.. each flag.. that take care of one kind of moviment.. PHP Code:
Done ^_^ We made a 3D script.. now lets post alot of 3D scripts on Forums to help other people too =)) I think Kai will agree to help people too if needed.. You can pm me if you want to.. not sure If I will answer it.. lol Hugs see ya.. Omg.. all my Saturday morning writing this, I hope someone reads it X.x I had to use more posts.. couse I used more then 10,000 letters.. lol |
1 Attachment(s)
Quote:
I just made a simple model in 3D studio.. and I imported to my Poly script.. It has 372 vertex and 124 faces.. its pretty fast in graal =) Dont look how I mess the script =P I just would show the 3D model imported.. lol.. ^^ Editing: I made that so fast I forgot many things.. Ignore press 1,2,3 or 4.. =P It doesnt do anything.. Also + is far not near.. same for - =) Editing2: http://forums.graalonline.com/forums...ad.php?t=51990 can help too.. to understand better the rotations and projections |
O_O
Can I worship you as god? |
Hm, nice, i will be reading your posts later Amon-Ra, i really want to learn how to introduce 3D engines on GScript. Guess i will need take some math lessons too.
|
Quote:
Only I can do that. Kai is a newbie compared to my fun machine. |
Quote:
|
Quote:
nop =P rectangles = 2 triangles... ---> "ALL" <--- Animations are made with triangles... 3D Studio max, Maya, Lightware, anim8or, 3d scanner, .... All them use triangles what happeness is that when you select "show wireframes" in 3D studio, Maya, etc. It shows as rectangle.. But the triangles are there, and you can select to show them ;) |
Quote:
|
Its usually bettter to use 2 triangle as that way when your rectangle has a 'crease' you can ensure it is formed on the correct diagonal.
Mathematica is rather powerful.... :D |
Quote:
Quote:
Quote:
|
Scripters scripters calm down. Get together and make the ultimate 3D field >:O!
|
Did you people like the graal 3D tutorial I tried to make? Does someone read it?
o.O Quote:
Quote:
sorry :frown: =X |
| All times are GMT +2. The time now is 08:11 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.