public void AddMaterial(Document inDocument, MaterialNode inNode)
        {
            if (!m_pMaterialDict.ContainsKey(inNode.MaterialId.IntegerValue))
            {
                Autodesk.Revit.DB.Material _revitMat = inDocument.GetElement(inNode.MaterialId) as Autodesk.Revit.DB.Material;
                if (_revitMat != null && _revitMat.IsValidObject)
                {
                    BoldarcManagedFbx.Material _mat = new BoldarcManagedFbx.Material(_revitMat.Name);

                    _mat.Red = _revitMat.Color.Red;
                    _mat.Green = _revitMat.Color.Green;
                    _mat.Blue = _revitMat.Color.Blue;
                    _mat.Shininess = _revitMat.Shininess;
                    _mat.Smoothness = _revitMat.Smoothness;
                    _mat.Transparency = _revitMat.Transparency;

                    m_pMaterialDict.Add(inNode.MaterialId.IntegerValue, _mat);
                    m_pCurrentMesh.MaterialIDPerFace.Add(m_pCurrentMesh.FaceCount, inNode.MaterialId.IntegerValue);
                }
                else
                    m_pCurrentMesh.MaterialIDPerFace.Add(m_pCurrentMesh.FaceCount, -1);
            }
            else
                m_pCurrentMesh.MaterialIDPerFace.Add(m_pCurrentMesh.FaceCount, inNode.MaterialId.IntegerValue);
        }
Exemple #2
0
        public override void Init()
        {
            TexturedPolygon quad = TexturedPolygon.CreateTexturedQuad("ScreenQuad", Vector3.Zero, 1920, 1080);
            ImageLoadInformation info = new ImageLoadInformation()
            {
                BindFlags = BindFlags.None,
                CpuAccessFlags = CpuAccessFlags.Read,
                FilterFlags = FilterFlags.None,
                Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
                MipFilterFlags = FilterFlags.None,
                OptionFlags = ResourceOptionFlags.None,
                Usage = ResourceUsage.Staging,
                MipLevels = 1
            };
            Texture2D tex = Texture2D.FromFile(Game.Context.Device, "medusa.jpg",  info);

            ShaderResourceView srv = new ShaderResourceView(Game.Context.Device,  Make3D(tex));
            quad.DiffuseMapResource = srv;
            rNode = new RenderableNode(quad);
            iMat = new ImageMaterial();
            FixedNode fNode = new FixedNode();
            fNode.Init();
            quad.PositionV3 = Layout.OrthographicTransform(Vector2.Zero, 100, new Size(1920,1080));

            RenderableCollection rCol = new RenderableCollection(iMat.RenderableCollectionDescription);
            MaterialNode mMat = new MaterialNode(iMat);
            rCol.Add(rNode);

            fNode.AppendChild(mMat);
            mMat.AppendChild(rNode);

            rCommand = new RenderCommand(mMat, rCol);
            rCommand.Init();
            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Scene.Tree.RootNode.AppendChild(fNode);
            Scene.BuildRenderScene();
        }
Exemple #3
0
        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.APT_Reference)
                {
                    AssetPropertyReference e = properties[index] as AssetPropertyReference;
                    if (e != null)
                    {
                        AssetProperty p = e.GetConnectedProperty(0);
                        if (p.Type == AssetPropertyType.APT_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;
        }
 public void OnMaterial(MaterialNode inNode)
 {
     //if(inNode.HasOverriddenAppearance)
        m_Exporter.AddMaterial(m_Document, inNode);
 }
Exemple #5
0
 public void Activate()
 {
     text = new TextLiteral(FrameStats, new Vector3(10, 10, 0));
     FunctionalMaterial textWriter = new FunctionalMaterial();
     MaterialNode mNode = new MaterialNode("Logger", textWriter);
     RenderableNode rNode = new RenderableNode(text);
     mNode.AppendChild(rNode);
     RenderableCollection rCollection = new RenderableCollection(textWriter.RenderableCollectionDescription)
                                            {rNode};
     //RenderCommand rCommand = new RenderCommand(mNode, rCollection);
     Game.CurrentRenderer.Scene.Tree.RootNode.AppendChild(mNode);
 }
Exemple #6
0
	/**
	 * LoadSceneOrig
	 *
	 * @param filename
	 * @return int
	 */
	private int LoadSceneOrig(String filename)
	{
		sceneLines = File.ReadAllLines(filename);
		scenePos = 0;

		int numObj = 0, ObjID = 0;

		camera = null;
		lights = null;
		objects = null;
		materials = null;
		MaxX = MinX = MaxY = MinY = MaxZ = MinZ = 0.0f;
		String input;

		input = readString();

		while(input != null)
		{
			if(input.Equals("camera {"))
			{
				ReadCamera();
			}
			else if(input.Equals("point_light {"))
			{
				ReadLight();
			}
			else if(input.Equals("sphere {"))
			{
				numObj += ReadSphere(ObjID);
			}
			else if(input.Equals("poly_set {"))
			{
				numObj += ReadPoly(ObjID);
			}
			else
			{ ;}

			input = readString();
		}

		return (numObj);
	}
Exemple #7
0
	/**
	 * ReadMaterial
	 *
	 * @param infile
	 * @return Material
	 */
	private Material ReadMaterial()
	{
		String temp;
		double[] input = new double[3];
		Color[] colors = new Color[4];
		int i, j;
		double shininess, ktran;

		temp = readString();
		for(i = 0; i < 4; i++)
		{
			temp = readString();
			if(i != 1)
			{
				temp = temp.Substring(14);
			}
			else
			{
				temp = temp.Substring(13);
			}
			for(j = 0; j < 2; j++)
			{
				input[j] = (double)Double.Parse(temp.Substring(0, temp.IndexOf(' ')));
				temp = temp.Substring(temp.IndexOf(' ') + 1);
			}
			input[2] = (double)Double.Parse(temp);
			colors[i] = new Color(input[0], input[1], input[2]);
		}
		temp = readString();
		shininess = (double)Double.Parse(temp.Substring(14));
		temp = readString();
		ktran = (double)Double.Parse(temp.Substring(10));
		temp = readString();
		Material newmaterial = new Material(colors[0], colors[1], colors[2], colors[3], shininess, ktran);
		MaterialNode newnode = new MaterialNode(newmaterial, materials);
		materials = newnode;
		return (newmaterial);
	}
Exemple #8
0
        private bool ProcessCurrentNode(MaterialNode CurNode, List <string> UsedFunctions, List <string> FunctionCalls)
        {
            List <string> ArgumentTexts = new List <string>();
            List <string> OutputNames   = new List <string>();
            ShaderMaterialTranslatorEntry FunctionEntry = null;

            for (int i = 0; i < this._Entries.Count; i++)
            {
                if (CurNode.FunctionID == this._Entries[i].ID)
                {
                    FunctionEntry = this._Entries[i];
                }
            }
            if (FunctionEntry == null)
            {
                return(false);
            }
            if (!UsedFunctions.Contains(CurNode.FunctionID))
            {
                UsedFunctions.Insert(0, CurNode.FunctionID);
            }
            for (int i = 0; i < FunctionEntry.EngineInputs.Count; i++)
            {
                ArgumentTexts.Add(GenerateArgumentFromEngineVariable(FunctionEntry.EngineInputs[i]));
            }
            for (int i = 0; i < CurNode.Inputs.Count; i++)
            {
                if (CurNode.Inputs[i].Value.Type == MaterialValueType.TextureValue)
                {
                    if (CurNode.Inputs[i].Value.Value != "" && File.Exists(CurNode.Inputs[i].Value.Value))
                    {
                        ArgumentTexts.Add(TexturesNumber.ToString());
                        Bitmap Img = new Bitmap(Image.FromFile(CurNode.Inputs[i].Value.Value));
                        this._TextureBitmaps.Add(Img);
                        this.TexturesNumber++;
                    }
                    else
                    {
                        ArgumentTexts.Add("-1");
                    }
                }
                else
                {
                    if (CurNode.Inputs[i].InputTarget != null)
                    {
                        ArgumentTexts.Add(CurNode.Inputs[i].InputTarget.Parent.Name + "_" + CurNode.Inputs[i].InputTarget.Name);
                    }
                    else
                    {
                        ArgumentTexts.Add(GenerateArgumentFromValue(CurNode.Inputs[i].Value));
                    }
                }
            }
            for (int i = 0; i < CurNode.Outputs.Count; i++)
            {
                OutputNames.Add(CurNode.Name + "_" + CurNode.Outputs[i].Name);
            }
            FunctionCalls.Insert(0, GenerateFunctionCall(CurNode.FunctionID, ArgumentTexts.ToArray(), OutputNames.ToArray()));
            for (int i = 0; i < CurNode.Inputs.Count; i++)
            {
                if (CurNode.Inputs[i].InputTarget != null)
                {
                    ProcessCurrentNode(CurNode.Inputs[i].InputTarget.Parent, UsedFunctions, FunctionCalls);
                }
            }
            return(true);
        }
Exemple #9
0
 public virtual void Visit(MaterialNode node)
 {
     this.Visit((SceneNode)node);
 }