3D lighting + 3D Verlet Integration physics [Source]

Post your Construct-made creations!

Post » Thu Dec 30, 2010 10:08 pm

Another random programming test. 3D physics using verlet integration, and 3D lighting using vectors cross products to find normals and vector dot products to find angular differences.

Controls are mouse click and mouse wheel to manipulate.


http://dl.dropbox.com/u/1010927/Verlet%20Cube.cap

sometimes the normals flip because my physics implementation doesn't iterate for increased stability/accuracy
B
77
S
13
G
8
Posts: 1,973
Reputation: 9,891

Post » Fri Dec 31, 2010 4:06 am

Dude... seriously. Very cool!
B
3
S
1
G
4
Posts: 42
Reputation: 1,609

Post » Fri Dec 31, 2010 4:06 am

Brilliant! :)
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Dec 31, 2010 7:44 am

man, how can you come up with such stuff so quickly? :shock: brilliant!
some questions though-
I too know quite a bit about vectors but still have no idea about how to use them for lighting, any articles for help??
Meanwhile i'll search for verlet integration :)
B
9
S
3
G
3
Posts: 366
Reputation: 2,306

Post » Fri Dec 31, 2010 7:48 am

seriously impressive
Spriter Dev
B
99
S
21
G
12
Posts: 3,259
Reputation: 16,894

Post » Fri Dec 31, 2010 9:11 am

Very impressive.
Might I suggest you try turning this into a plugin once you have the dev system setup.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,374
Reputation: 58,430

Post » Fri Dec 31, 2010 12:07 pm

[quote="lucid":1g0nufwv]seriously impressive[/quote:1g0nufwv]

Indeed, frame rate is pretty much constant, even at 8x multisampling.
Image ImageImage
B
168
S
50
G
169
Posts: 8,280
Reputation: 108,189

Post » Fri Dec 31, 2010 1:33 pm

Doing something like this with events as a finger exercise - I bow deep to your wit.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Fri Dec 31, 2010 4:30 pm

HOLY (BEEP) ON A (BEEP) SANDVICH

This is freaking awesome! The things you can do with Construct are absolutely incredible! Man...
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Fri Dec 31, 2010 5:54 pm

for lighting I used two edges of the cube as vectors per face found the cross product to get a 3rd vector that gave me the normal of the cubes face, and then found the dot product of that normal vector and an unchanging "light direction vector" (specified with the variables 'Lx' 'Ly' and 'Lz') that belong to the object L (L is just an object i use to store variables, because its faster to write L than global('etc') all the time), anyways, i find the dot product using the components of the two vectors, then i find the norm of those vectors with distance formula sqrt(x^2+y^2+z^2), the norm of the light is precomputed in the variable ('Ln'). with the norms and the dot product i can get the angle between the vectors that they form in their unique plane, by dividing the dot product by the product of the two norms, and then finding the arccosine of that value. the lighting from therein is just setting the filter of the face to a scaled value of that angle difference. R=G=B=('Anglebetween'/180)*255
B
77
S
13
G
8
Posts: 1,973
Reputation: 9,891

Next

Return to Your Creations

Who is online

Users browsing this forum: No registered users and 1 guest