Rajawali / Rajawali

Android OpenGL ES 2.0/3.0 Engine
https://rajawali.github.io/Rajawali/
Other
2.34k stars 701 forks source link

First Rajawali project. Rags and Flags LWP #631

Closed Fossor closed 11 years ago

Fossor commented 11 years ago

Hi there! This is my first Rajawali live wallpaper. Kinda rushed to publish it on Google, without too much QA. So use it at your own risk, cause bugs and lags are possible ;) https://play.google.com/store/apps/details?id=com.fossor.ragsandflags promo

Oh, and thank you guys for a great engine and support! You are awesome!

ToxicBakery commented 11 years ago

Well done, I really like it.

MasDennis commented 11 years ago

Great, I absolutely love it. Did you do the physics yourself? How long did it take you?

Thanks for mentioning Rajawali by the way :thumbsup:

Oh, and please put it on the Wiki page. But be modest with the size of the image please :)

Fossor commented 11 years ago

Thanks guys! MasDennis, I took physics from some 2d example, it's called "verlet integration", there are couple of demos in different languages here and there, added Z coordinate and translated it onto a plane. Took me around 3 weeks (I am really bad with Java and Android).

alenko commented 11 years ago

So you used in shader a for loop, isnt that bad for GL ES?

else, this is very nice and very very nice LWP ;)

AndrewJo commented 11 years ago

Depends on the device. Smart GPUs will automatically unroll loops when it compiles the shader these days. Ones that hiccups are the Tegra GPUs from my experience. (And @Davhed can attest to that as well)

alenko commented 11 years ago

So only on tegra devices for loops ar bad bad. Like Nexus 7?

Fossor commented 11 years ago

alenko, hadn't used shaders :) Physics are a pure CPU here.

alenko commented 11 years ago

can u explain me? :)

Fossor commented 11 years ago

alenko, yep! There is a Rajawali plane that consists of a number of vertical and horizontal segments. And there is also a separate array of objects that represents each vertex of a Rajawali plane. Physics (a number of rules, like gravity, constraints, touch events etc.) are working on this array. After each physics iteration new coordinates are translated onto a plane through its vertex buffer.

androidder commented 11 years ago

Wow nice! Is it hard to make a sphere+flag /cloth/ collision? Some tutorial would be nice on this :)

Fossor commented 11 years ago

androidder, thanks! Collisions are heavy for a real time. Here is some explanation of verlet integration: http://gamedev.tutsplus.com/tutorials/implementation/simulate-fabric-and-ragdolls-with-simple-verlet-integration/

alenko commented 11 years ago

and u push this calculations into shader right?

Fossor commented 11 years ago

alenko, nope :) Directly on a plane.

vertBuffer = plane.getGeometry().getVertices(); int index = 0; for (int i = 0; i < vertBuffer.capacity(); i += 3) { vertBuffer.put(i, vertices.get(index).x); vertBuffer.put(i + 1, vertices.get(index).y); vertBuffer.put(i + 2, vertices.get(index).z); index++; } plane.getGeometry().changeBufferData(plane.getGeometry().getVertexBufferInfo(), vertBuffer, 0, vertBuffer.limit());

alenko commented 11 years ago

will try to figure out ;)

plane.getGeometry().changeBufferData(plane.getGeometry().getVertexBufferInfo(), vertBuffer, 0, vertBuffer.limit()); this is setting the vertices?

Fossor commented 11 years ago

Yes, this line updates vertex buffer