Codea (Beta 15 & 16)

I’ve removed modelViewProjection from the bindings editor in the next build. In addition, setting the modelViewProjection property on a shader object will cause a warning to be printed stating that Codea will overwrite the value.

This fixes the bug that @mpilgrem experienced with his Arc code — however it means you can not set a custom modelViewProjection matrix. If you want to use a custom matrix in your vertex shader you will have to create a mat4 uniform with a different name (you can also delete the modelViewProjection uniform from your vertex shader if you’re not using it — and instead use your own).

In the future I’d like to change this behaviour so that modelViewProjection can be overwritten by the user, but if not set, use the current matrix. This won’t make it for 1.5 though.

Thanks for your answer about big images @Simeon. I understand your position. And what about just being able to read a part of binary file into a table of values? You probably already have the code available, so there is almost no dev. Is it one of the things forbiden by Apple?

You should be able to read binary files using the io.* package in Lua, it is unsandboxed in version 1.5.

Simeon/Jvm38/tnology/Xavier,

thanks for your answers. Yes, I calculate the normals on my own, or better said, I import it from PLY. Until now I had to copy and paste a PLY into an editor tab, which could get tricky for large 3D models :slight_smile: But as I understand, 1.5 is unsandboxed, so I could read the PLY from file → Very nice.

These are the two programs where I calculate the lighting in LUA and want to replace with the shader:

http://twolivesleft.com/Codea/Talk/discussion/1528/code-sample%3A-lighting-in-3d-meshes#Item_7

http://twolivesleft.com/Codea/Talk/discussion/1723/3d-model-loading-from-blender-ply-and-suggestion%3A-need-to-load-local-files#Item_44

Let’s see how far I get with that :slight_smile:

Kilam.

.@Simeon this is great! I will try it soon then. Meanwhile i was looking into pythonista which has a lot of tools, and i found i could lauch a pythonista script from Codea with:

    openURL("pythonista://Clock?action=run") -- launch 'clock' script

does codea has a ‘url scheme’ like pythonista? This way i would be able to launch a Codea script from pythonista, which means i can launch python from codea for some specifics tools and send back the results to codea… Wouldn’t that be great? I have looked in the list of url scheme collected by python community, but did not find Codea in it.

I’ve been thinking about adding a URL scheme to Codea. You mention that results can be sent back, how does that work?

They describe the following in their doc: i can send data to the script with:

Basics
Open the app:

Use pythonista:// without any additional parameters to open the app without doing anything else.

Open a script for editing:

Use pythonista://MyScript for opening one of your scripts in the editor. The name of the script can contain the .py file extension, but it doesn’t have to.

Run a script from your library:

Use pythonista://MyScript?action=run for running a script that is in your library. This only works if no script is already running when the app is started.

Note You can only open or run scripts that are already in your library. It is not possible to run arbitrary code or create new scripts using the URL scheme.
Command-line Arguments
When using the action=run parameter (see above), you can pass command-line arguments to the script in two ways:

Method 1: One args parameter

Example: pythonista://MyScript?action=run&args=foo%20bar

When you pass a single string with the args URL parameter, the string is split by spaces (the space is encoded as %20 here) and sys.argv would be [<script_path>, 'foo', 'bar'] in this example.

If you want to pass arguments that contain spaces, you have to enclose them in double quotes (as you would in a classic shell).

This is basically the same as running a script by long-pressing the run button.

Method 2: Multiple argv parameters

Example: pythonista://MyScript?action=run&argv=foo&argv=bar

Using multiple arguments that are all named argv, you don’t have to worry about quoting arguments that contain spaces. Each of the parameters corresponds to one element in sys.argv.

If the URL contains at least one argv parameter, args is ignored.

Launching Other Apps
If you want to go in the opposite direction, and open an app from Pythonista, you can do this with the webbrowser module.

For example, to open TweetBot, you could use the following code:

CopyOpen in Editor
import webbrowser
webbrowser.open('tweetbot://')

so my idea is to write in pythonista webbrowser.open(“codea://myscript.codea?myVeryLongString=str”) at the end of my python script to pass data as strings back to codea.
Maybe it even already works with http.request fom Codea, since python url scheme is just like a web browers, and you have nothing to change? But then i dont know how to do it yet.