예제 #1
0
 public sphere(Vector3 cen, float r, zMaterial mat, int instanceID = -1)
 {
     center   = cen;
     radius   = r;
     material = mat;
     id       = instanceID;
 }
예제 #2
0
 public triangle(Vector3 a, Vector3 b, Vector3 c, zMaterial mat, int instanceId = 0)
 {
     this.a   = a;
     this.b   = b;
     this.c   = c;
     normal   = Vector3.Cross(b - a, c - a).normalized;
     material = mat;
     id       = instanceId;
 }
예제 #3
0
 public moving_sphere(Vector3 cen0, Vector3 cen1, float t0, float t1, float r, zMaterial m)
 {
     center0  = cen0;
     center1  = cen1;
     time0    = t0;
     time1    = t1;
     material = m;
     radius   = r;
 }
예제 #4
0
    public void Generate()
    {
        for (int i = 0; i < ObjCount; i++)
        {
            int       index = Random.Range(0, materials.Count);
            zMaterial mat   = materials[index];

            var go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            go.AddComponent <rtObject>().material = mat;
            Vector3 pos = origin;
            do
            {
                pos = Random.insideUnitSphere * range;
            } while (pos.y < 0f);
            go.transform.position   = pos;
            go.transform.localScale = Vector3.one * Random.Range(0.2f, 3f);
            go.transform.parent     = transform;
            go.GetComponent <rtObject>().DoPreview();
        }
    }
예제 #5
0
    public quad(zMaterial mat, Transform transform, int instanceID = 0)
    {
        k = 0;
        //Vector3 worldmin = transform.localToWorldMatrix.MultiplyPoint(new Vector3(-0.5f, -0.5f, 0f));
        //Vector3 worldmax = transform.localToWorldMatrix.MultiplyPoint(new Vector3(0.5f, 0.5f, 0f));
        //x0 = Mathf.Min(worldmin.x, worldmax.x);
        //x1 = Mathf.Max(worldmin.x, worldmax.x);
        //z0 = Mathf.Min(worldmin.z, worldmax.z);
        //z1 = Mathf.Max(worldmin.z, worldmax.z);
        x0       = -0.5f;
        x1       = 0.5f;
        y0       = -0.5f;
        y1       = 0.5f;
        material = mat;
        normal   = -transform.forward;
        id       = instanceID;
        trans    = transform;
        Bounds bd = trans.GetComponent <Renderer>().bounds;

        aabb = new rtAABB(bd.min, bd.max);
    }