Esempio n. 1
0
        public ViewerForm( GeneratorForm _Owner )
        {
            InitializeComponent();
            m_Owner = _Owner;

            // Setup camera
            m_Camera.CreatePerspectiveCamera( (float) (60.0 * Math.PI / 180.0), (float) Width / Height, 0.01f, 100.0f );
            m_Manipulator.Attach( this, m_Camera );
            m_Manipulator.InitializeCamera( new float3( 0, 1, 1 ), new float3( 0, 0, 0 ), float3.UnitY );
            m_Camera.CameraTransformChanged += new EventHandler( Camera_CameraTransformChanged );
            m_Manipulator.EnableMouseAction += new CameraManipulator.EnableMouseActionEventHandler( m_Manipulator_EnableMouseAction );
            //			Camera_CameraTransformChanged( m_Manipulator, EventArgs.Empty );

            Application.Idle += new EventHandler( Application_Idle );
        }
Esempio n. 2
0
        public ViewerForm(GeneratorForm _Owner)
        {
            InitializeComponent();
            m_Owner = _Owner;

            // Setup camera
            m_Camera.CreatePerspectiveCamera((float)(60.0 * Math.PI / 180.0), (float)Width / Height, 0.01f, 100.0f);
            m_Manipulator.Attach(this, m_Camera);
            m_Manipulator.InitializeCamera(new float3(0, 1, 1), new float3(0, 0, 0), float3.UnitY);
            m_Camera.CameraTransformChanged += new EventHandler(Camera_CameraTransformChanged);
            m_Manipulator.EnableMouseAction += new CameraManipulator.EnableMouseActionEventHandler(m_Manipulator_EnableMouseAction);
//			Camera_CameraTransformChanged( m_Manipulator, EventArgs.Empty );

            Application.Idle += new EventHandler(Application_Idle);
        }
Esempio n. 3
0
        static void Main(string[] _args)
        {
// _args = new string[] {
//  "-height",
//  "../Example/heights.tga",
//  "-normal",
//  "../Example/normals.tga",
//  "-ao",
//  "../Example/occlusion3.png",
//  "-texsize",
//  "100",
//  "-dispsize",
//  "100",
//  "-rayscount",
//  "100",
//  "-range",
//  "10",
//  "-coneangle",
//  "180",
//  "-clamp",
//  "-bilateralRadius",
//  "4.0",
//  "-bilateralTolerance",
//  "0.2",
// };



            if (_args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GeneratorForm());
                return;
            }

            // Attach to command console
            AttachConsole(ATTACH_PARENT_PROCESS);

            // Arguments-driven generation
            GeneratorForm.BuildArguments buildArgs = new GeneratorForm.BuildArguments();
            try {
                for (int i = 0; i < _args.Length; i++)
                {
                    string arg = _args[i].ToLower().Trim();
                    if (arg.Length < 2)
                    {
                        throw new Exception("Invalid argument at position " + i);
                    }
                    if (arg[0] != '-')
                    {
                        throw new Exception("Argument \"" + arg + "\" missing heading '-' character");
                    }

                    switch (arg.Substring(1))
                    {
                    case "height":
                        buildArgs.heightMapFileName = ReadNextArg(_args, ref i);
                        break;

                    case "normal":
                        buildArgs.normalMapFileName = ReadNextArg(_args, ref i);
                        break;

                    case "ao":
                        buildArgs.AOMapFileName = ReadNextArg(_args, ref i);
                        break;

                    case "texsize":
                        buildArgs.textureSize_cm = ReadFloatArg(_args, ref i);
                        break;

                    case "dispsize":
                        buildArgs.displacementSize_cm = ReadFloatArg(_args, ref i);
                        break;

                    case "rayscount":
                        buildArgs.raysCount = ReadIntArg(_args, ref i);
                        break;

                    case "range":
                        buildArgs.searchRange = ReadIntArg(_args, ref i);
                        break;

                    case "coneangle":
                        buildArgs.coneAngle = ReadFloatArg(_args, ref i);
                        break;

                    case "clamp":
                        buildArgs.tile = false;
                        break;

                    case "bilateralradius":
                        buildArgs.bilateralRadius = ReadFloatArg(_args, ref i);
                        break;

                    case "bilateraltolerance":
                        buildArgs.bilateralTolerance = ReadFloatArg(_args, ref i);
                        break;

                    default:
                        throw new Exception("Unrecognized argument \"" + arg + "\" at position " + i);
                    }
                }

                if (buildArgs.heightMapFileName == null)
                {
                    throw new Exception("You failed to provide the mandatory height map name to generate AO for...");
                }
                if (buildArgs.AOMapFileName == null)
                {
                    throw new Exception("You failed to provide the mandatory target AO map name to save the results to...");
                }
            }
            catch (Exception _e) {
                Console.WriteLine("Unexpected argument parsing error: " + _e.Message + "\r\n\r\n"
                                  + "Usage: GenerateAmbientOcclusionMap.exe"
                                  + " -height \"path/to/heightmap\""
                                  + " -ao \"path/to/target/aomap\""
                                  + " [-normal \"path/to/normalmap\"]"
                                  + " [-texSize <physical texture size, in centimeters>]"
                                  + " [-dispSize <displacement size encoded by height map, in centimeters>]"
                                  + " [-raysCount <amount of rays per pixel>]"
                                  + " [-range <search range, in pixels>]"
                                  + " [-coneAngle <search cone aperture angle, in degrees>]"
                                  + " [-clamp]"
                                  + " [-bilateralRadius <bilateral filtering radius, in pixels>]"
                                  + " [-bilateralTolerance <bilateral filtering height tolerance>]"
                                  );
                return;
            }

            try {
                GeneratorForm F = new GeneratorForm();
                F.Build(buildArgs);
            } catch (Exception _e) {
                Console.WriteLine("An error occurred during AO map generation: " + _e.Message + "\r\n");
            }
        }
Esempio n. 4
0
        static void Main( string[] _args )
        {
            // _args = new string[] {
            // 	"-height",
            // 	"../Example/heights.tga",
            // 	"-normal",
            // 	"../Example/normals.tga",
            // 	"-ao",
            // 	"../Example/occlusion3.png",
            // 	"-texsize",
            // 	"100",
            // 	"-dispsize",
            // 	"100",
            // 	"-rayscount",
            // 	"100",
            // 	"-range",
            // 	"10",
            // 	"-coneangle",
            // 	"180",
            // 	"-clamp",
            // 	"-bilateralRadius",
            // 	"4.0",
            // 	"-bilateralTolerance",
            // 	"0.2",
            // };

            if ( _args.Length == 0 ) {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault( false );
                Application.Run( new GeneratorForm() );
                return;
            }

            // Attach to command console
            AttachConsole( ATTACH_PARENT_PROCESS );

            // Arguments-driven generation
            GeneratorForm.BuildArguments	buildArgs = new GeneratorForm.BuildArguments();
            try {
                for ( int i=0; i < _args.Length; i++ ) {
                    string	arg = _args[i].ToLower().Trim();
                    if ( arg.Length < 2 )
                        throw new Exception( "Invalid argument at position " + i );
                    if ( arg[0] != '-' )
                        throw new Exception( "Argument \"" + arg + "\" missing heading '-' character" );

                    switch ( arg.Substring( 1 ) ) {
                        case "height":
                            buildArgs.heightMapFileName = ReadNextArg( _args, ref i );
                            break;
                        case "normal":
                            buildArgs.normalMapFileName = ReadNextArg( _args, ref i );
                            break;
                        case "ao":
                            buildArgs.AOMapFileName = ReadNextArg( _args, ref i );
                            break;
                        case "texsize":
                            buildArgs.textureSize_cm = ReadFloatArg( _args, ref i );
                            break;
                        case "dispsize":
                            buildArgs.displacementSize_cm = ReadFloatArg( _args, ref i );
                            break;
                        case "rayscount":
                            buildArgs.raysCount = ReadIntArg( _args, ref i );
                            break;
                        case "range":
                            buildArgs.searchRange = ReadIntArg( _args, ref i );
                            break;
                        case "coneangle":
                            buildArgs.coneAngle = ReadFloatArg( _args, ref i );
                            break;
                        case "clamp":
                            buildArgs.tile = false;
                            break;
                        case "bilateralradius":
                            buildArgs.bilateralRadius = ReadFloatArg( _args, ref i );
                            break;
                        case "bilateraltolerance":
                            buildArgs.bilateralTolerance = ReadFloatArg( _args, ref i );
                            break;

                        default:
                            throw new Exception( "Unrecognized argument \"" + arg + "\" at position " + i );
                    }
                }

                if ( buildArgs.heightMapFileName == null )
                    throw new Exception( "You failed to provide the mandatory height map name to generate AO for..." );
                if ( buildArgs.AOMapFileName == null )
                    throw new Exception( "You failed to provide the mandatory target AO map name to save the results to..." );
            }
            catch ( Exception _e ) {
                Console.WriteLine( "Unexpected argument parsing error: " + _e.Message + "\r\n\r\n"
                    + "Usage: GenerateAmbientOcclusionMap.exe"
                    + " -height \"path/to/heightmap\""
                    + " -ao \"path/to/target/aomap\""
                    + " [-normal \"path/to/normalmap\"]"
                    + " [-texSize <physical texture size, in centimeters>]"
                    + " [-dispSize <displacement size encoded by height map, in centimeters>]"
                    + " [-raysCount <amount of rays per pixel>]"
                    + " [-range <search range, in pixels>]"
                    + " [-coneAngle <search cone aperture angle, in degrees>]"
                    + " [-clamp]"
                    + " [-bilateralRadius <bilateral filtering radius, in pixels>]"
                    + " [-bilateralTolerance <bilateral filtering height tolerance>]"
                    );
                return;
            }

            try {
                GeneratorForm	F = new GeneratorForm();
                F.Build( buildArgs );
            } catch ( Exception _e ) {
                Console.WriteLine( "An error occurred during AO map generation: " + _e.Message + "\r\n" );
            }
        }