Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-20-2012, 06:50 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Attempting to render 3D shapes

Hey, tried playing around rendering a hollow cylinder, sort of worked.
Here is my script:
Graal Script Code:
//#CLIENTSIDE
function onCreated(){
  const 
radius 200//The radius of the cylinder.
  
const detail 2//How much detail to show.
  
const ntsc false//NTSC colours, sort of.
  
const blurlevel 1//To skew the render.
  
const spinspeed 0.05//How fast it rotates.
  
DrawGUI();
}
function 
DrawGUI(){
  
this.imgs 0;
  
temp.tx screenwidth/250;
  
temp.ty screenheight/50;
  
//Loops through and shows all polygons for the render.
  
for(temp.0radius*detail++){
    
this.imgs.add(i);
    
temp.tx += sin(i)*radius//Changes the positioning to a circle.
    
temp.ty -= cos(i)*radius//Same
    
with(findimg(1+i)){
      
layer 4;
      
polygon = {
        
temp.txtemp.ty,
        
temp.tx radius/2,
        
temp.ty radius/2,
      };
      
useowncenter true;
      
rotationcenter = {temp.tx -radius/2temp.ty -radius/2};
    }
  }
  
onTimeout();
}
function 
onTimeout(){
  
//Loops through all images and rotates them.
  
for(temp.this.imgs){
    
findimg(1+this.imgs[i]).rotation += spinspeed;
    if(
ntsc){
      
findimg(1+this.imgs[i]).red random(0,1);
      
findimg(1+this.imgs[i]).green random(0,1);
      
findimg(1+this.imgs[i]).blue random(0,1);
    }
    
//Skews the polygons.
    
findimg(1+this.imgs[i]).stretchx random(1,blurlevel);
    
findimg(1+this.imgs[i]).stretchy random(1,blurlevel);
  }
  
settimer(0.05);

The script can cause the Graal client to become quite laggy if rendering a large cylinder with a high detail value.
Not quite sure how to actually make the shape proper 3D.
In which I could rotate it on each axis, x,y,z.
If anyone has some formulas they'd like to share it's more than welcome.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 12-20-2012 at 07:01 AM..
Reply With Quote
  #2  
Old 12-20-2012, 11:44 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
Dat logic. Also if you want proper 3d try think of your object encapsulated by a sphere rotating on all axis(x,y,z), then through working with some basic trigonometry you determine positions. Since it looks like you somewhat picked up scraps of maths from some place... I would first brush up on your trig, then give it a shot.
__________________
Quote:
Originally Posted by Crono View Post
No look at it, Stefan is totally trolling Thor. Calling Classic a "playerworld" (something it's not supposed to be) is the ultimate subtle insult to a true fan.

It's genius.
Reply With Quote
  #3  
Old 12-20-2012, 12:32 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
I did study trigonometry in my senior years, so that would be where I "picked up scraps of math" lol.
But rendering could be a problem, Graal starts lagging when you try to render anything above about 1,000 polygons.
Do you know any good sites that are informative?
I know my way around sine and cosine, but tan not too much.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 12-20-2012, 09:46 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
http://lodev.org/cgtutor/raycasting.html I wouldn't bother doing proper 3d. Anyway, downsider made a quite
successful wolfenstein clone in GS1 using raycasting, so you should be able to do this no prob.
__________________
Quote:
Originally Posted by Crono View Post
No look at it, Stefan is totally trolling Thor. Calling Classic a "playerworld" (something it's not supposed to be) is the ultimate subtle insult to a true fan.

It's genius.

Last edited by Tricxta; 12-20-2012 at 09:57 PM..
Reply With Quote
  #5  
Old 12-20-2012, 10:22 PM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Proper 3D isn't trig, it's linear algebra. My raycasting also is a proper 3D projection, but it's a shortcut that just requires some basic math. You could make a Minecraft-style renderer in Graal that would probably run at 20 FPS without textures using some neat tricks that I picked up over the years as a graphics programmer on really low-end devices. But again, textures would be difficult because of the way Graal inefficiently renders stuff.

Quote:
Originally Posted by Gunderak View Post
I did study trigonometry in my senior years, so that would be where I "picked up scraps of math" lol.
But rendering could be a problem, Graal starts lagging when you try to render anything above about 1,000 polygons.
Do you know any good sites that are informative?
I know my way around sine and cosine, but tan not too much.
lol'd.
Reply With Quote
  #6  
Old 12-20-2012, 11:55 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
Quote:
Originally Posted by Hezzy002 View Post
lol'd.
In all fairness not everyone has a mathematical mind. Play nice.
__________________
Quote:
Originally Posted by Crono View Post
No look at it, Stefan is totally trolling Thor. Calling Classic a "playerworld" (something it's not supposed to be) is the ultimate subtle insult to a true fan.

It's genius.
Reply With Quote
  #7  
Old 12-21-2012, 02:24 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Thanks for the link, I might try that. It seems fairly easy.
I'll post back with results.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #8  
Old 12-21-2012, 03:21 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quote:
Originally Posted by Gunderak View Post
Thanks for the link, I might try that. It seems fairly easy.
I'll post back with results.
If you need any help, ask a 3rd grader.
Reply With Quote
  #9  
Old 12-21-2012, 04:57 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
I highly doubt a 3rd grader would be able to understand it, let alone do the code.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #10  
Old 12-21-2012, 07:06 AM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Quote:
Originally Posted by Gunderak View Post
I highly doubt a 3rd grader would be able to understand it, let alone do the code.
ur a qt 3.14
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:46 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.