本文整理汇总了C#中Renderer.RenderFrame方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.RenderFrame方法的具体用法?C# Renderer.RenderFrame怎么用?C# Renderer.RenderFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderer
的用法示例。
在下文中一共展示了Renderer.RenderFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var mediaPath = Path.GetFullPath("../../../../../js/r68/examples/");
var texturesPath = Path.Combine(mediaPath, "textures");
var renderer = new Renderer();
var scene = new Scene()
{
//Fog = new FogExp2(Color.Blue, 0.24f)
};
var camera = new OrthographicCamera(renderer, -1000, 1000)
{
Position = new Vector3(0, 0, 2)
};
//// create a point light
scene.Add(new DirectionalLight(Color.White)
{
Target = Vector3.UnitX
});
var geometry = new BoxGeometry(20, 20, 20);
for (var i = 0; i < 2000; i++)
{
var o = new Mesh(geometry, new MeshLambertMaterial(renderer) { Diffuse = Color.Random() });
o.Position = new Vector3(Mathf.RandomF(-400, 400), Mathf.RandomF(-400, 400), Mathf.RandomF(-400, 400));
o.Rotation = new Euler(Mathf.Tau * Mathf.RandomF(), Mathf.Tau * Mathf.RandomF(), Mathf.Tau * Mathf.RandomF());
o.Scale = new Vector3(Mathf.RandomF(0.5f, 1.5f), Mathf.RandomF(0.5f, 1.5f), Mathf.RandomF(0.5f, 1.5f));
scene.Add(o);
}
var raycaster = new Raycaster();
Object3D INTERSECTED = null;
Color previousColor = Color.White;
var radius = 100;
var previousTime = 0f;
var stopwatch = Stopwatch.StartNew();
while (!renderer.Done)
{
var now = (float)stopwatch.Elapsed.TotalSeconds;
var deltaTime = now - previousTime;
previousTime = now;
var offset = now / 4;
var sin = Mathf.Sin(offset) * radius;
var cos = Mathf.Cos(offset) * radius;
camera.Position = new Vector3(sin, sin, cos);
camera.LookAt(Vector3.Zero);
#region FindIntersections
var vector = Projector.UnprojectVector(new Vector3(renderer.MousePositionNormalized,-1),camera.projectionMatrix, camera.matrixWorld);
var direction = new Vector3(0, 0, -1);
direction.TransformDirection(camera.matrixWorld);
raycaster.Set(vector, direction);
var intersects = raycaster.IntersectObjects(scene.Children);
if (intersects != null && intersects.Count > 0)
{
var first = intersects[0];
if (INTERSECTED != first.Object)
{
if (INTERSECTED != null)
{
var basic = INTERSECTED.Material as MeshLambertMaterial;
basic.Emissive = previousColor;
}
var firstMat = first.Object.Material as MeshLambertMaterial;
INTERSECTED = first.Object;
previousColor = firstMat.Emissive;
firstMat.Emissive = Color.Red;
}
}
else
{
if (INTERSECTED != null)
{
(INTERSECTED.Material as MeshLambertMaterial).Emissive = previousColor;
}
INTERSECTED = null;
}
#endregion
renderer.RenderFrame(scene, camera);
}
}
示例2: Main
//.........这里部分代码省略.........
NormalMap = new Texture(Path.Combine(texturesPath, "planets\\earth_normal_2048.jpg")),
SpecularMap = new Texture(Path.Combine(texturesPath, "planets\\earth_specular_2048.jpg")),
DiffuseMap = new Texture(Path.Combine(texturesPath, "planets\\earth_atmos_2048.jpg")),
//DiffuseColor = Color.Red,
};
var materialNoMap = new MeshPhongMaterial(renderer)
//var materialNoMap = new MeshBasicMaterial(renderer)
//var materialNoMap = new MeshLambertMaterial(renderer)
{
Hardness = 1,
Shininess = 10,
Specular = new Color(.001f, .05f, .1f),
ShouldWrapAround = true,
NormalMap = new Texture(Path.Combine(texturesPath, "planets\\earth_normal_2048.jpg")),
SpecularMap = new Texture(Path.Combine(texturesPath, "planets\\earth_specular_2048.jpg")),
DiffuseMap = new Texture(Path.Combine(texturesPath, "planets\\earth_atmos_2048.jpg")),
//DiffuseColor = Color.Blue,
};
var cube = CreateCube(renderer, scene, texturesPath, materialMap);
var cube2
= CreateCube(renderer, scene, texturesPath, materialNoMap);
var cube3 = CreateCube(renderer, scene, texturesPath, materialMap);
var p = cube.Position;
//p.x -= 2;
cube.Position = p;
p = cube2.Position;
p.x += 2;
cube2.Position = p;
scene.Add(cube);
//scene.Add(cube2);
//scene.Add(cube3);
//frankie.Add(cube);
//cube.Position = new Vector3(0, 1, 1);
var lines = CreateHilbertCube(renderer, scene);
lines.Scale = new Vector3(4, 4, 4);
//scene.Add(lines);
//lines.Position = new Vector3(0, 1, -1);
var arrowHelper = ArrowHelper.Create(renderer, new Vector3(1,1,0), Vector3.Zero, 0.35f, Color.Red);
arrowHelper.Position = new Vector3(0.25f, 0.25f, 0.25f);
//scene.Add(arrowHelper);
var axisHelper = AxisHelper.Create(renderer, 0.25f);
axisHelper.Position = new Vector3(-0.25f, 0.25f, 0.25f);
//scene.Add(axisHelper);
//var boundingBoxHelper = BoundingBoxHelper.Create(renderer, frankie);
//scene.Add(boundingBoxHelper);
var previousTime = 0f;
var stopwatch = Stopwatch.StartNew();
while (!renderer.Done)
{
var now = (float)stopwatch.Elapsed.TotalSeconds;
var deltaTime = now - previousTime;
previousTime = now;
//var offset = material.DiffuseMap.Offset;
//offset.x += deltaTime * 0.75f;
//offset.y -= deltaTime * 0.5f;
//material.DiffuseMap.Offset = offset;
//var r = frankie.Rotation;
//r.y += deltaTime;
//frankie.Rotation = r;
//r = axisHelper.Rotation;
//r.x = Mathf.Pi / 4;
//r.y -= deltaTime;
//axisHelper.Rotation = r;
var r = cube.Rotation;
r.y -= deltaTime / 2;
r.x = Mathf.Sin(now / 4);
cube.Rotation = r;
r = cube2.Rotation;
r.y -= deltaTime / 2;
cube2.Rotation = r;
//boundingBoxHelper.Update();
renderer.RenderFrame(scene, camera);
}
}