Author |
Topic: Wavefront OBJ to FVF converter (Read 484 times) |
|
michael
Full Member
member is offline


Posts: 157
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #1 on: Sep 16th, 2017, 01:15am » |
|
Do you have a converter for OBJ to B3D file? This would be handy since I do have Hexagon 3D and it creates OBJ files.
|
|
Logged
|
I like reinventing the wheel, but for now I will work on tools for D3D
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #2 on: Sep 16th, 2017, 09:30am » |
|
on Sep 16th, 2017, 01:15am, michael wrote:| Do you have a converter for OBJ to B3D file? |
|
What do you mean by a B3D file? That extension normally refers to a Blitz 3D file (used by Blitz BASIC) which has nothing to do with BBC BASIC. I accidentally used the same extension in the early days for 3D files used by BBC BASIC, but that caused great confusion: the formats have nothing in common.
So now I always use the extension FVF (flexible vertex format) for the 3D files accepted by FN_load3D in D3DLIB(A), OGLLIB and GLESLIB, i.e. the file format described here. You should already be aware of that, because you know that BB4W and BBCSDL are highly compatible in their 3D functionality, which is why Rubik.bbc for example runs equally well in either version without modification.
To avoid perpetuating the confusion please use the extension FVF rather than B3D for BBC BASIC's 3D files. My OBJ to FVF converter creates the right kind of file for use with BB4W and BBCSDL, of course! I'm not stupid, well not totally stupid, well.... 
Richard.
|
|
Logged
|
|
|
|
michael
Full Member
member is offline


Posts: 157
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #3 on: Sep 16th, 2017, 12:06pm » |
|
I am quite surprised.
Both me and DDRM have been using this code from your lessons located in:
HELP table of contents Graphics Pyramid-Direct3Dlibrary
And its what you and I have been working on this board earlier when I asked for help.
The lessons are inside BBC Basic For Windows (full version 6.10a). I can see now that FVF has similar code. Ill look at the code you linked.
Code:F% = OPENOUT"TRIANGLE.B3D"PROC4(3):REM 3 verticesPROC4(&100042):REM vertex size &10 and format &42PROC4(FN_f4(-1.0)):PROC4(FN_f4(-1.0)):PROC4(FN_f4(1.0)):PROC4(&FF0000FF)PROC4(FN_f4(1.0)):PROC4(FN_f4(-1.0)):PROC4(FN_f4(1.0)):PROC4(&FF00FF00)PROC4(FN_f4(0.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(&FFFF0000)CLOSE #F%DEF PROC4(A%):BPUT#F%,A%:BPUT#F%,A%>>8:BPUT#F%,A%>>16:BPUT#F%,A%>>24:ENDPROC
|
| « Last Edit: Sep 16th, 2017, 12:17pm by michael » |
Logged
|
I like reinventing the wheel, but for now I will work on tools for D3D
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #4 on: Sep 16th, 2017, 1:15pm » |
|
on Sep 16th, 2017, 12:06pm, michael wrote:| I am quite surprised. Both me and DDRM have been using this code from your lessons |
|
As you should know, BB4W is supplied with the files BASE.B3D and PYRAMID.B3D (in the EXAMPLES\GRAPHICS folder) so everybody ends up with those files on their disk and I can't make them 'disappear'! Even if I were to change their names in the BB4W distribution, the new files would be stored in addition to the old ones rather than replacing them.
So my judgement was that little would be achieved, other than perhaps even more confusion, by retrospectively changing the extension of the files supplied with BB4W. However you should find that I have consistently used the FVF extension in the context of BBCSDL, so for example the equivalent files supplied with that product are base.fvf and pyramid.fvf. They are the same files, just renamed.
I thought I had made it perfectly clear that the 3D libraries for BBCSDL - ogllib.bbc and gleslib.bbc - are designed to be as compatible as possible with D3DLIBA. That was after all the whole point: to make writing cross-platform programs as painless an exercise as possible (the main residual incompatibility being that the BBCSDL libraries will only accept textures in BMP format). As I said in my previous message, Rubik.bbc runs on both BB4W and BBCSDL without any modification.
Therefore I don't really understand how you came to the conclusion that the (BB4W) B3D and FVF file formats are different. What is certainly the case is that the original Blitz3D variety of B3D file is still in common use and you can find many examples online. There was even a post made to a Blitz forum pointing out (incorrectly) that BB4W uses the same file format. The potential for confusion was far too great for it to be allowed to continue.
I cannot comment on the decision of the admin of the 'other' BB4W forum to continue to use the B3D extension. Perhaps he feels that the FVF extension is associated with BBCSDL, which neither he nor his forum supports.
Richard.
|
|
Logged
|
|
|
|
michael
Full Member
member is offline


Posts: 157
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #5 on: Sep 16th, 2017, 1:22pm » |
|
Richard, it isn't the files that are at issue. The HELP section in BBC4W, when accessing direct 3D uses the B3D format. I am sure it was just overlooked by DDRM as it wasn't the focus of the goal to make the tools.
I can focus on the FVF extension if there is an issue concerning the other extension. Like with languages, I doubt that a file format can cause issues, aside from giving attention to the other Basic platform.
BBC Basic is far easier than the other language you mentioned.
Also I must say, your work on that converter is a fantastic creation. I have been looking for an OBJ converter for basic for years. (since around 2009
And it really is no big issue, as I see that the code you supplied for FVF and B3D examples are identical:
Code: DEF PROCcreate3d F% = OPENOUT"TRIANGLE.B3D" PROC4(3):REM 3 vertices PROC4(&100042):REM vertex size &10 and format &42 REM LL x LL y LL z LL colour PROC4(FN_f4(-1.0)):PROC4(FN_f4(-1.0)):PROC4(FN_f4(1.0)):PROC4(&FF0000FF) REM LR x LR y LR z LR colour PROC4(FN_f4(1.0)):PROC4(FN_f4(-1.0)):PROC4(FN_f4(1.0)):PROC4(&FF00FF00) REM PEAK X PEAK Y PEAK Z Peak colour PROC4(FN_f4(0.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(&FFFF0000) CLOSE #F% ENDPROC : DEF PROC4(A%):BPUT#F%,A%:BPUT#F%,A%>>8:BPUT#F%,A%>>16:BPUT#F%,A%>>24:ENDPROC Code: F% = OPENOUT"TRIANGLE.FVF" PROC4(3):REM 3 vertices PROC4(&100042):REM vertex size &10 and format &42 PROC4(FN_f4(-1.0)):PROC4(FN_f4(-1.0)):PROC4(FN_f4(1.0)):PROC4(&FF0000FF) PROC4(FN_f4(1.0)):PROC4(FN_f4(-1.0)):PROC4(FN_f4(1.0)):PROC4(&FF00FF00) PROC4(FN_f4(0.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(&FFFF0000) CLOSE #F% DEF PROC4(A%):BPUT#F%,A%:BPUT#F%,A%>>8:BPUT#F%,A%>>16:BPUT#F%,A%>>24:ENDPROC
|
| « Last Edit: Sep 16th, 2017, 1:45pm by michael » |
Logged
|
I like reinventing the wheel, but for now I will work on tools for D3D
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #6 on: Sep 16th, 2017, 1:45pm » |
|
on Sep 16th, 2017, 1:22pm, michael wrote:| Richard, it isn't the files that are at issue. The HELP section in BBC4W, when accessing direct 3D uses the B3D format. |
|
There is no such thing as "B3D format" (or, if you prefer to look at it this way, it's the format of Blitz 3D object files which isn't used by BBC BASIC). Admittedly the code example in the Help file creates a file with the .B3D extension but it's not the extension that defines the file's contents - it's how you create the file! The extension could be anything at all and it would still work.
I don't see what I could have done differently, other than not making the (stupid) mistake of misusing the B3D extension in the first place. Obviously I hugely regret that mistake, as I do the many other stupid decisions that I made when originally creating BB4W. It's one reason why it would have been far better if BBC BASIC for Windows had never existed.
But I did make those mistakes and it's something I have to live with every day (or perhaps not live with, and that's an option I consider every day too). All I can do now is to attempt to put things right as far as possible by no longer using the misleading B3D extension, but you seem to think that is yet another mistake. Argggh!!!!
Richard.
|
|
|
|
michael
Full Member
member is offline


Posts: 157
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #7 on: Sep 16th, 2017, 1:57pm » |
|
Quote:| but you seem to think that is yet another mistake |
|
Its not a mistake. (you shouldn't have had to change the extension) It was a coincidence. Everything is ok.
I wish I could be at your skill level. And BBC4W is a fine product.
|
| « Last Edit: Sep 16th, 2017, 2:22pm by michael » |
Logged
|
I like reinventing the wheel, but for now I will work on tools for D3D
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #8 on: Sep 16th, 2017, 4:29pm » |
|
on Sep 16th, 2017, 1:57pm, michael wrote: I can't claim that excuse. Before adopting the B3D extension I should have looked it up on a site like filext.com (quite different then from what it is now) when I would have discovered its existing use(s).
Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Wavefront OBJ to FVF converter
« Reply #9 on: Sep 17th, 2017, 09:06am » |
|
Has anybody else tried the Nottingham University 3D Face Reconstruction tool? It's very easy to use:
Find a full-face straight-on selfie (preferably without glasses), with good contrast between your face and the background, and upload it here.
When it has finished processing, download the generated .OBJ file and convert it to a .FVF using the code I listed previously in this thread.
Plug the FVF file into the program below if you want to use the same animation as I did for Donald Trump, or adapt it to your preference.
Upload a video capture to YouTube (etc.), so we can see the result, if you dare! Richard.
Code: REM. Turning Face by Richard Russell, 16-Sep-2017 HIMEM = PAGE + 5000000 IF INKEY$(-256)="W" INSTALL @lib$+"D3DLIBA" ELSE INSTALL @lib$+"ogllib" ON CLOSE PROCcleanup : QUIT ON ERROR PROCcleanup : IF ERR=17 CHAIN @lib$+"../examples/tools/touchide" ELSE MODE 3 : PRINT REPORT$ : END ON MOVE IF @msg% <> 5 RETURN ELSE PROCcleanup : CLEAR VDU 20,26,12 DIM pVB%(0), nv%(0), vf%(0), vl%(0), l%(0), m%(0), t%(0), y(0), p(0), r(0) DIM X(0), Y(0), Z(0), eye(2), at(2) REM. Initialise OpenGL: IF INKEY$(-256)="W" pDev% = FN_initd3d(@hwnd%, 1, 0) ELSE pDev% = FN_initgl(@hwnd%, 1, 0) IF pDev% = 0 ERROR 100, "Couldn't initialise 3D subsystem" REM. Load 3D object: pVB%(0) = FN_load3d(pDev%, @dir$ + "trump.fvf", nv%(0), vf%(0), vl%(0)) IF pVB%(0) = 0 ERROR 101, "Couldn't load FVF file" REM. Render the turning face: at() = 100, 100, 40 REPEAT turn = SIN(TIME/100) eye() = at(0)+400*SIN(turn), 0, at(2)+400*COS(turn) PROC_render(pDev%, &7F7F90, 0, l%(), 1, m%(), t%(), pVB%(), nv%(), vf%(), vl%(), \ \ y(), p(), r(), X(), Y(), Z(), eye(), at(), PI/6, @vdu%!208/@vdu%!212, 1, 1000, PI) UNTIL INKEY(1)=0 END DEF PROCcleanup pVB%(0) += 0 : IF pVB%(0) PROC_release(pVB%(0)) *REFRESH ON ENDPROC
|
|
|
|
|