ivansafrin / polycode Goto Github PK
View Code? Open in Web Editor NEWPolycode is a cross-platform framework for creative code.
Home Page: polycode.org
License: MIT License
Polycode is a cross-platform framework for creative code.
Home Page: polycode.org
License: MIT License
"local v = bullet:getPosition(); v.x = 100; v.y = 100; screen:setTransform(bullet, v, 0)"
This works. This:
"screen:setTransform(bullet, Vector2(100,100), 0)"
. . .does NOT work, it appears to have the effect of moving the bullet to screen position (0,0). Meanwhile THIS:
"screen:setTransform(bullet, Vector3(100,100,0), 0)"
. . .DOES work. However the documentation on the website clearly describes setTransform as taking a Vector2 not a Vector3.
MinGW's version of mkdir() seems to take just 1 argument, so the current code that takes file mode bits into account does not compile.
Moreover, the file mode bit defines S_IRWXG, S_IROTH and S_IXOTH (used by OSBasics::createFolder) are not defined by MinGW.
Currently there is no reasonable way to remove an entity from a scene using the update loop.
When creating a new ScreenShape
like
ScreenShape *s = new ScreenShape(ScreenShape::SHAPE_CUSTOM);
And then adding points via
s->addShapePoint(x,y);
Will cause the polygon to overlap itself and render improperly if the points aren't added in CW or CCW order. I suggest this behavior should be modified to sort the points and render them properly as default, perhaps with a boolean option to disable this functionality
If you desire an implementation, I could provide one.
So I want to say:
shape = ScreenMesh(TRI_MESH)
But when I do this I get:
11/18/11 10:36:43 PM [0x0-0x2b0eb0c].PolycodePlayer[26467] status=1, [string "Polycode/ScreenMesh.lua"]:26: bad argument #1 to 'ScreenMesh' (string expected, got number)
11/18/11 10:36:43 PM [0x0-0x2b0eb0c].PolycodePlayer[26467] CRASH LOADING SCRIPT FILE
ScreenMesh has two constructors:
ScreenMesh (String fileName)
Creates the screen mesh and loads a mesh from a file name.
ScreenMesh (int meshType)
Create an empty screen mesh of specified type.
It's calling the wrong one.
When I poke at the inside of the lua bindings, it seems pretty clear that ScreenMesh() ONLY knows how to call ScreenMesh(string) and doesn't know how to call the version where argument 0 is an integer. This means that you can't create a StringMesh at all from LUA unless it's from a file...
When asked, Ivan says:
"Ok, so issue number one here is that the Lua class system that I'm using supports only one constructor, while C++ of course supports many, so currently it takes the first constructor in the C++ class and uses that as the default one in Lua. I'm trying to figure out a way around this (I will probably rewrite the class system in Lua from scratch as it has many other issues currently)."
I'm not sure a total rewrite is necessary for this, if there was simply a function ScreenMesh2() or something that corresponded to the second constructor this would be totally sufficient for my purposes.
I got a VERY strange behavior in this particular revision of my LUA polycode project: https://bitbucket.org/runhello/luatest/changeset/8a5544f67203
where after calling SetTransform(), the object thus transformed would "snap back" to a particular position on the very next frame.
This came up because of issue #29 above where removing objects from a physics space causes a crash; I had to do something with the bullets in my game after they were "destroyed", so I handled this by setTransforming() them to be at a random coordinate in the vicinity of 10000,10000, far outside of the window. If I did this naively, here is what I would see:
The bullet collides with an asteroid. Because I think (?? may file an issue about this later) bad things happen if you setTransform during a collision handler, I put the collision-detected bullet into a "dying bullets" list. On the next update loop, I setTransform() all the "dying bullets" to 10000,10000 plus a random offset, and set their velocities to zero.
When I do this, the bullet will disappear for one frame, then suddenly on the very next frame snap back to ALWAYS THE SAME POSITION-- it would materialize somewhere around (300,100), every single time this happened the bullet would appear in the same place-- with about the same velocity it had before the collision it had but a seemingly random trajectory. If the same bullet then hit another asteroid and went through the banishment procedure again, the second time it would take and would NOT return to the mysterious (300,100) position.
The way I eventually got around this was that the "dead bullets", the ones which have collided with an asteroid, go into a "dead bullet" array, stay there forever, and get re-SetTransformed outside of the visible space on every single frame. However it is not reasonable to have to take this workaround. I don't even know what's happening here but it looks like a bug at polycode's end.
The physics collision event is sending faulty world coordinates. Reference: http://polycode.org/forum/viewtopic.php?f=4&t=44
In order to facilitate inheritance, make most of the currently private members protected.
Hey there! This project is ballin', but I'd love to make it work for quick prototyping on iOS devices. The polycode website says that an iOS port is currently on development, but I can't see the code anywhere.
Do you have a work plan or TODO list for the port? I may be able to throw you a hand.
Cheers!
Quote from forum: "everything works as long as I use my C: drive (which is where the polyplayer and polybuild are located.."
Polycode::Sound is failing to load sound files. .ogg files fail quietly besides an error message in the output pane, and nothing happens when it tries to play. .wav files throw an exception while trying to load.
Using Visual Studio 2010 on windows 7 32bit, "test.wav" from the website's tutorials, and baystart.ogg from dwarf fortress, because that's the first .ogg I found lying around my hard drive.
Some of the issues:
MainMenu.xib - Unsupported Configuration - NSOpenGLViews in One Shot memory enabled window
OSBasics.h - Lexical or Prerocessor Issue - Extra tokens at end of #include directive
PolyObject.h - Semantic Issue - Implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'int'
PolyShader.h - Semantic issue - Static data member 'MODE_IN' not allowed in anonymous struct ( swell as MODE_OUT )
PolyScene.h - Semantic issue - Implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'int'
PolycodeView.mm - Semantic Issue - another integer precision loss but with NSUInteger and Unused Entity Issue - Unused variable 'mouseLoc'
Mesh::TRISTRIP_MESH is an option in the Mesh, but its rendering is not actually implemented in the renderer. Need to take it out or implement it.
If you have a ScreenImage, and you set a "scale" on it, and then you add it as a physics child, the physics space will react incorrectly. The image will be at 1/2 size (or whatever) but the "physics object" will remain at full size, it will be like an invisible barrier around the shrunken image.
Can provide LUA demonstration code if needed.
EDIT: I changed the title based on ivansafrin's post below
I am on OS X Snow Leopard with XCode 3. I have a complete build of Polycode that I made by running the standard cmake instructions against c3c534c but adding BUILD_POLYCODE_PLAYER=1 (or whatever it is?) at one step. Note, since the last time I did a clean build I have several times up'd the polycode repository and rebuilt without cleaning; don't know if that's potentially significant.
If I go into the new LUA "2DPhysics_Basic" directory and run:
../../../Release/Darwin/Framework/Tools/polybuild --config=2DPhysics_Basic.xml --out=Test.polyapp
polybuild segmentation faults:
andis-macbook:2DPhysics_Basic mcc$ ../../../Release/Darwin/Framework/Tools/polybuild --config=2DPhysics_Basic.xml --out=Test.polyapp
Polycode build tool v0.8.2
Reading config file from /Users/mcc/work/p/Polycode/Examples/Lua/2DPhysics_Basic/2DPhysics_Basic.xml
Reading xml from /Users/mcc/work/p/Polycode/Examples/Lua/2DPhysics_Basic/2DPhysics_Basic.xml
OK!
Entry point: 2DPhysics_Basic.lua
Width: 640
Height: 480
Anti-aliasing level: 0
Background color: 0.250000 0.250000 0.250000
Packaging 2DPhysics_Basic.lua as 2DPhysics_Basic.lua
Adding module: Physics2D
Path:/Users/mcc/work/p/Polycode/Examples/Lua/2DPhysics_Basic/../../../Release/Darwin/Framework/Modules/Physics2D/API
Segmentation fault
It creates a Test.polyapp file, but it is not a valid zip file. unzip emits the error "End-of-central-directory signature not found" and PolycodePlayer, when I try to open the polyapp in there, claims it cannot find the xml file. This is 100% reproducible for me.
SetTransform() appears to have several unexpected behaviors and side effects. For one thing it appears to reset/zero out all forces applied to an object in the current "frame"
For example, if I apply a force then setTransform() to change the angle, OR if I setTransform and then apply the force afterward, the force will have no effect.
This came up for me because I had a game with a "spaceship" ; on each frame I tried to "move" it by applying a force based on which of the arrow keys are being pressed, and also SetTransform it to rotate it such that it is facing the mouse. The movement via force worked until I added the per-frame SetTransform, then it stopped working. You can see my sample code for this bug here (see "get source" in upper right corner): https://bitbucket.org/runhello/luatest/changeset/95b0f5f63d0d
We should be able to execute such
entityInheritedObj.setScale(entityInheritedObj.getScale() * 0.9);
also we should be able to execute this two lines:
entityInheritedObj->getScale() = entityInheritedObj->getScale() * 0.98;
entityInheritedObj->getScale() *= 0.98;
or execution of such code should be prohibited and produce an error. Now it does nothing, scale does not change and no error is produced.
I am working on using the Polycode Lua bindings inside of a program built against the C++ API. So far, it is working; since api.pak and such are deposited in the release directory most of what I need is part of a built polycode distribution. One exception is the create_lua_lbrary script found in Bindings/Scripts, which right now can only be accessed with a copy of the source repository. IMO this should be copied into Framework/Tools or somewhere similar when a build w/bindings+player is run.
This one's pretty minor but...
andis-macbook:Bin mcc$ ./polybuild --config=/work/p/lua1/Project.xml --out=./test.polyapp/work/p/lua1/Project.xml
Polycode build tool v0.8.2
Reading config file from /Users/mcc/work/p/Polycode/Release/Darwin/Standalone/Bin/
Reading xml from /Users/mcc/work/p/Polycode/Release/Darwin/Standalone/Bin/~/work/p/lua1/Project.xml
Error loading xml file: Failed to open file
Specified config file doesn't exist!
Put tilde in filename: It didn't work.
andis-macbook:Bin mcc$ ./polybuild --config=/Users/mcc/work/p/lua1/Project.xml --out=./test.polyapp
Polycode build tool v0.8.2
Reading config file from /Users/mcc/work/p/lua1/Project.xml
Reading xml from /Users/mcc/work/p/lua1/Project.xml
[etc]
Expand tilde into full path in filename: It worked.
I built a version of Polycode c3c534c with very minor patches. I then created a polyapp using the polybuild included therein. The polyapp uses the 2D Physics module; you can find it inside of the package of this StandalonePlayer http://www.glorioustrainwrecks.com/files/UnplayableAsteroidsMac.zip or source code at https://bitbucket.org/runhello/luatest .
If I run this Polyapp I built using the stock 0.8.2 Polycode Player downloaded from the website, on any machine, it crashes with a segfault: http://pastie.org/2896232
Unless something is wrong with my build process (unlikely; I'm using the build script inside the "luatest" project linked above, which is in lockstep with BUILD.md plus what Ivan said about the standalone/ directory) it appears that a polyapp built using a post-0.8.2 version of Polycode (at least with modules; I have not tested a module-less polyapp) when run with 0.8.2, will cause a crash. One of two fixes, if possible both, is needed.
When trying to compile on archlinux, I get following error:
[ 97%] Building C object Tools/Contents/polybuild/CMakeFiles/polybuild.dir/__/__/Dependencies/unzip11/ioapi.c.o
In file included from /tmp/polycode/Tools/Dependencies/unzip11/ioapi.h:47:0,
from /tmp/polycode/Tools/Dependencies/unzip11/ioapi.c:17:
/usr/include/stdio.h:811:12: error: conflicting types for ‘fseeko’
/usr/include/stdio.h:766:12: note: previous declaration of ‘fseeko’ was here
/usr/include/stdio.h:812:18: error: conflicting types for ‘ftello’
/usr/include/stdio.h:771:16: note: previous declaration of ‘ftello’ was here
The fix might be to move "#include" before "#define".
I built a StandalonePlayer as described in #48. I have not tested the following with "stock" StandalonePlayer.
I find that when this StandalonePlayer is renamed-- to ANYTHING else-- the icon changes to the application with an X over it and it will no longer open. I get the error: "You cannot open the application StandalonePlayer2 because it may be damaged or incomplete". People on other machines testing with the same StandalonePlayer saw the same effect.
Since the point of StandalonePlayer is to be repurposed and renamed this bug defeats the purpose of StandalonePlayer. It also can create problems if you download a zipped version of the program multiple times in safari (this will lead to the program being automatically renamed for example "StandalonePlayer 2").
There appears to be this thing where BEFORE an object is added as a physics child, you may call setPosition and setRotation, however afterward these methods have no effect and one must call setTransform() on the physics space to move/rotate an object.
This is actually a reasonable behavior imo but it is not documented and needs to be if it is not going to be fixed.
(I assume that what is actually happening is that setPosition and setRotation are being executed, but then on the next visit to the update loop the physics step occurs and the position/rotation are being overridden with something out of box2d).
When an object is scaled, the only part of the object that will dispatch the event is the non scaled part of it.
In the example below only the top left corner dispatches the event.
TestPolyApp::TestPolyApp(PolycodeView *view) : Application(view)
{
Screen *screen = new Screen();
ScreenShape *rect = new ScreenShape(ScreenShape::SHAPE_RECT, 100, 100);
rect->setColor(1.0, 0, 0, 1.0);
rect->setScale(4.0, 4.0, 1);
screen->addChild(rect);
rect->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
}
void TestPolyApp::handleEvent(Event *e)
{
std::cout << "The rect was clicked!" << std::endl;
}
As described in this thread:
http://polycode.org/forum/viewtopic.php?f=4&t=11
Possibly an issue with how pow() is handled in nVidia's GLSL compiler.
Where can I find working examples of the stuff inside of the 'Learning' section of the site?
Sometimes its fun to just see something working, then after see how it works
There is no way to remove 3D physics children.
The physics screen has a documented "setSpin" method
http://polycode.org/docs/physics2d/class_polycode_1_1_physics_screen.html
setSpin (ScreenEntity *ent, Number spin)
Sets the spin of an entity.
But . . . what does it do? I mean, what is "Spin"? It is not a concept discussed in the box2d manual. Is "spin" angular momentum? Is it angular velocity? I cannot possibly use the method without knowing its meaning and units...
The 'Material' class' destructor will leak memory due to function-local redefinitions of member data 'materialShaders', 'shaderBindings' and 'renderTargets'.
If keys are held down for a long period of time the events will keep getting called for a period of time even if the key is unpressed.
EDIT:
After looking at the source code (stupid me for not doing so), it seems Mesh::createSphere is not finished. Calculations are made, but no polygons are added to the mesh.
/EDIT
Spheres simply don't seem to be rendered.
How to reproduce this:
Take this code from http://polycode.org/learning/3d_basics (box made bigger than in that example, camera has to be placed further away too, so that we don't end up inside the primitive).
ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 10,10,10);
box->setColor(0.0,1.0,0.0,1.0);
box->setPosition(0.0, 0.5, 0.0);
scene->addEntity(box);
A 10x10x10 box gets rendered.
Change the type of the primitive to TYPE_SPHERE, and a sphere of 10 radius, 10 segments and rings should appear in the place of the box, but it doesn't.
The MinGW implementation of dirent that comes with CodeBlocks 10.05 has no member d_type, which is used in OSBasics.cpp. This makes building Polycode under MinGW fail.
The struct is defined as follows:
struct dirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
char d_name[FILENAME_MAX]; /* File name. */
};
Dialog says: PolycodePlayer.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
Both polyapp file and player executable are in the same directory. Also running the published template.exe using same polyapp results in crash too. Opening PolycodePlayer.exe by itself works fine, but on open of a polyapp causes an error dialog as above and returns to blank Player when dialog is closed.
Operating system: Windows XP Home SP3 32-bit
Video card: 64MB, OpenGL 1.5.7 / DirectX 7 support
Visual C++ re-distributable 10 is installed, I have tried with and without the included msvc*100.dll with no success.
Edit: Also does same thing when attempting to run a simple app built with the C++ library.
Edit2: Okay, I took a peek into default.pak, and saw there were some default vertex and fragment shaders in there. I removed all of them and then re-zipped the pak, and the polyapp ran with no error. As I suspected, this is probably a hardware issue dealing with the default shaders since OpenGL 1.5.7 doesn't support them.
Context: As described in issue #49, I had trouble creating a ScreenMesh. I tried to work around the problem with initializing ScreenMesh by creating (with a C++ polycode program) a mesh file for a totally empty mesh; then I tried loading that and operating on it. This part worked, but...
screen = PhysicsScreen(10, 60) screen:setGravity( Vector2( 0,0 ) ) polygon = Polygon() for i=0,2 do local theta = i/3 * 2 * math.pi polygon:addVertex(math.sin(theta),math.cos(theta),0) end shape = ScreenMesh("blankmesh.dat") shape:getMesh():addPolygon(polygon) shape:setColor(0.0,0.0,0.0,1.0) shape:setPosition(640/2, 400) screen:addPhysicsChild(shape, ENTITY_MESH, false)
So look, I load the blank mesh, then add (what I hope to be) one triangle to it.
When I run this I get:
11/18/11 11:37:36 PM [0x0-0x2b2cb2a].PolycodePlayer[26794] Opened entrypoint file...Tried to make a mesh collision object from a non-mesh
When I look in PolyPhysicsScreenEntity.cpp I find this outcome is possible only if dynamic_cast<ScreenMesh*>(entity) fails (where entity comes from the first argument to addPhysicsChild()). This looks like a LUA problem; I am passing in what should definitely be a ScreenMesh, but C++ is not recognizing it as such.
Ivan says "sounds like a pointer casting issue with the bindings".
Note, this was with a PolycodePlayer I built myself, as described in issue #48. I doubt this could be the problem though.
Because of issue #47, I found myself needing to distribute a polyapp via StandalonePlayer. I built an OS X StandalonePlayer from Polycode c3c534c with very minor patches. You can find the StandalonePlayer I built at http://www.glorioustrainwrecks.com/files/UnplayableAsteroidsMac.zip and source code at https://bitbucket.org/runhello/luatest . The polyapp uses the 2D physics library.
I have two separate reports that this StandalonePlayer crashes on launch with a dyld error on OS X 10.5 (Leopard). Here is a screenshot http://i.imgur.com/SNrcz.png
I have not had the opportunity to test with the stock/website StandalonePlayer, nor to test with a polyapp that does not use modules.
Player straight up quits on certain types of Lua errors.
The LUA "MouseInput" example says
"local pos = inputEvent:getMousePosition();"
then later says
"delete(pos);"
What is delete(pos) doing? When do I need to call it? It doesn't seem to be a LUA thing.
This needs to be explained either in the Polycode documentation, the Polycode tutorial describing your LUA object/binding system, a comment in the MouseINput example, or maybe all three.
The debug draw only draws the bones that don't have a parent bone.
not much else to say
Possibly to do with the included runtime DLLs.
I sat down last night with the new LUA examples in c3c534c. I witnessed the following behavior with both a self-built PolycodePlayer built from c3c534c and also the 0.8.1 PolycodePlayer on the website. I am on OS X Snow Leopard.
If I drag the polyapps I built into the PolycodePlayer, then close the polyapp and open a new one, things work.
If however I drag a polyapp into the PolycodePlayer, then drag on a second polyapp or the same one a second time, the player breaks. I see the following behavior every time:
One time, when one of the two polyapps was corrupt (i.e. not a valid zip file), I saw the additional behavior of one of the windows filling with crazy GPU uninitialized-data noise.
One crash log (I have several), from the website-download version of the player: http://vote.grumpybumpers.com/j/p/crash/Polycode%20Player_2011-11-15-092207_Andis-Macbook.crash
Screenshot of normal case: http://vote.grumpybumpers.com/j/p/crash/polyappcrash2.png
Screenshot of crazy gpu snow case: http://vote.grumpybumpers.com/j/p/crash/polyappcrash2.png
Right now it seems to be commented out.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.