Scolring - Forum

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.

#1 Openspace3D » How to customize a plugit to your needs easily » 18-Sep-2019 20:55:54

ARappy
Replies: 1

Here is an example with "dialoglist" plugit:

In my project i'm often using the plugit "dialoglist" in "Interface" folder. So to simplify the use of this plugit, I choose to create only one instance of it, and manage it dynamically by just changing the items list it contains at runtime, using its Action "Add element to list".

After adding some items to the dialog by calling its Action "Add element to list" and the user answered to this dialog, you can remove those items by calling the reverse Action "Remove element from list", if you want to use it again with different items, instead of creating a new one (when using it dynamically).

But this is not very convenient because you need to delete all items one by one, and suppose you saved their names in some var.

So i decided to modify this plugit to do it more simply.

By chance (and especially OS3D developpers great skills), OS3D plugit code is in plain text and its structure is very well designed, so it is easily understandable and customizable.

In this case, you can simply add a new action i called "Reset" to this plugit, to empty the item's list completely in one call. This is done simply by adding a few lines in the plugit code:

dialoglist.xml:

   <ACTION name="Reset"/>


cdialoglist.pkg:

    PluginRegisterAction inst "Reset" mkfun6 @cbReset obstr; 
    
    fun cbReset(inst, from, action, param, reply, obstr)=
        set obstr.PDLGL_lList = nil;
    0;;

This take effect after closing dialog and reopen it again, when need to interract again with user.


Of course, this can be a problem to customized the original plugit for just one specific need in a particular project, and although the need to keep compatibility with OS3D next release.

But there is a very simple way to do a copy of the orginal plugit and make a customized one, that will then be completely independant from the original one.


Here is one Method to do it, if it can help some new OS3D users:

For this you just have to change one line in the xml definition file of the plugit called "plugit_name.xml" (for dialoglist it is dialoglist.xml).


1) In windows explorer, make a copy of the plugit folder in a new folder category (in my case i call this type folder "user"). This will create a new category in the plugit list where you can keep all your customized plugit, without interfering with the original ones.


2) Inside this new folder open the file "plugit_name.xml". In this example, it is "dialoglist.xml":

   Then Search the string:

    <PLUGIN name="Dialog List" version="1.0" type="interface">

This line indicate to OS3D the name of the plugit and the type of plugit folder in which it should go (here "Interface")


3) Then You just have to change only this two parameters:

   1) The name of the plugit, because OS3D can't have two plugit with the same name.
 
   2) The type of the plugit.

      In this example:
   
        <PLUGIN name="Dialog List" version="1.0" type="interface">

          becomes:
   
        <PLUGIN name="Dialog Liste" version="1.0" type="user">
       
        (i choose the new name "Dialog Liste" because i'm french, but you can choose anything else)
       
   There is nothing else to change in the code, just this line.
   
    If OS3D is already running, just press F5 on the scene to reload all plugits and see your customized plugit appears in the new category folder "user" you have created (the original one will still be in "Interface"). Here's an example with some others plugit i have already customized:

user
   
When this is done, you can now add in the code of your customized plugit any action or event you need (if they were not present in the original one) without breaking anything to the original plugits.

#2 Openspace3D » Maybe a little bug in the interface plugit "dialog list" » 18-Sep-2019 20:41:09

ARappy
Replies: 1

Hi,

There is maybe a little bug in the interface plugit "dialog list" (but maybe it comes from my configuration or misuse from my part).

Description:

You can fill the item dialog list "statically" by adding items directly in its window parameters before to play the scene:

parameters

It works fine and the result is this:

dialog list

But you can also fill the items list dynamically on run by calling its action "Add element to list" (in this example i just use a button to call this action) :

dynamic link

I do it 3 times to add the same 3 elements than above. But then the size of the list item is not update and three little dots appears to indicate that not all items are displayed because dialog height is too small to show them all :

dynamic result

Origin of Problem:

In the plugit code (cdialoglist.pkg), the problem seems to come from the mecanism that should update the variables containing the item's list, but that don't work. In particular the number of items in the list is not update :

   obstr.PDLGL_iNbElem
   
   This var is used to compute the height of the dialog list, when it is created on show:
   
   Ln285:
   let 30 + (obstr.PDLGL_iNbElem * 36 + (obstr.PDLGL_iNbElem - 1) * oh) -> height in

But when you use action "Add element to list", this var is not update to the new number of items, so neither the height of the dialog that should grow accordingly.


The code of the action "Add element to list" is in :

    fun cbAddElement(...):

which call differents functions of v3dui.pkg like:

    VUIaddListElement & VUIunfoldListElement
   
   
Line 5543: fun VUIaddListElement(...)=

does different things to add the new item to list, then ask for an update of the dialoglist:

    VUIelementNeedUpdate parentstr.VUILE_element 1;


I haven't yet the time to follow the rest of the code, but apparently the update mecanism of the dialog list is not done somehere and the dialoglist height stays as there was only one item in the list.

Maybe it is wanted as this, but i don't find a way to adjust the height of the dialog after it is created. Of course the height of the dialog box can't grow infinitely, but I think it should at least be able to grow to show 3 or 4 elements, as it is possible when doing it with first method.

Thank's for reading.

#3 Re: Openspace3D » Screen resolution problem on Android export : everything becomes tiny » 18-Sep-2019 20:22:53

Woow ! Thank you very much ! It will be of great help for android user. I will try it as soon as the next update is released.

#4 Re: Openspace3D » Screen resolution problem on Android export : everything becomes tiny » 16-Sep-2019 19:44:55

Thank you for the tip.

I'm not sure this is a mistake, as you had certainly test this part of the code with different devices before to include it in 1.81 last release.

Maybe for not very powerful device (like those tablets), launch is longer (in my case the app takes about 1min to start) and some UI components are not yet initialized when calling to get their size as you said, so return nil. I have already encountered such kind of problem on Visual Studio framework for other projects.

Another solution could be to let user choose to set "androidscale" var by code automatically, as it is done for the moment, or to override its value with a new option in the project settings or in android export windows, if some problem appears. For example like this (at bottom):

display settings

Furthermore, it would allow a more fine UI size choice, because in the actual code "androidscale" can only take 3 values:

screen size > 1920 :  androidscale = 2.0
screen size > 1280 :  androidscale = 1.5
sreen size <= 1280 :  androidscale = 1.0

So if your app targets specific android devices (for a school or a company for example) the UI dialog could be a little bit smaller or bigger than wished, as i have on my mobile with about 500dpi.

#5 Re: Openspace3D » Screen resolution problem on Android export : everything becomes tiny » 15-Sep-2019 00:36:42

Hi arkeon,

I have investigate further and find where the problem comes from.

1) _getDeviceScreenDensity:

First i try to check if the tablet returns correctly the screen dpi value. If i'm not mistaking,
this test is done in OS3D by calling _getDeviceScreenDensity(), you can find for example in ScolExternal.java at Line 86 here:
 
     OS3D\androidDeployerTools\scolbase\java\org\imaginer\scol\

  public float getDeviceScreenDensity()
  {
    return mActivity.getApplicationContext().getResources().getDisplayMetrics().density;
  }

As you said it calls Android's API getDisplayMetrics().density that return (display dpi)/160 (resolution independant dpi value).

As this function can be called directly inside a link parameter code:

      let _getDeviceScreenDensity -> dpi in
      ftoa dpi

i could check that the value is correct for my personal mobile and Lenovo Tablets.

For example, resolution of tablet is 1280x800 and the dpi is given by Lenovo to be 213dpi.
The value returned by _getDeviceScreenDensity is 1.331250, that corresponds well to 213/160.

So there is no problem from this side.


2) fVUIPIXELDENSITY:

_getDeviceScreenDensity is called at startup by fun VUIinit(sessionstr) in v3dui.pkg
located in OS3D\partition_LockedApp\tools\os3dlib. This file defines all the 2D UI in OS3D as far as I have understood it.

So I check if _getDeviceScreenDensity value was correctly returned in this part of code, and the answer is yes.

Then check other parameters that appears in v3dui.pkg since Ln7141, especially the final fVUIPIXELDENSITY that is used for all 2D UI to set their size according to display dpi.

   let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport -> [_ _ vw vh] in
   let max vw vh -> scsize in
   let if scsize > 1920 then 2.0 else if scsize > 1280 then 1.5 else 1.0 -> androidscale in 
    set fVUIPIXELDENSITY = if (_platform == SCOL_PLATFORM_ANDROID) then 1.0 /. (_getDeviceScreenDensity /. androidscale) else if (_platform == SCOL_PLATFORM_IOS) then 4.0 else 1.0;

When I calulate manualy fVUIPIXELDENSITY for those tablets i should got:

androidscale = 1.0 (because width = 1280)
so fVUIPIXELDENSITY = 1.0 / (1.331250 / 1.0) = 0.75117

but when I check fVUIPIXELDENSITY on runtime I got about 1.50, so twice the expected value.

Furthermore, when I force fVUIPIXELDENSITY to the expected value at 0.75117, then UI dialogbox size become normal (not tiny).

Apparently the problem comes from var "androidscale" that is set to 2.0 for any of the devices i have tested, although it should be at 1.0 for the tablet because its biggest resolution is 1280.

Not completely sure for now on, but it seems this appends because scsize is returned empty because vw vh are also empty after calling:

     let SO3ViewportGetPixelPositionSize viewportstr.V3D_viewport
     
I then try to set manually androidscale to 1.0 simply with:     set androidscale = 1.0;

and then the size of 2D UI dialogbox became normal (not anymore tiny). As i had also changed previously all font size to huge value to compensate this problem of dpi, i rechange them to normal font size 20, and voila, everything display fine now with normal size.


Of course, I usualy never make change directly in the framework code because it will break at next update, but as i need to use this app this week with my pupils, I will use this trick for the moment, waiting to find a better solution.


Could you know a reason why for some android devices the viewport size returned by SO3ViewportGetPixelPositionSize  could not return a value ?


The only thing that is missing me now is (french) accentued characters on Android. Especially for a school educational project, because they allow better word recognition for pupils with some reading difficulties. I would be particulary thankful if someday you could find a solution for that problem as you told us in a previous thread.


Anyway, Thank you very much for all this nice framework.

#6 Openspace3D » String manipulation Plugit example » 12-Sep-2019 21:03:47

ARappy
Replies: 1

Hi OS3D community,

To my little beginner knowledge, there is no plugit to do usual string manipulation (sorry if i didn't see it and it already exists somewhere), so made one simple example and propose it here, if it could be of any help for someone.

It is just an example, as I made it only with the functions specially needed for my os3D project, but it is not very difficult to modify it, if you want to add some other string functions you need, as there is many more of them in scol. You can find the list here, (mainly in the str... section):

https://svn.scolring.org/trunk/scol/doc … brary.html

This code has certainly to be improved and written more efficiently, as this is my first step in scol langage, but it works.


HOW TO USE:

Jut create a folder "string" in the "misc" plugits folder and create 3 text files to copy the following code in the respective files named:
string.xml, estring.pkg, cstring.pkg and inside this folder "string", create a folder "lang" to put local files: string.french.lang & string.english.lang



The string that you want to manipulate is send to the plugit in the link parameter (for example with a global var: %var%) or send by the previous plugit as usual.


Parameters (inside plugit pannel):


1) Number of occurence: when trying to find a substring in a string, allow to choose which occurence of the substring you want, if there is more than one.
                        If let to 0, when using Action "GetReplace" (see below), all occurences are replaced.

            example:   "i want to go to the zoo" --> with occurence=2 will select the 2nd "to" (the zoo).
         

2) from char: apply string manipulation not from begining, but from the char n (first char is 1).

3) to char: same for the end.

4) Searched string: a substring you want to find in the original string

5) Replacement string: if calling action getReplaced, the searched string (see above) is replaced by this string


ACTION/EVENT:


1) Action: GetPos -> Event: Position    return the position (start at 1) of the first char of the "Searched string" found in orginal string


2) Action: GetSubStr   has 2 usage mode

                       a) if occurence = 0: just return the substring between "from char" to "to char"
                          (like usual Substring, SubStr, MID function etc.)
                       
                       b) if occurence = n:  search occurence n of "Searched string" in the original string and return two events
                       
                          -> Event: PreString   return the part of the string situated before the "Searched string" [all the string if "Searched string" not found]
                          -> Event: SubString   return the part of the string situated after the "Searched string"  [(-1) if "Searched string" not found]
                   
       
        example:   GetSubStr of string "I want to go to the zoo"
                   parameters: occurence=1, Searched string=" go "
                     
                     -->  PreString="I want to"
                          SubString="to the zoo"
                         
                   In my project, "Searched string" is often just a symbol like # that separate two different data that i want to separate at runtime,
                   but need to get them Simultaneously in 2 separate events.
       
       
3) Action: GetReplace  -> Event: Replaced   return the original string, where the "Searched string" is replaced by the "Replacement string" given in parameters
                                            (same as Replace function in javascript)
       
4) Action: LowerCase -->  Event: LowerCase   return lower or uppercase of original string (not sure this comment is really neccessary smile
   Action: UpperCase -->  Event: UpperCase
       
                                           
5) Event: Done    fired when other actions are finished, return just 'nil'
                  (needed when i wanted to know an action is finished to fired the next plugit, but don't need the returned string)
                 

Code:

File: string.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PLUGIN name="string" version="1.0" type="misc">
  <DESCRIPTION>String Manipulation</DESCRIPTION>
  <HELP></HELP>
  <RESOURCE></RESOURCE>
  <EDITOR>
    <SCRIPT path="./estring.pkg" />
    <PARAM name="occurence" type="value" />
    <PARAM name="start" type="start" />
    <PARAM name="end" type="end" />
    <PARAM name="find" type="find" />
    <PARAM name="replace" type="value" />
  </EDITOR>
  <CLIENT minstance="true">
    <SCRIPT path="./cstring.pkg" />
    <ACTION name="GetPos" />
    <EVENT name="Position" />
    <ACTION name="GetSubString" />
    <EVENT name="PreString" />
    <EVENT name="SubString" />
    <ACTION name="GetReplace" />
    <EVENT name="Replaced" />   
    <EVENT name="Done" />
    <ACTION name="LowerCase" />
    <EVENT name="LowerCase" />
    <ACTION name="UpperCase" />
    <EVENT name="UpperCase" />
  </CLIENT>
</PLUGIN>

File: estring.pkg

fun cbCloseEdit(v)=
   let v -> [ctrlocc ctrlstart ctrlend ctrlfind ctrlrep] in
   let getEdCtrlFloatValue ctrlocc -> nocc in
   let getEdCtrlFloatValue ctrlstart -> start in
   let getEdCtrlFloatValue ctrlend -> end in
   let getEdCtrlEditTextValue ctrlfind -> find in
   let getEdCtrlEditTextValue ctrlrep -> replace in
   ["occurence" ftoa nocc]::
   ["start" ftoa start]::
   ["end" ftoa end]::
   ["find" find]::
   ["replace" replace]::
   nil;;


fun dynamicedit(winstr, inst, viewstr, applybtn)=
  let [400 300] -> [iw ih] in
  (
    setEdWindowSize winstr iw ih;
    
    let atof (getPluginInstanceParam inst "occurence") -> nocc in
    let atof (getPluginInstanceParam inst "start") -> start in
    let atof (getPluginInstanceParam inst "end") -> end in
    
    let (getPluginInstanceParam inst "find") -> find in
    let if find == nil then "" else find -> find in
    let (getPluginInstanceParam inst "replace") -> replace in
    let if replace == nil then "" else replace -> replace in

    let crEdCtrlLabel winstr 10 12 160 20 (loc "OS3STRING_0001") nil -> labeltitle in
    let crEdCtrlFloat winstr 180 10 40 20 nocc 0.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlocc in 

    let crEdCtrlLabel winstr 10 37 160 20 (loc "OS3STRING_0002") nil -> labeltitle in
    let crEdCtrlFloat winstr 180 35 40 20 start 1.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlstart in 
    
    let crEdCtrlLabel winstr 10 65 160 20 (loc "OS3STRING_0003") nil -> labeltitle in
    let crEdCtrlFloat winstr 180 63 40 20 end 0.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlend in            

    let crEdCtrlLabel winstr 10 90 160 20 (loc "OS3STRING_0004") nil -> labeltitle in
    let crEdCtrlEditText winstr 10 108 (iw - 20) 90 find nil EDWIN_RESIZE_MW -> ctrlfind in
    
    let crEdCtrlLabel winstr 10 223 160 20 (loc "OS3STRING_0005") nil -> labeltitle in
    let crEdCtrlEditText winstr 10 241 (iw - 20) 90 replace nil EDWIN_RESIZE_MW -> ctrlrep in
    (
      [mkfun1 @cbCloseEdit [ctrlocc ctrlstart ctrlend ctrlfind ctrlrep] nil];
    );
  );;

  File: cstring.pkg

  fun deleteOb(inst)=
  0;;

  fun GetPos(str, nocc, start, end, find)=
        set nocc = if nocc == 0 then 1 else nocc;      
        let start -> pos in
        let if (end == 0) then (strlen str) else end -> end in
        let 1 -> count in
          if find == nil then (-1) else
           (
              while ( (count <= nocc) && (pos <= end) && (pos != nil) ) do (
                 set pos = (strfind find str pos);
                 if (pos != nil) then set pos = pos + 1;      
                 set count = count + 1;
              );
              let if (pos == nil) then -1 else pos -> pos in
                  pos;
           );;

  fun cbGetPos(inst, from, action, str, reply, p)=
       let p -> [nocc start end find _] in
       let GetPos str nocc start end find -> pos in
           SendPluginEvent inst "Position" itoa pos nil;
           SendPluginEvent inst "Done" nil nil;
  0;;
  
  
  fun cbGetSubString(inst, from, action, str, reply, p)=
       let p -> [nocc start end find _] in
       let start - 1 ->  start in               
       let if ( (end == 0) || (start > end) )then (strlen str) else end -> end in
       let start -> pos in
       let "" -> pre in
       let "" -> sub in
       (
          if nocc != 0 then (      
               set pos = GetPos str nocc start end find;
               if pos != -1 then (
                   set pre = substr str 0 (pos - 1);
                   
                   let pos + (strlen find) - 1 -> start in
                   let end - start -> len in 
                       set sub = substr str start len;
               )
               else (
                   set pre = str;      
                   set sub = "-1";
               )
          )
          else
          (
              set pre = substr str 0 (start - 1);
              let end - start -> len in            
                  set sub = substr str start len;
           );
           
          SendPluginEvent inst "PreString" pre nil;
          SendPluginEvent inst "SubString" sub nil;
          SendPluginEvent inst "Done"      nil nil;
       );
  0;;


 fun GetReplace(str, find, replace, nocc, start, end)=
        let 0 -> pos in 
       let GetPos str nocc start end find -> pos in (
       if ( pos >= 0 ) then (
          let substr str 0 (pos - 1) -> first in
          let substr str (pos - 1 + strlen find) strlen str -> last in ( 
          set str = strcatn first::replace::last::nil;
          str;
          )
       )
       else nil
       )
 ;;

 fun cbGetReplace(inst, from, action, str, reply, p)=
    let p -> [nocc start end find replace] in
    let start - 1 ->  start in              
    let if (end == 0) then (strlen str) else end -> end in
    (  
       if (nocc != 0) then ( 
           let GetReplace str find replace nocc start end -> res in
           if res != nil then (set str = res);
           0                                          
       )                                             
       else (
          let 1 -> loop in  
           while ( loop == 1) do ( 
             let GetReplace str find replace 1 start end -> res in 
             if res != nil then (set str = res; 0;) else (set loop = 0; 0;)
           );
           1                                                
        );                                           
       SendPluginEvent inst "Replaced" str nil;
       SendPluginEvent inst "Done" nil nil;
    );
  0;;

fun cbLowerCase(inst, from, action, str, reply, p)=
    SendPluginEvent inst "LowerCase" (strlowercase str) nil;
0;;

fun cbUpperCase(inst, from, action, str, reply, p)=
    SendPluginEvent inst "UpperCase" (struppercase str) nil;
0;;

fun newOb(inst)=
  let atoi (getPluginInstanceParam inst "occurence") -> nocc in
  let atoi (getPluginInstanceParam inst "start") -> start in
  let atoi (getPluginInstanceParam inst "end") -> end in
  let (getPluginInstanceParam inst "find") -> find in
  let if (find == nil) then "" else find -> find in
  let (getPluginInstanceParam inst "replace") -> replace in
  let if (replace == nil) then "" else replace -> replace in
  let [nocc start end find replace] -> struc in
  (
    PluginRegisterAction inst "GetPos" mkfun6 @cbGetPos struc;
    PluginRegisterAction inst "GetSubString" mkfun6 @cbGetSubString struc;
    PluginRegisterAction inst "GetReplace" mkfun6 @cbGetReplace struc;
    PluginRegisterAction inst "LowerCase" mkfun6 @cbLowerCase struc;
    PluginRegisterAction inst "UpperCase" mkfun6 @cbUpperCase struc;
    setPluginInstanceCbDel inst @deleteOb;
  );
  0;;


fun IniPlug(file)=
  PlugRegister @newOb nil;
  setPluginEditor @dynamicedit;
  0;;

File: string.english.lang (to be put in folder "lang")

LANGUAGE english
OS3STRING_DESC String manipulation: find, substring, replace, case replace
OS3STRING_HELP
OS3STRING_0001 Number of occurence
OS3STRING_0002 from char
OS3STRING_0003 To char
OS3STRING_0004 Searched string
OS3STRING_0005 Replacement string

File: string.french.lang (to be put in folder "lang")

LANGUAGE french
OS3STRING_DESC Manipulation de chaine de caracteres: find, replace, subtring, case
OS3STRING_HELP
OS3STRING_0001 Nombre d'occurences
OS3STRING_0002 A partir du caractère
OS3STRING_0003 Jusqu'au caractére
OS3STRING_0004 Chaîne recherchée
OS3STRING_0005 Chaîne de remplacement

#7 Re: Openspace3D » Screen resolution problem on Android export : everything becomes tiny » 12-Sep-2019 20:26:47

Hi arkeon,

Thank's for replying.

I'm using the last version available on OS3D website 1.81 – 31/07/2019 as i started to try it this august.
Is there a beta somewhere i can try to fix this problem ?

I have also try the apk on my personal mobile (display: qhd 2560x1440, dpi > 500) and there the texts and the windows dialog have normal size (or a little bit too big), but no problem to use them.

So i'm asking myself if it is not a display setting problem with the Lenovo tablets (but didn't find a settings to change that in android parameters).

#8 Openspace3D » Screen resolution problem on Android export : everything becomes tiny » 11-Sep-2019 20:08:26

ARappy
Replies: 9

Hi,

My project is working fine now, but i have apparently a last annoying problem of screen resolution.

When using OS3D under win7 with a screen resolution of 1440x900, every elements of project is rendered fine (2D text & pictures, 3D mesh...).

But after exporting to android tablet Lenovo Tab 2 A8-50 (screen: 1280x800, Android 5.1), all 2D user UI objects appears very very tiny: text zone, dialoglist, custom interface...

For example a text written in custom interface plugit with font size 20, appears like something size 3 on the tablet. Also a Dialoglist plugit window, is so small, i can barely click on the ok button to close it.

I don't understand why all the scene is so shrink between windows version and android export. The resolution of the screen of the pc & tablet are very close (1440x900 vs 1280x800), but the size of the scene is rendered completely differently.

I have try different width & height default size in OS3D project settings (player settings), with no effect.

The problem comes certainly from those Lenovo tablets, but there isn't any settings i can find to change that (android settings to set text size doesn't fix the problem).

The only solution i found is to increase a lot the font size and width/height of all 2D user interface control (button, text...) in windows, where they are now very huge, even cut at bottom, but then in Android they appears quite normaly.

But i can't do this with dialogbox UI taken from interface plugit folder (dialog list, dialog number, dialog text input) for which there is unfortunately no settings to change the font size, so they stay very tiny and quite unusable. The problem is that i use a lot of them in my project.

I'm teacher, doing this project for my student and can only use this model of tablets that are available at my school.

Does someone knows if there is a setting somewhere when export to android to change something about screen resolution, or what could cause this problem ?

As this project is also using the webcam for AR recognition, and the webcam resolution on my pc & the tablets is quite different, could the problem comes from this ?

Thank you very much for any help.

#9 Re: Openspace3D » Need some help for OS3D beginner » 2-Sep-2019 16:50:02

Hello arkeon,

Thanks for your answer.

In fact, I already have done a string plugit as it is essential to my project. It embeds different usual string functions (find a string in a bigger string, replace or do substring). It works well, but it is probably not nicely coded as i have just begun to learn scol. I can send it if you want to review it, and see if it can help. Can i send it in pm as there is probably some improvement and bugs correction to do, before expose it, as it is for the moment.

Also would you have some clue to the use of execch scol function in addsourcecode plugit ? Is it possible to used it instead of _scriptc, if they are somehow equivalent as i believe ?

Thank you

#10 Openspace3D » Character Font not included in Android export ? » 2-Sep-2019 16:30:41

ARappy
Replies: 1

Hi,

I'm building a OS3D project to be used on android platform, and add a hud with some text. As it is proposed in the plugit "custom interface" or "text zone", i choose a particular character font type that is on my pc to write the text without problem.

But it seems that when you export your project to android apk, the font.ttf file is not included in the package and so can't be displayed on android devices.

There is very few default fonts included in the different versions of Android, so usually when you make an android app in other framework, you can add any fonts you want with some code in the manifest file and the xml files coming with it in the res folder.

So could you please tell me if i am making a mistake or if there is a way to ask OS3D apk exporter to embed font files used in a project inside the apk ?

Or maybe is it possible to add necessary code manually in the source files produced by OS3D apk exporter (especially in manifest), then recompile the apk in Android studio or other framework.

Thank you for your help

#11 Re: Openspace3D » Need some help for OS3D beginner » 26-Aug-2019 20:13:21

Hi Xeonadow,

Thank you very much for all those precisions. Things are very clear for point 2) & 3), but here is some precisions for point 1) & 4) I liked to ask (sorry for the length of all this):

1) HGH CPU USAGE:

I really apologize about this because my question is probably stupid, as i'm new to 3D. I understand what you say, but there must be still something i don't get about what is doing Ogre in OS3D.

Before to choose OS3D for its wonderful simplicity, i have tried some other 3D engine like Babylon.js or Unity. In none of them, my old cpu is overloaded permanently, especialy with empty scene at load.

When not playing the scene, they just show the scene with the 3D objects, and i can rotate the scene, zoom on it, but it don't needs such cpu usage, because i'm just "building" a scene, not "rendering" it (sorry for the imprecision of my vocabulary).

In Unity for example, when i was trying a little project (add mesh, doing little C# code ..) without "playing" the scene, the 3D previsualisation of the scene that is shown by unity don't make the cpu get high, it stays at a few percent, especially for a static scene (no animation to render, only static 3D mesh).

It's only when playing (render) the scene when you click on the play |> button that the cpu goes high as expected for an old pc. I probably didn't understand, but it doesn't seems there is a permanent render at high fps, as Ogre does in OS3D.

So if you don't "play" the scene, why Ogre has to render the scene continuously and at so much fps ? I don't know if "fps" has the same meaning here than in video game for example, but who needs 400 fps in a simple application ? I really goes at about 400 fps immediately since i launched OS3D, athough the scene is empty, i haven't done anything yet and the play button is on stop.

Do you know if maybe there is some ini file somewhere in Ogre folder to limit fps, at least during developping the project ?


4) PLUGIT ADDSOURCECODE:

I know how to use var and global var in the link parameter, but it is not sufficient for what i'm trying to do.

If i ask question about how to get any instance of the project programmatically, it is because you can't access all the properties (attributes) of one of the plugit by links. This is limited to the "action" & "event" they exposed in their links, and only a few of them exists.

For example, when using plugit "Custom Interface" to create a text or a button, you can change the value of a text, but not its color, or something else.

If I wish to change color during runtime (to make a text blink for example), or the font size, or the image used in a button etc, there is no "action" or "event" for it. All the things you can do easily when all instances of the scene can be accessed by code (as in Babylon with js or Unity with C#).

As there is also an underlying language under OS3D (Scol), why can't we use it to access directly any instance present in the scene, to be able to change dynamically any of its property ? Because of course we are not going to make a plugit for each properties we want to change.

To give you another example, at the moment i was stucked by the lack of a plugit to manage string variable (like substring, replace, left, right, find etc..).

I hoped to be able to do it with ADDSOURCECODE plugit, because there is all what i need in scol to do it (strfind, strlen, substr..). But I didn't understand how ADDSOURCECODE can exchange data with the scene, and now i think it can't.

So I have writen my own plugit to do string manipulation using those scol functions and it works, but it would be more simple to be able to do it from a scol interface like ADDSOURCECODE plugit.


I have looked in ADDSOURCECODE code and at line 57, the scol command that run the user script on a channel is:

   _scriptc ch script;   
   
Unfortunately scol function "_scriptc" doesn't return a value, so it is not possible to use ADDSOURCECODE plugit to return a value from the code you write inside, and get it back in the links of the plugit, to change something on runtime.


Do you know if it possible to use "execch" instead of "_scriptc" :

   https://redmine.scolring.org/projects/s … xecch.html
   
that seems somehow equivalent to "_scriptc" but can return a value.

I have to try to replace it in the actual code of ADDSOURCECODE plugit and adapts its parameters that are differents, but I always get compilation error. It is something like :

    execch ch script arg;

If execch could return me a value created by the user script written in ADDSOURCECODE (make a substring of a string for example), then i can easily return this value to an event link for the next plugit.

And if ADDSOURCECODE plugit could return a value, that could helps me a lot to use more scol functions and make things more dynamic.


Thank you anyway for your appreciated concern.

#12 Openspace3D » Need some help for OS3D beginner » 15-Aug-2019 17:41:42

ARappy
Replies: 5

Hello to all the OS3D community,

I am completely new to OS3D and I am a trying to make android AR tutorials for my students on different scolar subjects, to make learning more attractive. I have followed a video tutorial to use AR with OS3D and i succeeded to make a 3D object follows a trained image marker without problem and then export the apk to android device. All this works very well.

So now i'm trying to go a step further, but i am stuck by different problems for which I really don't find solutions so far, could you please help me about those :


1) CPU USAGE: I apologize for this probably dumb question, but first i have a concern about cpu usage. Since OS3D is loaded, the OS3D process make cpu load at 50% permanently, so quickly the fan goes to max and the pc heats a lot.

As my pc is quite old, i can understand it is highly sollicited for 3D rendering, but even when i open a new project where there is nothing in the scene (no 3D object, default_light desactivated) i don't understand why it needs all this cpu.

At first i believed that the toolbar button Play/Stop has purpose to start or stop 3D rendering, but then i have understood that 3D rendering is done in real time permanently.  So I have look up in render settings, but didn't find an option to desactivate real time rendering or something to limit fps (it is at about 400 for now) or to lower render quality, because for my old pc i don't need so much quality to just make some test. I have unchecked all options in rendering settings window, but cpu still always at 50% (using directX or OpenGl).

So could you please explain me, what is the 3D motor rendering, although there is absolutely nothing in the scene, and is it possible to desactivate this real time rendering or lower its quality when i don't need it, for example when i am just working in the edit zone to try differents plugits.


2) ACCENTUED CHARACTER: I use OS3D in french language, and I have a problem with text (create in a custom interface for example) that use french accent that are not recognized when exporting to android app. When testing it on Windows 7 everything is fine, but when export to android apk, accentued character (é,à,ç etc.) are replaced by "?". I try on 2 differents android devices (tablet & phone) with same result, although there is no problem when using the project on windows.

Scol voyager is set to french, project setting is set to french, OS3D option is set to language french, and when export to android I put FR for country when asking to sign apk. Does i forgot an option somewhere about that or are the french accentued character not supported by android apk compiled by OS3D ?


3) TEXT SMOOTHNESS:  I have also a big concern about the quality of text rendering that seems not to be really smooth. For example, creating a text in plugit "custom interface", i choose a classic font Arial and police size 10 to 20 to test. But the text (in 2D) i obtain gives something like "aliased", not smooth (irregular) when i compare with exactly the same text and size i see in an text editor like Word. Is there something to do, to make characters appears more smooth ?


4) PLUGIT ADDSOURCECODE: Last thing, could you please help me to use plugit "addsourcecode", for example to be able to call directly a method of some instance. I have look some examples, but didn't manage to make it work:

For example, i make an instance of the plugit "custom interface" named MyCustomInterface, and inside create a text named myText and give it some value ("hello" or anything else).

If now i want to change the value of this text with an instance of the plugit addsourcecode, using action "set Text" of the plugit "custom interface", to replace the text by another text contained in a global var named Myvar: 

is there something like that ?

fun main(inst)
     Scene.MyCustomInterface.myText.setText(Myvar);
     0;;


Thanks a lot for any help you could provide me.

Board footer

Powered by FluxBB