Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Attempting to render 3D shapes (https://forums.graalonline.com/forums/showthread.php?t=134267604)

Gunderak 12-20-2012 06:50 AM

Attempting to render 3D shapes
 
Hey, tried playing around rendering a hollow cylinder, sort of worked.
Here is my script:
PHP 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.

Tricxta 12-20-2012 11:44 AM

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.

Gunderak 12-20-2012 12:32 PM

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.

Tricxta 12-20-2012 09:46 PM

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.

Hezzy002 12-20-2012 10:22 PM

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 (Post 1710024)
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.

Tricxta 12-20-2012 11:55 PM

Quote:

Originally Posted by Hezzy002 (Post 1710064)
lol'd.

In all fairness not everyone has a mathematical mind. Play nice.

Gunderak 12-21-2012 02:24 AM

Thanks for the link, I might try that. It seems fairly easy.
I'll post back with results.

Hezzy002 12-21-2012 03:21 AM

Quote:

Originally Posted by Gunderak (Post 1710082)
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.

Gunderak 12-21-2012 04:57 AM

I highly doubt a 3rd grader would be able to understand it, let alone do the code.

Tim_Rocks 12-21-2012 07:06 AM

Quote:

Originally Posted by Gunderak (Post 1710092)
I highly doubt a 3rd grader would be able to understand it, let alone do the code.

ur a qt 3.14


All times are GMT +2. The time now is 04:55 AM.

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