Flipping Playing Cards

Everything about Expressions, MEL-Scripts and C++ Language

Flipping Playing Cards

Postby johnnyz on Thu 4. Sep 2008, 22:22

I'm working on a project that requires playing cards to flip over like when they are spread out and you flip one and there is somewhat of a domino effect. I'm reluctant to do this dynamically. I've tried using aim constraints and writing expressions on the offset without getting very far and am now at a loss as to what to try next. if anyone could help I'd greatly appreciate it.
johnnyz
 
Posts: 4
Joined: Thu 4. Sep 2008, 22:17

Re: Flipping Playing Cards

Postby boris on Mon 8. Sep 2008, 11:21

do you have a screenshot that shows a little bit more what you have achieved so far ?
boris
Administrator
 
Posts: 29
Joined: Fri 18. Apr 2008, 14:50
Location: Frankfurt / Germany

Re: Flipping Playing Cards

Postby johnnyz on Mon 8. Sep 2008, 15:31




you can see the gaps near the apex of the wave although they are present throughout the entire deck. Hope this helps explain my problem.
johnnyz
 
Posts: 4
Joined: Thu 4. Sep 2008, 22:17

Re: Flipping Playing Cards

Postby boris on Sun 14. Sep 2008, 17:14

Using an aim-cionstraint is a quick and dirty way to do this but not accurate. Depending on how fast you want your flipping-effect this might be ok..

I also think you have to script it because with expressions you can control how the "fade-off" of the flipping will occur (and this HAS to be specified since it is depending on the height and the distance of your cards)

What did you code so far ?
boris
Administrator
 
Posts: 29
Joined: Fri 18. Apr 2008, 14:50
Location: Frankfurt / Germany

Re: Flipping Playing Cards

Postby johnnyz on Mon 15. Sep 2008, 15:38

I had started by using the return value of a distance dimension node to control the offset of the aim constraint which only sort of worked and when it did it only worked when it was within a certain distance from the origin because I wrote an if statement to control the negative action of the rotation. Here's what I had.

float $locPos = group1.translateX*20;
float $cardRot = -$locPos;

pPlane1.rotateZ = $cardRot;
pPlane2.rotateZ = $cardRot;
pPlane3.rotateZ = $cardRot;
pPlane4.rotateZ = $cardRot;
pPlane5.rotateZ = $cardRot;
pPlane6.rotateZ = $cardRot;
pPlane7.rotateZ = $cardRot;
pPlane8.rotateZ = $cardRot;
pPlane9.rotateZ = $cardRot;
pPlane10.rotateZ = $cardRot;
pPlane11.rotateZ = $cardRot;
pPlane12.rotateZ = $cardRot;
pPlane13.rotateZ = $cardRot;



if (distanceDimensionShape1.distance >= 9.1 && group1.translateX <= 0)
pPlane1.rotateZ = 0;

if (distanceDimensionShape1.distance >= 9.1 && group1.translateX > 0)
pPlane1.rotateZ = -180;

if(pPlane12.rotateZ > 0)
pPlane1.rotateZ = 0;
///
if (distanceDimensionShape2.distance >= 9.1 && group1.translateX <= 0)
pPlane2.rotateZ = 0;

if (distanceDimensionShape2.distance >= 9.1 && group1.translateX > 0)
pPlane2.rotateZ = -180;

if(pPlane2.rotateZ > 0)
pPlane2.rotateZ = 0;

if(pPlane2.rotateZ < -180)
pPlane2.rotateZ = -180;
///
if (distanceDimensionShape3.distance >= 9.1 && group1.translateX <= 0)
pPlane3.rotateZ = 0;

if (distanceDimensionShape3.distance >= 9.1 && group1.translateX > 0)
pPlane3.rotateZ = -180;

if(pPlane3.rotateZ > 0)
pPlane3.rotateZ = 0;

if(pPlane3.rotateZ < -180)
pPlane3.rotateZ = -180;
///
if (distanceDimensionShape4.distance >= 9.1 && group1.translateX <= 0)
pPlane4.rotateZ = 0;

if (distanceDimensionShape4.distance >= 9.1 && group1.translateX > 0)
pPlane4.rotateZ = -180;

if(pPlane4.rotateZ > 0)
pPlane4.rotateZ = 0;

if(pPlane4.rotateZ < -180)
pPlane4.rotateZ = -180;
///
if (distanceDimensionShape5.distance >= 9.1 && group1.translateX <= 0)
pPlane5.rotateZ = 0;

if (distanceDimensionShape5.distance >= 9.1 && group1.translateX > 0)
pPlane5.rotateZ = -180;

if(pPlane5.rotateZ > 0)
pPlane5.rotateZ = 0;

if(pPlane5.rotateZ < -180)
pPlane5.rotateZ = -180;
///
if (distanceDimensionShape6.distance >= 9.1 && group1.translateX <= 0)
pPlane6.rotateZ = 0;

if (distanceDimensionShape6.distance >= 9.1 && group1.translateX > 0)
pPlane6.rotateZ = -180;

if(pPlane6.rotateZ > 0)
pPlane6.rotateZ = 0;

if(pPlane6.rotateZ < -180)
pPlane6.rotateZ = -180;
///
if (distanceDimensionShape7.distance >= 9.1 && group1.translateX <= 0)
pPlane7.rotateZ = 0;

if (distanceDimensionShape7.distance >= 9.1 && group1.translateX > 0)
pPlane7.rotateZ = -180;

if(pPlane7.rotateZ > 0)
pPlane7.rotateZ = 0;

if(pPlane7.rotateZ < -180)
pPlane7.rotateZ = -180;
///
if (distanceDimensionShape8.distance >= 9.1 && group1.translateX <= 0)
pPlane8.rotateZ = 0;

if (distanceDimensionShape8.distance >= 9.1 && group1.translateX > 0)
pPlane8.rotateZ = -180;

if(pPlane8.rotateZ > 0)
pPlane8.rotateZ = 0;

if(pPlane8.rotateZ < -180)
pPlane8.rotateZ = -180;
///
if (distanceDimensionShape9.distance >= 9.1 && group1.translateX <= 0)
pPlane9.rotateZ = 0;

if (distanceDimensionShape9.distance >= 9.1 && group1.translateX > 0)
pPlane9.rotateZ = -180;

if(pPlane9.rotateZ > 0)
pPlane9.rotateZ = 0;

if(pPlane9.rotateZ < -180)
pPlane9.rotateZ = -180;
///
if (distanceDimensionShape10.distance >= 9.1 && group1.translateX <= 0)
pPlane10.rotateZ = 0;

if (distanceDimensionShape10.distance >= 9.1 && group1.translateX > 0)
pPlane10.rotateZ = -180;

if(pPlane10.rotateZ > 0)
pPlane10.rotateZ = 0;

if(pPlane10.rotateZ < -180)
pPlane10.rotateZ = -180;
///
if (distanceDimensionShape11.distance >= 9.1 && group1.translateX <= 0)
pPlane11.rotateZ = 0;

if (distanceDimensionShape11.distance >= 9.1 && group1.translateX > 0)
pPlane11.rotateZ = -180;

if(pPlane11.rotateZ > 0)
pPlane11.rotateZ = 0;

if(pPlane11.rotateZ < -180)
pPlane11.rotateZ = -180;
///
if (distanceDimensionShape12.distance >= 9.1 && group1.translateX <= 0)
pPlane12.rotateZ = 0;

if (distanceDimensionShape12.distance >= 9.1 && group1.translateX > 0)
pPlane12.rotateZ = -180;

if(pPlane12.rotateZ > 0)
pPlane12.rotateZ = 0;

if(pPlane12.rotateZ < -180)
pPlane12.rotateZ = -180;
///
if (distanceDimensionShape13.distance >= 9.1 && group1.translateX <= 0)
pPlane13.rotateZ = 0;

if (distanceDimensionShape13.distance >= 9.1 && group1.translateX > 0)
pPlane13.rotateZ = -180;

if(pPlane13.rotateZ > 0)
pPlane13.rotateZ = 0;

if(pPlane13.rotateZ < -180)
pPlane13.rotateZ = -180;
johnnyz
 
Posts: 4
Joined: Thu 4. Sep 2008, 22:17


Return to MEL & Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

 
 
   CONTACT   |   DISCLAIMER   |   SITEMAP