Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
colleagues:
I'm attempting to have the vm download a predetermined .pak file, in this case,
http://ifam.net/openspace/hybridui3/mainwindow/mainwindow.pak mainwindow/mainwindow.pak
here is the code that calls filedownload. The vm is able to resolve all the variables in these lines without indicating an error:
let "http://ifam.net/openspace/hybridui3/mainwindow/mainwindow.pak mainwindow/mainwindow.pak" -> urlstring in
downloadFile urlstring mkfun3 @loadpakfile [viewstr loadwidget];
here is the downloadfile callback:
fun loadpakfile (url,data, p)=
let p -> [viewstr loadwidget] in
(
_cacheActivate;
set loadedProject.PRJ_xmlFile = XMLloadString mkUnpakProject data;
setProjectCbSceneLoaded loadedProject mkfun2 @cbProjectLoaded p;
loadProject loadedProject viewstr nil nil nil nil 1;
);
0;;
the player opens up and then hangs.
The log terminates here
File "C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\mediaoctopus3dplayer\mainsplash.png" isn't a BMP file : 20617 is found as file type.
_load_bitmap failed
jpeg : error
Not a JPEG file: starts with 0x89 0x50bad type 78 80 0
C:\Program Files (x86)\Scol Voyager/Partition_LockedApp/ - tools/os3dlib/res/def/azerty.def - C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\os3dlib\res\def\azerty.def
C:\Program Files (x86)\Scol Voyager/Partition_LockedApp/ - tools/os3dlib/res/def/qwerty.def - C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\os3dlib\res\def\qwerty.def
_CHANGEobjNodeCoordinates: ObjNode is nil !
_CHANGEobjNodeCoordinates: ObjNode is nil !
ObjCURL destroyed.
Cache Activation
pp : -67
debut GC : 83ffaa/840000
---NbBitmaps = 6
GC end : 53ba2
pp : -67
debut GC : 83ffaa/840000
---NbBitmaps = 6
GC end : 53ba2
goes on repeating itself, I suspect there is a problem with how I am handling the objurl object, with which I am unfamiliar. I thought that once the .pak file is downloaded, I can just go ahead and call
_cacheActivate;
set loadedProject.PRJ_xmlFile = XMLloadString mkUnpakProject data;
setProjectCbSceneLoaded loadedProject mkfun2 @cbProjectLoaded p;
loadProject loadedProject viewstr nil nil nil nil 1;
without having to save the unpacked .pak file, since I assumed that is handled by the loadProject function.
In any case, I welcome any guidance, I'm a bit lost in this new territory of file downloading and network communications (ui and 3d terms I comprehend, but I don't know too much so far about network communications)
thx for your help
-h
Offline
Hi,
I don't know precisely the os3d APIs but there is an error at least in your code.
let "http://ifam.net/openspace/hybridui3/mainwindow/mainwindow.pak mainwindow/mainwindow.pak" -> urlstring in downloadFile urlstring mkfun3 @loadpakfile [viewstr loadwidget];
Your url is incorrect.
I assume that the last term is the destination file (the file where the content will be saved), it is not a part of the url (the address where the resource is on the server).
"http://ifam.net/openspace/hybridui3/mai … window.pak" could be the correct url
"mainwindow/mainwindow.pak" could be the destination file on the hard disk.
So, the good statment should be :
let "mainwindow/mainwindow.pak" -> destinationFile in
let "http://ifam.net/openspace/hybridui3/mainwindow/mainwindow.pak" -> urlstring in
downloadFile urlstring mkfun3 @loadpakfile [viewstr loadwidget];
You should probably add destinationFile somewhere.
goes on repeating itself, I suspect there is a problem with how I am handling the objurl object, with which I am unfamiliar. I thought that once the .pak file is downloaded, I can just go ahead and call
Yes, it is correct. But your url was incorrect and thus your download is corrupted.
Offline
thx Iri...so when I declare a particular file, it includes the file name and the folder above it?
I think I'm a little closer:
let "mainwindow/mainwindow.pak" -> destinationfile in
let "http://ifam.net/openspace/hybridui3/mainwindow/mainwindow.pak mainwindow/mainwindow.pak" -> urlstring in
(
downloadFile destinationfile mkfun3 @loadpakfile [viewstr loadwidget destinationfile];
);
and here is the changed callback:
fun loadpakfile (url,data, p)=
let p -> [viewstr loadwidget destinationfile] in
(
_cacheActivate;
///do somethign with destinationfile here, I don't quite know, or perhaps I do something after unpaking the .pak file
set loadedProject.PRJ_xmlFile = XMLloadString mkUnpakProject destinationfile;
setProjectCbSceneLoaded loadedProject mkfun2 @cbProjectLoaded [viewstr loadwidget];
loadProject loadedProject viewstr nil nil nil nil 1;
);
0;;
it looks like the vm is doing something useful, although no scene is displaying.
excerpt from log, it shows that vm doesn't hang and is unzipping the .pak file, so thx Iri for that
Cache Activation
C:\Users\Daniel Green\AppData\Local/Scol Voyager/Cache/Scol_25c807c67f3/ - mainwindow/mainwindow.pak - C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cache\Scol_25c807c67f3\mainwindow\mainwindow.pak
Opening the file C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cache\Scol_25c807c67f3\mainwindow\mainwindow.pak : 1984
unzip 1701/1720
C:\Program Files (x86)\Scol Voyager/Partition_LockedApp/ - tools/os3dplugins/misc/mainwindow/cmainwindow.pkg - C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\os3dplugins\misc\mainwindow\cmainwindow.pkg
unzip 6341/2295
pp : -149
debut GC : 3ba1a4/840000
---NbBitmaps = 6
GC end : 53cb1
C:\Program Files (x86)\Scol Voyager/Partition_LockedApp/ - tools/os3dplugins/misc/mainwindow/mainwindow.xml - C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\os3dplugins\misc\mainwindow\mainwindow.xml
pp : -149
debut GC : 53d7f/840000
---NbBitmaps = 6
GC end : 53a5f
unzip 6066/1697
_CHANGEobjNodeCoordinates: ObjNode is nil !
_CHANGEobjNodeCoordinates: ObjNode is nil !
Destroyed Scol Machine
EndScolMachine 0
Destroy window name : (SCOL)0.v3dwin_buffer_1
delete servers
SCKend-
flagactiveX=0
################################################################
[INFOS] Unloading plugins/XTension.dll plugin.
[INFOS] plugins/XTension.dll plugin was correctly unloaded.
################################################################
################################################################
[INFOS] Unloading plugins/MMedia24.dll plugin.
[INFOS] plugins/MMedia24.dll plugin was correctly unloaded.
################################################################
I 'll wait for arkeon's input on this. I'd like to teach myself more of the api, but the online documentation isn't very explanatory (I'm not complaining, you guys are so helpful. And I'm writing a tutorial about custom callbacks that hopefully will help others...I will submit it to you and arkeon.)
Offline
this still not good
fun loadpakfile (url, data, p)=
let p -> [viewstr loadwidget destpath] in
(
//save the data in the file
_storepack data destpath;
//unpak / read pak file
set loadedProject.PRJ_xmlFile = XMLloadString mkUnpakProject destpath;
setProjectCbSceneLoaded loadedProject mkfun2 @cbProjectLoaded [viewstr loadwidget];
loadProject loadedProject viewstr nil nil nil nil 1;
);
0;;
fun downloadPak(viewstr, loadwidget)=
//can enable cache first
_cacheActivate;
let "mainwindow/mainwindow.pak" -> destpath in
let "http://ifam.net/openspace/hybridui3/mainwindow/mainwindow.pak" -> urlsrc in
(
downloadFile urlsrc mkfun3 @loadpakfile [viewstr loadwidget destpath ];
);
0;;
Offline
Thx arkeon I'll try that this evening
Offline
The cache is enable here to do not unpak / overwrite into the default user partition.
So the files are unpaked in the cache partition.
Offline
thx arkeon, I think I''m closer but the project is not loading.
before I get to what I encountered.....where exactly is the cache partition....in Usm.ini, the code says cache ./Cache 256, but i don't see such a folder in my Openspace or Partition_LockedApp folders
back to my code, ...I put a flag in the pakloaded function:
fun loadpakfile (url,data, p)=
let p -> [viewstr loadwidget destpath] in
(
//save the data in the file
_storepack data destpath;
_fooS "pak file downloaded";
_DLGMessageBox _channel mainWindow.EDW_win "pak file downloaded" "pak file downloaded" 0;
//unpak / read pak file
set loadedProject.PRJ_xmlFile = XMLloadString mkUnpakProject destpath;
_fooS strcatn "pak file downloaded and unpacked from: ":: destpath :: " "::nil;
setProjectCbSceneLoaded loadedProject mkfun2 @cbProjectLoaded [viewstr loadwidget];
loadProject loadedProject viewstr nil nil nil nil 1;
);
0;;
and the console is displaying
"pak file downloaded and unpacked from: mainwindow/mainwindow.pak", so the .pak file is downloading successfully
however the cbProjectLoaded function is not being called (I assume the scene is not loading).
I put flags in cbProjectLoaded and the cbPlugLoaded functions, but neither are executing...the vm isn't getting further than downloading and unpacking the .pak file.
fun cbPlugLoaded(trm, p)=
let p -> [viewstr loadwidget] in
if bPluginsLoaded then
(
_fooS "plugins have all loaded";
_deltimer trm;
//SO3WidgetDestroy loadwidget;
V3DsetCbResizeView viewstr @cbPlugView3dResize;
0;
)
else nil;
0;;
fun cbProjectLoaded(project, p)=
_DLGMessageBox _channel mainWindow.EDW_win "project loaded callback executed" "project loaded callback executed" 0;
_fooS "projected has been loaded, triggering plugloaded callback";
_rfltimer _starttimer _channel 100 @cbPlugLoaded p;
0;;
Offline
heres the relevant (I think, at least) part of the log:
Cache Activation
_CHANGEobjNodeCoordinates: ObjNode is nil !
_CHANGEobjNodeCoordinates: ObjNode is nil !
ObjCURL destroyed.
pak file downloaded
C:\Users\Daniel Green\AppData\Local/Scol Voyager/Cache/Scol_25c807c67f3/ - mainwindow/mainwindow.pak - C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cache\Scol_25c807c67f3\mainwindow\mainwindow.pak
Opening the file C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cache\Scol_25c807c67f3\mainwindow\mainwindow.pak : 2012
unzip 1264/1283
C:\Users\Daniel Green\AppData\Local/Scol Voyager/Cache/Scol_25c807c67f3/ - tools/os3dplugins/misc/chatwindow/cchatwindow.pkg - C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cache\Scol_25c807c67f3\tools\os3dplugins\misc\chatwindow\cchatwindow.pkg
pp : -59
debut GC : 3ba50f/840000
---NbBitmaps = 6
GC end : 53d78
C:\Users\Daniel Green\AppData\Local/Scol Voyager/Cache/Scol_25c807c67f3/ - tools/os3dplugins/misc/chatwindow/chatwindow.xml - C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cache\Scol_25c807c67f3\tools\os3dplugins\misc\chatwindow\chatwindow.xml
pp : -59
debut GC : 53e33/840000
---NbBitmaps = 6
GC end : 53c4f
unzip 4623/1260
pak file downloaded and unpacked from: mainwindow/mainwindow.pak
Offline
Hi, the cache is here as you can see in the log
C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cache
did you call that earlier in the code ? : set loadedProject = crProject sCurrentScenePath nil 1;
Offline
Hi, the cache is here as you can see in the log
C:\Users\Daniel Green\AppData\Local\Scol Voyager\Cachedid you call that earlier in the code ? : set loadedProject = crProject sCurrentScenePath nil 1;
Thx I'll try that in around an hour and report back.
Offline
Thx arkeon it works!!!!!!! Now to build a download bar for the .pak file and a common interface for loading files from the openspace3d partition and web based .pak file.
Last edited by hebdemnobad (27-Oct-2014 13:59:41)
Offline
Thx arkeon it works!!!!!!!
In Scol, a new type object can be created on the fly. It will be added to the basic types like I, S, Chn, Srv, ObjWin, etc and available in the channel where it is created.
To define it, a way is to define a structure (keyword struct).
Some fields are defined in a structure, these fields are seen like functions by the VM.
Once done, you can use this new type.
Always, the first thing to do is to initialize each variable (locale and globale) which uses this new type. Otherwise, the variable will be always nil, even if you try to set it later.
OS3D define itself a lot of specific types like the type named "Project". Project is a structure (os3dlib / os3dstruct.pkg). To avoid to initialize it manually each time, Arkeon has written a function "crProject".
You must call it at first for each new Project variable.
If you are interested by that, you can read the wiki : http://redmine.scolring.org/projects/tu … es_in_Scol
Now to build a download bar for the .pak file and a common interface for loading files from the openspace3d partition and web based .pak file.
I've also written this in the wiki, this may be inspirational.
http://redmine.scolring.org/projects/scol/wiki/Gauge
You could see in the tutorials repository :
http://redmine.scolring.org/projects/sc … /tutorials
Offline
thank you Iri
the lesson I take from this thread is always look at each and every function being called.
I know how to make structs now, but I'm not the best at understanding them when I encounter a call to a function in another file. I've looked at the crProject function and now understand, it's a short way of creating a Project struct without assigning values to all of the fields manually.
Thanks for the link to the slider bar tutorial and the repository of tutorials. It never hurts to be reminded (again.) For a loading bar, I prefer just a rectangle.
I will post my question about creating a download bar for a .pak file in a separate thread.
Offline
and this is the working code, with some notes as a help for beginning coders and as a reminder to myself (always check to see that ALL structs are initialized, or instanced)
hard coded download of an arbitrary .pak file.....first make the vm begin to download it
//code..
let "mainwindow/mainwindow.pak" -> destpath in
let "http://ifam.net/openspace/spacemanshooter1/dan_no_mohawk/spacemanwithtank.pak" -> urlsrc in
(
_cacheActivate;
downloadFile urlsrc mkfun3 @loadpakfile [viewstr loadwidget destpath ];
);
//code..
when the file is downloaded, loadpakfile is called. since it only passes the downloadFile url and data to the callback 2 parameters), and I need to pass the view structure, loading widget, and destination path to it, I use mkfun3 and so I can add a third parameter, the tuple [viewstr loadwidget destpath ].
here is the loadpakfile function. p is the third parameter, which I used mkfun3, so I break p into its parts, [viewstr loadwidget destpath ], so each object in the tuple can be used anywhere in the function.
fun loadpakfile (url,data, p)=
let p -> [viewstr loadwidget destpath] in
(
//set scene_is_loaded global variable to opening a new file will reinitialize scene
set scene_is_loaded = 1;
//save the data in the file
_storepack data destpath;
_fooS "pak file downloaded";
//unpak / read pak file
set sCurrentScenePath = destpath;
set loadedProject = crProject destpath nil 1;
set loadedProject.PRJ_xmlFile = XMLloadString mkUnpakProject destpath;
_fooS strcatn "pak file downloaded and unpacked from: ":: destpath :: " "::nil;
setProjectCbSceneLoaded loadedProject mkfun2 @cbProjectLoaded [viewstr loadwidget];
loadProject loadedProject viewstr nil nil nil nil 1;
);
0;;
I didn't change cbProjectLoaded or any subsequent callbacks.
Offline
About mkfunX, here is a small console application written by Bob Le Gob :
Offline