Example #1
0
    // Declare member variables here. Examples:
    // private int a = 2;
    // private string b = "text";

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //add perf info label
        AddChild(new MonoDiagLabel()
        {
            position = MonoDiagLabel.POSITION.TOP_CENTER,
        });

        //setup a moveable camera
        var inputControl = new InputController();

        inputControl.Translate(new Vector3(0, 0, 3));
        inputControl.AddChild(new Camera());
        AddChild(inputControl);

        var dirLight = new DirectionalLight();

        dirLight.Rotation = Vector3.One;        //rotate aprox 57' in xyz
        AddChild(dirLight);


        var procMM = new ProcMultimesh();

        AddChild(procMM);
    }
    // Declare member variables here. Examples:
    // private int a = 2;
    // private string b = "text";

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //add perf info label
        AddChild(new MonoDiagLabel()
        {
            position = MonoDiagLabel.POSITION.TOP_CENTER,
        });

        //setup a moveable camera
        var inputControl = new InputController();

        inputControl.Translate(new Vector3(0, 0, 3));
        inputControl.AddChild(new Camera());
        AddChild(inputControl);

        var dirLight = new DirectionalLight();

        dirLight.Rotation = Vector3.One;        //rotate aprox 57' in xyz
        AddChild(dirLight);



        //add a fish via code, put it at (0,3,0)
        {
            var mesh    = GD.Load <Mesh>("res://asset/fish/Fish1.obj");
            var shader  = GD.Load <Shader>("res://asset/fish/fish1.shader");
            var diffuse = GD.Load <Texture>("res://asset/fish/Fish1-diffuse_base.png");
            shader.SetDefaultTextureParam("texture_albedo", diffuse);
            var meshInst = new MeshInstance();
            meshInst.Mesh = mesh;
            var shadMat = new ShaderMaterial();
            shadMat.Shader = shader;
            shadMat.SetShaderParam("texture_albedo", diffuse);
            meshInst.MaterialOverride = shadMat;
            meshInst.Translate(Vector3.Up * 3);
            AddChild(meshInst);
        }
    }