Пример #1
0
        public void Dispose()
        {
            DefaultShader.Dispose();
            DepthShader.Dispose();
            DepthCubeShader.Dispose();
            DefaultTexture.Dispose();
            FallbackTexture.Dispose();
            WhiteTexture.Dispose();
            BlackTexture.Dispose();
            DefaultMaterial.Dispose();
            DefaultTextureMaterial.Dispose();
            MissingTextureMaterial.Dispose();
            m_shaderRegistry.Dispose();

            foreach (CResource waitingResource in m_waitingResources)
            {
                waitingResource.Dispose();
            }

            m_waitingResources.Clear();

            foreach (var registeredResource in m_registeredResources)
            {
                registeredResource.Value.Dispose();
            }

            m_registeredResources.Clear();
        }
Пример #2
0
        public void FillPolygonConvex(SolidBrush brush, PointF[] points)
        {
            if (points.Length < 3)
            {
                return;
            }

            if (DefaultMaterial != null)
            {
                DefaultMaterial.SetPass(0);
                DefaultMaterial.color = brush.Color.ToUColor();
            }

            GL.Begin(GL.TRIANGLES);

            var color = brush.Color.ToUColor();

            GL.Color(color);

            for (int i = 1; i + 1 < points.Length; i += 1)
            {
                GL.Vertex3(points[0].X, points[0].Y, 0);
                GL.Vertex3(points[i].X, points[i].Y, 0);
                GL.Vertex3(points[i + 1].X, points[i + 1].Y, 0);
            }

            GL.End();
        }
Пример #3
0
        private void revertMaterialsToDefaultToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DefaultMaterial defaultMat = new DefaultMaterial();

            foreach (OnyxProjectAsset matAsset in ProjectManager.Instance.Content.Materials)
            {
                Material mat = AssetLoader <Material> .Load(matAsset.Path, true);

                foreach (KeyValuePair <string, MaterialProperty> prop in defaultMat.Properties)
                {
                    if (!mat.Properties.ContainsKey(prop.Key))
                    {
                        mat.Properties.Add(prop.Key, prop.Value.Clone());
                    }
                    else
                    {
                        mat.Properties[prop.Key].Order = prop.Value.Order;
                    }

                    // TODO - Check if the property type has changed and update it
                }

                AssetLoader <Material> .Save(mat, matAsset.Path);

                ProjectManager.Instance.Content.MarkDirty(mat.LinkedProjectAsset.Guid);
            }
            mOnyxInstance.Resources.RefreshDirty();
        }
Пример #4
0
		protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
		{
			YAMLMappingNode node = base.ExportYAMLRoot(container);
			node.AddSerializedVersion(GetSerializedVersion(container.Version));
			node.Add("m_Gravity", Gravity.ExportYAML(container));
			node.Add("m_DefaultMaterial", DefaultMaterial.ExportYAML(container));
			node.Add("m_BounceThreshold", BounceThreshold);
			node.Add("m_SleepThreshold", GetSleepThreshold(container.Version));
			node.Add("m_DefaultContactOffset", GetDefaultContactOffset(container.Version));
			node.Add("m_DefaultSolverIterations", DefaultSolverIterations);
			node.Add("m_DefaultSolverVelocityIterations", GetDefaultSolverVelocityIterations(container.Version));
			node.Add("m_QueriesHitBackfaces", QueriesHitBackfaces);
			node.Add("m_QueriesHitTriggers", GetQueriesHitTriggers(container.Version));
			node.Add("m_EnableAdaptiveForce", EnableAdaptiveForce);
			node.Add("m_ClothInterCollisionDistance", ClothInterCollisionDistance);
			node.Add("m_ClothInterCollisionStiffness", ClothInterCollisionStiffness);
			node.Add("m_ContactsGeneration", (int)GetContactsGeneration(container.Version));
			node.Add("m_LayerCollisionMatrix", GetLayerCollisionMatrix(container.Version).ExportYAML(true));
			node.Add("m_AutoSimulation", GetAutoSimulation(container.Version));
			node.Add("m_AutoSyncTransforms", GetAutoSyncTransforms(container.Version));
			node.Add("m_ClothInterCollisionSettingsToggle", ClothInterCollisionSettingsToggle);
			node.Add("m_ContactPairsMode", (int)ContactPairsMode);
			node.Add("m_BroadphaseType", (int)BroadphaseType);
			node.Add("m_WorldBounds", GetWorldBounds(container.Version).ExportYAML(container));
			node.Add("m_WorldSubdivisions", GetWorldSubdivisions(container.Version));
			return node;
		}
Пример #5
0
        public Line(Vector3 a, Vector3 b, Vector4 col) : base()
        {
            Name = "Line";

            A     = a;
            B     = b;
            color = col;

            positionVboData = new Vector3[] { a, b };

            indicesVboData = new int[]
            {
                0, 1
            };

            material = new DefaultMaterial();
            if (!material.Ready)
            {
                Log.WriteLine(Log.LOG_ERROR, "failed to load default material");
                return;
            }

            createVBOs();
            createVAOs();

            ready = true;
        }
Пример #6
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(GravityName, Gravity.ExportYAML(container));
            node.Add(DefaultMaterialName, DefaultMaterial.ExportYAML(container));
            node.Add(BounceThresholdName, BounceThreshold);
            node.Add(SleepThresholdName, GetSleepThreshold(container.Version));
            node.Add(DefaultContactOffsetName, GetDefaultContactOffset(container.Version));
            node.Add(DefaultSolverIterationsName, DefaultSolverIterations);
            node.Add(DefaultSolverVelocityIterationsName, GetDefaultSolverVelocityIterations(container.Version));
            node.Add(QueriesHitBackfacesName, QueriesHitBackfaces);
            node.Add(QueriesHitTriggersName, GetQueriesHitTriggers(container.Version));
            node.Add(EnableAdaptiveForceName, EnableAdaptiveForce);
            node.Add(ClothInterCollisionDistanceName, ClothInterCollisionDistance);
            node.Add(ClothInterCollisionStiffnessName, ClothInterCollisionStiffness);
            node.Add(ContactsGenerationName, (int)GetContactsGeneration(container.Version));
            node.Add(LayerCollisionMatrixName, GetLayerCollisionMatrix(container.Version).ExportYAML(true));
            node.Add(AutoSimulationName, GetAutoSimulation(container.Version));
            node.Add(AutoSyncTransformsName, GetAutoSyncTransforms(container.Version));
            node.Add(ReuseCollisionCallbacksName, ReuseCollisionCallbacks);
            node.Add(ClothInterCollisionSettingsToggleName, ClothInterCollisionSettingsToggle);
            node.Add(ContactPairsModeName, (int)ContactPairsMode);
            node.Add(BroadphaseTypeName, (int)BroadphaseType);
            node.Add(WorldBoundsName, GetWorldBounds(container.Version).ExportYAML(container));
            node.Add(WorldSubdivisionsName, GetWorldSubdivisions(container.Version));
            if (IsReadFrictionType(container.ExportVersion))
            {
                node.Add(FrictionTypeName, (int)FrictionType);
                node.Add(EnableEnhancedDeterminismName, EnableEnhancedDeterminism);
                node.Add(EnableUnifiedHeightmapsName, GetEnableUnifiedHeightmaps(container.Version));
            }
            return(node);
        }
Пример #7
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(LineSpacingName, LineSpacing);
            node.Add(DefaultMaterialName, DefaultMaterial.ExportYAML(container));
            node.Add(FontSizeName, FontSize);
            node.Add(TextureName, Texture.ExportYAML(container));
            node.Add(AsciiStartOffsetName, AsciiStartOffset);
            node.Add(TrackingName, GetTracking(container.Version));
            node.Add(CharacterSpacingName, CharacterSpacing);
            node.Add(CharacterPaddingName, GetCharacterPadding(container.Version));
            node.Add(ConvertCaseName, ConvertCase);
            node.Add(CharacterRectsName, CharacterRects.ExportYAML(container));
            node.Add(KerningValuesName, KerningValues.ExportYAML(container));
            node.Add(PixelScaleName, GetPixelScale(container.Version));
            node.Add(FontDataName, GetFontData(container.Version).ExportYAML());
            node.Add(AscentName, Ascent);
            node.Add(DescentName, Descent);
            node.Add(DefaultStyleName, (int)DefaultStyle);
            node.Add(FontNamesName, GetFontNames(container.Version).ExportYAML());
            node.Add(FallbackFontsName, GetFallbackFonts(container.Version).ExportYAML(container));
            node.Add(FontRenderingModeName, (int)FontRenderingMode);
            node.Add(UseLegacyBoundsCalculationName, UseLegacyBoundsCalculation);
            node.Add(ShouldRoundAdvanceValueName, GetShouldRoundAdvanceValue(container.Version));
            return(node);
        }
Пример #8
0
        public void InitDefaultResources(DeviceContext deviceContext)
        {
            DefaultShader   = RequestShaderResource(new SHashedName("SimpleLitShader"));
            DepthShader     = RequestShaderResource(new SHashedName("depthShader"));
            DepthCubeShader = RequestShaderResource(new SHashedName("depthCubeShader"));

            DefaultTexture  = new CTextureSampler(m_graphicsDevice, deviceContext, "Resources/Textures/DefaultTexture.tga");
            FallbackTexture = new CTextureSampler(m_graphicsDevice, deviceContext, "Resources/Textures/MissingTexture.tga");
            WhiteTexture    = new CTextureSampler(m_graphicsDevice, deviceContext, "Resources/Textures/DefaultWhite.tga");
            BlackTexture    = new CTextureSampler(m_graphicsDevice, deviceContext, "Resources/Textures/DefaultBlack.tga");

            DefaultMaterial = CMaterial.CreateDefaultMaterial();
            DefaultMaterial.ShaderResource = DefaultShader;
            DefaultMaterial.SetTextureParameter(new SHashedName("DiffuseTexture"), WhiteTexture);
            DefaultMaterial.FinishLoading();

            DefaultTextureMaterial = CMaterial.CreateDefaultMaterial();
            DefaultTextureMaterial.ShaderResource = DefaultShader;
            DefaultTextureMaterial.SetTextureParameter(new SHashedName("DiffuseTexture"), DefaultTexture);
            DefaultTextureMaterial.FinishLoading();

            MissingTextureMaterial = CMaterial.CreateDefaultMaterial();
            MissingTextureMaterial.ShaderResource = DefaultShader;
            MissingTextureMaterial.SetTextureParameter(new SHashedName("DiffuseTexture"), FallbackTexture);
            MissingTextureMaterial.FinishLoading();
        }
Пример #9
0
        public override IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false)
        {
            foreach (Object asset in base.FetchDependencies(file, isLog))
            {
                yield return(asset);
            }

            yield return(DefaultMaterial.FetchDependency(file, isLog, ToLogString, "m_DefaultMaterial"));
        }
Пример #10
0
        /// <summary>
        /// Gets the <see cref="MaterialProperties"/> for the given rigid body, position and shape
        /// feature.
        /// </summary>
        /// <param name="body">The rigid body.</param>
        /// <param name="positionLocal">
        /// The local position on the rigid body for which the material properties should be returned.
        /// </param>
        /// <param name="featureIndex">
        /// The index of the shape feature from which the material properties are needed. For a
        /// <see cref="CompositeShape"/> the feature index is the index of the child of the composite
        /// shape. For a <see cref="TriangleMeshShape"/> the feature index is the index of a triangle.
        /// </param>
        /// <returns>
        /// The <see cref="MaterialProperties"/> of the given rigid body at the given position and
        /// child feature.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="body"/> is <see langword="null"/>.
        /// </exception>
        public MaterialProperties GetProperties(RigidBody body, Vector3 positionLocal, int featureIndex)
        {
            if (body == null)
            {
                throw new ArgumentNullException("body");
            }

            // No child feature - use default material.
            if (featureIndex < 0)
            {
                return(DefaultMaterial.GetProperties(body, positionLocal, featureIndex));
            }

            IMaterial material = null;

            // Try to find entry in list.
            if (featureIndex < Materials.Count)
            {
                material = Materials[featureIndex];
            }

            if (material == null)
            {
                // Check if feature is a rigid body.
                var compositeShape = body.Shape as CompositeShape;
                if (compositeShape != null && featureIndex < compositeShape.Children.Count)
                {
                    var childBody = compositeShape.Children[featureIndex] as RigidBody;
                    if (childBody != null)
                    {
                        material = childBody.Material;
                    }
                }
            }

            if (material == null)
            {
                // Fallback: Use DefaultMaterial.
                material = DefaultMaterial;
            }

            return(material.GetProperties(body, positionLocal, featureIndex));
        }
Пример #11
0
        public BuildingsCursor(Vector4 col) : base()
        {
            Name = "Buildings Cursor";

            color = col;
            //Scale = new Vector3(0.2f, 0.2f, 0.2f);

            material = new DefaultMaterial();
            if (!material.Ready)
            {
                Log.WriteLine(Log.LOG_ERROR, "failed to load default material");
                return;
            }

            columnGeometry(0, 0, 0, 0);
            createVBOs();
            createVAOs();

            ready = true;
        }
        // --------------------------------------------------------------------

        #region UI callbacks

        private void toolStripNewMaterialButton_Click(object sender, EventArgs e)
        {
            if (!ProjectLoader.AssertProjectExists())
            {
                return;
            }

            DefaultMaterial material = new DefaultMaterial();
            string          matPath  = SelectMaterialFile();

            if (matPath.Length == 0)
            {
                return;
            }

            ProjectManager.Instance.Content.AddMaterial(matPath, false, material);
            AssetLoader <Material> .Save(material, material.LinkedProjectAsset.Path);

            SetMaterial(material);
            materialViewList1.UpdateMaterialList(material.LinkedProjectAsset.Guid, true);
        }
Пример #13
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.Version));
            node.Add("m_Gravity", Gravity.ExportYAML(container));
            node.Add("m_DefaultMaterial", DefaultMaterial.ExportYAML(container));
            node.Add("m_VelocityIterations", VelocityIterations);
            node.Add("m_PositionIterations", PositionIterations);
            node.Add("m_VelocityThreshold", GetVelocityThreshold(container.Version));
            node.Add("m_MaxLinearCorrection", GetMaxLinearCorrection(container.Version));
            node.Add("m_MaxAngularCorrection", GetMaxAngularCorrection(container.Version));
            node.Add("m_MaxTranslationSpeed", GetMaxTranslationSpeed(container.Version));
            node.Add("m_MaxRotationSpeed", GetMaxRotationSpeed(container.Version));
            node.Add("m_BaumgarteScale", GetBaumgarteScale(container.Version));
            node.Add("m_BaumgarteTimeOfImpactScale", GetBaumgarteTimeOfImpactScale(container.Version));
            node.Add("m_TimeToSleep", GetTimeToSleep(container.Version));
            node.Add("m_LinearSleepTolerance", GetLinearSleepTolerance(container.Version));
            node.Add("m_AngularSleepTolerance", GetAngularSleepTolerance(container.Version));
            node.Add("m_DefaultContactOffset", GetDefaultContactOffset(container.Version));
            // 2018
            //node.Add("m_JobOptions", GetJobOptions(container.Version));
            node.Add("m_AutoSimulation", GetAutoSimulation(container.Version));
            node.Add("m_QueriesHitTriggers", QueriesHitTriggers);
            node.Add("m_QueriesStartInColliders", GetQueriesStartInColliders(container.Version));
            node.Add("m_ChangeStopsCallbacks", ChangeStopsCallbacks);
            node.Add("m_CallbacksOnDisable", GetCallbacksOnDisable(container.Version));
            node.Add("m_AutoSyncTransforms", GetAutoSyncTransforms(container.Version));
            node.Add("m_AlwaysShowColliders", GetAlwaysShowColliders());
            node.Add("m_ShowColliderSleep", GetShowColliderSleep(container.Version, container.Flags));
            node.Add("m_ShowColliderContacts", GetShowColliderContacts());
            node.Add("m_ShowColliderAABB", GetShowColliderAABB());
            node.Add("m_ContactArrowScale", GetContactArrowScale(container.Version, container.Flags));
            node.Add("m_ColliderAwakeColor", GetColliderAwakeColor(container.Version, container.Flags).ExportYAML(container));
            node.Add("m_ColliderAsleepColor", GetColliderAsleepColor(container.Version, container.Flags).ExportYAML(container));
            node.Add("m_ColliderContactColor", GetColliderContactColor(container.Version, container.Flags).ExportYAML(container));
            node.Add("m_ColliderAABBColor", GetColliderAABBColor(container.Version, container.Flags).ExportYAML(container));
            node.Add("m_LayerCollisionMatrix", LayerCollisionMatrix.ExportYAML(true));
            return(node);
        }
Пример #14
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(GravityName, Gravity.ExportYAML(container));
            node.Add(DefaultMaterialName, DefaultMaterial.ExportYAML(container));
            node.Add(VelocityIterationsName, VelocityIterations);
            node.Add(PositionIterationsName, PositionIterations);
            node.Add(VelocityThresholdName, GetVelocityThreshold(container.Version));
            node.Add(MaxLinearCorrectionName, GetMaxLinearCorrection(container.Version));
            node.Add(MaxAngularCorrectionName, GetMaxAngularCorrection(container.Version));
            node.Add(MaxTranslationSpeedName, GetMaxTranslationSpeed(container.Version));
            node.Add(MaxRotationSpeedName, GetMaxRotationSpeed(container.Version));
            node.Add(BaumgarteScaleName, GetBaumgarteScale(container.Version));
            node.Add(BaumgarteTimeOfImpactScaleName, GetBaumgarteTimeOfImpactScale(container.Version));
            node.Add(TimeToSleepName, GetTimeToSleep(container.Version));
            node.Add(LinearSleepToleranceName, GetLinearSleepTolerance(container.Version));
            node.Add(AngularSleepToleranceName, GetAngularSleepTolerance(container.Version));
            node.Add(DefaultContactOffsetName, GetDefaultContactOffset(container.Version));
            // 2018
            //node.Add("m_JobOptions", GetJobOptions(container.Version));
            node.Add(AutoSimulationName, GetAutoSimulation(container.Version));
            node.Add(QueriesHitTriggersName, QueriesHitTriggers);
            node.Add(QueriesStartInCollidersName, GetQueriesStartInColliders(container.Version));
            node.Add(ChangeStopsCallbacksName, ChangeStopsCallbacks);
            node.Add(CallbacksOnDisableName, GetCallbacksOnDisable(container.Version));
            node.Add(AutoSyncTransformsName, GetAutoSyncTransforms(container.Version));
            node.Add(AlwaysShowCollidersName, GetAlwaysShowColliders());
            node.Add(ShowColliderSleepName, GetShowColliderSleep(container.Version, container.Flags));
            node.Add(ShowColliderContactsName, GetShowColliderContacts());
            node.Add(ShowColliderAABBName, GetShowColliderAABB());
            node.Add(ContactArrowScaleName, GetContactArrowScale(container.Version, container.Flags));
            node.Add(ColliderAwakeColorName, GetColliderAwakeColor(container.Version, container.Flags).ExportYAML(container));
            node.Add(ColliderAsleepColorName, GetColliderAsleepColor(container.Version, container.Flags).ExportYAML(container));
            node.Add(ColliderContactColorName, GetColliderContactColor(container.Version, container.Flags).ExportYAML(container));
            node.Add(ColliderAABBColorName, GetColliderAABBColor(container.Version, container.Flags).ExportYAML(container));
            node.Add(LayerCollisionMatrixName, LayerCollisionMatrix.ExportYAML(true));
            return(node);
        }
Пример #15
0
        public Cube(float negX, float negY, float negZ, float posX, float posY, float posZ, Vector3 color) : base(color)
        {
            Name = "Cube";

            positionVboData = new Vector3[] {
                new Vector3(negX, negY, posZ),
                new Vector3(posX, negY, posZ),
                new Vector3(posX, posY, posZ),
                new Vector3(negX, posY, posZ),
                new Vector3(negX, negY, negZ),
                new Vector3(posX, negY, negZ),
                new Vector3(posX, posY, negZ),
                new Vector3(negX, posY, negZ)
            };

            indicesVboData = new int[] {
                // front face
                0, 1, 2, 2, 3, 0,

                // top face
                3, 2, 6, 6, 7, 3,
                // back face
                7, 6, 5, 5, 4, 7,
                // left face
                4, 0, 3, 3, 7, 4,
                // bottom face
                0, 1, 5, 5, 4, 0,
                // right face
                1, 5, 6, 6, 2, 1
            };


            material = new DefaultMaterial();

            createVBOs();
            createVAOs();

            ready = true;
        }
Пример #16
0
        public void DrawPolygon(Pen pen, Point[] points)
        {
            if (DefaultMaterial != null)
            {
                DefaultMaterial.SetPass(0);
            }

            for (int i = 0; i < points.Length; i++)
            {
                if (i + 1 >= points.Length)
                {
                    break;
                }

                GL.Begin(GL.LINES);
                GL.Color(pen.Color.ToUColor());

                GL.Vertex3(points[i].X, points[i].Y, 0);
                GL.Vertex3(points[i + 1].X, points[i + 1].Y, 0);

                GL.End();
            }
        }
Пример #17
0
        public static void CreateMaterial(JOB job)
        {
            #region BFS로 Routing
            { /* BFS하기 전에 초기화 */
                queue.Clear();
                isFound   = false;
                MAXOFMIN  = EnumClass.MINNUM;
                lastRoute = null;
            }
            // Start Vertex를 queue에 집어넣는다.
            queue.Enqueue(new Tuple <String, Route>(job.source, new Route(job.source)));

            Console.WriteLine("BFS 시작");
            Console.WriteLine("");

            BFS(job.terminal);
            #endregion BFS로 Routing

            #region Routing 결과
            Console.WriteLine("");
            Console.WriteLine("MaxOfMin(최소유량 중 최대값) = {0}", MAXOFMIN);
            Console.Write("가장 한가한 경로 : ");
            lastRoute.printRoute();
            #endregion Routing 결과

            #region 물류 객체 생성
            Material newMaterial;
            switch (job.MaterialType)
            {
            case MATERIAL_TYPE.DEFAULT_MATERIAL:
                newMaterial = new DefaultMaterial(lastRoute);
                break;

            default:
                newMaterial = new DefaultMaterial(lastRoute);
                break;
            }
            #endregion 물류 객체 생성

            #region Routing경로 사용
            Console.WriteLine("");
            Console.WriteLine("경로 사용..");
            try
            {
                lastRoute.useRoute(g);
            }
            catch (RouteException re)
            {
                Console.WriteLine(re.Message);
            }
            finally
            {
                Console.WriteLine("경로 사용 완료!");
                Console.WriteLine("----------------------");

                Console.WriteLine("경로 설정된 후의 Graph");
                Console.WriteLine("");
                g.printGraph();
            }

            #endregion Routing경로 사용
        }
Пример #18
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            if (IsReadFontImpl(reader.Version))
            {
                LineSpacing = reader.ReadSingle();
                DefaultMaterial.Read(reader);
                FontSize = reader.ReadSingle();
                Texture.Read(reader);
                reader.AlignStream(AlignType.Align4);
            }

            if (IsShortAsciiStartOffset(reader.Version))
            {
                AsciiStartOffset = reader.ReadInt16();
                FontCountX       = reader.ReadInt16();
                FontCountY       = reader.ReadInt16();
            }
            else
            {
                AsciiStartOffset = reader.ReadInt32();
                if (IsReadFontCount(reader.Version))
                {
                    FontCountX = reader.ReadInt32();
                    FontCountY = reader.ReadInt32();
                }
            }

            if (IsReadKerning(reader.Version))
            {
                Kerning = reader.ReadSingle();
            }
            if (IsReadTracking(reader.Version))
            {
                Tracking = reader.ReadSingle();
            }

            if (!IsReadFontImpl(reader.Version))
            {
                LineSpacing = reader.ReadSingle();
            }

            if (IsReadCharacterSpacing(reader.Version))
            {
                CharacterSpacing = reader.ReadInt32();
                CharacterPadding = reader.ReadInt32();
            }

            if (IsReadPerCharacterKerning(reader.Version))
            {
                if (IsBytePerCharacterKerning(reader.Version))
                {
                    m_perCharacterKerningByte = reader.ReadTupleByteSingleArray();
                }
                else
                {
                    m_perCharacterKerning = reader.ReadTupleIntFloatArray();
                }
            }

            ConvertCase = reader.ReadInt32();
            if (!IsReadFontImpl(reader.Version))
            {
                DefaultMaterial.Read(reader);
            }
            m_characterRects = reader.ReadArray <CharacterInfo>();
            if (!IsReadFontImpl(reader.Version))
            {
                Texture.Read(reader);
            }

            if (IsReadGridFont(reader.Version))
            {
                if (IsGridFontFirst(reader.Version))
                {
                    GridFont = reader.ReadBoolean();
                }
            }

            if (IsByteKerningValues(reader.Version))
            {
                m_kerningValuesByte = new Dictionary <Tuple <byte, byte>, float>();
                m_kerningValuesByte.Read(reader);
            }
            else
            {
                m_kerningValues.Read(reader);
            }

            if (IsReadPixelScale(reader.Version))
            {
                PixelScale = reader.ReadSingle();
                reader.AlignStream(AlignType.Align4);
            }

            if (IsReadGridFont(reader.Version))
            {
                if (!IsGridFontFirst(reader.Version))
                {
                    GridFont = reader.ReadBoolean();
                    if (IsAlign(reader.Version))
                    {
                        reader.AlignStream(AlignType.Align4);
                    }
                }
            }

            if (IsReadFontData(reader.Version))
            {
                m_fontData = reader.ReadByteArray();
                reader.AlignStream(AlignType.Align4);

                if (!IsReadFontImpl(reader.Version))
                {
                    FontSize = reader.ReadSingle();
                }
                Ascent = reader.ReadSingle();
            }
            if (IsReadDescent(reader.Version))
            {
                Descent = reader.ReadSingle();
            }
            if (IsReadDefaultStyle(reader.Version))
            {
                DefaultStyle = (FontStyle)reader.ReadUInt32();
                m_fontNames  = reader.ReadStringArray();
            }

            if (IsReadFallbackFonts(reader.Version))
            {
                m_fallbackFonts = reader.ReadArray <PPtr <Font> >();
                reader.AlignStream(AlignType.Align4);

                FontRenderingMode = (FontRenderingMode)reader.ReadInt32();
            }

            if (IsReadUseLegacyBoundsCalculation(reader.Version))
            {
                UseLegacyBoundsCalculation = reader.ReadBoolean();
            }
            if (IsReadShouldRoundAdvanceValue(reader.Version))
            {
                ShouldRoundAdvanceValue = reader.ReadBoolean();
            }
        }
Пример #19
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            bool isGrouped = IsFontGrouped(reader.Version);

            if (isGrouped)
            {
                LineSpacing = reader.ReadSingle();
                DefaultMaterial.Read(reader);
                FontSize = reader.ReadSingle();
                Texture.Read(reader);
                reader.AlignStream();
            }

            if (IsShortAsciiStartOffset(reader.Version))
            {
                AsciiStartOffset = reader.ReadInt16();
                FontCountX       = reader.ReadInt16();
                FontCountY       = reader.ReadInt16();
            }
            else
            {
                AsciiStartOffset = reader.ReadInt32();
                if (HasFontCount(reader.Version))
                {
                    FontCountX = reader.ReadInt32();
                    FontCountY = reader.ReadInt32();
                }
            }

            if (HasKerning(reader.Version))
            {
                Kerning = reader.ReadSingle();
            }
            if (HasTracking(reader.Version))
            {
                Tracking = reader.ReadSingle();
            }

            if (!isGrouped)
            {
                LineSpacing = reader.ReadSingle();
            }

            if (HasCharacterSpacing(reader.Version))
            {
                CharacterSpacing = reader.ReadInt32();
                CharacterPadding = reader.ReadInt32();
            }

            if (HasPerCharacterKerning(reader.Version))
            {
                if (IsBytePerCharacterKerning(reader.Version))
                {
                    PerCharacterKerningByte = reader.ReadTupleByteSingleArray();
                }
                else
                {
                    PerCharacterKerning = reader.ReadTupleIntSingleArray();
                }
            }

            ConvertCase = reader.ReadInt32();
            if (!isGrouped)
            {
                DefaultMaterial.Read(reader);
            }
            CharacterRects = reader.ReadAssetArray <CharacterInfo>();
            if (!isGrouped)
            {
                Texture.Read(reader);
            }

            if (HasGridFont(reader.Version))
            {
                if (IsGridFontFirst(reader.Version))
                {
                    GridFont = reader.ReadBoolean();
                }
            }

#warning TODO: create a dictionary with non unique keys
            if (IsByteKerningValues(reader.Version))
            {
                Dictionary <Tuple <byte, byte>, float> kerningValues = new Dictionary <Tuple <byte, byte>, float>();
                kerningValues.ReadSafe(reader);
                foreach (var kvp in kerningValues)
                {
                    Tuple <ushort, ushort> key = new Tuple <ushort, ushort>(kvp.Key.Item1, kvp.Key.Item2);
                    KerningValues.Add(key, kvp.Value);
                }
            }
            else
            {
                KerningValues.ReadSafe(reader);
            }

            if (HasPixelScale(reader.Version))
            {
                PixelScale = reader.ReadSingle();
                reader.AlignStream();
            }

            if (HasGridFont(reader.Version))
            {
                if (!IsGridFontFirst(reader.Version))
                {
                    GridFont = reader.ReadBoolean();
                    if (IsAlign(reader.Version))
                    {
                        reader.AlignStream();
                    }
                }
            }

            if (HasFontData(reader.Version))
            {
                FontData = reader.ReadByteArray();
                reader.AlignStream();

                if (!isGrouped)
                {
                    FontSize = reader.ReadSingle();
                }
                Ascent = reader.ReadSingle();
            }
            if (HasDescent(reader.Version))
            {
                Descent = reader.ReadSingle();
            }
            if (HasDefaultStyle(reader.Version))
            {
                DefaultStyle = (FontStyle)reader.ReadUInt32();
                FontNames    = reader.ReadStringArray();
            }

            if (HasFallbackFonts(reader.Version))
            {
                FallbackFonts = reader.ReadAssetArray <PPtr <Font> >();
                reader.AlignStream();

                FontRenderingMode = (FontRenderingMode)reader.ReadInt32();
            }

            if (HasUseLegacyBoundsCalculation(reader.Version))
            {
                UseLegacyBoundsCalculation = reader.ReadBoolean();
            }
            if (HasShouldRoundAdvanceValue(reader.Version))
            {
                ShouldRoundAdvanceValue = reader.ReadBoolean();
            }
        }
Пример #20
0
        public void DrawLine(Pen pen, float x1, float y1, float x2, float y2)
        {
            if (pen.Color.A <= 0)
            {
                return;
            }

            if (GL_Lines)
            {
                GL.PushMatrix();
                if (DefaultMaterial != null)
                {
                    DefaultMaterial.SetPass(0);
                }
                GL.LoadOrtho();

                GL.Begin(GL.LINES);
                GL.Color(pen.Color.ToUColor());

                // TODO: switch (pen.DashStyle) { ... }

                GL.Vertex3(x1, y1, 0);
                GL.Vertex3(x2, y2, 0);

                GL.End();
                GL.PopMatrix();
                return;
            }

            float x      = 0;
            float y      = 0;
            float width  = 0;
            float height = 0;

            if (x1 != x2 && y1 != y2)
            {
                Control.Batches++;

                float xDiff = x2 - x1;
                float yDiff = y2 - y1;
                var   angle = Math.Atan2(yDiff, xDiff) * 180.0 / Math.PI;

                DrawTexture(System.Windows.Forms.ApplicationBehaviour.Resources.Images.Circle, x1, y1, (float)Math.Sqrt(xDiff * xDiff + yDiff * yDiff), pen.Width, pen.Color, (float)angle, new PointF());
                return;
            }

            if (x1 == x2)
            {
                if (y1 > y2)
                {
                    y1 += pen.Width;
                }
                else
                {
                    y2 += pen.Width;
                }
                x     = x1;
                width = pen.Width;
                if (y1 < y2)
                {
                    y      = y1;
                    height = y2 - y1;
                }
                else
                {
                    y      = y2;
                    height = y1 - y2;
                }
            }
            if (y1 == y2)
            {
                y      = y1;
                height = pen.Width;
                if (x1 < x2)
                {
                    x     = x1;
                    width = x2 - x1;
                }
                else
                {
                    x     = x2;
                    width = x1 - x2;
                }
            }

            GUI.color = pen.Color.ToUColor();

            switch (pen.DashStyle)
            {
            case Drawing2D.DashStyle.Solid:
                if (Control != null)
                {
                    Control.Batches++;
                }
                GUI.DrawTexture(new Rect(x, y, width, height), System.Windows.Forms.ApplicationBehaviour.DefaultSprite);
                break;

            case Drawing2D.DashStyle.Dash:
                float dash_step = pen.Width * 6;
                if (y1 == y2)
                {
                    for (float i = 0; i < width; i += dash_step)
                    {
                        float dash_width = dash_step - 2;
                        if (i + dash_width > width)
                        {
                            dash_width = width - i;
                        }
                        if (Control != null)
                        {
                            Control.Batches++;
                        }
                        GUI.DrawTexture(new Rect(x + i, y, dash_width, pen.Width), System.Windows.Forms.ApplicationBehaviour.DefaultSprite);
                    }
                }

                if (x1 == x2)
                {
                    for (float i = 0; i < height; i += dash_step)
                    {
                        float dash_height = dash_step - 2;
                        if (i + dash_height > height)
                        {
                            dash_height = height - i;
                        }
                        if (Control != null)
                        {
                            Control.Batches++;
                        }
                        GUI.DrawTexture(new Rect(x + width - pen.Width, y + i, pen.Width, dash_height), System.Windows.Forms.ApplicationBehaviour.DefaultSprite);
                    }
                }
                break;
            }
        }
Пример #21
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            Gravity.Read(reader);
            DefaultMaterial.Read(reader);
            BounceThreshold = reader.ReadSingle();
            if (IsReadSleepThreshold(reader.Version))
            {
                SleepThreshold = reader.ReadSingle();
            }
            else
            {
                SleepVelocity        = reader.ReadSingle();
                SleepAngularVelocity = reader.ReadSingle();
            }
            if (IsReadSleepAngularVelocity(reader.Version))
            {
                MaxAngularVelocity = reader.ReadSingle();
            }
            if (IsReadDefaultContactOffset(reader.Version))
            {
                DefaultContactOffset = reader.ReadSingle();
            }
            else
            {
                MinPenetrationForPenalty = reader.ReadSingle();
            }
            DefaultSolverIterations = reader.ReadInt32();
            if (IsReadDefaultSolverVelocityIterations(reader.Version))
            {
                DefaultSolverVelocityIterations = reader.ReadInt32();
            }
            if (IsReadQueriesHitBackfaces(reader.Version))
            {
                QueriesHitBackfaces = reader.ReadBoolean();
            }
            if (IsReadQueriesHitTriggers(reader.Version))
            {
                QueriesHitTriggers = reader.ReadBoolean();
            }
            if (IsReadEnableAdaptiveForce(reader.Version))
            {
                EnableAdaptiveForce = reader.ReadBoolean();
            }
            if (IsReadEnablePCM(reader.Version))
            {
                EnablePCM = reader.ReadBoolean();
            }
            if (IsAlign(reader.Version))
            {
                reader.AlignStream(AlignType.Align4);
            }

            if (IsReadClothInterCollisionDistance(reader.Version))
            {
                ClothInterCollisionDistance  = reader.ReadSingle();
                ClothInterCollisionStiffness = reader.ReadSingle();
                ContactsGeneration           = (ContactsGeneration)reader.ReadInt32();
                reader.AlignStream(AlignType.Align4);
            }

            if (IsReadLayerCollisionMatrix(reader.Version))
            {
                m_layerCollisionMatrix = reader.ReadUInt32Array();
            }

            if (IsReadAutoSimulation(reader.Version))
            {
                AutoSimulation = reader.ReadBoolean();
            }
            if (IsReadAutoSyncTransforms(reader.Version))
            {
                AutoSyncTransforms = reader.ReadBoolean();
            }
            if (IsReadClothInterCollisionSettingsToggle(reader.Version))
            {
                ClothInterCollisionSettingsToggle = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);

                ContactPairsMode = (ContactPairsMode)reader.ReadInt32();
                BroadphaseType   = (BroadphaseType)reader.ReadInt32();
                WorldBounds.Read(reader);
                WorldSubdivisions = reader.ReadInt32();
            }
            if (IsReadFrictionType(reader.Version))
            {
                FrictionType = (FrictionType)reader.ReadInt32();
                EnableEnhancedDeterminism = reader.ReadBoolean();
                EnableUnifiedHeightmaps   = reader.ReadBoolean();
            }
        }
Пример #22
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            Gravity.Read(reader);
            DefaultMaterial.Read(reader);
            VelocityIterations = reader.ReadInt32();
            PositionIterations = reader.ReadInt32();
            if (IsReadVelocityThreshold(reader.Version))
            {
                VelocityThreshold    = reader.ReadSingle();
                MaxLinearCorrection  = reader.ReadSingle();
                MaxAngularCorrection = reader.ReadSingle();
                MaxTranslationSpeed  = reader.ReadSingle();
                MaxRotationSpeed     = reader.ReadSingle();
            }
            if (IsReadMinPenetrationForPenalty(reader.Version))
            {
                MinPenetrationForPenalty = reader.ReadSingle();
            }
            if (IsReadBaumgarteScale(reader.Version))
            {
                BaumgarteScale             = reader.ReadSingle();
                BaumgarteTimeOfImpactScale = reader.ReadSingle();
                TimeToSleep           = reader.ReadSingle();
                LinearSleepTolerance  = reader.ReadSingle();
                AngularSleepTolerance = reader.ReadSingle();
            }
            if (IsReadDefaultContactOffset(reader.Version))
            {
                DefaultContactOffset = reader.ReadSingle();
            }
            if (IsReadJobOptions(reader.Version))
            {
                JobOptions.Read(reader);
            }
            if (IsReadAutoSimulation(reader.Version))
            {
                AutoSimulation = reader.ReadBoolean();
            }
            QueriesHitTriggers = reader.ReadBoolean();
            if (IsReadQueriesStartInColliders(reader.Version))
            {
                QueriesStartInColliders = reader.ReadBoolean();
            }
            if (IsReadDeleteStopsCallbacks(reader.Version))
            {
                DeleteStopsCallbacks = reader.ReadBoolean();
            }
            if (IsReadChangeStopsCallbacks(reader.Version))
            {
                ChangeStopsCallbacks = reader.ReadBoolean();
            }
            if (IsReadCallbacksOnDisable(reader.Version))
            {
                CallbacksOnDisable = reader.ReadBoolean();
            }
            if (IsReadAutoSyncTransforms(reader.Version))
            {
                AutoSyncTransforms = reader.ReadBoolean();
            }
#if UNIVERSAL
            if (IsReadAlwaysShowColliders(reader.Version, reader.Flags))
            {
                AlwaysShowColliders  = reader.ReadBoolean();
                ShowColliderSleep    = reader.ReadBoolean();
                ShowColliderContacts = reader.ReadBoolean();
            }
            if (IsReadShowColliderAABB(reader.Version, reader.Flags))
            {
                ShowColliderAABB = reader.ReadBoolean();
            }
#endif
            reader.AlignStream(AlignType.Align4);

#if UNIVERSAL
            if (IsReadContactArrowScale(reader.Version, reader.Flags))
            {
                ContactArrowScale = reader.ReadSingle();
                ColliderAwakeColor.Read(reader);
                ColliderAsleepColor.Read(reader);
                ColliderContactColor.Read(reader);
            }
            if (IsReadColliderAABBColor(reader.Version, reader.Flags))
            {
                ColliderAABBColor.Read(reader);
            }
#endif
            m_layerCollisionMatrix = reader.ReadUInt32Array();
        }