ObjReader Community
WIP => WIP => Topic started by: Patrice Terrier on October 09, 2019, 07:46:04 pm
-
Here is the ZIP file to sync your code with mine.
#playaudio Back_to_Amiga_roots_(1992).mod 50 loop
Audio extension supported: ".mp3.wav.ogg.aif.mo3.it.xm.s3m.mtm.mod.umx."
To ease sync, search the code for:
// 10-09-2019 Bass.dll
-
Thank you Patrice,
I will study your code tomorrow and will come back with my impressions.
-
Patrice,
Your mobj.h contains traces of a "concentric rotation flag", which is evidently implemented as rotate[8]. I don't remember very well what it is (probably it was some latest request of yours that I didn't reimplement in my code). Can you send me your renderers.h, globals.h and any other files that might utilize this feature?
-
Here they are.
See Test.zip for an example of use.
-
I've got your mods to recompile correctly in my project.
Now I'm waiting for a test model to try out the new playaudio feature. :)
-
Try the attached audio with this one:
http://www.objreader.com/index.php?topic=22.msg2428#msg2428
-
Here is a small collection of free audio samples.
You can drop them all on MBox64, to select those that fit your taste ;)
-
I added the audio #meta to the material file as follows:
#wallpaper @background.jpg
#playaudio trongrid.ogg 50 loop
........
and then I put TronGrid.ogg in the Tron model folder, and bass.dll, in the \x64\Release\ folder alongside ObjReader64.exe.
My ObjReader crashes when trying to load the Tron model.
What am I doing wrong?
P.S. And why there is a renderers.zip in the TronGrid archive?
-
Also, I have a call to gl_LoadBackgrounds() in my void backToStaticBkgnd() in shaders.h. What bReset flag are you using there?
-
The renderer.zip include with the audio was a mistake.
It looks like there is a problem with stream, i shall have to investigate.
(works well with music)
-
Please take your time. It all can wait till tomorrow. :)
-
case MENU_ANI_BKGND: // MLL 06-01-2019: ani backgrounds
gP.bAniBkgnd = !gP.bAniBkgnd;
if (gP.bAniBkgnd) {
dwStyle = MF_CHECKED;
resetCurAniShader();
parseAniShader(L"voronoi.fs"); // default
if (!gl_LoadAniBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX))) {
CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_UNCHECKED);
EnableMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_GRAYED);
break;
}
gP.tCurAniBkgndShader.nShaderID = glsl_LoadShaderFromFile("voronoi.fs");
rAniStart = GetTickCount64() / 1000.0f;
StartSync();
} else {
dwStyle = MF_UNCHECKED;
gl_LoadBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX), TRUE); // PAT 09-09-2019 use TRUE to restore the current wallpaper rather than "back02.jpg"
resetCurAniShader();
//if (!(gP.bGiration | gP.bUseFPS | gP.bAnimateLights | gP.bRotation | gP.bIsLerping))
// StopSync(SYNC_OFF);
}
CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, dwStyle);
gP.bRedraw = TRUE; // Redraw the OpenGL scene
break;
-
No, I need the call to gl_LoadBackgrounds() in the void backToStaticBkgnd() function in shaders.h!
Do you have such a function at all?
-
Indeed #playaudio trongrid.ogg 50 loop
causes an error in Mobj.h there
case 't': // Tr
switch (szBuffer[1]) {
case 'r': // Tr
if (pMaterial->alpha == 1.0f) { // 12-06-2015 ML: only if alpha is still default
fscanf(pFile, "%f", &pMaterial->alpha);
if (pMaterial->alpha > 0.0f) {
pMaterial->alpha = 1.0f - pMaterial->alpha; // 12-06-2015 ML: follow OBJ specs
}
if (pMaterial->alpha == 0.0f) { pMaterial->alpha = 1.0f; } // 02-05-2016
} else {
fgets(szBuffer, sizeof(szBuffer), pFile); // 12-06-2015 ML: ignore
}
break;
Because of the use of "Tr" go figure !!!
No, I need the call to gl_LoadBackgrounds() in the void backToStaticBkgnd() function in shaders.h!
void backToStaticBkgnd() { // MLL 06-10-2019:
BKSHADER* cs = &gP.tCurAniBkgndShader;
gP.bAniBkgnd = FALSE;
CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_UNCHECKED);
if (cs->nShaderID) {
for (int idx = 0; idx <= 3; idx++) {
if (cs->samplerMapID[idx]) {
glActiveTexture(GL_TEXTURE0 + idx);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
}
}
resetCurAniShader();
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHT0);
}
gl_LoadBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX), FALSE);
gP.bRedraw = TRUE;
gl_DrawScene();
}
-
Thank you Patrice!
Renaming the OGG file to Grid.ogg...
-
Now it works fine! But the audio and background aren't killed and reset, respectively, on clicking the File->Close all and clear scene menu... ???
-
Renaming the OGG file to Grid.ogg...
Yes, but we must protect us against it anyway
-
File->Close all and clear scene menu
I never used it until now, easy to fix
add a BassCloseChannel()
-
Re. protection: who does the appropriate protection, you or me? ;)
Re. fix: should be somewhere at the beginning of the function, I presume?
But the overall effect is very, very good! Thanks a lot for this enhancement! :)
-
There is another problem
Try to use "Reload model" after that a "Close and clear scene" has been performed.
-
This isn't a problem but a feature. ;)
Clearing everything also clears the memory about the last model loaded.
Reloading the model is primarily meant for actualizing the most recent changes to its materials, maps, and geo.
-
I did this to protect the code in mobj.h starting form line 1079
but i am unsure that it is the best way to do it.
// Load the materials in the MTL file.
while (fscanf(pFile, "%s", szBuffer) != EOF) {
CharLowerA(szBuffer);
if (strcmp(szBuffer, "#playaudio") == 0) { // 10-10-2019 Bass.dll (we must ignore this meta there)
s1[0] = 0; s2[0] = 0; s3[0] = 0;
fgets(szBuffer, sizeof(szBuffer), pFile);
sscanf(szBuffer, "%s %s %s", s1, s2, s3);
}
switch (szBuffer[0]) {
case 'n': // Ns
-
Alternatively,
........
case 't': // Tr
switch (szBuffer[1]) {
case 'r': // Tr
if (szBuffer[2] == 32 || szBuffer[2] == 9) { // MLL 10-10-2019: Tr should always be followed by a space or tab
if (pMaterial->alpha == 1.0f) { // 12-06-2015 ML: only if alpha is still default
fscanf(pFile, "%f", &pMaterial->alpha);
if (pMaterial->alpha > 0.0f) {
pMaterial->alpha = 1.0f - pMaterial->alpha; // 12-06-2015 ML: follow OBJ specs
}
if (pMaterial->alpha == 0.0f) { pMaterial->alpha = 1.0f; } // 02-05-2016
} else {
fgets(szBuffer, sizeof(szBuffer), pFile); // 12-06-2015 ML: ignore
}
}
break;
........
This way the style of existing code is preserved.
8)
P.S. And I also think that every two-letter case for the other parameters should be supplied with such a sanity check... ::)
-
My friend
Indeed i think that we must protect for all the cases, this i the reason why i made the test before the switch.
To follow what you suggested here:
Re. fix: should be somewhere at the beginning of the function, I presume?
and avoiding code duplication for each two letter-case of the other parameters.
I have attached the Version_2_80.zip sync, just to make sure that we are both using the same latest changes.
Shall we release this version as the new official one, to be able to add audio in the new material files?
-
Patrice,
Thank you for the code!
1. Don't you think that checking only a few scarce enough two-letter abbreviations (Tr, Ns, Ka, Kd, etc.) for just one space byte after them will be much faster than checking every line in the .MTL file for a multibyte #playaudio char sequence, and thus worthy of code duplication?
2. I have added much code to my selectable MSAA/CSAA/FXAA option but it isn't either complete or fully tested yet, nor does it go well with the PP options ATM that are also far too few for a sterling release.
So if all that code is still not used then yes, we can publish another intermediary release that won't be a major one until both AA and PP options are fully complete... ???
-
1. Don't you think that checking only a few scarce enough two-letter abbreviations (Tr, Ns, Ka, Kd, etc.) for just one space byte after them will be much faster than checking every line in the .MTL file for a multibyte #playaudio char sequence, and thus worthy of code duplication?
Then please could you make the change for me, because i am currently working on a WinDev demo project that i would like to complete first.
-
OK I'll do that tomorrow if you don't mind.
-
Patrice,
If you want to release your code as v2.80, please send me the entire set of your files for sync'ing, not just these few. There may be more differences in our code elsewhere. It's been a long time indeed since we merged last.
TIA
-
Here they are, within distinct ZIP files inside of SYNC.zip
-
I plan to release animated backgrounds altogether with audio, in version #2.80, to have only one version to manage, do you have any fixup to apply befeore i publish the new official version?