Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-02-2004, 04:25 AM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
3d

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..
Attached Files
File Type: zip amonra3d.zip (5.7 KB, 712 views)
  #2  
Old 08-02-2004, 04:42 AM
Galdor Galdor is offline
░▒▓██▓▒░
Galdor's Avatar
Join Date: Feb 2004
Posts: 2,434
Galdor has a reputation beyond reputeGaldor has a reputation beyond reputeGaldor has a reputation beyond reputeGaldor has a reputation beyond reputeGaldor has a reputation beyond reputeGaldor has a reputation beyond reputeGaldor has a reputation beyond reputeGaldor has a reputation beyond reputeGaldor has a reputation beyond repute
WOW! damn great dude! you rocks!
__________________
Links
Draenin's Villains
Draenin's Quests

My Albums
Quote:
Originally Posted by Unixmad
This forums is going worst each day.
  #3  
Old 08-02-2004, 04:53 AM
teshy2 teshy2 is offline
Purple cat!
teshy2's Avatar
Join Date: Mar 2004
Location: Sweden
Posts: 485
teshy2 is on a distinguished road
Send a message via AIM to teshy2 Send a message via MSN to teshy2
Very nice, especially the "fire" like yellow effect.
__________________


Co-head admin of Mushia.

Give us a visit today!
  #4  
Old 08-02-2004, 04:56 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
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
  #5  
Old 08-02-2004, 05:17 AM
Geno Geno is offline
Prinking Droblem
Geno's Avatar
Join Date: Jul 2003
Posts: 7,013
Geno has much to be proud ofGeno has much to be proud ofGeno has much to be proud ofGeno has much to be proud ofGeno has much to be proud ofGeno has much to be proud of
Send a message via AIM to Geno
Quote:
Originally Posted by amonrabr
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..
woh i havnt heard much from you in forever :O! i thought you disapeared.
pretty sweet stuff.
  #6  
Old 08-02-2004, 05:30 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Nice effect, hideous coding. And the sphere's a little unoriginal, don't you think? :-p
__________________
  #7  
Old 08-02-2004, 07:00 AM
Trevor Trevor is offline
True
Trevor's Avatar
Join Date: Mar 2003
Posts: 2,253
Trevor is on a distinguished road
Please post screenshots for those of us who can't run Graal levels.
__________________


name: Trevor Fancher
email: trevor at fancher dot org
home page: fancher.org
  #8  
Old 08-02-2004, 11:30 AM
VeX_RaT_Boy VeX_RaT_Boy is offline
WannaBe Scripter
VeX_RaT_Boy's Avatar
Join Date: Aug 2002
Location: Norway
Posts: 960
VeX_RaT_Boy is on a distinguished road
Send a message via ICQ to VeX_RaT_Boy Send a message via AIM to VeX_RaT_Boy Send a message via Yahoo to VeX_RaT_Boy
Truely amazing. Mind commenting that code? :O
__________________
-Kjetil Valen
  #9  
Old 08-02-2004, 01:16 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Quote:
Originally Posted by Python523
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
My own technique XD I forgot to put "keypressed" in particleflow script.. I prefer make the script be called not just for timeout, the reason I put everything directly in the script is that when you hold any key.. the things happens faster.. try hold any key in "poly" script..
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 =)
  #10  
Old 08-02-2004, 06:15 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Nifty, as well.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
  #11  
Old 08-02-2004, 08:01 PM
Xecutor Xecutor is offline
Former UN Manager
Join Date: Apr 2004
Posts: 117
Xecutor is on a distinguished road
Very nice.

Quote:
Originally Posted by Trevor
Please post screenshots for those of us who can't run Graal levels.
Attached .
Attached Thumbnails
Click image for larger version

Name:	poly.png
Views:	458
Size:	4.3 KB
ID:	29243   Click image for larger version

Name:	particle_flow.png
Views:	473
Size:	57.8 KB
ID:	29244  
  #12  
Old 08-02-2004, 08:30 PM
XxDarkrazorxX XxDarkrazorxX is offline
Uber Master
XxDarkrazorxX's Avatar
Join Date: Jan 2004
Location: The Netherlands
Posts: 162
XxDarkrazorxX is on a distinguished road
Send a message via AIM to XxDarkrazorxX Send a message via MSN to XxDarkrazorxX
NICE WORK, very original (pokes kaimetsu) har har
__________________
|\ ______
|......\.....\
|...|..|......\
/...|..|..|....\
\...|..|......./
_|....|.......\
\___/|__|__\
  #13  
Old 08-02-2004, 10:56 PM
DarkShadows_Legend DarkShadows_Legend is offline
Cult of the Winky
DarkShadows_Legend's Avatar
Join Date: Apr 2003
Location: Florida
Posts: 614
DarkShadows_Legend is on a distinguished road
Send a message via AIM to DarkShadows_Legend
Very nice work. I wish I could do stuff like that.
__________________
- Criminal X

"I rather be hated for being myself, than be liked for being what you like best. I go above the influence, not under." - Me
  #14  
Old 08-02-2004, 11:04 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Wow, nice. Good job. Too bad I can't understand it because it's far beyond my level.
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
  #15  
Old 08-03-2004, 01:37 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by amonrabr
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 =)
It's not exactly 'running faster than 20fps'. It's just that, sometimes, the world manipulation happens twice in one frame. Since you're not producing any extra screen updates, all this means is that occasionally the animation skips and looks disjointed. This is not a good effect.
__________________
  #16  
Old 08-07-2004, 04:08 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
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.
  #17  
Old 08-08-2004, 12:15 AM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Quote:
Originally Posted by R0bin
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.
when an event has an external param.. like Keypress has #p() params.. The script is called twice. So this way you can run it faster.. Sure that normal timeout cant be faster then 50 miliseconds. But you can call your script twice.. thats what I mean and I proved..

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..
  #18  
Old 08-08-2004, 01:04 AM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
Quote:
Originally Posted by amonrabr
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..
Who are you talking to?
  #19  
Old 08-08-2004, 06:07 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by R0bin
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.
There's a difference between code size and efficiency. I believe I've seen what you're referring to. It's far more than thirty lines, the lighting doesn't work properly and it cheats by using showpoly2 rather than projecting manually.

Quote:
Originally Posted by amonrabr
when an event has an external param.. like Keypress has #p() params.. The script is called twice
Yes. But the screen only updates once, meaning the second processing was wasted time, serving no purpose but to desync the animation slightly. I already explained this.
__________________
  #20  
Old 08-08-2004, 06:15 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally Posted by amonrabr
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..
Where's the envy
  #21  
Old 08-08-2004, 06:27 AM
Nappa Nappa is offline
The Great Nappa
Nappa's Avatar
Join Date: Sep 2003
Location: Florida
Posts: 1,911
Nappa is on a distinguished road
Send a message via AIM to Nappa
I think Kai should strike back with an even greater 3d object.
__________________
  #22  
Old 08-08-2004, 06:31 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Nappa
I think Kai should strike back with an even greater 3d object.
I am all lazy and stuff
__________________
  #23  
Old 08-08-2004, 06:38 AM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally Posted by Nappa
I think Kai should strike back with an even greater 3d object.
I don't think Amon-Ra's intention was beat Kaimetsu's work.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
  #24  
Old 08-08-2004, 07:24 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Nappa
I think Kai should strike back with an even greater 3d object.
Do you think he could create...a 3d FUN MACHINE?
  #25  
Old 08-08-2004, 02:32 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Quote:
Originally Posted by Nappa
I think Kai should strike back with an even greater 3d object.
I think that too.. Some time ago.. I saw a sphere made with Lights by Kai.. and I liked that so much, so I started learning Trigonometry.. Its difficult to find content in Brazil. So I started reading René Descartes to understand better Cartesian plans and So I learned the Left and Right Hand projection. So I understood the 3D Rotation matrixs, and finally the Cull mode maths. Now its easy to put a 3D Studio or Maya model in Graal. This Poly script I made is pretty simple.. Just export from 3D studio as Ascii so you get the vertex positions and put in my Poly script and its done. You dont need the 3D studio normals, since I made a math to determinate that, its not so acurally like 3D studio, but it works. What I mean is that Kai probably knows all these Im seeing, I hope you dont be mad with me for I will say Kai, but you are always seeing your the best of everything. Thats a leason you really should learn, your a person like me, like everybody. I play soccer better then my neighbor, and he can **** girls better then me. There are so much things we dont understand. So we are all the same, we are all special, I hate seeing you always posting when I post a script trying to change the post content for "how Kai could make it better". I made this in this post, and all the others I post something.. not sure why you make this.. Well I know.. couse for you, you have to be the best.. And in my opinion you are, in your way.
  #26  
Old 08-08-2004, 02:43 PM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
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.
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache

Last edited by Polo; 08-08-2004 at 02:48 PM.. Reason: Additions....
  #27  
Old 08-08-2004, 02:52 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
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.

It's not torque, but it's progress.
__________________
*Don't let the door hit you on the way out.*
  #28  
Old 08-08-2004, 03:56 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Quote:
Originally Posted by VeX_RaT_Boy
Truely amazing. Mind commenting that code? :O
Thats too big..

=) I will comment other so.. the commands are the keys: 1,2,3 or 4

PHP Code:
if(rotatex==true)ax = (ax+0.1)%6.28;
if(
rotatey==true)ay = (ay+0.1)%6.28;
if(
rotatez==true)az = (az+0.1)%6.28;
if (
created){
//make everything black
for(i=0;i<4096;i++)tiles[int(i/64),i%64]=632;
  
total 400;
  
setarray xx,total;
  
setarray yy,total;
  
setarray zz,total;
    for(
i=0;i<total;i++){
      
xx[i]=random(-2000,2000);
      
yy[i]=random(-2000,2000);
      
zz[i]=random(-1000,500);
    }
  
lente 256;
}
for(
i=0;i<total;i++){
  
sx xx[i] - camx;
  
sy yy[i] - camy;
  
sz zz[i] - camz;
  
//pré calculo
  
xx cos(ay)*cos(az);
  
xy sin(ax)*sin(ay)*cos(az) - cos(ax)*sin(az);
  
xz cos(ax)*sin(ay)*cos(az) + sin(ax)*sin(az);
  
yx cos(ay)*sin(az);
  
yy cos(ax)*cos(az) + sin(ax)*sin(ay)*sin(az);
  
yz = -sin(ax)*cos(az) + cos(ax)*sin(ay)*sin(az);
  
zx = -sin(ay);
  
zy sin(ax)*cos(ay);
  
zz cos(ax)*cos(ay);
  
//calculo
  
sx sx*xx sy*xy sz*xz;
  
sy sx*yx sy*yy sz*yz;
  
sz sx*zx sy*zy sz*zz ;


  
distancia lente sz;
  if(
distancia>0){
    
meux= (screenwidth/2) + (lente sx distancia);
    
meuy= (screenheight/2) - (lente sy distancia);

    
showimg 300+i,light4.png,meux,meuy;
    if((
sz/300)>0.05){
      
changeimgzoom 300+i,sz/300;
    }else{
      
changeimgzoom 300+i,0.05;

    }
    
changeimgcolors 300+i,1,0,1,.99;
    
changeimgvis 300+i,5;

  }


  if(
come>0){
    if(
zz[i]>lente){
      
xx[i]=random(-500,500);
      
yy[i]=random(-500,500);
      
zz[i]=random(-500,500);

    }
    
zz[i]+=10;
  }
}
hideplayer 0.05;
timeout 0.05;

if(
keypressed){

  if(
strcontains(#p(1),1)){
    
come=1-come;
  }
  if(
strcontains(#p(1),2)){
    
rotatex=1-rotatex;
  }
  if(
strcontains(#p(1),3)){
    
rotatey=1-rotatey;
  }
  if(
strcontains(#p(1),4)){
    
rotatez=1-rotatez;
  }



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:

/*
If it has  to rotate in X.. add some value to 'AX' not leting be bigger then 360o.. Or 2*PI.. ok?
*/
if(rotatex==true)ax = (ax+0.1)%6.28;
/*
The same for Y
*/
if(rotatey==true)ay = (ay+0.1)%6.28;
/*
The same for Z
when Az be equal 2*PI.. it will back to 0.. because MOD(%) means the rest of the divides
*/
if(rotatez==true)az = (az+0.1)%6.28

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:
if (created){
  
total 400;
  
setarray xx,total;
  
setarray yy,total;
  
setarray zz,total
So lets random any value for each star position =)

PHP Code:
    for(i=0;i<total;i++){
      
xx[i]=random(-2000,2000);
      
yy[i]=random(-2000,2000);
      
zz[i]=random(-1000,500);
    } 
Well.. we usually use a LENS value... why? Couse its better to know from where it starts showing something.. In old games they didnt use a LENS value.. they used the LENS like 0.. you can use like 0.. But you will see the diference
My LENS is "lente", couse Im brazillian

PHP Code:
  lente 256;

Ok when created the Script all the standart values where created.

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:
for(i=0;i<total;i++){
  
sx xx[i] - camx;
  
sy yy[i] - camy;
  
sz zz[i] - camz
The difficult part Rotating... just kidding its not difficult.. we just have to pay atention..

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?
  #29  
Old 08-08-2004, 03:57 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
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:
  //pré calculo
  
xx cos(ay)*cos(az);
  
xy sin(ax)*sin(ay)*cos(az) - cos(ax)*sin(az);
  
xz cos(ax)*sin(ay)*cos(az) + sin(ax)*sin(az);
  
yx cos(ay)*sin(az);
  
yy cos(ax)*cos(az) + sin(ax)*sin(ay)*sin(az);
  
yz = -sin(ax)*cos(az) + cos(ax)*sin(ay)*sin(az);
  
zx = -sin(ay);
  
zy sin(ax)*cos(ay);
  
zz cos(ax)*cos(ay);

  
//calculo
  
sx sx*xx sy*xy sz*xz;
  
sy sx*yx sy*yy sz*yz;
  
sz sx*zx sy*zy sz*zz 
Uf.. the difficult part is done..

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:
  distancia lente sz;
  if(
distancia>0){
    
meux= (screenwidth/2) + (lente sx distancia);
    
meuy= (screenheight/2) - (lente sy distancia); 
Draw my stars.. I made a zoom way.. so Stars are bigger or smaller when Z is near or far..
PHP Code:
    showimg 300+i,light4.png,meux,meuy;
    if((
sz/300)>0.05){
      
changeimgzoom 300+i,sz/300;
    }else{
      
changeimgzoom 300+i,0.05;

    }
    
changeimgcolors 300+i,1,0,1,.99;
    
changeimgvis 300+i,5;

  } 
Come is my flag to tell if it has to come for out eyes.. or ours LENS
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:
  if(come>0){
    if(
zz[i]>lente){
      
xx[i]=random(-500,500);
      
yy[i]=random(-500,500);
      
zz[i]=random(-500,500);

    }
    
zz[i]+=10;
  }

Hide player so it doesnt bore us..
And the timeout to repeat what is not in “created” part..
PHP Code:
hideplayer 0.05;
timeout 0.05
Pressing.. the keys 1..2...3.. or 4..
It turns on/off.. each flag.. that take care of one kind of moviment..
PHP Code:
if(keypressed){

  if(
strcontains(#p(1),1)){
    
come=1-come;
  }
  if(
strcontains(#p(1),2)){
    
rotatex=1-rotatex;
  }
  if(
strcontains(#p(1),3)){
    
rotatey=1-rotatey;
  }
  if(
strcontains(#p(1),4)){
    
rotatez=1-rotatez;
  }



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
  #30  
Old 08-08-2004, 04:15 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Quote:
Originally Posted by Raelyn
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.

It's not torque, but it's progress.

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
Attached Files
File Type: zip 3dmodel.zip (4.7 KB, 236 views)

Last edited by amonrabr; 08-08-2004 at 05:02 PM..
  #31  
Old 08-08-2004, 04:23 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
O_O

Can I worship you as god?
__________________
  #32  
Old 08-08-2004, 06:15 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
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.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
  #33  
Old 08-08-2004, 08:11 PM
Nappa Nappa is offline
The Great Nappa
Nappa's Avatar
Join Date: Sep 2003
Location: Florida
Posts: 1,911
Nappa is on a distinguished road
Send a message via AIM to Nappa
Quote:
Originally Posted by Lance
Do you think he could create...a 3d FUN MACHINE?
Psht no

Only I can do that. Kai is a newbie compared to my fun machine.
__________________
  #34  
Old 08-08-2004, 08:36 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally Posted by amonrabr
Sherek 2 caracters where made all by triangles.. any 3D thing is made by triangles..
untrue, some use rectangles
  #35  
Old 08-08-2004, 09:25 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Quote:
Originally Posted by Python523
untrue, some use rectangles

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

  #36  
Old 08-08-2004, 10:09 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally Posted by amonrabr
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

Mathematica. (I believe that's the name)
  #37  
Old 08-09-2004, 01:17 AM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
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....
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
  #38  
Old 08-09-2004, 07:09 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by amonrabr
I hate seeing you always posting when I post a script trying to change the post content for "how Kai could make it better".
You hate seeing suggestions on how to make it better? If you'd rather just see gushing praise then I'm sorry, because you won't get that from me. We both know that your script's pretty nifty, but I post under the assumption that you'd like to make it more so.

Quote:
Originally Posted by Polo
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
Hmm? So is mine. It just won't render properly in some circumstances because I took the more challenging route of projecting all the vertices manually.

Quote:
Originally Posted by Polo
I'd still rather use showpoly2 than go through every single possible situation (2 sided polygons, clipped, obfuscation etc..)
Two-sided polys are hardly a problem. Clipping is unnecessary if the edges of your screen are the edges of your viewport - hell, Graal probably does it itself. Obfuscation is by far the biggest problem, as there's no Z-buffer to rely on and you can't tell the polygons to draw in any particular order. But part of the fun of scripting is solving difficult obstacles, inventing your own methods so you end up with more than just an adapted generic engine.
__________________
  #39  
Old 08-09-2004, 12:14 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
Scripters scripters calm down. Get together and make the ultimate 3D field >:O!
__________________
  #40  
Old 08-09-2004, 04:44 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Did you people like the graal 3D tutorial I tried to make? Does someone read it?

o.O

Quote:
Originally Posted by Gerami
Scripters scripters calm down. Get together and make the ultimate 3D field >:O!
XD


Quote:
Originally Posted by Python523
Mathematica. (I believe that's the name)
ah.. I dont know this one o.O
sorry

=X
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.