2 registered members (AndrewAMD, ozgur),
1,421
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Is 3d GS fit for Drawing App?
#20532
11/28/03 04:23
11/28/03 04:23
|
Joined: Jan 2003
Posts: 748 California
BHoltzman
OP
Developer
|
OP
Developer
Joined: Jan 2003
Posts: 748
California
|
I've been wanting to write a drawing application for a while now. So far I'm just researching my current set of resources. I like the easier languages like Blitz Basic and IBasic for their syntax. But I'm also wondering how 3dGS would be able to perform as a 2d/3d drawing application? Would I have to use the sdk for more than 50% of the project?
Thanks,
Ben
I'm not Mr Franklin but I am Benjamin. My avatar partly suites me.
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: BHoltzman]
#20533
11/28/03 10:18
11/28/03 10:18
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
i experimented with bresenhams linedraw algorithm a while ago. maybe it's helpful for you:
Code:
var video_mode=8;
var video_depth=32;
on_f5=null;
string debug;
bmap bmp_arrow=<arrow_blue.pcx>;
bmap bmp_canvas=<canvas.tga>; //1024x768 black
panel canvas
{
bmap=bmp_canvas;
flags=d3d,refresh,visible;
}
function putpixel(x,y)
{
var format;
var pixel;
format=bmap_lock(bmp_canvas,0);
pixel=pixel_for_vec(vector(255,255,255),null,888);
pixel_to_bmap(bmp_canvas,x,y,pixel);
bmap_unlock(bmp_canvas);
}
function line(x1,y1,x2,y2) //bresenham algorithm
{
var x;
var y;
var dx;
var dy;
var incx;
var incy;
var balance;
if(x2>=x1)
{
dx=x2-x1;
incx=1;
}
else
{
dx=x1-x2;
incx=-1;
}
if(y2>=y1)
{
dy=y2-y1;
incy=1;
}
else
{
dy=y1-y2;
incy=-1;
}
x=x1;
y=y1;
if(dx>=dy)
{
dy=dy<<1;
balance=dy-dx;
dx=dx<<1;
while(x!=x2)
{
putpixel(x,y);
if(balance>=0)
{
y+=incy;
balance-=dx;
}
balance+=dy;
x+=incx;
}
putpixel(x,y);
}
else
{
dx=dx<<1;
balance=dx-dy;
dy=dy<<1;
while(y!=y2)
{
putpixel(x,y);
if(balance>=0)
{
x+=incx;
balance-=dy;
}
balance+=dx;
y+=incy;
}
putpixel(x,y);
}
}
function main()
{
var ox;
var oy;
var cx;
var cy;
mouse_map=bmp_arrow;
mouse_mode=2;
while(1)
{
mouse_pos.x=pointer.x;
mouse_pos.y=pointer.y;
if(mouse_left)
{
ox=mouse_pos.x;
oy=mouse_pos.y;
while(mouse_left)
{
mouse_pos.x=pointer.x;
mouse_pos.y=pointer.y;
cx=mouse_pos.x;
cy=mouse_pos.y;
line(ox,oy,cx,cy);
ox=mouse_pos.x;
oy=mouse_pos.y;
wait(1);
}
}
wait(1);
}
}
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: BHoltzman]
#20534
11/30/03 02:36
11/30/03 02:36
|
Joined: Aug 2003
Posts: 180 Reactor Core
NeutronBlue
Member
|
Member
Joined: Aug 2003
Posts: 180
Reactor Core
|
I'm working on a similar project - using standard C-script (No SDK).
Ventilator's code is great - however, it doesn't provide the ability to treat a line as an "object" in an object list.
Why would you need an object? - for reference purposes.
How could you move a static line? Move an endpoint?
You'll need an object list to store the items you've drawn onscreen.
Store the object's handle into this list, then you can move, resize, delete, etc...
A further benefit: If properly scripted, the Mouse can give you the entity clicked on.... (line, circle, box, etc..)
I'm not saying I have it all figured out - but I have a lot of the logic ground work laid out...
-Neut.
Dreaming ain't Doing..! <sigh> Darn semicolons - I always manage to miss at least 1..!
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: NeutronBlue]
#20535
11/30/03 03:33
11/30/03 03:33
|
Joined: Jan 2003
Posts: 748 California
BHoltzman
OP
Developer
|
OP
Developer
Joined: Jan 2003
Posts: 748
California
|
Wow, thanks for the example c-script.
Neutronblue, With your method, how would you implement functions like smudge or blur?
Thanks,
Ben
I'm not Mr Franklin but I am Benjamin. My avatar partly suites me.
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: BHoltzman]
#20536
11/30/03 04:00
11/30/03 04:00
|
Joined: Aug 2003
Posts: 180 Reactor Core
NeutronBlue
Member
|
Member
Joined: Aug 2003
Posts: 180
Reactor Core
|
My project doesn't use "pixel effects".
I guess I'm not really giving any project secrets away -
OK, here's my Drawing Object data structure: (Note: Z-coords are fixed for Floor/Ceiling)
define ObjArea,0; // Num define ObjNum,1; // Num define ObjType,2; // Text: "Line", "Box", "Ellipse" define ObjX1,3; // Num define ObjY1,4; // Num define ObjX2,5; // Num define ObjY2,6; // Num define ObjLen1,7; // Num define ObjTxtPos,7; // Num define ObjLen2,8; // Num define ObjText,9; // Text define ObjS_ID,9; // Text define ObjTag1,10; // Num define ObjTag2,11; // Num
Now, using the above, say you click on Line with the mouse - mouse_ent gives you the entity (handle?) clicked on, look up the line's endpoints (X1/Y1 and X2/Y2), apply your "transform" (blur)..
-Neut.
Dreaming ain't Doing..! <sigh> Darn semicolons - I always manage to miss at least 1..!
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: NeutronBlue]
#20537
11/30/03 09:21
11/30/03 09:21
|
Joined: Jan 2003
Posts: 748 California
BHoltzman
OP
Developer
|
OP
Developer
Joined: Jan 2003
Posts: 748
California
|
Do you use a one to one correspondence for viewport pixel to object on the screen? I just wrote a blur function today in Blitz that takes the color information to pixels adjucent to the current pixel and averages them out. Then the whole picture is blured that way.
In a 2d Blitz application this process takes about 1.5 seconds. I'm wondering how fast you're able to implement this using a vector graphic like buffer?
P.S. Blurring a picture isn't really heavy and abstract math but I don't expect you to give out your secrets if it really bothers you.
I'm not Mr Franklin but I am Benjamin. My avatar partly suites me.
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: BHoltzman]
#20538
11/30/03 13:45
11/30/03 13:45
|
Joined: Aug 2003
Posts: 180 Reactor Core
NeutronBlue
Member
|
Member
Joined: Aug 2003
Posts: 180
Reactor Core
|
Take the Bresenham incremental line drawing code (Ventilator's post), and modify the "PutPixel" function. Since that code draws every dot (incrementaly), simply add additional code that looks at adjacent pixels - average (or whatever..) the pixels, then store the calculated color back to the "original" (versus adjacent) pixel.
Hope it helps,
-Neut.
Dreaming ain't Doing..! <sigh> Darn semicolons - I always manage to miss at least 1..!
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: NeutronBlue]
#20539
11/30/03 17:52
11/30/03 17:52
|
Joined: Jan 2003
Posts: 748 California
BHoltzman
OP
Developer
|
OP
Developer
Joined: Jan 2003
Posts: 748
California
|
Do you know how to implement a Guassian Blur or a radial blur? I've come to the conclusion that my method of blurring isn't very efficient. It was fun to experiment with my idea though.
I'm not Mr Franklin but I am Benjamin. My avatar partly suites me.
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: BHoltzman]
#20540
12/02/03 00:29
12/02/03 00:29
|
Joined: Aug 2003
Posts: 180 Reactor Core
NeutronBlue
Member
|
Member
Joined: Aug 2003
Posts: 180
Reactor Core
|
Sorry, I don't have any code for stuff like that.
Somewhere, I have code for drawing circles based on a variation of the Bresenham algorithm - but that's about it...
My project simply draws shape "primitives" at the moment. (It's a start...)
-Neut.
Dreaming ain't Doing..! <sigh> Darn semicolons - I always manage to miss at least 1..!
|
|
|
Re: Is 3d GS fit for Drawing App?
[Re: NeutronBlue]
#20541
12/02/03 00:32
12/02/03 00:32
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
|
|
|
|