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/2 - 250; temp.ty = screenheight/2 + 50; //Loops through and shows all polygons for the render. for(temp.i = 0; i < radius*detail; i ++){ 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.tx, temp.ty, temp.tx + radius/2, temp.ty + radius/2, }; useowncenter = true; rotationcenter = {temp.tx -radius/2, temp.ty -radius/2}; } } onTimeout(); } function onTimeout(){ //Loops through all images and rotates them. for(temp.i : 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.
|