Example #1
0
        //barycentricCoordinate	The barycentric coordinate of the triangle we hit. // RESEARCH: are there any equivalents to triangles I should be creating?
        //lightmapCoord	The uv lightmap coordinate at the impact point.
        //textureCoord	The uv texture coordinate at the collision location.
        //textureCoord2	The secondary uv texture coordinate at the impact point.
        //triangleIndex	The index of the triangle that was hit.

        /// <summary>
        /// Constructor - creates the Planetaria equivalent of UnityEngine.RaycastHit
        /// </summary>
        /// <param name="raycast_arc">The path along which the raycast (inverse path for negative distances).</param>
        /// <param name="geometry_arc">The arc which intersects the raycast (i.e. the arc hit).</param>
        /// <param name="intersection_point">The intersection point of two circular arcs in 3D space.</param>
        /// <returns>The result of a point sweep / raycast in spherical 2D space.</returns>
        private PlanetariaRaycastHit(Arc raycast_arc, PlanetariaCollider planetaria_collider, Arc geometry_arc, Vector3 intersection_point, float raycast_distance)
        {
            arc      = geometry_arc;
            collider = planetaria_collider;

            distance  = raycast_arc.position_to_angle(intersection_point) * (raycast_arc.length() / raycast_arc.angle()); // TODO: verify
            distance += raycast_arc.length() / 2;
            if (raycast_distance < 0)
            {
                distance = raycast_arc.length() - distance;
            }
            positive_face_collision = true; // FIXME: HACK: LAZY: // also dynamic changes

            Transform  internal_transform = collider.gameObject.internal_game_object.GetComponent <Transform>();
            Quaternion arc_to_world       = internal_transform.rotation;
            Quaternion world_to_arc       = Quaternion.Inverse(arc_to_world);

            Vector3 local_intersection_point = world_to_arc * intersection_point;
            float   angle        = raycast_arc.position_to_angle(local_intersection_point);
            Vector3 local_normal = raycast_arc.normal(angle);

            normal    = arc_to_world * local_normal;
            point     = intersection_point;
            rigidbody = collider.GetComponent <PlanetariaRigidbody>();
            transform = Miscellaneous.GetOrAddComponent <PlanetariaTransform>(collider);
        }
Example #2
0
        // FIXME: For now, VolumeRenderer can draw the Mesh asset without alteration, but when zoom is implemented a flatten mesh shader will have to be implemented *with respect to (0,0,0), not the camera's position*

        protected sealed override void set_renderer()
        {
            if (internal_renderer == null)
            {
                internal_renderer = Miscellaneous.GetOrAddComponent <MeshRenderer>(internal_transform);
            }
            if (internal_mesh_filter == null)
            {
                internal_mesh_filter = Miscellaneous.GetOrAddComponent <MeshFilter>(internal_transform);
            }
            internal_renderer.sharedMaterial = material;
            internal_mesh_filter.sharedMesh  = mesh;
        }
Example #3
0
        protected sealed override void set_renderer()
        {
            if (internal_renderer == null)
            {
                internal_renderer = Miscellaneous.GetOrAddComponent <LineRenderer>(internal_transform);
            }
            internal_renderer.sharedMaterial = material;
            LineRenderer line_renderer = internal_transform.GetComponent <LineRenderer>();

            line_renderer.alignment  = LineAlignment.View; // both options suck, but this one renders on both sides (the right shader could fix it, but it's not gonna work well no matter what)
            line_renderer.startWidth = line_renderer.endWidth = angular_width;
            recalculate();
        }
Example #4
0
 private void initialize()
 {
     if (internal_camera == null)
     {
         GameObject dolly = this.GetOrAddChild("CameraDolly");
         dolly_transform = dolly.GetComponent <Transform>();
         Miscellaneous.GetOrAddComponent <AudioListener>(dolly);
         GameObject camera_object = dolly.transform.GetOrAddChild("Camera");
         internal_camera = Miscellaneous.GetOrAddComponent <Camera>(camera_object);
     }
     XRDevice.SetTrackingSpaceType(TrackingSpaceType.Stationary);
     dolly_transform.localPosition = Vector3.forward * zoom;
     dolly_transform.localScale    = Vector3.zero; // sets interpupillary  distance (IPD) to zero so there is no eye distance and therefore no depth // TODO: I thought there was something wrong with this
     initialize_camera(internal_camera, new Rect(0, 0, 1, 1), 1);
 }
Example #5
0
        protected sealed override void set_renderer()
        {
            if (internal_renderer == null)
            {
                internal_renderer = Miscellaneous.GetOrAddComponent <SpriteRenderer>(internal_transform);
            }
            if (sprite_renderer == null)
            {
                sprite_renderer = Miscellaneous.GetOrAddComponent <SpriteRenderer>(internal_transform);
            }
            internal_renderer.sharedMaterial = material;

            SpriteRenderer renderer = Miscellaneous.GetOrAddComponent <SpriteRenderer>(internal_transform);

            renderer.sprite = sprite;
        }
Example #6
0
 private void initialize()
 {
     if (internal_transform == null)
     {
         internal_transform = gameObject.internal_game_object.GetComponent <Transform>();
     }
     //collider = this.GetOrAddComponent<PlanetariaCollider>();
     if (internal_rigidbody == null)
     {
         internal_rigidbody = Miscellaneous.GetOrAddComponent <Rigidbody>(this);
     }
     internal_rigidbody.isKinematic = true;
     internal_rigidbody.useGravity  = false;
     previous_position = get_position();
     acceleration      = get_acceleration();
 }
Example #7
0
        // Methods (non-Public)

        private void initialize()
        {
            GameObject game_object = this.GetOrAddChild("InternalLight");

            if (internal_light == null)
            {
                internal_light = Miscellaneous.GetOrAddComponent <Light>(game_object);
            }
            if (internal_transform == null)
            {
                internal_transform = Miscellaneous.GetOrAddComponent <Transform>(game_object);
            }
            internal_light.range   = 1000f; // FIXME: magic number: Setting light ranges to float.MaxValue does not work; the max range for SpotLights is a lot worse than PointLights.
            internal_light.shadows = LightShadows.None;
            on_pole_light_changed();
            on_sector_light_changed();
            on_arc_light_changed();
        }
 private void initialize()
 {
     if (internal_collider == null)
     {
         internal_collider = Miscellaneous.GetOrAddComponent <SphereCollider>(this.gameObject.internal_game_object);
     }
     if (internal_transform == null)
     {
         internal_transform = Miscellaneous.GetOrAddComponent <Transform>(this.gameObject.internal_game_object);
     }
     if (planetaria_transform == null)
     {
         planetaria_transform = this.GetOrAddComponent <PlanetariaTransform>();
     }
     if (!rigidbody.exists)
     {
         rigidbody = this.GetComponentInParent <PlanetariaRigidbody>();
     }
     cache(this.shape);
     // add to collision_map and trigger_map for all objects currently intersecting (via Physics.OverlapBox()) // CONSIDER: I think Unity Fixed this, right?
 }
Example #9
0
 public PlanetariaTransform Find(string name)
 {
     return(Miscellaneous.GetOrAddComponent <PlanetariaTransform>(internal_transform.Find(name)));
 }
 public Subtype GetOrAddComponent <Subtype>() where Subtype : PlanetariaComponent
 {
     return(Miscellaneous.GetOrAddComponent <Subtype>(gameObject.internal_game_object));
 }