コード例 #1
0
        public void setupEnvironment()
        {
            environmentScene = new SSScene();

            // add skybox cube
            SSObject skyboxCube = new SSObjectMeshSky(new SSMesh_wfOBJ(SSAssetManager.mgr.getContext("./skybox/"),"skybox.obj",true));
            environmentScene.addObject(skyboxCube);
            skyboxCube.Scale = new Vector3(0.7f);
            skyboxCube.renderState.lighted = false;

            // scene.addObject(skyboxCube);

            SSObject skyboxStars = new SSObjectMeshSky(new SSMesh_Starfield(800));
            environmentScene.addObject(skyboxStars);
            skyboxStars.renderState.lighted = false;
        }
コード例 #2
0
        public void setupScene()
        {
            scene = new SSScene ();

            var lightPos = new Vector3 (5.0f, 40.0f, 10.0f);
            // 0. Add Lights
            var light = new SSLight (LightName.Light0);
            light.Pos = lightPos;
            scene.addLight(light);

            // 1. Add Objects
            SSObject triObj;
            scene.addObject (triObj = new SSObjectTriangle () );
            triObj.Pos = lightPos;

            // add drone
            SSObject droneObj = new SSObjectMesh (new SSMesh_wfOBJ (SSAssetManager.mgr.getContext ("./drone2/"), "drone2.obj", true, shaderPgm));
            scene.addObject (this.activeModel = droneObj);
            droneObj.renderState.lighted = true;
            droneObj.ambientMatColor = new Color4(0.2f,0.2f,0.2f,0.2f);
            droneObj.diffuseMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            droneObj.specularMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            droneObj.shininessMatColor = 10.0f;
            droneObj.MouseDeltaOrient(-40.0f,0.0f);
            droneObj.Pos = new OpenTK.Vector3(-5,0,0);

            // add second drone

            SSObject drone2Obj = new SSObjectMesh(
                new SSMesh_wfOBJ(SSAssetManager.mgr.getContext("./drone2/"), "drone2.obj", true, shaderPgm)
                );
            scene.addObject (drone2Obj);
            drone2Obj.renderState.lighted = true;
            drone2Obj.ambientMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            drone2Obj.diffuseMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            drone2Obj.shininessMatColor = 10.0f;
            drone2Obj.Pos = new OpenTK.Vector3(20,0,0);
            drone2Obj.MouseDeltaOrient(20.0f,0.0f);

            // last. Add Camera

            scene.addObject (scene.activeCamera =
                    new SSCameraThirdPerson (droneObj));
        }
コード例 #3
0
        public void setupHUD()
        {
            hudScene = new SSScene ();

            // HUD Triangle...
            //SSObject triObj = new SSObjectTriangle ();
            //hudScene.addObject (triObj);
            //triObj.Pos = new Vector3 (50, 50, 0);
            //triObj.Scale = new Vector3 (50.0f);

            // HUD text....
            fpsDisplay = new SSObjectGDISurface_Text ();
            fpsDisplay.Label = "FPS: ...";
            hudScene.addObject (fpsDisplay);
            fpsDisplay.Pos = new Vector3 (10f, 10f, 0f);
            fpsDisplay.Scale = new Vector3 (1.0f);

            // wireframe mode text....
            wireframeDisplay = new SSObjectGDISurface_Text ();
            hudScene.addObject (wireframeDisplay);
            wireframeDisplay.Pos = new Vector3 (10f, 40f, 0f);
            wireframeDisplay.Scale = new Vector3 (1.0f);
            updateWireframeDisplayText (scene.renderConfig);
        }
コード例 #4
0
        protected virtual void setupScene()
        {
            scene = new SSScene (mainShader, pssmShader, instancingShader, instancingPssmShader);
            sunDiskScene = new SSScene ();
            sunFlareScene = new SSScene ();
            hudScene = new SSScene ();
            environmentScene = new SSScene ();

            scene.renderConfig.frustumCulling = true;  // TODO: fix the frustum math, since it seems to be broken.
            scene.BeforeRenderObject += beforeRenderObjectHandler;

            // 0. Add Lights
            var light = new SSDirectionalLight (LightName.Light0);
            light.Direction = new Vector3(0f, 0f, -1f);
            #if true
            if (OpenTKHelper.areFramebuffersSupported ()) {
                if (scene.renderConfig.pssmShader != null && scene.renderConfig.instancePssmShader != null) {
                    light.ShadowMap = new SSParallelSplitShadowMap (TextureUnit.Texture7);
                } else {
                    light.ShadowMap = new SSSimpleShadowMap (TextureUnit.Texture7);
                }
            }
            if (!light.ShadowMap.IsValid) {
                light.ShadowMap = null;
            }
            #endif
            scene.AddLight(light);

            #if true
            var smapDebug = new SSObjectHUDQuad (light.ShadowMap.TextureID);
            smapDebug.Scale = new Vector3(0.3f);
            smapDebug.Pos = new Vector3(50f, 200, 0f);
            hudScene.AddObject(smapDebug);
            #endif

            // setup a sun billboard object and a sun flare spriter renderer
            {
                var sunDisk = new SSMeshDisk ();
                var sunBillboard = new SSObjectBillboard (sunDisk, true);
                sunBillboard.MainColor = new Color4 (1f, 1f, 0.8f, 1f);
                sunBillboard.Pos = new Vector3 (0f, 0f, 18000f);
                sunBillboard.Scale = new Vector3 (600f);
                sunBillboard.renderState.frustumCulling = false;
                sunBillboard.renderState.lighted = false;
                sunBillboard.renderState.castsShadow = false;
                sunDiskScene.AddObject(sunBillboard);

                SSTexture flareTex = SSAssetManager.GetInstance<SSTextureWithAlpha>(".", "sun_flare.png");
                const float bigOffset = 0.8889f;
                const float smallOffset = 0.125f;
                RectangleF[] flareSpriteRects = {
                    new RectangleF(0f, 0f, 1f, bigOffset),
                    new RectangleF(0f, bigOffset, smallOffset, smallOffset),
                    new RectangleF(smallOffset, bigOffset, smallOffset, smallOffset),
                    new RectangleF(smallOffset*2f, bigOffset, smallOffset, smallOffset),
                    new RectangleF(smallOffset*3f, bigOffset, smallOffset, smallOffset),
                };
                float[] spriteScales = { 20f, 1f, 2f, 1f, 1f };
                var sunFlare = new SimpleSunFlareMesh (sunDiskScene, sunBillboard, flareTex,
                                                     flareSpriteRects, spriteScales);
                sunFlare.Scale = new Vector3 (2f);
                sunFlare.renderState.lighted = false;
                sunFlareScene.AddObject(sunFlare);
            }
        }
コード例 #5
0
ファイル: TestBench2.cs プロジェクト: kniteli/SimpleScene
        protected override void setupScene()
        {
            base.setupScene ();

            laserOccDiskScene3d = new SSScene (mainShader, pssmShader, instancingShader, instancingPssmShader);
            laserFlareScene2d = new SSScene (mainShader, pssmShader, instancingShader, instancingPssmShader);

            var mesh = SSAssetManager.GetInstance<SSMesh_wfOBJ> ("./drone2/", "Drone2.obj");

            // add drones
            droneObj1 = new SSObjectMesh (mesh);
            droneObj1.Pos = new OpenTK.Vector3(-20f, 0f, -15f);
            droneObj1.Orient(Quaternion.FromAxisAngle(Vector3.UnitY, (float)Math.PI/2f));
            droneObj1.AmbientMatColor = new Color4(0.1f,0.1f,0.1f,0.1f);
            droneObj1.DiffuseMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            droneObj1.SpecularMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            droneObj1.EmissionMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            //droneObj1.renderState.visible = false;
            droneObj1.Name = "attacker drone";
            main3dScene.AddObject (droneObj1);

            droneObj2 = new SSObjectMesh (mesh);
            droneObj2.Pos = new OpenTK.Vector3(20f, 0f, -15f);
            droneObj2.AmbientMatColor = new Color4(0.1f,0.1f,0.1f,0.1f);
            droneObj2.DiffuseMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            droneObj2.SpecularMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            droneObj2.EmissionMatColor = new Color4(0.3f,0.3f,0.3f,0.3f);
            droneObj2.Name = "target drone";
            droneObj2.MainColor = new Color4(1f, 0f, 0.7f, 1f);
            //droneObj2.renderState.visible = false;
            main3dScene.AddObject (droneObj2);

            // manages laser objects
            laserManager = new SLaserManager(alpha3dScene, laserOccDiskScene3d, laserFlareScene2d);

            // tweak the laser start point (by adding an offset in object-local coordinates)
            laserSourceTxfm = Matrix4.CreateTranslation (0f, 1f, 2.75f);

            // debugging snippets:
            //droneObj1.MainColor = Color4.Green;
            //droneObj1.renderState.visible = false;
        }