Sprites and light - babylonjs

Is there a way to have a BABYLON.Sprite affected by lights just the way meshes are?
The Sprite API has access to the RGB values, so indirectly it can be done, but I'm not sure there is a better way to do this.

Hello if you want to get access to standard shades, the best way is then to use meshes with mesh.billboardMode = BABYLON.MESH.BILLBOARD_ALL
(http://doc.babylonjs.com/classes/2.3/AbstractMesh#billboardmode-number)

Related

How to generate recursive shapes like geokone.net using GL.Begin?

http://app.geokone.net/ is an open source javascript app for generating shapes (if you can look at it, it's really fast, for 5 seconds, I'm sure you'll get the idea).
It's hard for me to go through it because it's a lot of code, what is the general idea?
also, I need those shapes as GameObject with polygon collider around them (anything from 0 to 20 of them on the screen at the same time, could be different shapes also), is it even possible with GL?
would GL help me? I think GL would be fast for just 1 shape or something (as it's using recursion), but for what I want, I think drawing them in real time to a texture, then using the texture as a sprite would be faster (as I can save the sprite for shapes that are the same), or maybe I should use a shader? any other method that you can think of?
and for the algorithm itself, what is the general idea?
You don't want to use GL, look into custom mesh generation with MeshFilter. It is required for the colliders anyway.
Meshes have to be updated just once and probably will be faster than any optimisation you proposed. You might need a shader to draw it, though.
As for the algorithm, I'm afraid you have to look into it yourself or hire someone for it. StackOverflow is for helping with issues, not doing the work for you. If you need a hint, look into basic fractals

Bad openGL performance with many QGLMaterial items

in a project I want to render a lot of shapes with different colors.
I created the color of the shape with a QGLMaterial and add the shape to the QGLBuilder with this commands:
//Build SceneNode
m_lpBuilder->newSection();
...
m_lpBuilder->currentNode()->setMaterialIndex(idxMaterial); //idx in range of 0 to 1000
m_lpBuilder->currentNode()->setEffect(QGL::LitMaterial);
when I only have a few colors (QGLMaterial) the scene is rendered very fast but with a large kind of colors it is very slow.
is there a way to improve this?
I really recommend you use OpenGL directly. It will be much more obvious how much each operation costs you.
Here it's likely that Qt changes a Uniform and calls DrawArrays each time it renders with a different material, while the correct way to do this is to make the color a vertex attribute and put all your geometry into the same VAO. Perhaps it's possible to achieve with Qt, but I don't know how.

BOX2D flash game Applyforce/Apply Impulse?

I am trying to replicate this game for flash using Box2D http://www.physicsgames.net/game/Tricharge.html . I have everything fine, the only problem i am having is when the group of bubbles burst, How do i apply a uniform increase in speed like it does in the game. I have tried ApplyForce, ApplyImpulse but all i get is what looks like an explosion of balls.
It depends on which framework you are using.
One way to accomplish this is to apply a gravity vector that is specific to these objects in the upward direction.
Another way to accomplish this is to apply an elastic joint so that it's a constant acceleration.
I'm assuming you're using http://www.box2dflash.org/docs/2.0.2/manual#The_Joint_Definition. I believe that you may be able to use the mouse joint.

Flash mesh tweening/animation

Is there a way to correctly tween/animate meshes in Flash authoring tool?
Shape tweens don't recognise movement of specific vertices, don't preserve connections and generally mess things up. Shape hints are too few for any non-trivial mesh, and too much manual labor anyway.
I am trying to accomplish smooth animation between two mesh shapes, but with all the points and vertices preserved, and no new points/vertices added.
Meshes in question are strictly 2D, but I won't mind if the solution called for Actionscript/Papervision3D assistance, although the authoring of keyframe mesh states needs to be done interactively in flash authoring tool (too complex shapes/movements to code them by hand).
Ideas?
Depending on the animation, bones might help. Though you need Flash CS4 to use them.
Their available from the standard toolbar.

Generating a picture/graphic of a graph

In working on a shortest path algorithm across a network I would like to generate a picture of the network. I'd like to represent nodes (circles), links (lines), cost to traverse the link (number in the middle of the link line), and capacity of the link (number on the link line next to the node it represents) in the picture. Is there any library/software out there that would help to automate creating this picture?
I can do this manually in Visio or with some drawing application but I'd like to generate them from code as I change/tweak the network.
Sounds like a job for GraphViz , it generates graphs from a short text description file. I've used it to produce connected node graphs and I believe it should be possible to add link labels, as you require.
If you're using python, Nodebox draws pretty graphs.
One of the big problems in displaying networks like this is figuring out where to put the nodes on the display screen. If arranging nodes is logically simple given your network, then an off-the-shelf product is likely to suit your needs.
If the arrangements are much more complicated, you may have to accept a certain amount of manual intervention to get this to work with off-the-shelf stuff, or byte the bullet and program the whole thing yourself.
.NET is one choice, and once you've mastered the Graphics class it's easy to use and plenty fast for something like this. However, there are probably better languages/platforms than .NET for something graphics-oriented like this.
Update: .NET is much better for 2D graphics than I knew. The key is finding a fast workaround to the pitifully slow GetPixel() and SetPixel() methods in the Bitmap class. Once you can read and write individual pixels easily and quickly, you can do whatever you want as a programmer.
Did you by chance check out the R programming language? I'm not positive but I believe that you can make images and such out of graphs. r-project.org
There are a bunch of visualizations of various algorithms here: Algorithmics Animation Workshop

Resources