Ejemplo n.º 1
0
        void AddDemoData()
        {
            MCube            c  = Helper.CreateCube(MScene.ModelRoot, "Cube");
            MObjectAnimation ma = new MObjectAnimation("Animation");

            ma.Speed       = 1;
            ma.AngleOffset = new OpenTK.Quaterniond(0.1, 0.1, 0.1);
            c.Add(ma);
            c.Setup();
        }
Ejemplo n.º 2
0
        void CreateTest()
        {
            for (int i = 0; i < 1000; i++)
            {
                Vector3d pos = Globals.Avatar.Target.transform.Position + Globals.LocalUpVector * i;

                MCube          c  = (MCube)Helper.CreateCube(MScene.ModelRoot, "Cube" + i, pos);
                MPhysicsObject po = new MPhysicsObject(c, "cube", 0.1, MPhysicsObject.EShape.Box, false, Vector3d.One);
            }
        }
Ejemplo n.º 3
0
    void Traversal(Transform t)
    {
        for (int i = 0; i < t.childCount; i++)
        {
            Transform tt = t.GetChild(i);
            if (tt.GetComponent <Light>() != null)
            {
                Light  l      = tt.GetComponent <Light>();
                Mlight mlight = new Mlight();
                mlight.Name       = l.type.ToString();
                mlight.Intensity  = l.intensity;
                mlight.Range      = l.range;
                mlight.SpotAngle  = l.spotAngle;
                mlight.CookieSize = l.cookieSize;
                mlight.x          = l.transform.position.x;
                mlight.y          = l.transform.position.y;
                mlight.z          = l.transform.position.z;
                mlight.r          = l.color.r;
                mlight.g          = l.color.g;
                mlight.b          = l.color.b;
                mlight.a          = l.color.a;
                mlight.rx         = l.transform.rotation.x;
                mlight.ry         = l.transform.rotation.y;
                mlight.rz         = l.transform.rotation.z;
                mlight.rw         = l.transform.rotation.w;
                mTerrain.Add(mlight);
            }
            else
            {
                MCube mcube = new MCube();
                mcube.Name   = tt.name;
                mcube.x      = tt.position.x;
                mcube.y      = tt.position.y;
                mcube.z      = tt.position.z;
                mcube.rx     = tt.rotation.x;
                mcube.ry     = tt.rotation.y;
                mcube.rz     = tt.rotation.z;
                mcube.rw     = tt.rotation.w;
                mcube.parent = tt.parent.name;
                mTerrain.Add(mcube);
            }

            Traversal(tt);
        }
    }
Ejemplo n.º 4
0
    public void LoadCubes()
    {
        string path = getPath();

        if (!File.Exists(path))
        {
            File.WriteAllText(path, DefaultAsset.text);
        }

        string[] lines = File.ReadAllLines(path);
        MCubes = new List <MCube>(lines.Length);


        if (lines.Length != linesNum)
        {
            Debug.Log("linesNum: " + linesNum + " lines: " + lines.Length);
            changed = true;
            string[] newLines = DefaultAsset.text.Split('\n');

            for (int i = 0; i < linesNum; i++)
            {
                MCubes.Add(JsonUtility.FromJson <MCube>(newLines[i]));
            }

            for (int i = 0; i < lines.Length; i++)
            {
                MCube current = JsonUtility.FromJson <MCube>(lines[i]);
                if (MCubes[i] != null && current != null)
                {
                    MCubes[i].available = current.available;
                }
                //Debug.Log("DONE:" + i);
            }
        }
        else
        {
            for (int i = 0; i < lines.Length; i++)
            {
                MCubes.Add(JsonUtility.FromJson <MCube>(lines[i]));
            }
        }
    }
Ejemplo n.º 5
0
 // 针对预制件的初始化
 public MObject(GameObject template, MPrefabType type)
 {
     this.template = template;
     gameObject = GameObject.Instantiate(template);
     switch (type)
     {
         case MPrefabType.CUBE:
             mesh = MCube.GetMMesh();
             break;
         case MPrefabType.SPHERE:
             mesh = MSphere.GetMMesh();
             break;
         case MPrefabType.CYLINDER:
             mesh = MCylinder.GetMMesh();
             break;
         case MPrefabType.CONE:
             mesh = MCone.GetMMesh();
             break;
         case MPrefabType.PRISM:
             mesh = MPrism.GetMMesh();
             break;
         case MPrefabType.PYRAMID:
             mesh = MPyramid.GetMMesh();
             break;
         case MPrefabType.REGULAR_TRIANGLE:
             mesh = MRegularTriangle.GetMMesh();
             break;
         case MPrefabType.CIRCLE:
             mesh = MCircle.GetMMesh();
             break;
         default:
             Debug.Log("Unknown prefab type: " + type);
             return;
     }
     InitObject();
 }
Ejemplo n.º 6
0
 public void Add(MCube zone)
 {
     cubes_.Add(zone);
 }