Author |
Topic: 3D editor tryout (12 triangles) (Read 201 times) |
|
michael
Senior Member
member is offline


Posts: 335
|
 |
3D editor tryout (12 triangles)
« Thread started on: Sep 19th, 2017, 02:31am » |
|
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)
I did it like this because the file cant be read and written to at the same time. ( I will work that out later)
Also, the top of the triangle controls the LR and the LR controls the top... (oops!! Ill fix that 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: all fixes will be listed bellow here and will be active in the link files once you see them
Fixed memory leak : These 3 pieces of code are added to the render cycle 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))
|
« Last Edit: Sep 19th, 2017, 12:08pm by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: 3D editor tryout (12 triangles)
« Reply #1 on: Sep 19th, 2017, 09:11am » |
|
Hi Michael,
I can't make it work very cleanly, but I am using Windows 7 - is there a particular reason you require Windows 10? The problem seems to be the renderer opening the file, presumably because the editor is still writing it.
If you combined the editing and rendering programs you could hold the vertex buffer in memory, which would (a) probably be much faster, and (b) allow you to access it from both parts of the program.
At the moment it looks like the renderer simply loads a new copy of the file with each update, without releasing the previous one. That's probably not too big a problem with 12 triangles, but represents a significant memory leak, which would be a major problem with a bigger model.
Are you updating the file with every click of the positioning boxes? Could you add a "macro-move" function - perhaps by dragging a triangle around a virtual window, and then working out the coordinates at the end? And/or allow a number of clicks, then a button saying "make it so" (choose Star Trek version of your choice!) to tell the editor to actually update the file? Could you make a right-click of the boxes move it 10 times as far?
Can you group triangles? So you can make a sub-assembly and then move the whole thing?
At the moment your code is hard-programmed for 12 triangles, with separate routines to handle each. How about using a 2D array, allowing you to identify the triangle by the first coordinate and the specific parameters by the second one? Then if you wanted more triangles you'd simply change the size of the array - or you could DIM the array to allow a maximum number, and then add them dynamically. That might also make the rendering less confusing, since you wouldn't have 11 stacked triangles hiding what is going on! Then you could also have a single routine to alter the relevant triangle, and just pass it tn%.
If you encoded your corners as 1,2, and 4, then 7 would mean all 3 - then you could make your update routines (PrOCone etc) a bit more compact as you could use "IF sel% AND 1", for example, which would update the relevant corner either when just that corner or the whole triangle is selected.
One advantage of separate arrays for each triangle is that you could use matrix arithmetic to move/rotate etc individual triangles. That's why I've used separate arrays for vertices, normals and textures in my program. However, combining them will make your program much more compact, and easy to extend.
Hope that's helpful!
D
|
|
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: 3D editor tryout (12 triangles)
« Reply #2 on: Sep 19th, 2017, 12:18pm » |
|
Yeah, I will eventually work out the kinks and I will add rotational controls.
I did discover a way to simulate communication between programs.
When the program windows are along side each other, coordinates outside the window can be sensed with the mouse. So if the modules are beside each other, I technically could make buttons in the other program and use the mouse to sense the activity in that section.
I did merge both programs together, but I like a nice display that doesn't flash, so that's why there are two separate programs. (that and behold!! 2 separate threads !)
I am experimenting with ways to send data back and forth without using files.
Also Ill work out a way to drag triangles from a staggered stack at the side and add slight color diffrences so they are easier to see
|
« Last Edit: Sep 19th, 2017, 12:22pm by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
|