Forum archive
Evaldraw: Some suggestions.
- hi,
Here are some features I would like to see in the future versions of evaldraw:
- Access to 'context'/'state' variables. somehow the inverse of setcol(), moveto()...etc. This would be very helpful inside (sub)functions.
- Deactivation of FPU exceptions. I'm not sure about that but it seems that FPU exceptions consume a lot of clock cycles.
- Ability to remove textures/sprites (generated with glsettex()) from memory.
- Ability to use static variables and arrays in (x,y...) modes while Multithreading is on.
- Support for user defined interaction in (x,y...) modes.
- Hollow sphere and cone. to 'dig' cave like environments. Other quadrics also such as ellipsoid.
Best regards. Re: Evaldraw: Some suggestions.
Those are some good suggestions.- Access to 'context'/'state' variables. somehow the inverse of setcol(), moveto()...etc. This would be very helpful inside (sub)functions.
This one isn't hard. The question is what's the best design. I could do a quick hack like: setcol_get(&r,&g,&b) and moveto_get(&x,&y). I could instead give access to the internal variables, but then there would be no reason to use setcol()/moveto(). I was also thinking of a push/pop (with maybe a stack limit of 16) that could either backup individual fields, or all of them (color, pos, font, camera, view).- Deactivation of FPU exceptions. I'm not sure about that but it seems that FPU exceptions consume a lot of clock cycles.
If all this takes is changing an FPU flag, it's just a matter of finding a good evil script to test it.- Ability to remove textures/sprites (generated with glsettex()) from memory.
Good suggestion. Perhaps: glremovetex(handle_number).- Ability to use static variables and arrays in (x,y...) modes while Multithreading is on.
I know this would be useful, but it would take some thought in how to do it.- Support for user defined interaction in (x,y...) modes.
I don't understand this request.- Hollow sphere and cone. to 'dig' cave like environments. Other quadrics also such as ellipsoid.
I don't understand the first part of this request. Do you mean some kind of hack to the Z-buffer? Don't expect a function for ellipsoids anytime soon.- Thanks for the fast reply.
- 'context' variables: I prefere the push/pop solution as in OpenGL. One haven't to worry about storing anything in temporary variables. :)
- FPU exceptions: that was a stupid suggestion. :-X
- User interaction in (x,y...) mode : By user I mean the one who is writing the script. I work a lot under this mode mainly because of multithreading. the inetraction (Imean input) is done at the begining of each frame, consequently, at the first pixel. With multithreading on, there are usually some flickering (I think because of simultaneous modification of the variables by the threads). Anyway, I feel like this will make things too complicated... :-\
- Hollow sphere and ellipsoid: This is not very important.
I did a little script some time ago rendering what i call 'hollow sphere'. here it is:
()
{
static r,g,b,z;
cls(0x8f8f8f); clz(40);
setcol(128,100,120);
drawsph(0,0,20,5);
setcol(0,100,120);
drawcone(-5,0,15,3,0,0,10,0.1);
{
z=getpix(mousx,mousy,r,g,b);
x=(mousx - xres/2)*2*z/xres;
y=(mousy - yres/2)*2*z/xres;
drawhsph(x,y,z,2.5);
}
z=getpix(mousx,mousy,r,g,b);
moveto(8,yres-10);
setcol(0xffffff);
printnum(z);
moveto(8,yres-30);
printnum(x);
moveto(8,yres-50);
printnum(y);
}
drawhsph(xc,yc,zc,r)
{
r=abs(r);
if (zc<r) return;//for now
D=xres*0.5;D1=yres*0.5;
//Bounding box
xmax=-1e30; ymax=-1e30;
A=r*r-zc*zc;
B=zc*xc;
if (abs(A)<1e-10){
xmin=D*(r*r-xc*xc)*0.5/B;
} else {
Delta=B*B-A*(r*r-xc*xc);
A=1/A; Delta=sqrt(Delta);
xmin=ceil(-D*(B-Delta)*A);
xmax=ceil(-D*(B+Delta)*A);
if (xmin<-D) xmin=-D;
if (xmax>D) xmax=D;
}
A=r*r-zc*zc; B=zc*yc;
if (abs(A)<1e-10){
ymin=D*(r*r-yc*yc)*0.5/B;
} else {
Delta=B*B-A*(r*r-yc*yc);
Delta=sqrt(Delta);
A=1/A;
ymin=ceil(-D*(B-Delta)*A);
ymax=ceil(-D*(B+Delta)*A);
if (ymin<-D1) ymin=-D1;
if (ymax>D1) ymax=D1;
}
//A little Hack to obtain current color
static rcol,gcol,bcol,rc,gc,bc;
getpix(xmin+D,ymin+D1,rc,gc,bc);
setpix(xmin+D,ymin+D1);
getpix(xmin+D,ymin+D1,rcol,gcol,bcol);
setcol(rc,gc,bc);
setpix(xmin+D,ymin+D1);
//let's rock (slowly!)
C=xc*xc+yc*yc+zc*zc-r*r;r1=1/sqrt(3)/r;
for (yp=ymin;yp<ymax;yp++){
A1=yp*yp+D*D;B1=yp*yc+D*zc;
for (xp=xmin;xp<xmax;xp++){
A=A1+xp*xp; B=B1+xp*xc;
Delta=B*B-A*C;
if (Delta>0){
Delta=sqrt(Delta);A=1/A;
tmin=(B-Delta)*A;zmin=D*tmin;
tmax=(B+Delta)*A;zmax=D*tmax;
z=getpix(xp+D,yp+D1,rc,gc,bc);
if (zmin<z)
if (zmax>z){
col=(r1*((xp+yp)*tmax-(xc+yc+zc)+zmax));
col=1+col*0.5+col^20;
setcol(col*rcol,col*gcol,col*bcol);
setpix(xp+D,yp+D1,zmax);
}
}
}
}
setcol(rcol,gcol,bcol);
}
Thanks again. - oh I remember it just now: Function pointer as argument to another function. It would be very useful too :)
for example:
(){
printnum(fooo(&fo,1));
printnum(fooo(&foo,1));
}
fo(x){2*x}
foo(x){x*x}
fooo(f(x),y){f(y)+y} - 'context' variables: I prefere the push/pop solution as in OpenGL.
Ok.- FPU exceptions: that was a stupid suggestion.
I have found that FPU exceptions are already masked. If you do 1/0 or sqrt(-1), you'll just have to suffer the penalty. Probably it would handle these conditions faster if I used SSE registers, but that's a project for another month.User interaction in (x,y...) mode
Ok, I see this is a problem for multithread mode.- Hollow sphere and ellipsoid: This is not very important.
That's a cool script, but there's no way I'm going to support that.Function pointer as argument to another function.
Ok.- Thanks a lot.
Evaldraw: Some suggestions.
Hello,
Here is some evaldraw suggestions :
- Have the ability of setting evaldraw window size and change zoom, center position of drawing by code
or at least give the possibility to access these variables (zoom, centerx, centery) so zooming or changing position can be taken in account
some effects depents heavily on this , sometimes i liked to set screen at 320x240 for some effects...
- Create a new mode : (x,y,&r,&g,&b,n) and possibility to load a video (eg : avi uncompressed, can be proprietary format)
function is called for each pixel in a frame , then next frame is called. when all frames have been done it loops.
n is the index of frame
ctrl-something can be done to load video (like for pics)
i think in can been very cool to create insteresting filters realtime on videos .Re: Evaldraw: Some suggestions.
Have the ability of setting evaldraw window size
I have purposely not implemented certain features in Evaldraw for safety reasons. For example:
* You can't write a file - without first consenting via F6 or the File menu.
* There is no MessageBox function, because a malicious or buggy script could force you to kill Evaldraw via the task manager.
* A script cannot control when or who you connect to over the network - that must be done by the user under the File menu.
For similar reasons, I do not want to allow a script to change the window size. A malicious script could entice you to click on something, then suddenly change the window position, and you're clicking on something else.and change zoom, center position of drawing by code
This can already be done in the 2D graphing modes using setgrid().Create a new mode : (x,y,&r,&g,&b,n)
There is no need for a new mode. Try these examples:
(x,y,t) t%1
(x,y) (numframes/256)%1possibility to load a video
That's not a bad idea. I would write a new family of functions such as: vid(n,x,y), similar to my already existing: pic(x,y) functions.Re: Evaldraw: Some suggestions.
ok thx for your answers, I was not aware of setgrid() function (and understand some security reasons about evaldraw)
And for video you are right, there no need of new mode...
I feel very excited about a new vid() function, hope it will be implemented one day :P (already have TONS of ideas for it....)- Some commands for image output would be useful, something like saving an array into a binary file. I need to make hi-res stuff and series of images so screen capture isn't a good way to do this.Edited by CraigFatman at
evaldraw timer
Hi ken,
is there any way in evaldraw to get the actual time??
something like C time() that return number of seconds would be very cool , especially for script with analog/digital clocks inside.Re: Evaldraw: Some suggestions.
There is, as of right now ; ) Please download the latest version of EVALDRAW, and find the new description of klock() inside EVALDRAW.TXT.- thx !!!
- hello ken !
here is some things that yould be nice to see in evaldraw :
-have some direct access to screen buffer, actually I have to call getpixel (...) for each pixel which means a function call each time + push/pop parameter which is really slow and make things like blur or realtime filters not possible :(
- implement some kind of structure (like the struct keyword in C). i have no idea how much difficult it this to add this. right now (for creating a particle system for eg ) this is quite pain, you have to create a array for each variable. - - The next release of Evaldraw will have a gethlin() function, which has the same parameters as sethlin().
- I've been wanting to add structures for years. The compiler is a mess. Adding structures would require some serious hackery : /