Principales respuestas
Como coloreo un cubo con varios colores?

Pregunta
-
Hola, necesito hacer un cubo que tenga en cada cara un color diferente, pero he buscado y para colorear un cubo usan <GeometryModel3D.Material> y <DiffuseMaterial>, pero el cubo toma el color completo, y no se como hacer para que cada cara me de un color diferente... alguien puede ayudarme?!
Respuestas
-
Hola Sergio
Usando un código que encontré pude hacer lo que necesitas, mira como está la definición de este código:
<Viewport3D Margin="0" Name="viewCube"> <ModelVisual3D> <ModelVisual3D.Content> <Model3DGroup> <!-- Lights --> <AmbientLight Color="Gray" /> <DirectionalLight Color="Gray" Direction="1,-2,-3" /> <DirectionalLight Color="Gray" Direction="-1,2,3" /> <!-- Top --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,1,1 1,1,1 1,1,-1 -1,1,-1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Red"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Front --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,-1,1 1,-1,1 1,1,1 -1,1,1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Black"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Right --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "1,-1,1 1,-1,-1 1,1,-1 1,1,1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Blue"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Left --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,-1,-1 -1,-1,1 -1,1,1 -1,1,-1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Gray"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Back --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "1,-1,-1 -1,-1,-1 -1,1,-1 1,1,-1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Green"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Bottom --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,-1,-1 1,-1,-1 1,-1,1 -1,-1,1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Yellow"/> </GeometryModel3D.Material> </GeometryModel3D> </Model3DGroup> </ModelVisual3D.Content> </ModelVisual3D> <Viewport3D.Camera> <PerspectiveCamera Position = "3, 3, 3" LookDirection = "-1, -1, -1" UpDirection = "0, 1, 0" FieldOfView = "60"> <PerspectiveCamera.Transform> <Transform3DGroup> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Axis="0 1 0" Angle="{Binding ElementName=hscroll, Path=Value}" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Axis="1 0 0" Angle="{Binding ElementName=vscroll, Path=Value}" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Transform3DGroup> </PerspectiveCamera.Transform> </PerspectiveCamera> </Viewport3D.Camera> </Viewport3D>
Saludos
Antonio Lobo
Para el correcto funcionamiento, y que otros usuarios se puedan beneficiar de la solucion de esta pregunta por favor marca las respuestas que te hayan ayudado como "Respuesta".
Si la respuesta te ha sido util Votala.
Mi blog- Marcado como respuesta SergioGiAr martes, 26 de julio de 2011 0:03
Todas las respuestas
-
Hola Sergio
Usando un código que encontré pude hacer lo que necesitas, mira como está la definición de este código:
<Viewport3D Margin="0" Name="viewCube"> <ModelVisual3D> <ModelVisual3D.Content> <Model3DGroup> <!-- Lights --> <AmbientLight Color="Gray" /> <DirectionalLight Color="Gray" Direction="1,-2,-3" /> <DirectionalLight Color="Gray" Direction="-1,2,3" /> <!-- Top --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,1,1 1,1,1 1,1,-1 -1,1,-1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Red"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Front --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,-1,1 1,-1,1 1,1,1 -1,1,1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Black"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Right --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "1,-1,1 1,-1,-1 1,1,-1 1,1,1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Blue"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Left --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,-1,-1 -1,-1,1 -1,1,1 -1,1,-1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Gray"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Back --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "1,-1,-1 -1,-1,-1 -1,1,-1 1,1,-1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Green"/> </GeometryModel3D.Material> </GeometryModel3D> <!-- Bottom --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions = "-1,-1,-1 1,-1,-1 1,-1,1 -1,-1,1" TriangleIndices = "0 1 2 2,3,0" TextureCoordinates="0,1 1,1 1,0 0,0" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial Brush="Yellow"/> </GeometryModel3D.Material> </GeometryModel3D> </Model3DGroup> </ModelVisual3D.Content> </ModelVisual3D> <Viewport3D.Camera> <PerspectiveCamera Position = "3, 3, 3" LookDirection = "-1, -1, -1" UpDirection = "0, 1, 0" FieldOfView = "60"> <PerspectiveCamera.Transform> <Transform3DGroup> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Axis="0 1 0" Angle="{Binding ElementName=hscroll, Path=Value}" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Axis="1 0 0" Angle="{Binding ElementName=vscroll, Path=Value}" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Transform3DGroup> </PerspectiveCamera.Transform> </PerspectiveCamera> </Viewport3D.Camera> </Viewport3D>
Saludos
Antonio Lobo
Para el correcto funcionamiento, y que otros usuarios se puedan beneficiar de la solucion de esta pregunta por favor marca las respuestas que te hayan ayudado como "Respuesta".
Si la respuesta te ha sido util Votala.
Mi blog- Marcado como respuesta SergioGiAr martes, 26 de julio de 2011 0:03
-
-
Hola Sergio
Claro que si! Existe una aplicación llamada ZAM3D (es de pago). Y te dejo este video (en ingles) de cómo lo usan. Además estuve leyendo que han creado un script para exportar las gráficas 3D hechas en Blender (no me abrió la página) a xaml.
Espero te ayude.
Saludos
Antonio Lobo
Para el correcto funcionamiento, y que otros usuarios se puedan beneficiar de la solucion de esta pregunta por favor marca las respuestas que te hayan ayudado como "Respuesta".
Si la respuesta te ha sido util Votala.
Mi blog