Re: [osg-users] Maya2OSG patches

2011-05-25 Thread Ryan Pavlik
The replacement of that inline function with a macro removes the type-safety
offered by C++ and makes the code more accident prone.  I did the
static-casts with the multiple parameters because the parameters to the
function aren't necessarily always the same type. Looking into it further, a
single parameter, which is manually specified when in doubt, seems to be the
smartest solution, since it makes it explicit at the point of the call what
precision is being used when it is ambiguous. I've attached files for an
updated function which combines the best of all solutions so far: template
function with a single parameter, body uses osg::absolute to simplify
expression, and one explicit specification of the template parameter in
calling code. Simpler and more explicit all around, I think - hopefully this
will be acceptable. It build cleanly here: windows, vc9, maya 2012 x64

Ryan

On Tue, May 24, 2011 at 5:20 PM, Javier Taibo javier.ta...@gmail.comwrote:

  Thanks for the fixes. Changes are now committed to svn trunk.

  About the second issue, it seems a much complicated piece of code
 for what it's doing. I suggest this lighter and cleaner alternative
 instead of a template with three different typename parameters and the
 huge expression with four static_cast.

 #define inTolerance(base, match, tolerance) (
 osg::absolute((base)-(match))  tolerance )

  However, this part of the code was written by Peter Particle, so
 I'll redirect to him both proposals.

  Meanwhile, can you test if it is working for you right now?


  Regards,


 On Tue, May 24, 2011 at 11:08 PM, Ryan Pavlik rpav...@iastate.edu wrote:
  The changes to osgpreview.cpp are for the first issue, while the changes
 to
  utility.h are for the second way of solving the second issue.
  Ryan
 
  On Tue, May 24, 2011 at 12:59 PM, Javier Taibo javier.ta...@gmail.com
  wrote:
 
   Hi Ryan,
 
   Thank you for the patches. Can you send the whole files instead of
  patches, please? You can zip all files together to make it easy.
 
   Thank you!
 
 
   Best Regards,
 
 
  On Tue, May 24, 2011 at 7:28 PM, Ryan Pavlik rpav...@iastate.edu
 wrote:
   Hello all,
   I've attached small patches to two issues I've found with Maya2OSG.
   One allows it to build successfully with the current 2.8 branch -
 there
   are
   some manipulators not available in this branch so we just disable them
   by
   checking the osg version.
   The other issue was ambiguity in calling inTolerance, preventing me
 from
   building successfully on VC9 x64.  I solved this two different ways:
   take
   your pick of which way you prefer.
  
   I've made inTolerance a template function with a single parameter type
   and
   explicitly specified the template parameter in the one case.
   (fix-vc9-build)
   inTolerance is a template function with three parameter types, and
   static_casts all arguments to the type of the tolerance parameter
 before
   doing math.  This one doesn't require explicit template param
   specification,
   and seems more correct to me, or at least more explicit in how it
   works. I
   personally prefer this one. (alternate-fix-build)
  
   These patches were made against the latest svn trunk of maya2osg using
   tortoisesvn.
   Ryan
   --
   Ryan Pavlik
   HCI Graduate Student
   Virtual Reality Applications Center
   Iowa State University
  
   rpav...@iastate.edu
   http://academic.cleardefinition.com
  
   ___
   osg-users mailing list
   osg-users@lists.openscenegraph.org
  
  
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
  
  
 
 
 
  --
  Javier Taibo
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 
  --
  Ryan Pavlik
  HCI Graduate Student
  Virtual Reality Applications Center
  Iowa State University
 
  rpav...@iastate.edu
  http://academic.cleardefinition.com
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 



 --
 Javier Taibo
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpav...@iastate.edu
http://academic.cleardefinition.com
#ifndef _ANIMATION_H_
#define _ANIMATION_H_


#include utility.h


// - Maya ---
#include maya/MTime.h
//#include maya/MDagNode.h
//#include maya/MDagPath.h
#include maya/MIntArray.h
#include maya/MPlugArray.h
#include maya/MAnimControl.h
#include maya/MDoubleArray.h
#include maya/MObjectArray.h
#include maya/MStringArray.h


// - OSG 

Re: [osg-users] Maya2OSG patches

2011-05-25 Thread Javier Taibo
  It's far more readable :)  Thanks for the changes. They are
submitted to svn trunk.


  Regards,

On Wed, May 25, 2011 at 4:50 PM, Ryan Pavlik rpav...@iastate.edu wrote:
 The replacement of that inline function with a macro removes the type-safety
 offered by C++ and makes the code more accident prone.  I did the
 static-casts with the multiple parameters because the parameters to the
 function aren't necessarily always the same type. Looking into it further, a
 single parameter, which is manually specified when in doubt, seems to be the
 smartest solution, since it makes it explicit at the point of the call what
 precision is being used when it is ambiguous. I've attached files for an
 updated function which combines the best of all solutions so far: template
 function with a single parameter, body uses osg::absolute to simplify
 expression, and one explicit specification of the template parameter in
 calling code. Simpler and more explicit all around, I think - hopefully this
 will be acceptable. It build cleanly here: windows, vc9, maya 2012 x64
 Ryan

 On Tue, May 24, 2011 at 5:20 PM, Javier Taibo javier.ta...@gmail.com
 wrote:

  Thanks for the fixes. Changes are now committed to svn trunk.

  About the second issue, it seems a much complicated piece of code
 for what it's doing. I suggest this lighter and cleaner alternative
 instead of a template with three different typename parameters and the
 huge expression with four static_cast.

 #define inTolerance(base, match, tolerance) (
 osg::absolute((base)-(match))  tolerance )

  However, this part of the code was written by Peter Particle, so
 I'll redirect to him both proposals.

  Meanwhile, can you test if it is working for you right now?


  Regards,


 On Tue, May 24, 2011 at 11:08 PM, Ryan Pavlik rpav...@iastate.edu wrote:
  The changes to osgpreview.cpp are for the first issue, while the changes
  to
  utility.h are for the second way of solving the second issue.
  Ryan
 
  On Tue, May 24, 2011 at 12:59 PM, Javier Taibo javier.ta...@gmail.com
  wrote:
 
   Hi Ryan,
 
   Thank you for the patches. Can you send the whole files instead of
  patches, please? You can zip all files together to make it easy.
 
   Thank you!
 
 
   Best Regards,
 
 
  On Tue, May 24, 2011 at 7:28 PM, Ryan Pavlik rpav...@iastate.edu
  wrote:
   Hello all,
   I've attached small patches to two issues I've found with Maya2OSG.
   One allows it to build successfully with the current 2.8 branch -
   there
   are
   some manipulators not available in this branch so we just disable
   them
   by
   checking the osg version.
   The other issue was ambiguity in calling inTolerance, preventing me
   from
   building successfully on VC9 x64.  I solved this two different ways:
   take
   your pick of which way you prefer.
  
   I've made inTolerance a template function with a single parameter
   type
   and
   explicitly specified the template parameter in the one case.
   (fix-vc9-build)
   inTolerance is a template function with three parameter types, and
   static_casts all arguments to the type of the tolerance parameter
   before
   doing math.  This one doesn't require explicit template param
   specification,
   and seems more correct to me, or at least more explicit in how it
   works. I
   personally prefer this one. (alternate-fix-build)
  
   These patches were made against the latest svn trunk of maya2osg
   using
   tortoisesvn.
   Ryan
   --
   Ryan Pavlik
   HCI Graduate Student
   Virtual Reality Applications Center
   Iowa State University
  
   rpav...@iastate.edu
   http://academic.cleardefinition.com
  
   ___
   osg-users mailing list
   osg-users@lists.openscenegraph.org
  
  
   http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
  
  
 
 
 
  --
  Javier Taibo
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 
  --
  Ryan Pavlik
  HCI Graduate Student
  Virtual Reality Applications Center
  Iowa State University
 
  rpav...@iastate.edu
  http://academic.cleardefinition.com
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 



 --
 Javier Taibo
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



 --
 Ryan Pavlik
 HCI Graduate Student
 Virtual Reality Applications Center
 Iowa State University

 rpav...@iastate.edu
 http://academic.cleardefinition.com

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





-- 
Javier Taibo

Re: [osg-users] Maya2OSG patches

2011-05-24 Thread Javier Taibo
  Hi Ryan,

  Thank you for the patches. Can you send the whole files instead of
patches, please? You can zip all files together to make it easy.

  Thank you!


  Best Regards,


On Tue, May 24, 2011 at 7:28 PM, Ryan Pavlik rpav...@iastate.edu wrote:
 Hello all,
 I've attached small patches to two issues I've found with Maya2OSG.
 One allows it to build successfully with the current 2.8 branch - there are
 some manipulators not available in this branch so we just disable them by
 checking the osg version.
 The other issue was ambiguity in calling inTolerance, preventing me from
 building successfully on VC9 x64.  I solved this two different ways: take
 your pick of which way you prefer.

 I've made inTolerance a template function with a single parameter type and
 explicitly specified the template parameter in the one case. (fix-vc9-build)
 inTolerance is a template function with three parameter types, and
 static_casts all arguments to the type of the tolerance parameter before
 doing math.  This one doesn't require explicit template param specification,
 and seems more correct to me, or at least more explicit in how it works. I
 personally prefer this one. (alternate-fix-build)

 These patches were made against the latest svn trunk of maya2osg using
 tortoisesvn.
 Ryan
 --
 Ryan Pavlik
 HCI Graduate Student
 Virtual Reality Applications Center
 Iowa State University

 rpav...@iastate.edu
 http://academic.cleardefinition.com

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





-- 
Javier Taibo
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Maya2OSG patches

2011-05-24 Thread Ryan Pavlik
The changes to osgpreview.cpp are for the first issue, while the changes to
utility.h are for the second way of solving the second issue.

Ryan

On Tue, May 24, 2011 at 12:59 PM, Javier Taibo javier.ta...@gmail.comwrote:

  Hi Ryan,

  Thank you for the patches. Can you send the whole files instead of
 patches, please? You can zip all files together to make it easy.

  Thank you!


  Best Regards,


 On Tue, May 24, 2011 at 7:28 PM, Ryan Pavlik rpav...@iastate.edu wrote:
  Hello all,
  I've attached small patches to two issues I've found with Maya2OSG.
  One allows it to build successfully with the current 2.8 branch - there
 are
  some manipulators not available in this branch so we just disable them by
  checking the osg version.
  The other issue was ambiguity in calling inTolerance, preventing me from
  building successfully on VC9 x64.  I solved this two different ways: take
  your pick of which way you prefer.
 
  I've made inTolerance a template function with a single parameter type
 and
  explicitly specified the template parameter in the one case.
 (fix-vc9-build)
  inTolerance is a template function with three parameter types, and
  static_casts all arguments to the type of the tolerance parameter before
  doing math.  This one doesn't require explicit template param
 specification,
  and seems more correct to me, or at least more explicit in how it
 works. I
  personally prefer this one. (alternate-fix-build)
 
  These patches were made against the latest svn trunk of maya2osg using
  tortoisesvn.
  Ryan
  --
  Ryan Pavlik
  HCI Graduate Student
  Virtual Reality Applications Center
  Iowa State University
 
  rpav...@iastate.edu
  http://academic.cleardefinition.com
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 



 --
 Javier Taibo
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpav...@iastate.edu
http://academic.cleardefinition.com
/**
Maya2OSG - A toolkit for exporting Maya scenes to OpenSceneGraph
Copyright (C) 2010-2011 Javier Taibo javier.ta...@gmail.com

This file is part of Maya2OSG.

Maya2OSG is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Maya2OSG is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Maya2OSG.  If not, see http://www.gnu.org/licenses/.
*/

// This is previewer is a modified version of OSG application osgviewer

#include osgpreview.h
#include version.h

#include maya/MArgList.h
#include maya/MStringArray.h

#include osg/Version
#include osgDB/ReadFile
#include osgUtil/Optimizer
#include osg/CoordinateSystemNode

#include osg/Switch
#include osgText/Text

#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers

#include osgGA/TrackballManipulator
#include osgGA/FlightManipulator
#include osgGA/DriveManipulator
#include osgGA/KeySwitchMatrixManipulator
#include osgGA/StateSetManipulator
#include osgGA/AnimationPathManipulator
#include osgGA/TerrainManipulator
#if OSG_MIN_VERSION_REQUIRED(2,9,5)
#include osgGA/OrbitManipulator
#include osgGA/SphericalManipulator
#endif


void* OSGPreview::creator()
{
	return new OSGPreview();
}

MStatus OSGPreview::doIt( const MArgList  args )
{
	MStringArray argStringArray;
	for( unsigned int i = 0 ; i  args.length() ; ++i ) {
		argStringArray.append( args.asString( i ) ) ;
	}

	int argc = args.length() + 1;
	char **argv = (char **)malloc(argc * sizeof(char *));
	argv[0] = osgpreview;

	argStringArray.get(argv+1);
osg::ArgumentParser arguments(argc, argv);

osgViewer::Viewer viewer(arguments);

unsigned int helpType = 0;
if ((helpType = arguments.readHelpType()))
{
arguments.getApplicationUsage()-write(std::cout, helpType);
return MStatus::kFailure;
}

// report any errors if they have occurred when parsing the program arguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return MStatus::kFailure;
}

if (arguments.argc()=1)
{
arguments.getApplicationUsage()-write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return MStatus::kFailure;
}

std::string url, username, password;
while(arguments.read(--login,url, username, password))
{
if 

Re: [osg-users] Maya2OSG patches

2011-05-24 Thread Javier Taibo
  Thanks for the fixes. Changes are now committed to svn trunk.

  About the second issue, it seems a much complicated piece of code
for what it's doing. I suggest this lighter and cleaner alternative
instead of a template with three different typename parameters and the
huge expression with four static_cast.

#define inTolerance(base, match, tolerance) (
osg::absolute((base)-(match))  tolerance )

  However, this part of the code was written by Peter Particle, so
I'll redirect to him both proposals.

  Meanwhile, can you test if it is working for you right now?


  Regards,


On Tue, May 24, 2011 at 11:08 PM, Ryan Pavlik rpav...@iastate.edu wrote:
 The changes to osgpreview.cpp are for the first issue, while the changes to
 utility.h are for the second way of solving the second issue.
 Ryan

 On Tue, May 24, 2011 at 12:59 PM, Javier Taibo javier.ta...@gmail.com
 wrote:

  Hi Ryan,

  Thank you for the patches. Can you send the whole files instead of
 patches, please? You can zip all files together to make it easy.

  Thank you!


  Best Regards,


 On Tue, May 24, 2011 at 7:28 PM, Ryan Pavlik rpav...@iastate.edu wrote:
  Hello all,
  I've attached small patches to two issues I've found with Maya2OSG.
  One allows it to build successfully with the current 2.8 branch - there
  are
  some manipulators not available in this branch so we just disable them
  by
  checking the osg version.
  The other issue was ambiguity in calling inTolerance, preventing me from
  building successfully on VC9 x64.  I solved this two different ways:
  take
  your pick of which way you prefer.
 
  I've made inTolerance a template function with a single parameter type
  and
  explicitly specified the template parameter in the one case.
  (fix-vc9-build)
  inTolerance is a template function with three parameter types, and
  static_casts all arguments to the type of the tolerance parameter before
  doing math.  This one doesn't require explicit template param
  specification,
  and seems more correct to me, or at least more explicit in how it
  works. I
  personally prefer this one. (alternate-fix-build)
 
  These patches were made against the latest svn trunk of maya2osg using
  tortoisesvn.
  Ryan
  --
  Ryan Pavlik
  HCI Graduate Student
  Virtual Reality Applications Center
  Iowa State University
 
  rpav...@iastate.edu
  http://academic.cleardefinition.com
 
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
 
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 



 --
 Javier Taibo
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



 --
 Ryan Pavlik
 HCI Graduate Student
 Virtual Reality Applications Center
 Iowa State University

 rpav...@iastate.edu
 http://academic.cleardefinition.com

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





-- 
Javier Taibo
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org