Exemple #1
0
                /// <summary>
                /// Queues a single triangle billboard for rendering
                /// </summary>
                public static void AddTriangle(ref TriMaterial mat, ref TriangleD triangle, MatrixD[] matrixRef = null)
                {
                    var bbPool     = instance.bbPoolBack;
                    var bbDataBack = instance.triangleList;
                    int index      = bbDataBack.Count;
                    var matList    = instance.matrixBuf;
                    var matTable   = instance.matrixTable;

                    // Find matrix index in table or add it
                    int matrixID = -1;

                    if (matrixRef != null && !matTable.TryGetValue(matrixRef, out matrixID))
                    {
                        matrixID = matList.Count;
                        matList.Add(matrixRef[0]);
                        matTable.Add(matrixRef, matrixID);
                    }

                    var bb = new TriangleBillboardData
                    {
                        Item1 = BlendTypeEnum.PostPP,
                        Item2 = new Vector2I(index, matrixID),
                        Item3 = mat.textureID,
                        Item4 = mat.bbColor,
                        Item5 = new MyTuple <Vector2, Vector2, Vector2>
                                (
                            mat.texCoords.Point0,
                            mat.texCoords.Point1,
                            mat.texCoords.Point2
                                ),
                        Item6 = new MyTuple <Vector3D, Vector3D, Vector3D>
                                (
                            triangle.Point0,
                            triangle.Point1,
                            triangle.Point2
                                ),
                    };

                    bbDataBack.Add(bb);

                    if (index >= bbPool.Count)
                    {
                        instance.AddNewBB(index - (bbPool.Count - 1));
                    }

                    MyTransparentGeometry.AddBillboard(bbPool[index], false);
                }
Exemple #2
0
                /// <summary>
                /// Queues a quad billboard for rendering
                /// </summary>
                public static void AddQuad(ref FlatQuad quad, ref BoundedQuadMaterial mat, MatrixD[] matrixRef, BoundingBox2?mask = null)
                {
                    var bbPool     = instance.bbPoolBack;
                    var bbDataBack = instance.flatTriangleList;
                    var matList    = instance.matrixBuf;
                    var matTable   = instance.matrixTable;

                    // Find matrix index in table or add it
                    int matrixID;

                    if (!matTable.TryGetValue(matrixRef, out matrixID))
                    {
                        matrixID = matList.Count;
                        matList.Add(matrixRef[0]);
                        matTable.Add(matrixRef, matrixID);
                    }

                    // Mask bounding check. Null mask if not intersecting.
                    BoundingBox2?   maskBox     = mask;
                    ContainmentType containment = ContainmentType.Contains;

                    if (maskBox != null)
                    {
                        BoundingBox2 bounds = new BoundingBox2(quad.Point2, quad.Point0);
                        maskBox.Value.Contains(ref bounds, out containment);

                        if (containment == ContainmentType.Contains)
                        {
                            maskBox = null;
                        }
                    }

                    if (containment != ContainmentType.Disjoint)
                    {
                        int indexL = bbDataBack.Count,
                            indexR = bbDataBack.Count + 1;

                        var bbL = new FlatTriangleBillboardData
                        {
                            Item1 = BlendTypeEnum.PostPP,
                            Item2 = new Vector2I(bbDataBack.Count, matrixID),
                            Item3 = mat.textureID,
                            Item4 = new MyTuple <Vector4, BoundingBox2?>(mat.bbColor, maskBox),
                            Item5 = new MyTuple <Vector2, Vector2, Vector2>
                                    (
                                new Vector2(mat.texBounds.Max.X, mat.texBounds.Min.Y), // 1
                                mat.texBounds.Max,                                     // 0
                                new Vector2(mat.texBounds.Min.X, mat.texBounds.Max.Y)  // 3
                                    ),
                            Item6 = new MyTuple <Vector2, Vector2, Vector2>
                                    (
                                quad.Point0,
                                quad.Point1,
                                quad.Point2
                                    ),
                        };
                        var bbR = new FlatTriangleBillboardData
                        {
                            Item1 = BlendTypeEnum.PostPP,
                            Item2 = new Vector2I(bbDataBack.Count + 1, matrixID),
                            Item3 = mat.textureID,
                            Item4 = new MyTuple <Vector4, BoundingBox2?>(mat.bbColor, maskBox),
                            Item5 = new MyTuple <Vector2, Vector2, Vector2>
                                    (
                                new Vector2(mat.texBounds.Max.X, mat.texBounds.Min.Y), // 1
                                new Vector2(mat.texBounds.Min.X, mat.texBounds.Max.Y), // 3
                                mat.texBounds.Min                                      // 2
                                    ),
                            Item6 = new MyTuple <Vector2, Vector2, Vector2>
                                    (
                                quad.Point0,
                                quad.Point2,
                                quad.Point3
                                    ),
                        };

                        bbDataBack.Add(bbL);
                        bbDataBack.Add(bbR);

                        if (indexR >= bbPool.Count)
                        {
                            instance.AddNewBB(indexR - (bbPool.Count - 1));
                        }

                        MyTransparentGeometry.AddBillboard(bbPool[indexL], false);
                        MyTransparentGeometry.AddBillboard(bbPool[indexR], false);
                    }
                }
Exemple #3
0
                /// <summary>
                /// Queues a quad billboard for rendering
                /// </summary>
                public static void AddQuad(ref BoundedQuadMaterial mat, ref MyQuadD quad, MatrixD[] matrixRef = null)
                {
                    var bbPool     = instance.bbPoolBack;
                    var bbDataBack = instance.triangleList;
                    int indexL     = bbDataBack.Count,
                        indexR     = bbDataBack.Count + 1;
                    var matList    = instance.matrixBuf;
                    var matTable   = instance.matrixTable;

                    // Find matrix index in table or add it
                    int matrixID = -1;

                    if (matrixRef != null && !matTable.TryGetValue(matrixRef, out matrixID))
                    {
                        matrixID = matList.Count;
                        matList.Add(matrixRef[0]);
                        matTable.Add(matrixRef, matrixID);
                    }

                    var bbL = new TriangleBillboardData
                    {
                        Item1 = BlendTypeEnum.PostPP,
                        Item2 = new Vector2I(indexL, matrixID),
                        Item3 = mat.textureID,
                        Item4 = mat.bbColor,
                        Item5 = new MyTuple <Vector2, Vector2, Vector2>
                                (
                            mat.texBounds.Min,
                            mat.texBounds.Min + new Vector2(0f, mat.texBounds.Size.Y),
                            mat.texBounds.Max
                                ),
                        Item6 = new MyTuple <Vector3D, Vector3D, Vector3D>
                                (
                            quad.Point0,
                            quad.Point1,
                            quad.Point2
                                ),
                    };
                    var bbR = new TriangleBillboardData
                    {
                        Item1 = BlendTypeEnum.PostPP,
                        Item2 = new Vector2I(indexR, matrixID),
                        Item3 = mat.textureID,
                        Item4 = mat.bbColor,
                        Item5 = new MyTuple <Vector2, Vector2, Vector2>
                                (
                            mat.texBounds.Min,
                            mat.texBounds.Max,
                            mat.texBounds.Min + new Vector2(mat.texBounds.Size.X, 0f)
                                ),
                        Item6 = new MyTuple <Vector3D, Vector3D, Vector3D>
                                (
                            quad.Point0,
                            quad.Point2,
                            quad.Point3
                                ),
                    };

                    bbDataBack.Add(bbL);
                    bbDataBack.Add(bbR);

                    if (indexR >= bbPool.Count)
                    {
                        instance.AddNewBB(indexR - (bbPool.Count - 1));
                    }

                    MyTransparentGeometry.AddBillboard(bbPool[indexL], false);
                    MyTransparentGeometry.AddBillboard(bbPool[indexR], false);
                }