示例#1
0
        public override void PopulateScene(Scene scene)
        {
            scene.addMaterial("Stone1", new Material(new Texture("stone1.jpg")));
            scene.addMaterial("Stone2", new Material(new Texture("stone2.jpg")));
            scene.addMaterial("Stone3", new Material(new Texture("stone3.jpg")));
            scene.addMaterial("Stone4", new Material(new Texture("stone4.jpg")));

            scene.addLight("Light1", new Light(new Vector(0.2f, 0.2f, 1f), 0xFFFFFF, 144, 120));
            scene.addLight("Light2", new Light(new Vector(-1f, -1f, 1f), 0x332211, 100, 40));
            scene.addLight("Light3", new Light(new Vector(-1f, -1f, 1f), 0x666666, 200, 120));

            try
            {
                new Importer3ds().importFromStream(File.OpenRead("wobble.3ds"), scene);
            }
            catch (Exception e) { Console.WriteLine(e + ""); }

            scene.rebuild();
            for (var i = 0; i < scene.objects; i++)
            {
                TextureProjector.ProjectFrontal(scene._object[i]);
            }

            scene.Object("Sphere1").setMaterial(scene.material("Stone1"));
            scene.Object("Wobble1").setMaterial(scene.material("Stone2"));
            scene.Object("Wobble2").setMaterial(scene.material("Stone3"));
            scene.Object("Wobble3").setMaterial(scene.material("Stone4"));
            scene.normalize();
        }
示例#2
0
        public override void PopulateScene(Scene scene)
        {
            void transformDemo(SceneObject sceneObject)
            {
                Timer tmr = new Timer(1);

                tmr.Elapsed += (sender, args) =>
                {
                    sceneObject.rotate(0, 0f, 0.1f);
                    sceneObject.shift(0, 0, 5);
                };
                tmr.Start();
            }

            scene.addMaterial("Stone1", new Material(new Texture("stone1.jpg")));
            scene.addMaterial("Stone2", new Material(new Texture("stone2.jpg")));
            scene.addMaterial("Stone3", new Material(new Texture("stone3.jpg")));
            scene.addMaterial("Stone4", new Material(new Texture("stone4.jpg")));
            var texture = new Texture(2, 2)[Color.Red, Color.Blue, Color.Yellow, Color.Green];

            scene.addMaterial("tiny", new Material(texture).setWireframe(true).setColor(Color.DeepPink));
            scene.addLight("Light1", new Light(new Vector(0.2f, 0.2f, 1f), 0xFFFFFF, 144, 120));
            scene.addLight("Light2", new Light(new Vector(-1f, -1f, 1f), 0x332211, 100, 40));
            scene.addLight("Light3", new Light(new Vector(-1f, -1f, 1f), 0x666666, 200, 120));
            var box = Square(scene);

            //new Importer3ds().importFromStream(File.OpenRead("wobble.3ds"), scene);

            //scene.addObject("tri", cube);
            scene.rebuild();
            for (var i = 0; i < scene.objects; i++)
            {
                TextureProjector.ProjectFrontal(scene._object[i]);
            }
            scene.Object("Sphere1").setMaterial(scene.material("tiny"));
            //scene.Object("Wobble1").setMaterial(scene.material("Stone2"));
            //scene.Object("Wobble2").setMaterial(scene.material("Stone3"));
            //scene.Object("Wobble3").setMaterial(scene.material("Stone4"));
            //scene.Object("tri").setMaterial(scene.material("Stone4"));
            //scene.normalize();
        }
示例#3
0
            void FixedUpdate()
            {
                if (Texture != null &&
                    !Texture.name.Equals(lastTextureLoaded))
                {
                    if (tempObj != null)
                    {
                        Destroy(tempObj);
                    }

                    lastTextureLoaded = Texture.name;

#if UNITY_EDITOR
                    string textureFilePath = AssetDatabase.GetAssetPath(Texture);
#else
                    // ERROR TESTING - THIS IS A PRETTY HEFTY ASSUMPTION, BUT THIS SHOULDN'T EVEN BE USED OUTSIDE OF THE EDITOR ANYWAYS
                    string textureFilePath = Constants.Folders.ClippedRoomTextureFolderPath + Texture.name + Constants.Suffixes.FileSuffix_PNG;
#endif
                    Texture.wrapMode = TextureWrapMode.Clamp;

                    tempObj      = new GameObject();
                    tempObj.name = "Temp Projector Object";

                    if (!CameraLocationFileName.Equals(string.Empty) &&
                        lastCameraLoadedName.Equals(CameraLocationFileName))
                    {
                        lastCameraLoadedName = CameraLocationFileName;

                        lastCameraLoaded = CameraLocation.Load(CameraLocationFileName);

                        TextureProjector.GenerateProjector(tempObj, CameraLocationFileName, textureFilePath);
                    }
                    else
                    {
                        Projector proj = tempObj.AddComponent <Projector>();
                        proj.material = MaterialMaker.GenerateRoomMaterial(Texture);
                    }
                }
            }