Beispiel #1
0
        internal MeshGameObject(LargeSketch sketch, MeshBuilder builder, object tag)
        {
            this.sketch      = sketch;
            geom_ids         = builder.geom_ids;
            face_mat_builder = builder.face_mat;
            all_triangles    = builder.triangles_final;
            all_stems        = builder.stems_final;

            mesh = new Mesh();

            if (builder.positions.Count >= 0xFFE0)
            {
                mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
            }
            mesh.SetVertices(builder.positions);

            if (builder.normals != null)
            {
                mesh.SetNormals(builder.normals);
            }

            if (builder.uvs != null)
            {
                mesh.SetUVs(0, builder.uvs);
            }

            RefreshRenderer(tag);
        }
Beispiel #2
0
        internal MeshBuilder(LargeSketch sketch, IMaterialBuilder face_mat, int level)
        {
            this.face_mat = face_mat;

            positions = new List <Vector3>();
            if (level >= 1)
            {
                normals = new List <Vector3>();
            }
            if (level >= 2)
            {
                uvs = new List <Vector2>();
            }
            triangles = new List <int>();    // if level == 0, should remain empty
            stems     = new List <int>();

            geom_ids       = new List <int>();
            renderer_index = sketch.NewRendererIndex();
        }
Beispiel #3
0
    /// <summary>
    /// Prepare new geometry with the given Material for the faces.
    ///
    /// This method returns a GeometryBuilder on which you can add vertices and then create
    /// triangles or stems between them.  You could try to reuse previous vertices on the
    /// same GeometryBuilder, but it's not something VR-Sketch-4 does.
    ///
    /// The returned GeometryBuilder structure also contains a unique id for this geometry,
    /// which can be saved and passed to ChangeMaterials() or RemoveGeometry().
    ///
    /// Note that performance does NOT require you to draw many triangles inside a single
    /// PrepareGeometry() call.  Typically, every two-sided polygon is done with two calls to
    /// PrepareGeometry(), corresponding to the two sides.  The edges are added as stems
    /// during one of the two calls, not during extra calls, to reuse the vertices.  If the
    /// two sides have the same material then they can be combined into a single call to
    /// further reuse the vertices.  But apart from easy vertex reuse, there is no point in
    /// combining calls.
    ///
    /// If you call with 'texture: true', the GeometryBuilder will have a non-null 'uvs' list
    /// into which you have to add UV coordinates for every vertex.
    /// </summary>
    public GeometryBuilder PrepareGeometry(IMaterialBuilder face_mat, bool texture = false, Visibility visibility = Visibility.Regular)
    {
        MeshBuilder builder;
        var         builders = texture ? mesh_builders_with_texture : mesh_builders;

        if (!builders.TryGetValue(face_mat, out builder) || TryFinish(builder))
        {
            builder            = new MeshBuilder(this, face_mat, texture ? 2 : 1);
            builders[face_mat] = builder;
        }
        return(new GeometryBuilder
        {
            id = NextGeomId(builder, visibility),
            positions = builder.positions,
            normals = builder.normals,
            uvs = builder.uvs,
            triangles = builder.triangles,
            stems = builder.stems,
        });
    }
Beispiel #4
0
 public MaterialService(IMaterialRepository materialRepository, IMaterialBuilder materialBuilder)
 {
     _materialRepository = materialRepository ?? throw new ArgumentNullException(nameof(materialRepository));
     _materialBuilder    = materialBuilder ?? throw new ArgumentNullException(nameof(materialBuilder));;
 }
 public MaterialSeller(IMaterialBuilder builder, EMaterialMixType materialMixType)
 {
     _builder = builder;
     Construct(materialMixType);
 }