public AssetProperty(string label,
                      AssetProperties assetProperties,
                      Autodesk.Revit.DB.Visual.AssetProperty val) : base(label)
 {
     m_val             = val;
     m_assetProperties = assetProperties;
 }
Beispiel #2
0
        private void DrawSelectedAsset(AssetProperties assetProperties)
        {
            _selectedAssetStore.Clear();
            foreach (var file in assetProperties.Asset.Files)
            {
                var row = _selectedAssetStore.AddRow();
                _selectedAssetStore.SetValue(row, _selectedAssetNameField, file.ReducedPath);
                var imageSize = imageService.GetImageSize(file.Path);
                _selectedAssetStore.SetValue(row, _selectedAssetSizeField, imageSize.Width + "x" + imageSize.Height);
                _selectedAssetStore.SetValue(row, _selectedAssetImageField, Image.FromFile(file.Path).WithBoxSize(30, 30));
            }

            _selectedAssetResultStore.Clear();
            if (assetProperties.Result.Value == null)
            {
                return;
            }
            foreach (var condition in assetProperties.Result.Value)
            {
                var row         = _selectedAssetResultStore.AddRow();
                var resultImage = condition.IsFulfilled ? Image.FromResource("SwissAddinKnife.Resources.success.png") :
                                  Image.FromResource("SwissAddinKnife.Resources.unsuccess.png");

                _selectedAssetResultStore.SetValue(row, _selectedAssetResultIconField, resultImage.WithBoxSize(15));
                _selectedAssetResultStore.SetValue(row, _selectedAssetResultDescriptionField, condition.Description);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Used for determing if two AssetProperties are identical.
 /// </summary>
 /// <param name="props"></param>
 /// <returns></returns>
 public bool Equals(AssetProperties props)
 {
     return
         (props.color.Red == color.Red && props.color.Green == color.Green && props.color.Blue == color.Blue &&
          transparency == props.transparency &&
          translucency == props.translucency &&
          props.specular == specular);
 }
        /// <summary>
        /// Adds a surface to the output mesh. Not saved as a sub-surface until <see cref="DumpOutput"/> is called.
        /// </summary>
        /// <param name="bufferSurface">Surface to add to mesh.</param>
        /// <param name="asset">Asset for surface.</param>
        public void AddSurface(ref PartialSurface bufferSurface, AssetProperties asset)
        {
            // Create new surface
            BXDAMesh.BXDASurface newMeshSurface = new BXDAMesh.BXDASurface();

            // Apply Asset Properties
            if (asset == null)
            {
                return;
            }

            newMeshSurface.hasColor     = true;
            newMeshSurface.color        = asset.color;
            newMeshSurface.transparency = (float)asset.transparency;
            newMeshSurface.translucency = (float)asset.translucency;
            newMeshSurface.specular     = (float)asset.specular;

            // Prevent too many vertices
            if (bufferSurface.verts.count > MAX_VERTS_OR_FACETS)
            {
                throw new TooManyVerticesException();
            }

            int indexOffset;

            lock (outputVerts)
            {
                // Prevent too many vertices
                if (outputVerts.count + bufferSurface.verts.count > MAX_VERTS_OR_FACETS)
                {
                    DumpOutputInternal();
                }

                // Copy buffer vertices into output
                Array.Copy(bufferSurface.verts.coordinates, 0, outputVerts.coordinates, outputVerts.count * 3, bufferSurface.verts.count * 3);
                Array.Copy(bufferSurface.verts.norms, 0, outputVerts.norms, outputVerts.count * 3, bufferSurface.verts.count * 3);

                // Store length of output verts for later
                indexOffset        = outputVerts.count - 1;
                outputVerts.count += bufferSurface.verts.count;
            }

            // Copy buffer surface into output, incrementing indices relative to where verts where stitched into the vert array
            newMeshSurface.indicies = new int[bufferSurface.facets.count * 3];
            for (int i = 0; i < bufferSurface.facets.count * 3; i++)
            {
                newMeshSurface.indicies[i] = bufferSurface.facets.indices[i] + indexOffset; // Why does Inventor start from 1?!
            }
            // Add the new surface to the output
            lock (outputMeshSurfaces)
                outputMeshSurfaces.Add(newMeshSurface);

            // Empty buffer
            bufferSurface.verts.count  = 0;
            bufferSurface.facets.count = 0;
        }
    /// <summary>
    /// Calculates the facets of a surface, storing them in a <see cref="MeshController"/>.
    /// </summary>
    private void CalculateSurfaceFacets(SurfaceBody surf, MeshController outputMesh, bool separateFaces = false)
    {
        double tolerance = DEFAULT_TOLERANCE;

        PartialSurface bufferSurface = new PartialSurface();

        // Store a list of faces separate from the Inventor API
        Faces faces = surf.Faces;

        // Don't separate if only one color
        if (separateFaces)
        {
            separateFaces = MultipleAssets(faces);
        }

        // Do separate if too many faces
        if (!separateFaces)
        {
            surf.CalculateFacets(tolerance, out bufferSurface.verts.count, out bufferSurface.facets.count, out bufferSurface.verts.coordinates, out bufferSurface.verts.norms, out bufferSurface.facets.indices);

            if (bufferSurface.verts.count > MAX_VERTS_OR_FACETS || bufferSurface.facets.count > MAX_VERTS_OR_FACETS)
            {
                separateFaces = true;
            }
        }

        if (separateFaces)
        {
            // Add facets for each face of the surface
            foreach (Face face in faces)
            {
                if (face.Appearance != null)
                {
                    face.CalculateFacets(tolerance, out bufferSurface.verts.count, out bufferSurface.facets.count, out bufferSurface.verts.coordinates, out bufferSurface.verts.norms, out bufferSurface.facets.indices);
                    outputMesh.AddSurface(ref bufferSurface, GetAssetProperties(face.Appearance));
                }
            }
        }
        else
        {
            // Add facets once for the entire surface
            AssetProperties asset;
            try
            {
                asset = GetAssetProperties(faces[1].Appearance);
            }
            catch (Exception)
            {
                asset = new AssetProperties();
            }

            outputMesh.AddSurface(ref bufferSurface, asset);
        }
    }
Beispiel #6
0
        private string GenerateAssetWeightUri(double?loadedWeight, AssetProperties assetProperties)
        {
            if (loadedWeight != null && loadedWeight > 0)
            {
                return($"&vehicleWeight={loadedWeight}");
            }

            if (assetProperties != null && assetProperties.AssetWeight != null)
            {
                return($"&vehicleWeight={assetProperties.AssetWeight}");
            }

            return("");
        }
Beispiel #7
0
        private string GenerateAssetWidthUri(double?loadedWidth, AssetProperties assetProperties)
        {
            if (loadedWidth != null && loadedWidth > 0)
            {
                return($"&vehicleWidth={loadedWidth}");
            }

            if (assetProperties != null && assetProperties.AssetWidth != null)
            {
                return($"&vehicleWidth={assetProperties.AssetWidth}");
            }

            return("");
        }
Beispiel #8
0
        private static string GetAssetInfos(AssetProperties a)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(
                "\n- Name:\t\t" + a.Name +
                "\n- Path:\t\t" + a.Path +
                "\n- Checked:\t" + a.IsChecked +
                "\n- Selected:\tTrue" +
                "\n"
                );

            return(sb.ToString());
        }
Beispiel #9
0
        private void RC_Properties_Click(object sender, RoutedEventArgs e)
        {
            if (AssetsListBox.SelectedIndex >= 0)
            {
                AssetProperties a     = AssetsListBox.SelectedItem as AssetProperties;
                string          infos = GetAssetInfos(a);
                if (DarkMessageBox.ShowYesNo(infos, a.Name, "Copy Properties", "OK") == MessageBoxResult.Yes)
                {
                    Clipboard.SetText(infos);

                    new UpdateMyConsole(a.Name, CColors.Blue).Append();
                    new UpdateMyConsole("'s properties successfully copied", CColors.White, true).Append();
                }
            }
        }
Beispiel #10
0
    /// <summary>
    /// Copies mesh information from the Inventor API to the temporary mesh buffer, then into the mesh structure.
    /// </summary>
    /// <param name="surf">The source mesh</param>
    /// <param name="tolerance">The chord tolerance for the mesh</param>
    private void AddFacets(Face surf, double tolerance)
    {
        tmpSurface.vertCount = 0;
#if USE_TEXTURES
        surf.GetExistingFacetsAndTextureMap(tolerances[bestIndex], out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies, out tmpSurface.textureCoords);
        if (tmpSurface.vertCount == 0)
        {
            surf.CalculateFacetsAndTextureMap(tolerances[bestIndex], out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies, out tmpSurface.textureCoords);
        }
#else
        surf.GetExistingFacets(tolerance, out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies);
        if (tmpSurface.vertCount == 0)
        {
            surf.CalculateFacets(tolerance, out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies);
        }
#endif
        AssetProperties assetProps = AssetProperties.Create(surf);
        AddFacetsInternal(assetProps);
    }
Beispiel #11
0
    /// <summary>
    /// Moves the mesh currently in the temporary mesh buffer into the mesh structure itself,
    /// with material information from the asset properties.
    /// </summary>
    /// <param name="assetProps">Material information to use</param>
    private void AddFacetsInternal(AssetProperties assetProps)
    {
        if (tmpSurface.vertCount > TMP_VERTICIES)
        {
            // This is just bad.  It could be fixed by exporting it per-face instead of with a single block.
            System.Windows.Forms.MessageBox.Show("Warning: Mesh segment exceededed " + TMP_VERTICIES + " verticies.  Strange things may begin to happen.");
        }
        // If adding this would cause the sub mesh to overflow dump what currently exists.
        if (tmpSurface.vertCount + postSurface.vertCount >= TMP_VERTICIES)
        {
            DumpMeshBuffer();
        }

        Array.Copy(tmpSurface.verts, 0, postSurface.verts, postSurface.vertCount * 3, tmpSurface.vertCount * 3);
        Array.Copy(tmpSurface.norms, 0, postSurface.norms, postSurface.vertCount * 3, tmpSurface.vertCount * 3);
#if USE_TEXTURES
        Array.Copy(tmpSurface.textureCoords, 0, postSurface.textureCoords, postSurface.vertCount * 2, tmpSurface.vertCount * 2);
#endif

        BXDAMesh.BXDASurface nextSurface = new BXDAMesh.BXDASurface();

        nextSurface.color = 0xFFFFFFFF;

        if (assetProps.color != null)
        {
            nextSurface.hasColor = true;
            nextSurface.color    = ((uint)assetProps.color.Red << 0) | ((uint)assetProps.color.Green << 8) | ((uint)assetProps.color.Blue << 16) | ((((uint)(assetProps.color.Opacity * 255)) & 0xFF) << 24);
        }
        nextSurface.transparency = (float)assetProps.transparency;
        nextSurface.translucency = (float)assetProps.translucency;
        nextSurface.specular     = (float)assetProps.specular;

        nextSurface.indicies = new int[tmpSurface.facetCount * 3];

        // Raw copy the indicies for now, then fix the offset in a background thread.
        Array.Copy(tmpSurface.indicies, nextSurface.indicies, nextSurface.indicies.Length);

        #region Fix Index Buffer Offset
        // Make sure we haven't exceeded the maximum number of background tasks.
        if (waitingThreads.Count > MAX_BACKGROUND_THREADS)
        {
            // Console.WriteLine("Got ahead of ourselves....");
            System.Threading.WaitHandle.WaitAll(waitingThreads.ToArray());
            waitingThreads.Clear();
        }
        {
            System.Threading.ManualResetEvent lockThing = new System.Threading.ManualResetEvent(false);
            waitingThreads.Add(lockThing);
            int offset            = postSurface.vertCount;
            int backingFacetCount = tmpSurface.facetCount;
            System.Threading.ThreadPool.QueueUserWorkItem(delegate(object obj)
            {
                for (int i = 0; i < backingFacetCount * 3; i++)
                {
                    nextSurface.indicies[i] = nextSurface.indicies[i] + offset - 1;
                    // Inventor has one-based indicies.  Zero-based is the way to go for everything except Inventor.
                }
                lockThing.Set();
            }, waitingThreads.Count);
        }
        #endregion

        postSurfaces.Add(nextSurface);

        postSurface.facetCount += tmpSurface.facetCount;
        postSurface.vertCount  += tmpSurface.vertCount;
    }
Beispiel #12
0
        public string GenerateURL(DispatchingParameters dispatchingParameters, AssetProperties assetProperties, bool isCarRoute = false)
        {
            var strBuilder = new StringBuilder("routeAttributes=routePath");

            if (dispatchingParameters.WayPoints != null)
            {
                strBuilder.Append(GenerateWayPointsUri(dispatchingParameters.WayPoints));
            }
            else
            {
                throw new BadArgumentException("WayPoints must be defined");
            }

            if (dispatchingParameters.MaxSolutions != null)
            {
                strBuilder.Append(GenerateMaxSolutionsUri(dispatchingParameters.MaxSolutions));
            }

            if (dispatchingParameters.DistanceUnit != null)
            {
                strBuilder.Append(GenerateDistanceUnitUri(dispatchingParameters.DistanceUnit));
            }

            if (dispatchingParameters.WeightUnit != null)
            {
                strBuilder.Append(GenerateWeightUnitUri(dispatchingParameters.WeightUnit));
            }

            if (dispatchingParameters.DimensionUnit != null)
            {
                strBuilder.Append(GenerateDimensionUnitUri(dispatchingParameters.DimensionUnit));
            }

            if (isCarRoute)
            {
                return(strBuilder.ToString());
            }

            if (dispatchingParameters.Optimize != null)
            {
                strBuilder.Append(GenerateOptimizeUri(dispatchingParameters.Optimize));
            }

            if (dispatchingParameters.Avoid != null && dispatchingParameters.Avoid.Count() > 0)
            {
                strBuilder.Append(GenerateAvoidUri(dispatchingParameters.Avoid));
            }

            if (dispatchingParameters.DistanceBeforeFirstTurn != null)
            {
                strBuilder.Append($"&distanceBeforeFirstTurn={dispatchingParameters.DistanceBeforeFirstTurn}");
            }

            if (dispatchingParameters.Heading != null)
            {
                strBuilder.Append(GenerateHeadingUri(dispatchingParameters.Heading));
            }

            if (dispatchingParameters.Tolerances != null)
            {
                strBuilder.Append(GenerateTolerancesUri(dispatchingParameters.Tolerances));
            }

            if (dispatchingParameters.AvoidCrossWind == true)
            {
                strBuilder.Append("&vehicleAvoidCrossWind=true");
            }

            if (dispatchingParameters.DateTime != null)
            {
                strBuilder.Append("&dateTime=" + dispatchingParameters.DateTime.ToString());

                if (dispatchingParameters.TimeType != null)
                {
                    strBuilder.Append(GenerateTimeTypeUri(dispatchingParameters.TimeType));
                }
            }

            strBuilder.Append(GenerateAssetHeightUri(dispatchingParameters.LoadedHeight, assetProperties));
            strBuilder.Append(GenerateAssetLengthUri(dispatchingParameters.LoadedLength, assetProperties));
            strBuilder.Append(GenerateAssetWidthUri(dispatchingParameters.LoadedWidth, assetProperties));
            strBuilder.Append(GenerateAssetWeightUri(dispatchingParameters.LoadedWeight, assetProperties));


            if (dispatchingParameters.AvoidGroundingRisk == true)
            {
                strBuilder.Append("&vehicleAvoidGroundingRisk=true");
            }

            if (dispatchingParameters.HazardousMaterials != null && dispatchingParameters.HazardousMaterials.Count() > 0)
            {
                strBuilder.Append(GenerateHazardousMaterialsUri(dispatchingParameters.HazardousMaterials));
            }

            if (dispatchingParameters.HazardousPermits != null && dispatchingParameters.HazardousPermits.Count() > 0)
            {
                strBuilder.Append(GenerateHazardousPermitsUri(dispatchingParameters.HazardousPermits));
            }

            if (assetProperties == null)
            {
                return(strBuilder.ToString());
            }

            if (assetProperties.AssetAxels != null)
            {
                strBuilder.Append($"&vehicleAxles={assetProperties.AssetAxels}");
            }

            if (assetProperties.AssetTrailers != null)
            {
                strBuilder.Append($"&vehicleTrailers={assetProperties.AssetTrailers}");
            }

            if (assetProperties.AssetSemi == true)
            {
                strBuilder.Append("&vehicleSemi=true");
            }

            if (assetProperties.AssetMaxGradient != null)
            {
                strBuilder.Append($"&vehicleMaxGradient={assetProperties.AssetMaxGradient}");
            }

            if (assetProperties.AssetMinTurnRadius != null)
            {
                strBuilder.Append($"&vehicleMinTurnRadius={assetProperties.AssetMinTurnRadius}");
            }

            return(strBuilder.ToString());
        }
Beispiel #13
0
        public async Task <IEnumerable <DispatchingResults> > CallRoutingAPI(DispatchingParameters dispatchingParameters, AssetProperties assetProperties)
        {
            var url      = $"{this.routingUrl}{GenerateURL(dispatchingParameters, assetProperties)}&key={this.bingMapsKey}";
            var response = await httpClient.GetAsync(url);

            if (!response.IsSuccessStatusCode)
            {
                throw new BadArgumentException($"Dispatching API returned: {response.StatusCode}");
            }

            var content = await response.Content.ReadAsStringAsync();

            var apiResult = JObject.Parse(content);

            var result = ExtractDispatchingResults(apiResult);

            if (dispatchingParameters.GetAlternativeCarRoute)
            {
                var alternativeUrl = $"{this.routingUrl}{GenerateURL(dispatchingParameters, assetProperties, true)}&key={this.bingMapsKey}";

                response = await httpClient.GetAsync(alternativeUrl);

                if (!response.IsSuccessStatusCode)
                {
                    throw new BadArgumentException($"Alternative dispatching API returned: {response.StatusCode}");
                }

                content = await response.Content.ReadAsStringAsync();

                apiResult = JObject.Parse(content);

                var alternativePath = ExtractAlternativeDispatchingResult(apiResult);

                foreach (var dispatchingResult in result)
                {
                    dispatchingResult.AlternativeCarRoutePoints = alternativePath;
                }
            }

            return(result);
        }
Beispiel #14
0
        private void LogMaterial(AssetProperty asset, StringBuilder log, string t = null)
        {
            if (asset == null)
            {
                return;
            }
            log.Append(t + "Asset.Type:" + asset.Type.ToString() + "::" + asset.Name + "=");
            switch (asset.Type)
            {
            case AssetPropertyType.APT_Asset:
                Asset a = asset as Asset;
                log.Append("Asset,Size:" + a.Size + "\n");
                for (int i = 0; i < a.Size; i++)
                {
                    LogMaterial(a[i], log, t + "\t");
                }
                break;

            case AssetPropertyType.APT_Boolean:
                AssetPropertyBoolean ab = asset as AssetPropertyBoolean;
                log.Append(ab.Value + "\n");
                break;

            case AssetPropertyType.APT_Distance:
                AssetPropertyDistance ad = asset as AssetPropertyDistance;
                log.Append(ad.Value + "\n");
                break;

            case AssetPropertyType.APT_Double:
                AssetPropertyDouble ado = asset as AssetPropertyDouble;
                log.Append(ado.Value + "\n");
                break;

            case AssetPropertyType.APT_Double44:
                break;

            case AssetPropertyType.APT_DoubleArray2d:
                AssetPropertyDoubleArray2d ado2 = asset as AssetPropertyDoubleArray2d;
                log.Append(ado2.Value.get_Item(0) + "," + ado2.Value.get_Item(1) + "\n");
                break;

            case AssetPropertyType.APT_DoubleArray3d:
                AssetPropertyDoubleArray3d ado3 = asset as AssetPropertyDoubleArray3d;
                log.Append(ado3.Value.get_Item(0) + "," + ado3.Value.get_Item(1) + "," + ado3.Value.get_Item(2) + "\n");
                break;

            case AssetPropertyType.APT_DoubleArray4d:
                AssetPropertyDoubleArray4d ado4 = asset as AssetPropertyDoubleArray4d;
                log.Append(ado4.Value.get_Item(0) + "," + ado4.Value.get_Item(1) + "," + ado4.Value.get_Item(2) + "," + ado4.Value.get_Item(3) + "\n");
                break;

            case AssetPropertyType.APT_Enum:
                AssetPropertyEnum ae = asset as AssetPropertyEnum;
                log.Append(ae.Value + "\n");
                break;

            case AssetPropertyType.APT_Float:
                AssetPropertyFloat af = asset as AssetPropertyFloat;
                log.Append(af.Value + "\n");
                break;

            case AssetPropertyType.APT_FloatArray:
                IList <float> lf = (asset as AssetPropertyFloatArray).GetValue();
                foreach (float f in lf)
                {
                    log.Append(f + ",");
                }
                log.Append("\n");
                break;

            case AssetPropertyType.APT_Int64:
                AssetPropertyInt64 ai6 = asset as AssetPropertyInt64;
                log.Append(ai6.Value + "\n");
                break;

            case AssetPropertyType.APT_Integer:
                AssetPropertyInteger ai = asset as AssetPropertyInteger;
                log.Append(ai.Value + "\n");
                break;

            case AssetPropertyType.APT_List:
                break;

            case AssetPropertyType.APT_Properties:
                AssetProperties ap = asset as AssetProperties;
                log.Append("AssetProperties,Count:" + ap.Size + "\n");
                for (int i = 0; i < ap.Size; i++)
                {
                    LogMaterial(ap[i], log, t + "\t");
                }
                break;

            case AssetPropertyType.APT_Reference:
                break;

            case AssetPropertyType.APT_String:
                AssetPropertyString _as = asset as AssetPropertyString;
                log.Append(_as.Value + "\n");
                break;

            case AssetPropertyType.APT_Time:
                AssetPropertyTime at = asset as AssetPropertyTime;
                log.Append(at.Value + "\n");
                break;

            case AssetPropertyType.APT_UInt64:
                AssetPropertyUInt64 aiu6 = asset as AssetPropertyUInt64;
                log.Append(aiu6.Value + "\n");
                break;

            case AssetPropertyType.APT_Unknown:
                log.Append("\n");
                break;

            default:
                log.Append("\n");
                break;
            }
            foreach (Asset _a in asset.GetAllConnectedProperties())
            {
                log.Append(t + "GetAllConnectedProperties:\n");
                LogMaterial(_a, log, t + "\t");
            }
        }
Beispiel #15
0
        //  public void OnDaylightPortal(DaylightPortalNode node)
        //{
        // Like RPCs, Daylight Portals too have their assets available only.
        // THere is no other public API for them currently available.


        //   return;
        //}

        public void OnMaterial(MaterialNode node)
        {
            materialNode = node;
            MessageBuffer mb = new MessageBuffer();

            mb.add(node.MaterialId.IntegerValue);
            mb.add(node.NodeName);
            mb.add(node.Color);
            mb.add((byte)(((100 - (node.Transparency)) / 100.0) * 255));
            Asset asset;

            if (node.HasOverriddenAppearance)
            {
                asset = node.GetAppearanceOverride();
            }
            else
            {
                asset = node.GetAppearance();
            }
            String          textureName = "";
            AssetProperties properties  = asset as AssetProperties;

            for (int index = 0; index < asset.Size; index++)
            {
                if (properties[index].Type == AssetPropertyType.Reference)
                {
                    AssetPropertyReference e = properties[index] as AssetPropertyReference;
                    if (e != null)
                    {
                        AssetProperty p = e.GetConnectedProperty(0);
                        if (p.Type == AssetPropertyType.Asset)
                        {
                            Asset a = p as Asset;
                            if (a != null)
                            {
                                Boolean         foundValidTexture = false;
                                AssetProperties prop = a as AssetProperties;
                                for (int ind = 0; ind < a.Size; ind++)
                                {
                                    if (prop[ind].Name == "unifiedbitmap_Bitmap")
                                    {
                                        AssetPropertyString ps = prop[ind] as AssetPropertyString;
                                        if (ps.Value != "")
                                        {
                                            textureName       = ps.Value;
                                            foundValidTexture = true;
                                        }
                                    }
                                    if (prop[ind].Name == "texture_URepeat")
                                    {
                                        AssetPropertyBoolean ps = prop[ind] as AssetPropertyBoolean;
                                        if (foundValidTexture)
                                        {
                                        }
                                        //textureName = ps.Value;
                                    }
                                    if (prop[ind].Name == "texture_VRepeat")
                                    {
                                        AssetPropertyBoolean ps = prop[ind] as AssetPropertyBoolean;
                                        if (foundValidTexture)
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            mb.add(textureName);
            OpenCOVERPlugin.COVER.Instance.sendMessage(mb.buf, OpenCOVERPlugin.COVER.MessageTypes.NewMaterial);

            return;
        }
Beispiel #16
0
        private IList <AssetCondition> GetAssetConditions(AssetProperties assetProperties)
        {
            List <AssetCondition> assetConditions = new List <AssetCondition>();

            if (assetProperties.Asset is AssetAndroid assetAndroid)
            {
                if (_androidStandardFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new AndroidContainsStandardFileCondition(assetAndroid));
                }

                if (_androidLdpiFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new AndroidContainsLdpiFileCondition(assetAndroid));
                }

                if (_androidMdpiFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new AndroidContainsMdpiFileCondition(assetAndroid));
                }

                if (_androidHdpiFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new AndroidContainsHdpiFileCondition(assetAndroid));
                }

                if (_androidXhdpiFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new AndroidContainsXhdpiFileCondition(assetAndroid));
                }

                if (_androidXxhdpiFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new AndroidContainsXxhdpiFileCondition(assetAndroid));
                }

                if (_androidXxxhdpiFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new AndroidContainsXxxhdpiFileCondition(assetAndroid));
                }

                if (_androidResolutionFileConditionCheckbox.Active)
                {
                    int.TryParse(_androidResolutionMarginTextEntry.Text, out int sizeMargin);
                    assetConditions.Add(new SizesFilesAndroidCondition(assetAndroid, sizeMargin));
                }

                if (_androidDrawableFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new DrawableAssetAndroidCondition(assetAndroid));
                }
            }
            else if (assetProperties.Asset is AssetiOS assetiOS)
            {
                if (_iosStandardFileConditionCheckbox.Active)
                {
                    assetConditions.Add(new IOSContainsStandardFileCondition(assetiOS));
                }

                if (_iosX2FileConditionCheckbox.Active)
                {
                    assetConditions.Add(new IOSContainsX2FileCondition(assetiOS));
                }

                if (_iosX3FileConditionCheckbox.Active)
                {
                    assetConditions.Add(new IOSContainsX3FileCondition(assetiOS));
                }

                if (_iosResolutionFileConditionCheckbox.Active)
                {
                    int.TryParse(_iosResolutionMarginTextEntry.Text, out int sizeMargin);
                    assetConditions.Add(new SizesFilesiOSCondition(assetiOS, sizeMargin));
                }
            }

            return(assetConditions);
        }
Beispiel #17
0
    /// <summary>
    /// Copies mesh information for the given surface body into the mesh storage structure.
    /// </summary>
    /// <param name="surf">The surface body to export</param>
    /// <param name="bestResolution">Use the best possible resolution</param>
    /// <param name="separateFaces">Separate the surface body into one mesh per face</param>
    private void AddFacets(SurfaceBody surf, bool bestResolution = false, bool separateFaces = false)
    {
        BXDAMesh.BXDASurface nextSurface = new BXDAMesh.BXDASurface();

        surf.GetExistingFacetTolerances(out tmpToleranceCount, out tolerances);

        int bestIndex = -1;

        for (int i = 0; i < tmpToleranceCount; i++)
        {
            if (bestIndex < 0 || ((tolerances[i] < tolerances[bestIndex]) == bestResolution))
            {
                bestIndex = i;
            }
        }

        #region SHOULD_SEPARATE_FACES
        AssetProperties sharedValue = null;
        string          sharedDisp  = null;
        if (separateFaces)  // Only separate if they are actually different colors
        {
            separateFaces = false;
            foreach (Face f in surf.Faces)
            {
                try
                {
                    Asset ast = f.Appearance;
                    if (sharedValue == null)
                    {
                        sharedValue = new AssetProperties(ast);
                        sharedDisp  = ast.DisplayName;
                    }
                    else if (!ast.DisplayName.Equals(sharedDisp))
                    {
                        separateFaces = true;
                        break;
                    }
                }
                catch
                {
                }
            }
        }
        #endregion

#if USE_TEXTURES
        surf.GetExistingFacetsAndTextureMap(tolerances[bestIndex], out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies, out tmpSurface.textureCoords);
        if (tmpSurface.vertCount == 0)
        {
            surf.CalculateFacetsAndTextureMap(tolerances[bestIndex], out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies, out tmpSurface.textureCoords);
        }
#else
        surf.GetExistingFacets(tolerances[bestIndex], out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies);
        if (tmpSurface.vertCount == 0)
        {
            surf.CalculateFacets(tolerances[bestIndex], out tmpSurface.vertCount, out tmpSurface.facetCount, out tmpSurface.verts, out tmpSurface.norms, out tmpSurface.indicies);
        }
#endif
        if (separateFaces || tmpSurface.vertCount > TMP_VERTICIES)
        {
            int i = 0;
            foreach (Face f in surf.Faces)
            {
                i++;
                AddFacets(f, tolerances[bestIndex]);
            }
        }
        else
        {
            //Console.WriteLine("Exporting single block for " + surf.Parent.Name + "\t(" + surf.Name + ")");
            AssetProperties assetProps = sharedValue;
            if (sharedValue == null)
            {
                assetProps = AssetProperties.Create(surf);
            }

            if (assetProps != null)
            {
                AddFacetsInternal(assetProps);
            }
        }
    }
Beispiel #18
0
 public AssetPropertyData(string label, AssetProperties assetProperties) : base(label)
 {
     _assetProperties = assetProperties;
 }