示例#1
0
 public static void SetProperty(string name, Orrb.RendererComponentConfig config, Vector2 value)
 {
     Orrb.Vector2 vector2 = new Orrb.Vector2();
     vector2.X = value.x;
     vector2.Y = value.y;
     config.Vector2Properties.Add(name, vector2);
 }
示例#2
0
    // Instantiate a component of a given type, name and config in the scene.
    public bool AddComponent(string type, string name, string path, Orrb.RendererComponentConfig config, bool enabled)
    {
        if (components_dictionary_.ContainsKey(name))
        {
            Logger.Error("ComponentManager::AddComponent::Component already exists: {0}.", name);
            return(false);
        }

        ComponentInstance component_instance = InstantiateComponentByType(type, name, path, enabled);

        if (component_instance == null)
        {
            Logger.Error("ComponentManager::AddComponent::Failed to instantiate component: {0} ({1}).", name, type);
            return(false);
        }

        if (!component_instance.renderer_component.InitializeComponent(config))
        {
            Logger.Error("ComponentManager::AddComponent::Failed to initialize: {0} of type: {1}.", name, type);
            return(false);
        }

        components_.Add(component_instance);
        components_dictionary_.Add(name, component_instance);

        return(true);
    }
示例#3
0
 public override bool UpdateComponent(Orrb.RendererComponentConfig config)
 {
     ConfigUtils.GetProperties(this, config);
     blacklist_prefixes_ = blacklist_prefix_.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
     whitelist_prefixes_ = whitelist_prefix_.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
     return(true);
 }
示例#4
0
 public static void SetProperty(string name, Orrb.RendererComponentConfig config, Vector3 value)
 {
     Orrb.Vector3 vector3 = new Orrb.Vector3();
     vector3.X = value.x;
     vector3.Y = value.y;
     vector3.Z = value.z;
     config.Vector3Properties.Add(name, vector3);
 }
示例#5
0
 public override bool InitializeComponent(Orrb.RendererComponentConfig config)
 {
     material_prefix_           = ConfigUtils.GetProperty("material_prefix", config, material_prefix_);
     material_blacklist_prefix_ = ConfigUtils.GetProperty("material_blacklist_prefix", config,
                                                          material_blacklist_prefix_);
     UpdateMaterialList();
     return(UpdateComponent(config));
 }
示例#6
0
 public static bool GetProperty(string name, Orrb.RendererComponentConfig config, bool default_value)
 {
     if (config != null && config.BoolProperties.ContainsKey(name))
     {
         return(config.BoolProperties[name]);
     }
     return(default_value);
 }
示例#7
0
 public override bool InitializeComponent(Orrb.RendererComponentConfig config)
 {
     // Cache the original translation, location, scale.
     original_translate_ = transform.localPosition;
     original_rotate_    = transform.localRotation;
     original_scale_     = transform.localScale;
     return(UpdateComponent(config));
 }
示例#8
0
 public static Vector2 GetProperty(string name, Orrb.RendererComponentConfig config, Vector2 default_value)
 {
     if (config != null && config.Vector2Properties.ContainsKey(name))
     {
         Orrb.Vector2 vector2 = config.Vector2Properties[name];
         return(new Vector2(vector2.X, vector2.Y));
     }
     return(default_value);
 }
示例#9
0
 public static T GetEnumProperty <T>(string name, Orrb.RendererComponentConfig config, T default_value)
     where T : struct, IConvertible
 {
     if (config != null && config.EnumProperties.ContainsKey(name))
     {
         return((T)Enum.Parse(typeof(T), config.EnumProperties[name]));
     }
     return(default_value);
 }
示例#10
0
 public static void SetProperty(string name, Orrb.RendererComponentConfig config, Color value)
 {
     Orrb.Color color = new Orrb.Color();
     color.R = value.r;
     color.G = value.g;
     color.B = value.b;
     color.A = value.a;
     config.ColorProperties.Add(name, color);
 }
示例#11
0
 public static Color GetProperty(string name, Orrb.RendererComponentConfig config, Color default_value)
 {
     if (config != null && config.ColorProperties.ContainsKey(name))
     {
         Orrb.Color color = config.ColorProperties[name];
         return(new Color(color.R, color.G, color.B, color.A));
     }
     return(default_value);
 }
示例#12
0
 public static void SetProperty(string name, Orrb.RendererComponentConfig config, Quaternion value)
 {
     Orrb.Quaternion quaternion = new Orrb.Quaternion();
     quaternion.X = value.x;
     quaternion.Y = value.y;
     quaternion.Z = value.z;
     quaternion.W = value.w;
     config.QuaternionProperties.Add(name, quaternion);
 }
示例#13
0
 public static Quaternion GetProperty(string name, Orrb.RendererComponentConfig config, Quaternion default_value)
 {
     if (config != null && config.QuaternionProperties.ContainsKey(name))
     {
         Orrb.Quaternion quaternion = config.QuaternionProperties[name];
         return(new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W));
     }
     return(default_value);
 }
示例#14
0
 public override bool UpdateComponent(Orrb.RendererComponentConfig config)
 {
     base.UpdateComponent(config);
     Clear();
     HideBodies();
     HideGeoms();
     HideSites();
     return(true);
 }
示例#15
0
 public static Vector3 GetProperty(string name, Orrb.RendererComponentConfig config, Vector3 default_value)
 {
     if (config != null && config.Vector3Properties.ContainsKey(name))
     {
         Orrb.Vector3 vector3 = config.Vector3Properties[name];
         return(new Vector3(vector3.X, vector3.Y, vector3.Z));
     }
     return(default_value);
 }
示例#16
0
 public override Orrb.RendererComponentConfig GetConfig()
 {
     Orrb.RendererComponentConfig config = base.GetConfig();
     ConfigUtils.SetProperty("mujoco_position", config, GetCameraPositionString());
     ConfigUtils.SetProperty("mujoco_rotation", config, GetCameraRotationString());
     ConfigUtils.SetProperty("mujoco_fov", config, GetCameraFovString());
     ConfigUtils.SetProperty("dactyl_camera_setup", config, GetDactylCameraSetupString());
     return(config);
 }
示例#17
0
 public override bool InitializeComponent(Orrb.RendererComponentConfig config)
 {
     // This component should be attached to an object with an actual camera.
     camera_ = GetComponent <Camera>();
     if (camera_ == null)
     {
         return(false);
     }
     return(UpdateComponent(config));
 }
示例#18
0
 public bool UpdateComponent(string name, Orrb.RendererComponentConfig config)
 {
     if (components_dictionary_.ContainsKey(name))
     {
         return(components_dictionary_[name].renderer_component.UpdateComponent(config));
     }
     else
     {
         Logger.Warning("ComponentManager::UpdateComponent::Cannot find component: {0}.", name);
         return(false);
     }
 }
示例#19
0
    public override bool UpdateComponent(Orrb.RendererComponentConfig config)
    {
        string old_camera_name = camera_name_;

        ConfigUtils.GetProperties(this, config);

        if (!camera_name_.Equals(old_camera_name))
        {
            UpdateCamera();
        }

        return(true);
    }
示例#20
0
    public override bool UpdateComponent(Orrb.RendererComponentConfig config)
    {
        int old_light_head_count = light_head_count_;

        ConfigUtils.GetProperties(this, config);

        if (old_light_head_count != light_head_count_)
        {
            BuildLightHeads();
        }

        return(true);
    }
示例#21
0
    // Cache the original camera positions, rotations and field of view values.
    public override bool InitializeComponent(Orrb.RendererComponentConfig config)
    {
        Camera[] cameras = GetComponentsInChildren <Camera>();
        foreach (Camera current_camera in cameras)
        {
            CameraState camera_state = new CameraState();
            camera_state.camera = current_camera;
            camera_state.fov    = current_camera.fieldOfView;
            camera_state.pos    = current_camera.transform.localPosition;
            camera_state.rot    = current_camera.transform.localRotation;
            initial_camera_states_.Add(camera_state);
        }

        return(UpdateComponent(config));
    }
示例#22
0
    public override bool UpdateComponent(Orrb.RendererComponentConfig config)
    {
        string old_material_prefix           = material_prefix_;
        string old_material_blacklist_prefix = material_blacklist_prefix_;

        ConfigUtils.GetProperties(this, config);

        if (!material_prefix_.Equals(old_material_prefix) ||
            !material_blacklist_prefix_.Equals(old_material_blacklist_prefix))
        {
            UpdateMaterialList();
        }

        return(true);
    }
示例#23
0
    public override bool InitializeComponent(Orrb.RendererComponentConfig config)
    {
        // Find the post processing profile first.
        PostProcessProfile profile = FindPostprocessingProfile();

        // Grab the settings we are interested in from this profile.
        profile.TryGetSettings(out color_grading_);
        profile.TryGetSettings(out bloom_);
        profile.TryGetSettings(out ambient_occlusion_);
        profile.TryGetSettings(out grain_);

        Debug.Assert(color_grading_ != null);
        Debug.Assert(bloom_ != null);
        Debug.Assert(ambient_occlusion_ != null);
        Debug.Assert(grain_ != null);

        return(base.InitializeComponent(config));
    }
示例#24
0
    public override bool InitializeComponent(Orrb.RendererComponentConfig config)
    {
        camera_names_                 = ConfigUtils.GetProperty("camera_names", config, camera_names_);
        tracked_object_names_         = ConfigUtils.GetProperty("tracked_object_names", config, tracked_object_names_);
        tracked_object_aliases_array_ = tracked_object_aliases_.Split(new char[] { ',' },
                                                                      StringSplitOptions.RemoveEmptyEntries);

        // Load the crosshair texture and the overlay material, to be used in interactive mode.
        marker_           = Resources.Load <Texture>("Marker");
        overlay_material_ = new Material(Shader.Find("Unlit/Overlay"));

        // Prepare the bounding box style from a 9-sliced background texture.
        bounding_box_texture_ = Resources.Load <Texture2D>("BoundingBox");
        bounding_box_style_   = new GUIStyle();
        bounding_box_style_.normal.background = bounding_box_texture_;
        bounding_box_style_.border            = new RectOffset(1, 1, 1, 1);

        UpdateObjectsAndCameras();
        return(UpdateComponent(config));
    }
示例#25
0
    public override bool UpdateComponent(Orrb.RendererComponentConfig config)
    {
        string old_camera_names            = camera_names_;
        string old_tracked_object_names    = tracked_object_names_;
        string old_tracked_object_aliases_ = tracked_object_aliases_;

        ConfigUtils.GetProperties(this, config);

        if (!camera_names_.Equals(old_camera_names) ||
            !tracked_object_names_.Equals(old_tracked_object_names))
        {
            UpdateObjectsAndCameras();
        }

        if (!tracked_object_aliases_.Equals(old_tracked_object_aliases_))
        {
            tracked_object_aliases_array_ = tracked_object_aliases_.Split(new char[] { ',' },
                                                                          StringSplitOptions.RemoveEmptyEntries);
        }
        return(true);
    }
示例#26
0
    public static void SetProperties(object subject, Orrb.RendererComponentConfig config)
    {
        Type utils = typeof(ConfigUtils);

        Type[]     setter_types         = new Type[] { typeof(string), typeof(Orrb.RendererComponentConfig), typeof(string) };
        object[]   setter_parameters    = { null, config, null };
        MethodInfo enum_property_setter = utils.GetMethod("SetEnumProperty");

        foreach (FieldInfo field_info in subject.GetType().GetFields())
        {
            if (field_info.IsDefined(typeof(ConfigProperty), true))
            {
                MethodInfo property_setter = null;
                if (field_info.FieldType.IsEnum)
                {
                    property_setter = enum_property_setter.MakeGenericMethod(field_info.FieldType);
                }
                else
                {
                    setter_types[2] = field_info.FieldType;
                    property_setter = utils.GetMethod("SetProperty", setter_types);
                }

                if (property_setter == null)
                {
                    Logger.Error("Cannot get property setter for: {0}.", field_info.FieldType);
                }
                else
                {
                    setter_parameters[0] = GetPropertyName(field_info.Name);
                    setter_parameters[2] = field_info.GetValue(subject);
                    property_setter.Invoke(null, setter_parameters);
                }
            }
        }
    }
示例#27
0
 public override bool InitializeComponent(Orrb.RendererComponentConfig config)
 {
     camera_name_ = ConfigUtils.GetProperty("camera_name", config, camera_name_);
     UpdateCamera();
     return(UpdateComponent(config));
 }
示例#28
0
 public virtual bool InitializeComponent(Orrb.RendererComponentConfig config)
 {
     return(UpdateComponent(config));
 }
示例#29
0
 // By default just pull the configurable properties from the config.
 public virtual bool UpdateComponent(Orrb.RendererComponentConfig config)
 {
     ConfigUtils.GetProperties(this, config);
     return(true);
 }
示例#30
0
 public virtual Orrb.RendererComponentConfig GetConfig()
 {
     Orrb.RendererComponentConfig config = new Orrb.RendererComponentConfig();
     ConfigUtils.SetProperties(this, config);
     return(config);
 }