本文整理汇总了C#中vec2类的典型用法代码示例。如果您正苦于以下问题:C# vec2类的具体用法?C# vec2怎么用?C# vec2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
vec2类属于命名空间,在下文中一共展示了vec2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Terrain
public Terrain(vec2 pos,Loader loader,ModelTexture texture)
{
this.texture = texture;
Position.x = pos.x * SIZE;
Position.y = pos.y * SIZE;
model = generateTerrain(loader);
}
示例2: mat2
public mat2(vec2 a, vec2 b)
{
this.cols = new[]
{
a, b
};
}
示例3: IconStyle
public IconStyle(float scale, float heading, Icon icon, vec2 hotSpot)
{
this.scale = scale;
this.heading = heading;
this.icon = icon;
this.hotSpot = hotSpot;
}
示例4: BrickFragmentShader
public BrickFragmentShader(vec2 size, vec2 pct, vec3 brickColor, vec3 mortColor)
{
BrickSize = size;
BrickPct = pct;
BrickColor = brickColor;
MortarColor = mortColor;
}
示例5: vec2
public vec2 this[int column]
{
get
{
vec2 r = new vec2(GetColumn(column));
return r;
}
}
示例6: scale
/// <summary>
/// Applies a scale transformation to matrix <paramref name="m"/> by vector <paramref name="v"/>.
/// </summary>
/// <param name="m">The matrix to transform.</param>
/// <param name="v">The vector to scale by.</param>
/// <returns><paramref name="m"/> scaled by <paramref name="v"/>.</returns>
public static mat3 scale(mat3 m, vec2 v)
{
mat3 result = m;
result.col0 = m.col0 * v.x;
result.col1 = m.col1 * v.y;
result.col2 = m.col2;
return result;
}
示例7: degrees
public static vec2 degrees(vec2 radians)
{
vec2 r;
r.x = radians.x * radToDeg;
r.y = radians.y * radToDeg;
return r;
}
示例8: WangAt
public vec4 WangAt(vec2 tex)
{
var address = tex - tex % (1.0f / 256.0f);
var subPos = Fraction(tex * 256.0f) / 4.0f;
var offset = Texture(WangMap, Fraction(address)).xw;
var tc = offset + subPos;
var tileScaledTex = tex * new vec2(32.0f / 1.0f);
return TextureGrad(WangTiles, tc, DeriveTowardsX(tileScaledTex), DeriveTowardsY(tileScaledTex));
}
示例9: WangAt
public vec4 WangAt(vec2 tex)
{
var address = tex - mod(tex, 1.0f / 256.0f);
var subPos = Fraction(tex * 256.0f) / 4.0f;
var offset = texture(WangMap, Fraction(address)).xw;
var tc = offset + subPos;
var tileScaledTex = tex * new vec2(32.0f / 1.0f);
return textureGrad(WangTiles, tc, dFdx(tileScaledTex), dFdy(tileScaledTex));
}
示例10: GetProperty
public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader)
{
if (bufferName == strPosition)
{
if (this.positionBufferPtr == null)
{
const float lower = -0.3f;
var positions = new vec2[codedColors.Length * 2 + 4];
for (int i = 0; i < codedColors.Length; i++)
{
positions[i * 2 + 0] = new vec2(codedColors[i].Coord*2, lower);
positions[i * 2 + 1] = new vec2(codedColors[i].Coord * 2, 1);
}
int index = codedColors.Length * 2 + 0;
positions[index++] = new vec2(codedColors[0].Coord * 2, 0);
positions[index++] = new vec2(codedColors[codedColors.Length - 1].Coord * 2, 0);
positions[index++] = new vec2(codedColors[0].Coord * 2, 1);
positions[index++] = new vec2(codedColors[codedColors.Length - 1].Coord * 2, 1);
// Move2Cente
float min = positions[0].x, max = positions[0].x;
for (int i = 1; i < positions.Length; i++)
{
vec2 value = positions[i];
if (value.x < min) { min = value.x; }
if (max < value.x) { max = value.x; }
}
float mid = max / 2 + min / 2;
for (int i = 0; i < positions.Length; i++)
{
positions[i].x = positions[i].x - mid;
}
using (var buffer = new PropertyBuffer<vec2>(varNameInShader, 2, OpenGL.GL_FLOAT, BufferUsage.StaticDraw))
{
buffer.Alloc(positions.Length);
unsafe
{
var array = (vec2*)buffer.Header.ToPointer();
for (int i = 0; i < positions.Length; i++)
{ array[i] = positions[i]; }
}
this.positionBufferPtr = buffer.GetBufferPtr() as PropertyBufferPtr;
}
}
return this.positionBufferPtr;
}
else
{
throw new NotImplementedException();
}
}
示例11: ArgumentOutOfRangeException
/// <summary>
/// Gets or sets the <see cref="vec2"/> column at the specified index.
/// </summary>
/// <value>
/// The <see cref="vec2"/> column.
/// </value>
/// <param name="column">The column index.</param>
/// <returns>The column at index <paramref name="column"/>.</returns>
public vec2 this[int column]
{
get
{
if (column == 0) { return this.col0; }
if (column == 1) { return this.col1; }
throw new ArgumentOutOfRangeException();
}
set
{
if (column == 0) { this.col0 = value; }
else if (column == 1) { this.col1 = value; }
else
{
throw new ArgumentOutOfRangeException();
}
}
}
示例12: lookAt
/// <summary>
/// Build a look at view matrix.
/// transform object's coordinate from world's space to camera's space.
/// </summary>
/// <param name="eye">The eye.</param>
/// <param name="center">The center.</param>
/// <param name="up">Up.</param>
/// <returns></returns>
public static mat3 lookAt(vec2 eye, vec2 center, bool up)
{
// camera's back in world space coordinate system
vec2 back = (eye - center).normalize();
// camera's right in world space coordinate system
vec2 right = up.cross(back).normalize();
if (!up) { right = -right; }
mat3 viewMatrix = new mat3(1);
viewMatrix.col0.x = right.x;
viewMatrix.col1.x = right.y;
viewMatrix.col0.y = back.x;
viewMatrix.col1.y = back.y;
// Translation in world space coordinate system
viewMatrix.col3.x = -eye.dot(right);
viewMatrix.col3.y = -eye.dot(back);
return viewMatrix;
}
示例13: SetValue
internal override bool SetValue(ValueType value)
{
#if DEBUG
if (value.GetType() != typeof(vec2))
{
throw new ArgumentException(string.Format("[{0}] not match [{1}]'s value.",
value.GetType().Name, this.GetType().Name));
}
#endif
var v = (vec2)value;
if (v != this.value)
{
this.value = v;
this.Updated = true;
return true;
}
else
{
return false;
}
}
示例14: main
public override void main()
{
vec3 ecPosition = new vec3(MVMatrix * MCvertex);
vec3 tnorm = normalize(NormalMatrix * MCnormal);
vec3 lightVec = normalize(LightPosition - ecPosition);
vec3 reflectVec = reflect(-lightVec, tnorm);
vec3 viewVec = normalize(-ecPosition);
float diffuse = max(dot(lightVec, tnorm), 0.0f);
float spec = 0.0f;
if (diffuse > 0.0f)
{
spec = max(dot(reflectVec, viewVec), 0.0f);
spec = pow(spec, 16.0f);
}
LightIntensity = DiffuseContribution * diffuse +
SpecularContribution * spec;
MCposition = new vec2(MCvertex);
GPPosition = new vec3(MVPMatrix * MCvertex);
}
示例15: _Apply
public static void _Apply(Texture2D Current, RenderTarget2D Output)
{
GridHelper.GraphicsDevice.SetRenderTarget(null);
for (int i = 0; i < 10; i++)
GridHelper.GraphicsDevice.Textures[i] = null;
vec2 OutputSize = new vec2(Output.Width, Output.Height);
var instance = new UpdateLife();
var _Current = new Field<cell>(Current); _Current.GetDataFromTexture();
var _Output = new Field<cell>(Output); _Output.GetDataFromTexture();
for (int i = 0; i < Output.Width ; i++) {
for (int j = 0; j < Output.Height; j++) {
VertexOut v = VertexOut.Zero;
v.TexCoords = new vec2(i, j) / OutputSize;
__SamplerHelper.TextureCoord = v.TexCoords;
var color = (color)instance.FragmentShader(v, _Current).ConvertTo();
//color = rgba(State.Alive, 0,0,0);
_Output.clr[i * _Output.Height + j] = new Color(FragSharpMarshal.Marshal(color));
}}
_Output.CopyDataToTexture();
}