Beispiel #1
0
    public void build(GameObject contentsObject, ShaderSettings shaders, Transform tfStructureRoot)
    {
        parts = contentsObject.GetComponentsInChildren <_StructurePart3>();

        for (var i = 0; i < parts.Length; i++)
        {
            parts[i].init(i);
        }


        meshBuilder = new StructureMeshBuilder(parts, contentsObject.transform);


        near = buildNearObject(shaders, tfStructureRoot);


        var tfNear = near.transform;

        buildChildWithCollider(_StructurePart3.enType.common, tfNear);
        buildChildWithCollider(_StructurePart3.enType.fence, tfNear);
        buildChildWithCollider(_StructurePart3.enType.invisible, tfNear);
        buildChildWithCollider(_StructurePart3.enType.occlusion, tfNear);


        //if( !meshBuilder.draw.isBoned ) return;


        //var tfBone = boneBuilder.build( contentsObject );

        //boneBuilder.attatch( tfStructureRoot, tfBone );
    }
Beispiel #2
0
 Shader selectShader(StructureMeshBuilder builder, ShaderSettings shaders)
 {
     if (meshBuilder.draw.isNeedTransparentShader)
     {
         return(shaders.structureTransparent);
     }
     else
     {
         return(shaders.structure);
     }
 }
Beispiel #3
0
        public static MeshDrawer CreateBox(Vector3 size)
        {
            var mesh = CreateBoxMesh(size / 2);

            ShaderSettings   ss   = new ShaderSettings();
            RenderDirectives rd   = new RenderDirectives();
            string           path = "Toys.Resourses.shaders.";
            string           vs   = ShaderManager.ReadFromAssetStream(path + "UIElement.vsh");
            string           fs   = ShaderManager.ReadFromAssetStream(path + "UIElement.fsh");

            ss.TextureDiffuse = true;
            var material = new MaterialCustom(ss, rd, vs, fs);

            material.Name = "Texture";
            material.SetTexture(Texture2D.LoadEmpty(), TextureType.Diffuse);

            return(new MeshDrawer(mesh));
        }
Beispiel #4
0
    // ------------------------

    GameObject buildNearObject(ShaderSettings shaders, Transform tfParent)
    {
        var go = new GameObject();

        go.name = "near";

        go.transform.SetParent(tfParent, false);


        //var hitter = go.AddComponent<StructureHitNear>();


        var rg = go.AddComponent <Rigidbody>();

        rg.isKinematic = true;


        var mf = go.AddComponent <MeshFilter>();

        mf.sharedMesh = meshBuilder.draw.mesh;


        var mr = go.AddComponent <MeshRenderer>();

        var mat = new Material(selectShader(meshBuilder, shaders));

        mat.mainTexture = meshBuilder.draw.texture;

        mr.sharedMaterial = mat;


        var sr = go.AddComponent <StructureRenderer3>();

        sr.initAllPartsVisibilityOn(parts, mr);


        go.SetActive(false);

        return(go);
    }