Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 27-02-2006, 12:40 PM   #1
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to detect odd or even numbers

How to Detect odd or even numbers in MEL

int $num = 1;
if ($num % 2 == 0)
print($num + " even");
else
print($num + " odd");
$num++;
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
skywola is offline   Reply With Quote
Old 27-02-2006, 11:59 PM   #2
MattTheMan
Registered User
 
MattTheMan's Avatar
 
Join Date: Apr 2005
Location: Fairfield, CT
Posts: 2,436
Thanks: 0
Thanked 18 Times in 18 Posts
Default

i dont know MEL, but I know C++, so:

cant u divide a number by 2, then store the result in a char with 8 places, then scan the char, if the char has a dot in it then its odd, if not its even.
__________________
Live the life you love, love the life you live
MattTheMan is offline   Reply With Quote
Old 28-02-2006, 05:06 AM   #3
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In MEL - no . . . . MEL is a much easier language than C++, although C++ undoubtably has more power, and more bells and whistles, so to speak.
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
skywola is offline   Reply With Quote
Old 28-02-2006, 09:00 AM   #4
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

you've done it right by using the modulus command. If you get nothing back then it's even (i think! it's a bit early in the morning for maths! )


A
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.