예제 #1
0
        public void FromObject3D(ObjectInputSettings ObjSettings, Object3D model, CollisionSettings colSettings = null)
        {
            var dicMatNames = new Dictionary <Material, string>();

            // Clear Lists
            Mesh.Vertices.Clear();
            Mesh.Triangles.Clear();

            // Create MatNames
            foreach (KeyValuePair <string, Material> kvp in model.Materials)
            {
                dicMatNames.Add(kvp.Value, kvp.Key);
            }

            // Add Faces
            var dicVertices = new Dictionary <Pilz.S3DFileParser.Vertex, Vertex>();

            foreach (Mesh m in model.Meshes)
            {
                foreach (Face f in m.Faces.OrderBy(n => n.Material))
                {
                    var cs = colSettings.GetEntry(dicMatNames[f.Material]);
                    if (!cs.IsNonSolid)
                    {
                        var t = new Triangle();
                        t.CollisionType = cs.CollisionType;
                        t.ColParams[0]  = cs.CollisionParam1;
                        t.ColParams[0]  = cs.CollisionParam2;
                        for (int i = 0, loopTo = Math.Min(f.Points.Count - 1, 2); i <= loopTo; i++)
                        {
                            Vertex v;
                            var    curVert = f.Points[i].Vertex;
                            if (dicVertices.ContainsKey(curVert))
                            {
                                v = dicVertices[curVert];
                            }
                            else
                            {
                                v   = new Vertex();
                                v.X = General.KeepInInt16Range(General.Round(curVert.X * ObjSettings.Scaling));
                                v.Y = General.KeepInInt16Range(General.Round(curVert.Y * ObjSettings.Scaling));
                                v.Z = General.KeepInInt16Range(General.Round(curVert.Z * ObjSettings.Scaling));
                                Mesh.Vertices.Add(v);
                                dicVertices.Add(curVert, v);
                            }

                            t.Vertices[i] = v;
                        }

                        Mesh.Triangles.Add(t);
                    }
                }
            }
        }
예제 #2
0
        public Task FromModelAsync(ObjectInputSettings ObjSettings, Pilz.S3DFileParser.Object3D vmap, Pilz.S3DFileParser.Object3D colmap, Fast3D.TextureFormatSettings texFormatSettings = null, Collision.CollisionSettings colSettings = null)
        {
            var t = new Task(() => FromModel(ObjSettings, vmap, colmap, texFormatSettings, colSettings));

            t.Start();
            return(t);
        }
예제 #3
0
        public void FromModel(ObjectInputSettings ObjSettings, Pilz.S3DFileParser.Object3D vmap, Pilz.S3DFileParser.Object3D colmap, Fast3D.TextureFormatSettings texFormatSettings, Collision.CollisionSettings colSettings = null)
        {
            // Add Collision
            Collision = new Collision.CollisionMap();
            Collision.FromObject3D(ObjSettings, colmap, colSettings);

            // Add Fast3DBuffer (replacement for 'Add Displaylists')
            if (Fast3DBuffer is object)
            {
                Fast3DBuffer.Close();
            }
            Fast3DBuffer = new Fast3D.Fast3DBuffer();
            Fast3DBuffer.FromModel(ObjSettings, vmap, texFormatSettings);
        }
예제 #4
0
        public Task FromObject3DAsync(ObjectInputSettings ObjSettings, Object3D model, CollisionSettings colSettings = null)
        {
            var t = new Task(() => FromObject3D(ObjSettings, model, colSettings));

            t.Start();
            return(t);
        }