本文整理汇总了C#中System.Windows.Media.Media3D.MaterialGroup类的典型用法代码示例。如果您正苦于以下问题:C# MaterialGroup类的具体用法?C# MaterialGroup怎么用?C# MaterialGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialGroup类属于System.Windows.Media.Media3D命名空间,在下文中一共展示了MaterialGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateMaterial
/// <summary>
/// Creates a material with the specifed brush as diffuse material.
/// This method will also add a white specular material.
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="specularPower">The specular power.</param>
/// <returns></returns>
public static Material CreateMaterial(Brush brush, double specularPower)
{
var mg = new MaterialGroup();
mg.Children.Add(new DiffuseMaterial(brush));
if (specularPower > 0)
mg.Children.Add(new SpecularMaterial(Brushes.White, specularPower));
return mg;
}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:15,代码来源:MaterialHelper.cs
示例2: TrackballGrabber
public TrackballGrabber(FrameworkElement eventSource, Viewport3D viewport, double sphereRadius, Color hoverLightColor)
{
if (viewport.Camera == null || !(viewport.Camera is PerspectiveCamera))
{
throw new ArgumentException("This class requires a perspective camera to be tied to the viewport");
}
_eventSource = eventSource;
_viewport = viewport;
_camera = (PerspectiveCamera)viewport.Camera;
this.SyncedLights = new List<Model3D>();
this.HoverVisuals = new ObservableCollection<Visual3D>();
this.HoverVisuals.CollectionChanged += HoverVisuals_CollectionChanged;
_eventSource.MouseEnter += new System.Windows.Input.MouseEventHandler(EventSource_MouseEnter);
_eventSource.MouseLeave += new System.Windows.Input.MouseEventHandler(EventSource_MouseLeave);
_eventSource.MouseDown += new System.Windows.Input.MouseButtonEventHandler(EventSource_MouseDown);
_eventSource.MouseUp += new System.Windows.Input.MouseButtonEventHandler(EventSource_MouseUp);
_eventSource.MouseMove += new System.Windows.Input.MouseEventHandler(EventSource_MouseMove);
#region Sphere
// Material
_sphereMaterials = new MaterialGroup();
_sphereMaterials.Children.Add(new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(25, 255, 255, 255))));
// This gets added/removed on mouse enter/leave
_sphereMaterialHover = new SpecularMaterial(new SolidColorBrush(Color.FromArgb(64, 128, 128, 128)), 33d);
// Geometry Model
GeometryModel3D geometry = new GeometryModel3D();
geometry.Material = _sphereMaterials;
geometry.BackMaterial = _sphereMaterials;
geometry.Geometry = UtilityWPF.GetSphere_LatLon(20, sphereRadius);
// Model Visual
_sphereModel = new ModelVisual3D();
_sphereModel.Content = geometry;
// Add it
_viewport.Children.Add(_sphereModel);
#endregion
#region Hover Light
// Light
PointLight hoverLight = new PointLight();
hoverLight.Color = hoverLightColor;
hoverLight.Range = sphereRadius * 10;
_hoverLight = new ModelVisual3D();
_hoverLight.Content = hoverLight;
#endregion
}
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:57,代码来源:TrackballGrabber.cs
示例3: ThrustLine
public ThrustLine(Viewport3D viewport, SharedVisuals sharedVisuals, Vector3D forceDirection, Vector3D localOffset)
{
this.Viewport = viewport;
_forceDirection = forceDirection;
_forceStrength = forceDirection.Length; // this way they don't have to set this if they don't want
this.BodyOffset = new TranslateTransform3D(localOffset); // just setting it to something so it's not null
#region Create Visual
// I'll create the visual, but won't add it until they fire the thruster
// Material
MaterialGroup materials = new MaterialGroup();
materials.Children.Add(new DiffuseMaterial(Brushes.Coral));
materials.Children.Add(new SpecularMaterial(Brushes.Gold, 100d));
// Geometry Model
// Create a skinny 3D rectangle along the x axis
GeometryModel3D geometry = new GeometryModel3D();
geometry.Material = materials;
geometry.BackMaterial = materials;
geometry.Geometry = sharedVisuals.ThrustLineMesh;
// Figure out how much to rotate the cube to be along the opposite of the force line. I do the opposite, because
// thruster flames shoot in the opposite direction that they're pushing
Vector3D flameLine = forceDirection;
flameLine.Negate();
Vector3D axis;
double radians;
Math3D.GetRotation(out axis, out radians, new Vector3D(1, 0, 0), flameLine);
if (radians == 0d)
{
_initialRotate = null;
}
else
{
_initialRotate = new RotateTransform3D(new AxisAngleRotation3D(axis, Math1D.RadiansToDegrees(radians)));
}
//// Transform
//Transform3DGroup transform = new Transform3DGroup(); // rotate needs to be added before translate
//transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(axis, Math3D.RadiansToDegrees(radians))));
//transform.Children.Add(new TranslateTransform3D(from));
// Model Visual
_model = new ModelVisual3D();
_model.Content = geometry;
_model.Transform = new TranslateTransform3D(); // I won't do anything with this right now
#endregion
}
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:57,代码来源:ThrustLine.cs
示例4: getSurfaceMaterial
//Create a default material of the specified colour:
public static MaterialGroup getSurfaceMaterial(Color colour)
{
var materialGroup = new MaterialGroup();
var emmMat = new EmissiveMaterial(new SolidColorBrush(colour));
materialGroup.Children.Add(emmMat);
materialGroup.Children.Add(new DiffuseMaterial(new SolidColorBrush(colour)));
var specMat = new SpecularMaterial(new SolidColorBrush(Colors.White), 30);
materialGroup.Children.Add(specMat);
return materialGroup;
}
开发者ID:CRogers,项目名称:KinectGroupPractical,代码行数:11,代码来源:Shapes.cs
示例5: SetColor
private void SetColor(Color color)
{
MaterialGroup unlitMaterial = new MaterialGroup();
unlitMaterial.Children.Add(new DiffuseMaterial(new SolidColorBrush(Colors.Black)));
unlitMaterial.Children.Add(new EmissiveMaterial(new SolidColorBrush(color)));
unlitMaterial.Freeze();
_model.Material = unlitMaterial;
_model.BackMaterial = unlitMaterial;
}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:10,代码来源:ScreenSpaceLines3D.cs
示例6: Egg
public Egg(Point3D position, World world, int materialID, ItemOptions itemOptions, ShipDNA dna)
{
// The radius should be 20% the size of the adult ship
this.Radius = dna.PartsByLayer.SelectMany(o => o.Value).
Max(o => o.Position.ToVector().Length + Math1D.Max(o.Scale.X, o.Scale.Y, o.Scale.Z))
* .2d;
Vector3D scale = new Vector3D(.75d, .75d, 1d);
#region WPF Model
// Material
MaterialGroup materials = new MaterialGroup();
materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(WorldColors.EggColor)));
materials.Children.Add(WorldColors.EggSpecular);
// Geometry Model
GeometryModel3D geometry = new GeometryModel3D();
geometry.Material = materials;
geometry.BackMaterial = materials;
geometry.Geometry = UtilityWPF.GetSphere_LatLon(5, this.Radius);
geometry.Transform = new ScaleTransform3D(scale);
this.Model = geometry;
// Model Visual
ModelVisual3D model = new ModelVisual3D();
model.Content = geometry;
#endregion
#region Physics Body
Transform3DGroup transform = new Transform3DGroup();
transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));
transform.Children.Add(new TranslateTransform3D(position.ToVector()));
double volume = (4d / 3d) * Math.PI * scale.X * this.Radius * scale.Y * this.Radius * scale.Z * this.Radius;
double mass = volume * itemOptions.Egg_Density;
using (CollisionHull hull = CollisionHull.CreateSphere(world, 0, scale * this.Radius, null))
{
this.PhysicsBody = new Body(hull, transform.Value, mass, new Visual3D[] { model });
this.PhysicsBody.MaterialGroupID = materialID;
this.PhysicsBody.LinearDamping = .01f;
this.PhysicsBody.AngularDamping = new Vector3D(.001f, .001f, .001f);
}
#endregion
this.CreationTime = DateTime.UtcNow;
}
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:52,代码来源:Egg.cs
示例7: GetBackShadow
/// <summary>
/// 获取纸张背面的半透明材质
/// </summary>
/// <returns></returns>
public MaterialGroup GetBackShadow()
{
transparentBackMaterial = backMaterial.Clone();
foreach (Material m in transparentBackMaterial.Children)
{
DiffuseMaterial dm = (DiffuseMaterial)m;
if (dm != null)
{
dm.Color = dm.AmbientColor = Color.FromArgb(100, 255, 255, 255);
}
}
return transparentBackMaterial;
}
开发者ID:cedricporter,项目名称:Clover,代码行数:17,代码来源:MaterialController.cs
示例8: MaterialLibrary
public MaterialLibrary(Loader l)
{
MaterialGroup group = null;
DiffuseMaterial diffuse = null;
SpecularMaterial specular = null;
foreach (Instruction i in l.Parse())
{
switch (i.Type)
{
case "newmtl":
group = new MaterialGroup();
diffuse = new DiffuseMaterial();
group.Children.Add(diffuse);
specular = new SpecularMaterial();
group.Children.Add(specular);
Materials.Add(i.Arg, group);
break;
case "Ns":
specular.SpecularPower = i.Double();
break;
case "d":
case "Tr":
diffuse.Brush.Opacity = i.Float();
break;
case "Ka":
diffuse.AmbientColor = i.Color();
break;
case "Kd":
diffuse.Brush = new SolidColorBrush(i.Color());
break;
case "Ks":
specular.Brush = new SolidColorBrush(i.Color());
break;
// TODO: UV Maps
case "illum":
case "Ni": // Index of Refraction
// Unsupported, ignore
break;
default:
// Unrecognized symbol
break;
}
}
}
开发者ID:danzhu,项目名称:JoyfulColours,代码行数:47,代码来源:MaterialLibrary.cs
示例9: Cartoon
/// <summary>
/// Builds the 3D model for the cartoon view a the given residue.
/// </summary>
/// <param name="residue">A residue.</param>
/// <param name="initialColor">The residue's current color.</param>
internal Cartoon(Residue residue, Color initialColor)
{
this.residue = residue;
this.materialGroup = new MaterialGroup();
this.diffuseMaterial = new DiffuseMaterial(new SolidColorBrush(initialColor));
this.materialGroup.Children.Add(diffuseMaterial);
SpecularMaterial specularMaterial = new SpecularMaterial();
specularMaterial.Brush = new SolidColorBrush(Color.FromArgb(192, 255, 255, 255));
specularMaterial.SpecularPower = 50;
this.materialGroup.Children.Add(specularMaterial);
this.model = new Model3DGroup();
this.residue.Ribbon.GetResidueSpline(this.residue, out this.ribbonPoints,
out this.torsionVectors, out this.normalVectors);
if (this.residue.IsHelix)
{
this.AddTube(Cartoon.helixWidth, Cartoon.helixHeight);
if (this.residue.IsStructureStart)
this.AddTubeCap(Cartoon.helixWidth, Cartoon.helixHeight);
if (this.residue.IsStructureEnd)
this.AddTubeCap(Cartoon.helixWidth, Cartoon.helixHeight);
}
else if (this.residue.IsSheet)
{
this.AddSheet();
if (this.residue.IsStructureStart || this.residue.IsStructureEnd)
this.AddSheetCap();
}
else
{
this.AddTube(Cartoon.turnWidth, Cartoon.turnWidth);
if (this.residue.IsStructureStart)
this.AddTubeCap(Cartoon.turnWidth, Cartoon.turnWidth);
if (this.residue.IsStructureEnd)
this.AddTubeCap(Cartoon.turnWidth, Cartoon.turnWidth);
}
}
开发者ID:alkampfergit,项目名称:BaktunShell,代码行数:52,代码来源:Cartoon.cs
示例10: ToMaterial
public static Material ToMaterial(this IfcSurfaceStyleRendering r)
{
MaterialGroup grp = new MaterialGroup();
if (r.DiffuseColour is IfcNormalisedRatioMeasure)
{
Brush brush = new SolidColorBrush(r.SurfaceColour.ToColor((IfcNormalisedRatioMeasure)r.DiffuseColour));
brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
grp.Children.Add(new DiffuseMaterial(brush));
}
else if (r.DiffuseColour is IfcColourRgb)
{
Brush brush = new SolidColorBrush(((IfcColourRgb)r.DiffuseColour).ToColor());
brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
grp.Children.Add(new DiffuseMaterial(brush));
}
else if (r.DiffuseColour == null)
{
Brush brush = new SolidColorBrush(r.SurfaceColour.ToColor());
brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
grp.Children.Add(new DiffuseMaterial(brush));
}
if (r.SpecularColour is IfcNormalisedRatioMeasure)
{
Brush brush = new SolidColorBrush(r.SurfaceColour.ToColor());
brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
grp.Children.Add(new SpecularMaterial(brush, (IfcNormalisedRatioMeasure)(r.SpecularColour)));
}
if (r.SpecularColour is IfcColourRgb)
{
Brush brush = new SolidColorBrush(((IfcColourRgb)r.SpecularColour).ToColor());
brush.Opacity = r.Transparency.HasValue ? 1.0 - r.Transparency.Value : 1.0;
grp.Children.Add(new SpecularMaterial(brush, 100.0));
}
if (grp.Children.Count == 1)
{
Material mat = grp.Children[0];
return mat;
}
else
{
return grp;
}
}
开发者ID:bnaand,项目名称:xBim-Toolkit,代码行数:45,代码来源:SurfaceStyleRenderingExtensions.cs
示例11: GetCylinder
public static Model3DGroup GetCylinder(MaterialGroup materialGroup, Point3D midPoint, double radius, double depth)
{
var cylinder = new Model3DGroup();
var nearCircle = new CircleAssitor();
var farCircle = new CircleAssitor();
var twoPi = Math.PI * 2;
var firstPass = true;
double x;
double y;
var increment = 0.1d;
for (double i = 0; i < twoPi + increment; i = i + increment)
{
x = (radius * Math.Cos(i));
y = (-radius * Math.Sin(i));
farCircle.CurrentTriangle.P0 = midPoint;
farCircle.CurrentTriangle.P1 = farCircle.LastPoint;
farCircle.CurrentTriangle.P2 = new Point3D(x + midPoint.X, y + midPoint.Y, midPoint.Z);
nearCircle.CurrentTriangle = farCircle.CurrentTriangle.Clone(depth, true);
if (!firstPass)
{
cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, farCircle.CurrentTriangle));
cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, nearCircle.CurrentTriangle));
cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, farCircle.CurrentTriangle.P2, farCircle.CurrentTriangle.P1, nearCircle.CurrentTriangle.P2));
cylinder.Children.Add(FYDP_3Dobject_Util.CreateTriangleModel(materialGroup, nearCircle.CurrentTriangle.P2, nearCircle.CurrentTriangle.P1, farCircle.CurrentTriangle.P2));
}
else
{
farCircle.FirstPoint = farCircle.CurrentTriangle.P1;
nearCircle.FirstPoint = nearCircle.CurrentTriangle.P1;
firstPass = false;
}
farCircle.LastPoint = farCircle.CurrentTriangle.P2;
nearCircle.LastPoint = nearCircle.CurrentTriangle.P2;
}
return cylinder;
}
开发者ID:hliang89,项目名称:FYDP,代码行数:43,代码来源:FYDP_3Dobject_Util.cs
示例12: GetImageMaterial
public static Material GetImageMaterial(ImageSource imageSource, Brush specularBrush = null, double specularPower = 10)
{
var material = new MaterialGroup();
var diffuse = new DiffuseMaterial
{
Brush = new ImageBrush
{
ImageSource = imageSource,
TileMode = TileMode.Tile
}
};
material.Children.Add(diffuse);
if (!ReferenceEquals(null, specularBrush))
{
var specular = new SpecularMaterial
{
Brush = specularBrush,
SpecularPower = specularPower
};
material.Children.Add(specular);
}
return material;
}
开发者ID:node-net,项目名称:Node.Net,代码行数:23,代码来源:MaterialHelper.cs
示例13: WireBase
// Constructor
// -----------
public WireBase()
{
LineCollection = new Point3DCollection();
// Create MeshGeometry3D.
MeshGeometry3D mesh = new MeshGeometry3D();
// Create MaterialGroup.
MaterialGroup matgrp = new MaterialGroup();
matgrp.Children.Add(new DiffuseMaterial(Brushes.Black));
matgrp.Children.Add(new EmissiveMaterial(new SolidColorBrush(Color)));
// Create GeometryModel3D.
GeometryModel3D model = new GeometryModel3D(mesh, matgrp);
// Remove this later
model.BackMaterial = new DiffuseMaterial(Brushes.Red);
// Set the Content property to the GeometryModel3D.
Content = model;
// Add to collection.
listWireBases.Add(new WireBaseAndUltimateParent(this));
}
开发者ID:samlcharreyron,项目名称:PedestrianTracker,代码行数:26,代码来源:WireBase.cs
示例14: GetMaterial
public Material GetMaterial(string texturePath)
{
var mg = new MaterialGroup();
if (DiffuseMap == null)
{
var diffuseBrush = new SolidColorBrush(Diffuse) { Opacity = Dissolved };
mg.Children.Add(new DiffuseMaterial(diffuseBrush));
}
else
{
var path = Path.Combine(texturePath, DiffuseMap);
if (File.Exists(path))
{
var img = new BitmapImage(new Uri(path, UriKind.Relative));
var textureBrush = new ImageBrush(img) { Opacity = Dissolved };
mg.Children.Add(new DiffuseMaterial(textureBrush));
}
}
mg.Children.Add(new SpecularMaterial(new SolidColorBrush(Specular), SpecularCoefficient));
return mg;
}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:24,代码来源:ObjReader.cs
示例15: CreateGeometry
private Model3DGroup CreateGeometry(bool isFinal)
{
int domeSegments = isFinal ? 2 : 10;
int cylinderSegments = isFinal ? 6 : 35;
Model3DGroup retVal = new Model3DGroup();
GeometryModel3D geometry;
MaterialGroup material;
DiffuseMaterial diffuse;
SpecularMaterial specular;
#region Insides
if (!isFinal)
{
ScaleTransform3D scaleTransform = new ScaleTransform3D(HEIGHT, HEIGHT, HEIGHT);
//TODO: This caps them to a sphere. It doesn't look too bad, but could be better
Model3D[] insideModels = BrainDesign.CreateInsideVisuals(.4, this.MaterialBrushes, base.SelectionEmissives, scaleTransform);
retVal.Children.AddRange(insideModels);
}
#endregion
#region Outer Shell
geometry = new GeometryModel3D();
material = new MaterialGroup();
Color shellColor = WorldColors.Brain;
if (!isFinal)
{
shellColor = UtilityWPF.AlphaBlend(shellColor, Colors.Transparent, .75d);
}
diffuse = new DiffuseMaterial(new SolidColorBrush(shellColor));
this.MaterialBrushes.Add(new MaterialColorProps(diffuse, shellColor));
material.Children.Add(diffuse);
specular = WorldColors.BrainSpecular;
this.MaterialBrushes.Add(new MaterialColorProps(specular));
material.Children.Add(specular);
if (!isFinal)
{
EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
material.Children.Add(selectionEmissive);
base.SelectionEmissives.Add(selectionEmissive);
}
geometry.Material = material;
geometry.BackMaterial = material;
List<TubeRingBase> rings = new List<TubeRingBase>();
rings.Add(new TubeRingRegularPolygon(0, false, RADIUSPERCENTOFSCALE_NARROW, RADIUSPERCENTOFSCALE_NARROW, true));
rings.Add(new TubeRingRegularPolygon(HEIGHT, false, RADIUSPERCENTOFSCALE_WIDE, RADIUSPERCENTOFSCALE_WIDE, true));
geometry.Geometry = UtilityWPF.GetMultiRingedTube(cylinderSegments, rings, true, true);
retVal.Children.Add(geometry);
#endregion
retVal.Transform = GetTransformForGeometry(isFinal);
return retVal;
}
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:67,代码来源:BrainRGBRecognizer.cs
示例16: CreateBot
/// <summary>
/// Set the properties, then call create
/// NOTE: This adds itself to the viewport and world. In the future, that should be handled by the caller
/// </summary>
protected void CreateBot(Viewport3D viewport, SharedVisuals sharedVisuals, World world, Point3D worldPosition)
{
_viewport = viewport;
_sharedVisuals = sharedVisuals;
_world = world;
// Thruster
_origThrustDirection = new Vector3D(0, _thrustForce, 0);
_thruster = new ThrustLine(_viewport, sharedVisuals, _origThrustDirection, new Vector3D(0, 0, 0));
_thruster.LineMaxLength = this.ThrustLineStandardLength * _thrustLineMultiplier;
MaterialGroup material = null;
GeometryModel3D geometry = null;
ModelVisual3D model = null;
_visuals = new List<ModelVisual3D>();
#region Interior Extra Visuals
// These are visuals that will stay oriented to the ship, but don't count in collision calculations
#region Core
// Neutral
_coreMaterialNeutral = new MaterialGroup();
_coreMaterialNeutralColor = new DiffuseMaterial(new SolidColorBrush(_coreColor));
_coreMaterialNeutral.Children.Add(_coreMaterialNeutralColor);
_coreMaterialNeutral.Children.Add(new SpecularMaterial(Brushes.DimGray, 75d));
// Attack
_coreMaterialAttack = new MaterialGroup();
_coreMaterialAttack.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.AlphaBlend(Colors.Red, UtilityWPF.AlphaBlend(Colors.Black, Colors.DimGray, .5), .15d))));
_coreMaterialAttack.Children.Add(new SpecularMaterial(new SolidColorBrush(Color.FromArgb(255, 255, 128, 128)), 100d));
_lightAttack = new PointLight();
_lightAttack.Color = Color.FromArgb(255, 96, 0, 0);
_lightAttack.Position = new Point3D(0, 0, 0);
_lightAttack.Range = _radius * 3;
// Geometry Model
_coreGeometry = new GeometryModel3D();
_coreGeometry.Material = _coreMaterialNeutral;
_coreGeometry.BackMaterial = _coreMaterialNeutral;
_coreGeometry.Geometry = UtilityWPF.GetSphere_LatLon(5, _radius * .4, _radius * .4, _radius * .4);
_coreGeometry.Transform = new TranslateTransform3D(0, 0, 0);
// Model Visual
_core = new ModelVisual3D();
_core.Content = _coreGeometry;
//NOTE: model.Transform is set to the physics body's transform every frame
_visuals.Add(_core);
// Add to the viewport
_viewport.Children.Add(_core);
#endregion
#endregion
#region Glass Shell
// Material
//NOTE: There seems to be an issue with drawing objects inside a semitransparent object - I think they have to be added in a certain order or something
Brush skinBrush = new SolidColorBrush(Color.FromArgb(25, 255, 255, 255)); // making the skin semitransparent, so you can see the components inside
material = new MaterialGroup();
material.Children.Add(new DiffuseMaterial(skinBrush));
material.Children.Add(new SpecularMaterial(Brushes.White, 75d)); // more reflective (and white light)
MaterialGroup backMaterial = new MaterialGroup();
backMaterial.Children.Add(new DiffuseMaterial(skinBrush));
backMaterial.Children.Add(new SpecularMaterial(new SolidColorBrush(Color.FromArgb(255, 20, 20, 20)), 10d)); // dark light, and not very reflective
// Geometry Model
geometry = new GeometryModel3D();
geometry.Material = material;
geometry.BackMaterial = backMaterial;
geometry.Geometry = UtilityWPF.GetSphere_LatLon(5, _radius, _radius, _radius);
// Transform
Transform3DGroup transform = new Transform3DGroup(); // rotate needs to be added before translate
transform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 0)));
transform.Children.Add(new TranslateTransform3D(worldPosition.ToVector()));
// Model Visual
model = new ModelVisual3D();
model.Content = geometry;
model.Transform = transform;
_visuals.Add(model);
// Add to the viewport
_viewport.Children.Add(model);
//.........这里部分代码省略.........
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:101,代码来源:SwarmBotBase.cs
示例17: CreateGeometry
//TODO: Rewrite this. Make it look like a cave, or sea shell - something organic with an opening
private Model3DGroup CreateGeometry(bool isFinal)
{
ScaleTransform3D scaleTransform = new ScaleTransform3D(SCALE, SCALE, SCALE);
Model3DGroup retVal = new Model3DGroup();
GeometryModel3D geometry;
MaterialGroup material;
DiffuseMaterial diffuse;
SpecularMaterial specular;
Transform3DGroup transformGroup = new Transform3DGroup();
transformGroup.Children.Add(scaleTransform);
#region Outer Shell
geometry = new GeometryModel3D();
material = new MaterialGroup();
diffuse = new DiffuseMaterial(new SolidColorBrush(WorldColors.SwarmBay));
this.MaterialBrushes.Add(new MaterialColorProps(diffuse, WorldColors.SwarmBay));
material.Children.Add(diffuse);
specular = WorldColors.SwarmBaySpecular;
this.MaterialBrushes.Add(new MaterialColorProps(specular));
material.Children.Add(specular);
if (!isFinal)
{
EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
material.Children.Add(selectionEmissive);
base.SelectionEmissives.Add(selectionEmissive);
}
geometry.Material = material;
geometry.BackMaterial = material;
transformGroup = new Transform3DGroup();
transformGroup.Children.Add(scaleTransform);
transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));
geometry.Geometry = UtilityWPF.GetSphere_Ico(.5, 0, false);
geometry.Transform = transformGroup;
retVal.Children.Add(geometry);
#endregion
#region Line
BillboardLine3D line = new BillboardLine3D();
line.Color = WorldColors.SwarmBay;
line.Thickness = .05 * SCALE;
line.IsReflectiveColor = false;
line.FromPoint = new Point3D(0, 0, 0);
line.ToPoint = new Point3D(0, 0, .55 * SCALE);
retVal.Children.Add(line.Model);
#endregion
// Transform
retVal.Transform = GetTransformForGeometry(isFinal);
// Exit Function
return retVal;
}
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:67,代码来源:SwarmBay.cs
示例18: CreateGeometry
private Model3DGroup CreateGeometry(bool isFinal)
{
const double INSIDEPOINTRADIUS = .45d;
ScaleTransform3D scaleTransform = new ScaleTransform3D(SCALE, SCALE, SCALE);
Model3DGroup retVal = new Model3DGroup();
GeometryModel3D geometry;
MaterialGroup material;
DiffuseMaterial diffuse;
SpecularMaterial specular;
Transform3DGroup transformGroup = new Transform3DGroup();
transformGroup.Children.Add(scaleTransform);
#region Insides
if (!isFinal)
{
Model3D[] insideModels = CreateInsideVisuals(INSIDEPOINTRADIUS, this.MaterialBrushes, base.SelectionEmissives, scaleTransform);
retVal.Children.AddRange(insideModels);
}
#endregion
#region Lights
// Neat effect, but it makes my fan spin up, and won't slow back down. Need to add an animation property to the options
// class (and listen for when it toggles)
//if (!isFinal)
//{
// int numLights = 1 + this.Options.Random.Next(3);
// for (int cntr = 0; cntr < numLights; cntr++)
// {
// PointLight light = new PointLight();
// light.Color = Colors.Black;
// light.Range = SCALE * INSIDEPOINTRADIUS * 2d;
// light.LinearAttenuation = 1d;
// transformGroup = new Transform3DGroup();
// transformGroup.Children.Add(new TranslateTransform3D(Math3D.GetRandomVectorSpherical(this.Options.Random, INSIDEPOINTRADIUS)));
// transformGroup.Children.Add(scaleTransform);
// light.Transform = transformGroup;
// retVal.Children.Add(light);
// ColorAnimation animation = new ColorAnimation();
// animation.From = UtilityWPF.ColorFromHex("CC1266");
// animation.To = Colors.Black;
// animation.Duration = new Duration(TimeSpan.FromSeconds(1d + (this.Options.Random.NextDouble() * 5d)));
// animation.AutoReverse = true;
// animation.RepeatBehavior = RepeatBehavior.Forever;
// animation.AccelerationRatio = .5d;
// animation.DecelerationRatio = .5d;
// light.BeginAnimation(PointLight.ColorProperty, animation);
// }
//}
#endregion
#region Outer Shell
geometry = new GeometryModel3D();
material = new MaterialGroup();
Color shellColor = WorldColors.Brain;
if (!isFinal)
{
shellColor = UtilityWPF.AlphaBlend(shellColor, Colors.Transparent, .75d);
}
diffuse = new DiffuseMaterial(new SolidColorBrush(shellColor));
this.MaterialBrushes.Add(new MaterialColorProps(diffuse, shellColor));
material.Children.Add(diffuse);
specular = WorldColors.BrainSpecular;
this.MaterialBrushes.Add(new MaterialColorProps(specular));
material.Children.Add(specular);
if (!isFinal)
{
EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
material.Children.Add(selectionEmissive);
base.SelectionEmissives.Add(selectionEmissive);
}
geometry.Material = material;
geometry.BackMaterial = material;
transformGroup = new Transform3DGroup();
transformGroup.Children.Add(scaleTransform);
transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation()))); // this is just so it's not obvious that the brains are shared visuals
geometry.Geometry = SharedVisuals.BrainMesh; // SharedVisuals keeps track of which thread made the request
geometry.Transform = transformGroup;
retVal.Children.Add(geometry);
//.........这里部分代码省略.........
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:101,代码来源:Brain.cs
示例19: CreateInsideVisuals
internal static Model3D[] CreateInsideVisuals(double radius, List<MaterialColorProps> materialBrushes, List<EmissiveMaterial> selectionEmissives, ScaleTransform3D scaleTransform)
{
List<Point3D[]> insidePoints = new List<Point3D[]>();
for (int cntr = 0; cntr < 3; cntr++)
{
GetLineBranch(insidePoints, Math3D.GetRandomVector_Spherical(radius).ToPoint(), radius, radius * .8d, .33d, 4);
}
Random rand = StaticRandom.GetRandomForThread();
List<Model3D> retVal = new List<Model3D>();
foreach (Point3D[] lineSegment in insidePoints)
{
GeometryModel3D geometry = new GeometryModel3D();
MaterialGroup material = new MaterialGroup();
Color color = WorldColors.BrainInsideStrand; // storing this, because it's random
DiffuseMaterial diffuse = new DiffuseMaterial(new SolidColorBrush(color));
materialBrushes.Add(new MaterialColorProps(diffuse, color));
material.Children.Add(diffuse);
SpecularMaterial specular = WorldColors.BrainInsideStrandSpecular;
materialBrushes.Add(new MaterialColorProps(specular));
material.Children.Add(specular);
//if (!isFinal)
//{
EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
material.Children.Add(selectionEmissive);
selectionEmissives.Add(selectionEmissive);
//}
geometry.Material = material;
geometry.BackMaterial = material;
Vector3D line = lineSegment[1] - lineSegment[0];
double lineLength = line.Length;
double halfLength = lineLength * .5d;
double widestWidth = lineLength * .033d;
List<TubeRingBase> rings = new List<TubeRingBase>();
rings.Add(new TubeRingPoint(0, false));
rings.Add(new TubeRingRegularPolygon(halfLength, false, widestWidth, widestWidth, false));
rings.Add(new TubeRingPoint(halfLength, false));
Quaternion zRot = new Quaternion(new Vector3D(0, 0, 1), 360d * rand.NextDouble()).ToUnit();
Quaternion rotation = Math3D.GetRotation(new Vector3D(0, 0, 1), line).ToUnit();
Transform3DGroup transformGroup = new Transform3DGroup();
transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Quaternion.Multiply(rotation, zRot))));
transformGroup.Children.Add(new TranslateTransform3D(lineSegment[0].ToVector()));
transformGroup.Children.Add(scaleTransform);
geometry.Geometry = UtilityWPF.GetMultiRingedTube(3, rings, true, false, transformGroup);
retVal.Add(geometry);
}
return retVal.ToArray();
}
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:61,代码来源:Brain.cs
|
请发表评论