davidbk
davidbk
Transform Data on Groups in Exports
@andybak seeing as how raw transforms are saved into the JSON file for models, I thought of a possible workaround where one could potentially use models instead of groups by sketching out assets and using the "Save Selected Strokes to Model Catalog" button in Experimental Mode and use the exported model for level design and layout instead. The problem is that this button seems to have a bug where it doesn't export selected strokes only (it exports the entire scene). Also, when the models appear in the library and are imported, they seem to be mirrored on one axis.
2 replies
OBOOpen Brush, Open Blocks, Icosa Gallery
Created by davidbk on 12/27/2023 in #open-brush-chat
Origin points in exports
I added the Unity SDK Package to a my Unity project and imported a .glb file hoping to see transforms on the groups, but unfortunately all transforms were set to zero. Then I tried one of the toolkit scripts geometry_json_to_fbx.py, thinking it might retrieve additional data in the file, but no luck there either, all the transforms were set to zero. I tested a number of other export formats in both Blender and Unity (FBX, OBJ, USD) and none of them seem to have any transform data on groups. As far as I can tell, this data isn't being saved out anywhere. I just posted a feature suggestion here: https://discord.com/channels/783806589991780412/1189764827539836938 I'd love to see this feature included in a future build. If there's anything I can do to move this issue along, offering testing or otherwise, let me know. I worked on a script in the past that did something similar from Gravity Sketch to Unreal Engine, if that is any use. I think GS has a switch on export to use Groups or Layers for the scene hierarchy.
5 replies
OBOOpen Brush, Open Blocks, Icosa Gallery
Created by davidbk on 12/27/2023 in #open-brush-chat
Origin points in exports
I didn't know about the Unity SDK and toolkit so I will check that out and do a test. When I was looking at the exported fbx and glb files in Blender, I did see that groups were preserved, but the transforms on these groups had position and rotation set to zero, scale set to one. Perhaps the Unity SDK behaves differently. I will get back to you.
5 replies
Using scripts to import images automatically
Here is a finished script that imports multiple images automatically. It has a simple form with file input, path input, delay between commands, some buttons to run and cancel, as well as an output log. The script sets a timer for each command to deal with the loading time and calculates the time between commands based on the number of images selected. There is also a Reset View button to fly to the scene origin since this is where the images are imported to. @andybak I could not find a way to get the path of a subfolder underneath the Images folder in JavaScript (I imagine this is for security reasons) so I made a manual text field instead. It's not the most elegant. Let me know if you can think of a better way.
40 replies
Using scripts to import images automatically
@andybak sorry, I can't get the -1 index trick it to work. I'm sending my script. It imports an image from a subfolder called 'test' and makes two copies at different positions, but it looks like only one image comes in, or they are positioned one on top of the other.
<!DOCTYPE html><html><head></head>
<body>
<input type="file" id="fileInput">
<button onclick="sendFileName()">Go</button>
<script>
function sendCommands(commands) {
var xmlHttp = new XMLHttpRequest();
var url = '/api/v1?' + commands.join('&');
xmlHttp.open('GET', url, false);
xmlHttp.send(null);
}

function sendFileName() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
if (!file) return;
const fileName = file.name;
sendCommands([
'image.import=test/' + fileName,
'image.position=-1,1,10,10',
'image.import=test/' + fileName,
'image.position=-1,2,10,10',
]);
}
</script>
</body></html>
<!DOCTYPE html><html><head></head>
<body>
<input type="file" id="fileInput">
<button onclick="sendFileName()">Go</button>
<script>
function sendCommands(commands) {
var xmlHttp = new XMLHttpRequest();
var url = '/api/v1?' + commands.join('&');
xmlHttp.open('GET', url, false);
xmlHttp.send(null);
}

function sendFileName() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
if (!file) return;
const fileName = file.name;
sendCommands([
'image.import=test/' + fileName,
'image.position=-1,1,10,10',
'image.import=test/' + fileName,
'image.position=-1,2,10,10',
]);
}
</script>
</body></html>
40 replies
Using scripts to import images automatically
Oh! I didn't try it with the HTTP API. I assumed I had to use the new plugin scripting API in order to use the -1 index trick. I'll give it a shot.
40 replies
Using scripts to import images automatically
Ah, ok I have it now. I see an "Open Brush/Plugins/LuaModules" folder with "lume.lua" and symmetryHueShift.lua". I also see that I can copy the four scripts (Dashes, AlongStroke, Circle, AutoSpinSymmetry) to user scripts folder. Do these four scripts correspond do the four plugin types listed in the doc? (Pointer, Symmetry, Tool, Background). Edit: I see they do indeed!
40 replies
Using scripts to import images automatically
@andybak Great! Where can I find the example plugins listed here? (https://docs.openbrush.app/alternate-and-experimental-builds/runtime-scripting/example-plugins)
40 replies
Using scripts to import images automatically
@andybak I had a chance to try out the file picker script you sent and I reworked it slightly to import images. I am having issues with the 'image.position' command to reposition the images on import because I noticed that the command accepts an index, which I assume is the index is the image we want to reposition, but this becomes a problem if the scene is not empty and we don't know the index of the last image. So I'm wondering whether it would be possible to somehow get the total number of images in the sketch so that we can get the index of last one, and pass that index as a parameter. Is this something that the plugin scripting system could do better? Also, I'm noticing that html input type="file" seems to only get the file name, and not the path, so unless I hard-code a subfolder name, it seems like there is no way to "get" or "list" subfolders within the "Media Libary/Images" folder. Is that consistent with what you know? Happy holidays by the way!
40 replies
OBOOpen Brush, Open Blocks, Icosa Gallery
Created by Shawn.Chiki on 6/30/2023 in #open-brush-bugs
Controllers/Hands disappear using Quest 2 Link on PC
@andybak ok this makes sense. When you say OpenXR version, what do you mean? Are you talking about the APK listed in the latest release on Git Hub (OpenBrush_OpenXR_2.3.133.apk)? Does APK mean it’s for standalone Quest only? Is there also an OpenXR version for Desktop? How are the releases on Git Hub different from what’s available on Steam or Oculus store? Sorry if that’s too many questions, haha.
22 replies
OBOOpen Brush, Open Blocks, Icosa Gallery
Created by Shawn.Chiki on 6/30/2023 in #open-brush-bugs
Controllers/Hands disappear using Quest 2 Link on PC
@Shawn.Chiki @andybak I am finding the same thing on my end. It makes using scripts impossible because every time I take off the headset to run the script in the browser, the controllers disappear and I can't retrieve them by pressing any number of button combinations or resetting the view. I guess one could put a piece of sticky tape over the sensor to trick it into thinking that you're still wearing it. The only workaround I have found with Quest 2 and Link has been to run OpenBrush through Steam VR. Not ideal since it's yet another layer of software that requires loading.
22 replies
Using scripts to import images automatically
@andybak I had a chance to test this out and was able to get it to work. I had a few questions... 1) I'm noticing that the position of the images on import is a bit unpredictable. Sometimes it puts two images side by side, and the third off on the other side of the arena (the location seems to be dependent on where I am in the VR environment, but I'm not entirely sure). Other times, it puts two images directly on top of one another, making them difficult to separate with the controllers. Is there another way to set the position on import? 2) I haven't worked with javascript in ages, but jumping ahead on this little assignment, I am asking myself the question as to whether it would be possible to import all files in a given subfolder without naming them explicitly. To do this, perhaps I could somehow list all files in a given folder, then loop through them and run that 'image.import' command. After a quick google search, I stumbled upon the javascript fs (File System) module as a way to list files in a folder (https://stackoverflow.com/questions/31274329/get-list-of-filenames-in-folder-with-javascript). Would this work in this case? I'm not sure if technically OpenBrush scripts are considered server side or not. 3) If didn't want to hard-code the image file names, I imagine I could add a text field on the HTML page to pass arguments to the function?
40 replies
Using scripts to import images automatically
Thanks @andybak ! This is great. Regarding the first script and the path 'test/image01.png' will OpenBrush assume that 'test' is a subfolder inside the Media Library Images folder? 'C:\Users\<username>\Documents\Open Brush\Media Library\Images'
40 replies