Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-24-2008, 04:55 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Planetary system

Thanks to Ziro (xXziroXx) for proof-reading this thread. He said he couldn't find much wrong with it, but since his opinion can't be trusted, I asked someone else who was quoted saying "Not funny."

Abstract:
It's a so called "physics engine" combined with a "graphics engine" in order to produce a rather excessively rapid simulation of a planetary system.
I originally tried to do this using Kepler's equations but that just gave me nightmares, so I settled for simple gravity, which can achieve the same thing.
The example setup creates a few planets which orbits around different axises with the immovable sun located at (0, 0, 0). You can alternatively make all bodies attract each other with gravity, allowing you to make moons. The problem with this is that it opens up a whole new can of worms stuffed with "Oh <deity>, I can't make them orbit for longer than twenty seconds."

Features:
  • Perspective projection giving an illusion of 3D.
  • Scaling according to your screen size (sort of, should work in most cases).
  • Rotation of the entire scene, revealing the planets to be made out of paper cutouts, which doesn't make sense but looks cool.
  • Anti-Newtonian gravity. If he saw that the gravitational constant equals one, he would choke on an apple.
  • Gimmicky object oriented programming that allows you to instantiate things you would never dream of instantiating. It's the paradigm of the year 3000!
  • Confusing z-x-z rotation.

No, I'm not releasing source code for anyone to just use without thinking. The attached document was accidentally posted and I don't know how to remove it. Don't read it! Forbidden knowledge, etc.

(The text that you have entered is too long (20830 characters). Please shorten it to 10000 characters long.)

Terms of use:
The origins of this script must be confused. Whenever you see fit to give credit, you must claim that you wrote it.
The most important rule to remember is that you must never attribute me. If you in anyway mention, hint, suggest or imply that I wrote this, I will connect to your server and say mean things to you.

Frequently asked questions that aren't really frequently asked since I just made them up:
Q: How do I spawn something?
A: yourWorld.newMass(position, velocity, massInKilograms);

Q: That's nice, but it always comes out as a white square.
A: The basic mass object doesn't include details about drawing. You must "derive" to do this. The example setup demonstrates this in newPlanet() and newCustomWorld(), which derives newMass() and newWorld() respectively. I didn't tell you about the gimmicky OOP just to be funny.

Q: What's up with renderer.color, renderer.rotate, renderer.translate etc?
A: These functions change certain variables which will affect all subsequent drawings, not unlike OpenGL. If you ever want to start from scratch, use yourRenderer.reset().

Q: Can I put players in orbit?
A: Technically, yes. I'm not going to do it for you. Make it a father-and-son-time of DIY so you'll have something to fight about. It'll be just like good old times.

Q: Sounds like fun! I'm going to remove //#CLIENTSIDE so it looks the same for everyone.
A: Please PM me your address so I can be the first to kill you.

Q: My planet's velocity breaches the speed of light when it gets really close to the sun. Isn't this impossible according to Einstein's special theory of relativity?
A: Einstein was a hobo. Are you going to listen to some chick on an Internet forum or a hobo? You're going to listen to me of course!

Q: Where do I test it?
A: Connect to Mythic Legends and type /startorbit. Reconnect to get out of there. If it's not working, stop reading old threads.

Peace out.
Attached Thumbnails
Click image for larger version

Name:	orbit.png
Views:	332
Size:	36.3 KB
ID:	45665   Click image for larger version

Name:	orbit2.png
Views:	300
Size:	37.2 KB
ID:	45666   Click image for larger version

Name:	orbit3.png
Views:	286
Size:	14.7 KB
ID:	45667  
Attached Images
 
Attached Files
File Type: txt orbit.txt (15.4 KB, 368 views)

Last edited by DrakilorP2P; 08-25-2008 at 01:04 PM.. Reason: Shortened. Taking conservative approach before edit time runs out.
Reply With Quote
 


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 09:52 PM.


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