Example #1
0
        private void createModel()
        {
            loadAllFiles();

            // Create Camera
            {
                //Create Camera Components
                SimulationObject cameraObject = model.AddObject();
                cameraObject.Name = "cameraObj";

                Transform transform_camera = cameraObject.GetComponent <Transform>();
                transform_camera.Position = new Vector3(0.0f, 40.0f, 250.0f);

                ETE.Render.Component.Camera comp_camera = cameraObject.AddComponent <ETE.Render.Component.Camera>();
                comp_camera.TargetDisplay    = 0;
                comp_camera.BackGround_Color = new Vector4(0.2f, 0.2f, 0.4f, 1.0f);
                comp_camera.CameraOrder      = 0;
                comp_camera.Near             = 2.0f;
                comp_camera.Far          = 10000.0f;
                comp_camera.FOV          = 35.0f;
                comp_camera.Aspect_Ratio = 1.7021f;
            }

            createGTModel();
        }
Example #2
0
        private void createObjects()
        {
            //Create Render Components_1
            SimulationObject testObject = model.AddObject();

            testObject.Name = "testObj";

            Transform transform_test = testObject.GetComponent <Transform>();

            transform_test.Position = new Vector3(0.0f, 0.0f, 0.0f);

            MeshFilter meshfilter_test = testObject.AddComponent <MeshFilter>();

            meshfilter_test.mesh = new Mesh("filepath", "Mesh");

            Material material_test = new Material(new Shader("filepath"));

            material_test.MainTexture = new Texture2D("filepath");
            material_test.Color       = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);

            MeshRenderer meshrenderer = testObject.AddComponent <MeshRenderer>();

            meshrenderer.material = material_test;

            //Create Render Components_2
            SimulationObject testObject_2 = model.AddObject();

            testObject_2.Name = "testObj_2";

            Transform transform_test_2 = testObject_2.GetComponent <Transform>();

            transform_test_2.Position = new Vector3(0.0f, 0.0f, 0.0f);

            MeshFilter meshfilter_test_2 = testObject_2.AddComponent <MeshFilter>();

            meshfilter_test_2.mesh = new Mesh("filepath", "Mesh");

            Material material_test_2 = new Material(new Shader("filepath"));

            material_test_2.MainTexture = new Texture2D("filepath");
            material_test_2.Color       = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);

            MeshRenderer meshrenderer_2 = testObject_2.AddComponent <MeshRenderer>();

            meshrenderer_2.material = material_test_2;

            //Create Camera Components
            SimulationObject cameraObject = model.AddObject();

            cameraObject.Name = "cameraObj";

            Transform transform_camera = cameraObject.GetComponent <Transform>();

            transform_camera.Position = new Vector3(0.0f, 0.0f, 0.0f);

            ETE.Render.Component.Camera comp_camera = cameraObject.AddComponent <ETE.Render.Component.Camera>();
            //comp_camera.Root = testObject;
            comp_camera.TargetDisplay    = 0; //아직 EGL 개발되지않음
            comp_camera.BackGround_Color = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
            comp_camera.CameraOrder      = 0;
        }
Example #3
0
        private void createModel()
        {
            //-----------------------------------
            //scene에서 사용할 모든 GTM 파일을 적으세요
            //mesh & material pool 구성
            if (RenderAsset.getRenderAsset() != null)
            {
                // 객체 로드
                RenderAsset.Load("tidus/tidus.gtm", typeof(Mesh));
                RenderAsset.Load("tidus/tidus.gtm", typeof(Material));
                RenderAsset.Load("shader/lighting.sh", typeof(Shader));

                //RenderAsset.Load("tidus/tidus.gtm", typeof(Mesh));
                //RenderAsset.Load("tidus/tidus.gtm", typeof(Material));
                //RenderAsset.Load("shader/lighting.sh", typeof(Shader));

                // 데이터 취득
                Mesh[]     meshArray     = RenderAsset.GetObjectsOfTypeAll(typeof(Mesh)) as Mesh[];
                Material[] materialArray = RenderAsset.GetObjectsOfTypeAll(typeof(Material)) as Material[];
                Shader[]   shaderArray   = RenderAsset.GetObjectsOfTypeAll(typeof(Shader)) as Shader[];

                // Create Model(Create Mesh by Model)
                int meshLength = meshArray.GetLength(0);

                for (int i = 0; i < meshLength; ++i)
                {
                    SimulationObject testObject = model.AddObject();
                    testObject.Name = meshArray[i].getMeshName() + "_Node";

                    Transform transform_test = testObject.GetComponent <Transform>();
                    transform_test.Position = new Vector3(0.0f, 0.0f, 0.0f);

                    MeshFilter meshfilter_test = testObject.AddComponent <MeshFilter>();
                    meshfilter_test.mesh = meshArray[i];

                    Material material_test = materialArray[i];
                    material_test.Shader = shaderArray[0];

                    MeshRenderer meshrenderer = testObject.AddComponent <MeshRenderer>();
                    meshrenderer.material = material_test;

                    //UserControl은 단순히 모델을 회전시켜주는 역할을 합니다.
                    UserControl.MeshControl mc = testObject.AddComponent <UserControl.MeshControl>();
                }

                // Create Cube(Create Mesh by Script)
                SimulationObject CubeObject = model.AddObject();
                CubeObject.Name = "CreateMesh_Test";

                Transform transform_Cube = CubeObject.GetComponent <Transform>();
                transform_Cube.Position = new Vector3(0.0f, 0.0f, 0.0f);

                UserControl.CreateMesh cm = CubeObject.AddComponent <UserControl.CreateMesh>();

                // Create Camera
                // 현재 있는 View 개수만큼 Camera를 생성합니다.
                int[] targetNumbers = ETE.Render.EGL.GLUserControlManager.Instance.getTargetNumbers();
                foreach (int targetnumber in targetNumbers)
                {
                    SimulationObject cameraObject = SimulationApplication.Instance.getModel().AddObject();
                    cameraObject.Name = "cameraObj";

                    ETE.Render.Component.Camera comp_camera = cameraObject.AddComponent <ETE.Render.Component.Camera>();
                    comp_camera.TargetDisplay    = targetnumber;
                    comp_camera.BackGround_Color = new Vector4(0.2f, 0.2f, 0.4f, 1.0f);
                    comp_camera.CameraOrder      = 0;
                    comp_camera.Near             = 2.0f;
                    comp_camera.Far          = 10000.0f;
                    comp_camera.FOV          = 35.0f;
                    comp_camera.Aspect_Ratio = 1.7021f;

                    // Camera의 위치 설정
                    Transform transform_camera = cameraObject.GetComponent <Transform>();
                    if (targetnumber == 0)
                    {
                        transform_camera.Position    = new Vector3(0.0f, 40.0f, 250.0f);
                        transform_camera.EulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
                    }
                    else if (targetnumber == 1)
                    {
                        transform_camera.Position    = new Vector3(0.0f, 250.0f, 0.0f);
                        transform_camera.EulerAngles = new Vector3(-90.0f, 0.0f, 0.0f);
                    }
                    else if (targetnumber == 2)
                    {
                        transform_camera.Position    = new Vector3(250.0f, 40.0f, 0.0f);
                        transform_camera.EulerAngles = new Vector3(0.0f, 90.0f, 0.0f);
                    }
                    else if (targetnumber == 3)
                    {
                        transform_camera.Position    = new Vector3(130.0f, 200.0f, 130.0f);
                        transform_camera.EulerAngles = new Vector3(-45.0f, 45.0f, 0.0f);
                    }
                }
            }
        }