BBC BASIC
« 3D editor tryout (12 triangles) »

Welcome Guest. Please Login or Register.
Jan 20th, 2018, 4:20pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: 3D editor tryout (12 triangles)  (Read 194 times)
michael
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 141
xx 3D editor tryout (12 triangles)
« Thread started on: Sep 19th, 2017, 02:25am »

This version requires windows and BBC4W, as I created an executable and the renderer can be run in BBC4W.

Instructions:
* Copy all the files to a working writable directory
* Open BBC4W
OPEN the file called "RENDER.BBC"

While the program is waiting in your editor, execute the program called 3DAUTOCAD proj.exe and move it to the left side of the screen.

Now go back to BBC4W and execute RENDER program

Move the window to a nice spot to the right of the renderer

Use your mouse left button to scratch the renderer to make it update the active triangles (there are 12 stacked)

You then can move back and forth between your editor and the renderer to see the results of any actions you make on the editor. Be sure to hold the left mouse button and scratch the editor to be sure you are seeing the latest edit.

I beat the clock, but it needs much improvement. (like different textures and automatic updates for both screens instead of the mouse presence)

Also, the top of the triangle controls the LR and the LR controls the top...
(its because the default triangle is on its side and the peak is on the lower right)

I did it like this because the file cant be read and written to at the same time. ( I will work that out later)

Here is the link to the files and if you have troubles with the executable, just make your own with the program provided with BBC Basic for windows or force it to run on your computer.

https://1drv.ms/f/s!AmYwmTjbmULXljBxPAfFwdi0XiZi


********************************************
NOTE:
Any fixes I show here will be updated in the link files

Update: fixed memory leak in RENDER

I added :
t%(1) += 0:IF t%(1) PROC_release(t%(1))
b%(0) += 0:IF b%(0) PROC_release(b%(0))
b%(1) += 0:IF b%(1) PROC_release(b%(1))

to the cycle
« Last Edit: Sep 19th, 2017, 3:25pm by michael » User IP Logged

I like reinventing the wheel, but for now I will work on tools for D3D
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: 3D editor tryout (12 triangles)
« Reply #1 on: Sep 19th, 2017, 4:09pm »

on Sep 19th, 2017, 02:25am, michael wrote:
I did it like this because the file cant be read and written to at the same time.

That depends on whether you're using BB4W or BBCSDL. In BB4W a file can be simultaneously open for writing and reading but in BBCSDL opening a file for output will cause attempts to open that same file for input to fail (and vice versa).

So assuming that you are wanting to keep your programs cross-platform (and I hope you are!) you need to write them in such a way that they will work in either case. For example when you open a file be aware that the open may fail (even if it won't when running in BB4W) and incorporate a 'retry' mechanism to cope with that.

Incidentally it appears that you are storing your shared FVF file in @dir$. That is a bad idea because it requires the two programs to reside in the same directory, which is an unnecessary and undesirable limitation, and more importantly @dir$ is not guaranteed to be writable (and frequently isn't). Far better to put the shared file in @tmp$ which should be writable and which is independent of the directory in which the program itself is stored.

Richard.
User IP Logged

michael
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 141
xx Re: 3D editor tryout (12 triangles)
« Reply #2 on: Sep 20th, 2017, 12:54am »

Quote:
assuming that you are wanting to keep your programs cross-platform (and I hope you are!)


The original version that I experimented with was 100% BBCSDL compatible. In fact the majority of all my work since I started BBC Basic has been cross platform orientated. ( I have been trying to reinvent windows right from the start )

The BBCSDL version is a simple merger of the two programs.

The only minor obstacle for cross platform was sharing the same screen as the renderer. I would need to deal with time sharing of the screen. So I would get a flicker that *REFRESH would not be able to solve. (as far as I know)

Not a big deal though, because once the 12 triangles get their own specific color scale, it should be easy to work with the slight flashing.

The other idea I have been thinking of is having 2 instances of BBCSDL in the same directory and then I could create two windows like in the one I provide.

If you have any suggestions that may solve the shared graphics, I could work it out.

Regardless, a 100% BBCSDL version will be made from the same program. (minor modifications)
« Last Edit: Sep 20th, 2017, 01:10am by michael » User IP Logged

I like reinventing the wheel, but for now I will work on tools for D3D
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: 3D editor tryout (12 triangles)
« Reply #3 on: Sep 20th, 2017, 08:36am »

on Sep 20th, 2017, 12:54am, michael wrote:
The other idea I have been thinking of is having 2 instances of BBCSDL in the same directory and then I could create two windows like in the one I provide.

I had assumed that is what you would do. Running two separate processes (the 3D editor and the renderer), as you do in BB4W, has several advantages - not least that it makes better use of the multiple CPU cores typically available on a modern PC (even a Raspberry Pi has multiple cores). I don't think it would be sensible to attempt it any other way.

I wonder if you have somehow convinced yourself that to achieve that you need to 'compile' one of the programs, but that's not true at all. When the BBCSDL IDE runs a BASIC program, it does it by launching another instance of the interpreter in another process. You can do exactly the same with your program: the 'editor' can launch the 'renderer', both being normal .bbc files.

Quote:
If you have any suggestions that may solve the shared graphics, I could work it out.

What you're doing now is basically fine and I wouldn't suggest making any major changes to the architecture. You will need to 'streamline' the way the FVF file is shared to make the two programs cooperate more smoothly, but that should not be too difficult.

Again there's a close correspondence with the way SDLIDE.bbc works when debugging a BASIC program. The IDE launches the program in another process, and that process opens a shared file to which it writes the 'List Variables' information. The IDE opens that same file and displays the variable list in the familiar way. It seems as though the IDE and the BASIC program are sharing memory but they're not - they're just sharing a file!

So I think you should carry on as you are now, but instead of expecting the user to launch the renderer program your 3D editor program should do that itself. If you're unsure how to achieve that simply copy PROCexecute() from SDLIDE.bbc which contains the multi-platform code required to do it:

Code:
      DEF PROCexecute(bbcfile$, flag$)
      ON ERROR LOCAL IF FALSE THEN
        IF BB4W% THEN
          OSCLI "RUN """ + @lib$ + "..\bbcwrun6.exe"" """ + bbcfile$ + """;"
        ELSE
          CASE @platform% AND &FF OF
            WHEN 0:
              SYS "WinExec", """" + @lib$ + "..\bbcsdl"" """ + bbcfile$ + """ " + flag$, 1
            OTHERWISE:
              OSCLI "RUN """ + @lib$ + "../bbcsdl"" """ + bbcfile$ + """ " + flag$ + ";"
          ENDCASE
        ENDIF
      ENDIF : RESTORE ERROR
      ENDPROC 

Richard.
« Last Edit: Sep 20th, 2017, 2:52pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls