public Plane(int xRes, int yRes, float xScale, float yScale) { Vertices = new Vector3[xRes * yRes]; Normals = new Vector3[xRes * yRes]; Indices = new uint[6 * xRes * yRes]; Texcoords = new Vector2[xRes * yRes]; int i = 0; for (int y = -yRes / 2; y < yRes / 2; y++) { for (int x = -xRes / 2; x < xRes / 2; x++) { Vertices[i].X = xScale * x / xRes; Vertices[i].Y = yScale * y / yRes; Vertices[i].Z = 0; Normals[i].X = Normals[i].Y = 0; Normals[i].Z = 1; i++; } } i = 0; for (int y = 0; y < yRes - 1; y++) { for (int x = 0; x < xRes - 1; x++) { Indices[i++] = (uint)((y + 0) * xRes + x); Indices[i++] = (uint)((y + 1) * xRes + x); Indices[i++] = (uint)((y + 0) * xRes + x + 1); Indices[i++] = (uint)((y + 0) * xRes + x + 1); Indices[i++] = (uint)((y + 1) * xRes + x); Indices[i++] = (uint)((y + 1) * xRes + x + 1); } } }
private VertexBufferElement(Vector3 position, int color, Vector2 textureUV, Vector3 normal) { Position = position; Color = color; TextureUV = textureUV; Normal = normal; }
private void CreateCube(float x, float y, float z, float sizeX, float sizeY, float sizeZ) { //Top vertexes var point1Bottom = new Vector3(x, z, y); var point2Bottom = new Vector3(x + sizeX, z, y); var point3Bottom = new Vector3(x + sizeX, z, y + sizeY); var point4Bottom = new Vector3(x, z, y + sizeY); //Bottom vertexes var point1Top = new Vector3(x, z + sizeZ, y); var point2Top = new Vector3(x + sizeX, z + sizeZ, y); var point3Top = new Vector3(x + sizeX, z + sizeZ, y + sizeY); var point4Top = new Vector3(x, z + sizeZ, y + sizeY); //Normals var topNormal = new Vector3(0, 1, 0); var bottomNormal = new Vector3(0, -1, 0); var leftNormal = new Vector3(-1, 0, 0); var rightNormal = new Vector3(1, 0, 0); var farNormal = new Vector3(0, 0, -1); var nearNormal = new Vector3(0, 0, 1); CreateCubeFace(point4Top, point1Top, point2Top, point3Top, topNormal); CreateCubeFace(point1Bottom, point4Bottom, point3Bottom, point2Bottom, bottomNormal); CreateCubeFace(point1Top, point1Bottom, point2Bottom, point2Top, farNormal); CreateCubeFace(point3Top, point3Bottom, point4Bottom, point4Top, nearNormal); CreateCubeFace(point4Top, point4Bottom, point1Bottom, point1Top, leftNormal); CreateCubeFace(point2Top, point2Bottom, point3Bottom, point3Top, rightNormal); }
public void ProcessVertex(string line, Mesh mesh) { if (!mesh.SubMeshes.Any()) mesh.SubMeshes.Add(new SubMesh()); var tokens = line.Split(' '); if (tokens.Length != 4) return; Vector3 vertex = new Vector3 { X = float.Parse(tokens[1], Style, Info), Y = float.Parse(tokens[2], Style, Info), Z = float.Parse(tokens[3], Style, Info) }; mesh.SubMeshes.Last().Vertices.Add(vertex); // Bounds if (vertex.X < mesh.MinVertex.X) mesh.MinVertex.X = vertex.X; if (vertex.Y < mesh.MinVertex.Y) mesh.MinVertex.Y = vertex.Y; if (vertex.Z < mesh.MinVertex.Z) mesh.MinVertex.Z = vertex.Z; if (vertex.X > mesh.MaxVertex.X) mesh.MaxVertex.X = vertex.X; if (vertex.Y > mesh.MaxVertex.Y) mesh.MaxVertex.Y = vertex.Y; if (vertex.Z > mesh.MaxVertex.Z) mesh.MaxVertex.Z = vertex.Z; }
public Face(Vector3[] vertices, Vector2[] texCoords, int[] indices) : this() { Vertices = vertices; TexCoords = texCoords; Indices = indices; }
public bool CheckSphere(Vector3 boundingSphereCenter, float boundingSphereR) { if (!this.Front.CheckSphere(ref boundingSphereCenter, ref boundingSphereR)) { return false; } if (!this.Back.CheckSphere(ref boundingSphereCenter, ref boundingSphereR)) { return false; } if (!this.Right.CheckSphere(ref boundingSphereCenter, ref boundingSphereR)) { return false; } if (!this.Right2.CheckSphere(ref boundingSphereCenter, ref boundingSphereR)) { return false; } if (!this.Right3.CheckSphere(ref boundingSphereCenter, ref boundingSphereR)) { return false; } if (!this.Right4.CheckSphere(ref boundingSphereCenter, ref boundingSphereR)) { return false; } return true; }
public TransformationManager(Vector3 pos) { Position = pos; Orientation = Quaternion.Identity; ScaleValue = new Vector3(1, 1, 1); BeenModified = true; }
public TransformationManager(Vector3 pos, Quaternion orient) { Position = pos; Orientation = orient; ScaleValue = new Vector3(1, 1, 1); BeenModified = true; }
/// <summary> /// Initializes a new instance of the <see cref="SimpleSpriteVertexData"/> struct. /// </summary> /// <param name="position">The position.</param> /// <param name="uv">The uv coordinates.</param> /// <param name="color">The color.</param> /// <param name="expand">The vector by which to move the vertex in camera space, parallel to the view plane.</param> public SimpleSpriteVertexData(Vector3 position, Vector2 uv, Color color, Vector2 expand) { this.Position = position; this.TexCoord = uv; this.Color = color; this.Expand = expand; }
public TransformationManager(Vector3 pos, Vector3 axis, float angle, float scale) { Position = pos; Orientation = Quaternion.FromAxisAngle(axis, angle); ScaleValue = new Vector3(scale, scale, scale); BeenModified = true; }
public void Update(CamViewState state, Point mouseLoc, Point beginLoc, Vector3 beginLocSpace, Vector3 lastLocSpace, Vector3 selectionCenter, float selectionRadius, CamViewState.LockedAxis lockedAxis) { state.ValidateSelectionStats(); float zMovement = state.CameraObj.Transform.Pos.Z - lastLocSpace.Z; Vector3 target = state.GetSpaceCoord(new Vector3(mouseLoc.X, mouseLoc.Y, selectionCenter.Z + zMovement)); Vector3 movLock = beginLocSpace - lastLocSpace; Vector3 mov = target - lastLocSpace; mov.Z = zMovement; target.Z = 0; if (lockedAxis == CamViewState.LockedAxis.X) { mov = new Vector3(mov.X, 0, 0); } else if (lockedAxis == CamViewState.LockedAxis.Y) { mov = new Vector3(0, mov.Y, 0); } else { mov = state.ApplyAxisLock(mov, movLock, target + (Vector3.UnitZ * state.CameraObj.Transform.Pos.Z) - beginLocSpace); } state.MoveSelectionBy(mov); state.ActionLastLocSpace += mov; }
//Spotlight constructor, takes a position Vector, a color Vector, a direction Vector and public Spotlight(Vector3 position, Vector3 color, Vector3 direction, float minDot) { pos = position; this.color = color; D = direction.Normalized(); this.minDot = minDot; }
public IEnumerable<Face> CreateCubeMesh() { //Front var vertex0 = new Vector3(-0.5f, -0.5f, 0.5f); var vertex1 = new Vector3(-0.5f, 0.5f, 0.5f); var vertex2 = new Vector3(0.5f, 0.5f, 0.5f); var vertex3 = new Vector3(0.5f, -0.5f, 0.5f); //Rear var vertex4 = new Vector3(-0.5f, -0.5f, -0.5f); var vertex5 = new Vector3(-0.5f, 0.5f, -0.5f); var vertex6 = new Vector3(0.5f, 0.5f, -0.5f); var vertex7 = new Vector3(0.5f, -0.5f, -0.5f); var front = new Face(new List<Vector3> { vertex0, vertex1, vertex2, vertex3 }); var back = new Face(new List<Vector3> { vertex4, vertex5, vertex6, vertex7 }); var left = new Face(new List<Vector3> { vertex4, vertex5, vertex1, vertex0 }); var right = new Face(new List<Vector3> { vertex7, vertex3, vertex2, vertex6 }); var top = new Face(new List<Vector3> { vertex1, vertex5, vertex6, vertex2 }); var bottom = new Face(new List<Vector3> { vertex0, vertex4, vertex7, vertex3 }); return new List<Face> {front, back, left, right, top, bottom}; }
internal Builder() { _position = Vector3.Zero; _color = 0; _textureUV = Vector2.Zero; _normal = Vector3.Zero; }
/// <summary> /// 立方体を作成する /// </summary> /// <param name="_size">1辺の長さ</param> /// <param name="_color">表示色</param> public Cube(float _size, Color4 _color) { // 各パラメーターを設定 this.position = new Vector3(); this.size = _size; this.color = _color; }
#pragma warning restore 414 public BuildingVertex(Vector3 position, Vector3 normal, Vector2 uv, float alpha = 1) { this.position = position; this.normal = normal; this.uv = uv; this.alpha = alpha; }
/// <summary> /// 粒子を作成する /// </summary> /// <param name="_d">直径</param> /// <param name="_color">表示色</param> public Particle(float _d, Color4 _color) { // 各パラメーターを設定 this.X = new Vector3(); this.d = _d; this.color = _color; }
public void LookAt(Vector3 location) { RotationMatrix = Matrix4.LookAt(Vector3.Zero, ( Transformation.GetPosition() + location).Normalized(), new Vector3(0, 1, 0)); ViewMatrix = Matrix4.LookAt(Transformation.GetPosition(), location, new Vector3(0, 1, 0)); Transformation.SetOrientation(RotationMatrix.ExtractRotation()); Transformation.ClearModifiedFlag(); }
public void Render(Vector3 pos, float rotation, Vector3 offset, Color4 color) { Vector3 rotate = new Vector3(0, 0, rotation); Vector2 dimension = new Vector2(_spriteWidth, _spriteHeight); Vector2 source = new Vector2(_xFrame * _spriteWidth, _yFrame * _spriteHeight); Graphics.DrawTexture(SpriteSheet, pos - offset, dimension, source, dimension, offset, rotate, color); }
public Ray(Vector3 position, Vector3 direction, float minT, float maxT) { Origin = position; Direction = direction; this.tMin = minT; this.tMax = maxT; }
/// <summary> /// 粒子を作成する /// </summary> /// <param name="_x">中心座標</param> /// <param name="_d">直径</param> /// <param name="_color">表示色</param> public OutputParticle(Vector3 _x, float _d, Color4 _color) { // 各パラメーターを設定 this.X = _x; this.d = _d; this.color = _color; }
/// <summary> /// Initializes a new instance of the <see cref="nginz.Vertex2D"/> struct. /// </summary> /// <param name="pos">Position.</param> /// <param name="texcoord">Texcoord.</param> /// <param name="color">Color.</param> public Vertex2D(Vector3 pos, Vector2 texcoord, Color4 color) : this() { Position = pos; TextureCoordinate = texcoord; Color = color; }
/// <summary> /// Returns a rotation matrix with position <0,0,0> according to vector x and z /// </summary> /// <param name="x"> the x vector</param> /// <param name="z">the z vector</param> /// <returns>Rotation matrix</returns> public static Matrix4 GetOrientationMatrix(Vector3 x, Vector3 z) { x.NormalizeFast(); z.NormalizeFast(); Vector3 y = Vector3.Cross(z, x); return GetMatrix(Vector3.Zero, z, y, Vector3.Cross(y, z)); }
public TransformationManager(Vector3 pos, Quaternion orient, Vector3 scale) { Position = new ValuePointer<Vector3>(pos); Orientation = orient; ScaleValue = scale; BeenModified = true; }
public void ApplyForce(Vector3 force) { //Newtons 2nd Law: F = Mass * Acceleration; //but also consider force accumulation: //acceleration equals the sum of all forces / Mass Acceleration += force / Mass; }
/// <summary> /// 立方体を作成する /// </summary> /// <param name="_position">中心座標</param> /// <param name="_size">1辺の長さ</param> /// <param name="_color">表示色</param> public Cube(Vector3 _position, float _size, Color4 _color) { // 各パラメーターを設定 this.position = _position; this.size = _size; this.color = _color; }
public Body(Vector3 location, float mass) { Acceleration = Vector3.Zero; Location = location; Mass = mass; Velocity = Vector3.Zero; }
public void GenerateGeometry(SharpGL.OpenGL gl) { HighlightCube.GenerateGeometry(gl); const float spacing = 1 + CubeSpacing; for (int z = 0; z < Size; z++) { for (int y = 0; y < Size; y++) { for (int x = 0; x < Size; x++) { var cube = new Cube(Colors.Black); ColourCubeFromConfiguration(cube, x, y, z); cube.GenerateGeometry(gl); var position = new Vector3(x * spacing, y * spacing, z * spacing); position += m_cubieCentre; // Centre string id = string.Format("{0},{1},{2}", x - 1, y - 1, z - 1); var cubie = new Cubie(id, cube, position); AddToConfiguration(cubie, x, y, z); m_animators.Add(new CubieAnimator(cubie)); } } } CubeConfiguration.CheckValid(); }
//The material constructor, takes a color Vector, a diffuse value, reflection value and a recursionDepth. public Material(Vector3 color, float diffuse, float reflection, float recursionDepth) { this.color = color; this.diffuse = diffuse; this.reflection = reflection; this.recursionDepth = recursionDepth; }
public NoiseModuleBase(OpenTK.Vector3 axial_frequencies, bool anti_y = false, bool pos_y = false, bool neg_y = false) { m_axial_frequencies = axial_frequencies; m_modifiers = new System.Collections.Generic.List <NoiseModifierBase>(); m_anti_vertical_bias = anti_y; m_positive_vertical_bias = pos_y; m_negative_vertical_bias = neg_y; }
public OpenTK.Vector3 SerializeIn_otk_vector3() { OpenTK.Vector3 v = new OpenTK.Vector3(); v.X = SerializeIn_float(); v.Y = SerializeIn_float(); v.Z = SerializeIn_float(); return(v); }
OpenTK.Vector3 ScreenToWorld(OpenTK.Vector3 screencoord) { OpenTK.Vector3 worldcoord = new OpenTK.Vector3(); screencoord.Y = Height - screencoord.Y; screencoord.Z = 0; OpenTK.Graphics.Glu.UnProject(screencoord, matView, matProj, viewport, out worldcoord); return(worldcoord); }
public SkinnedVertex(Vector3 pos, Vector3 normal, Vector2 uv) { Position = pos; Normal = normal; Texture = uv; Weights = Vector4.Zero; Bones = Vector4.Zero; }
public Material(OpenTK.Vector3 col, OpenTK.Vector4 Light, float reflection, float refraction, int type) { Color = col; LightCoeffs = Light; ReflectionCoef = reflection; RefractionCoef = refraction; MaterilaType = type; }
private void DrawHeightfield() { if (heightfield == null) { return; } GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.NormalArray); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.Light0); GL.Light(LightName.Light0, LightParameter.Position, new Vector4(0.5f, 1, 0.5f, 0)); GL.BindBuffer(BufferTarget.ArrayBuffer, heightfieldVoxelVbo); GL.VertexPointer(3, VertexPointerType.Float, 6 * 4, 0); GL.NormalPointer(NormalPointerType.Float, 6 * 4, 3 * 4); GL.Color4(0.5f, 0.5f, 0.5f, 1f); GL.BindBuffer(BufferTarget.ElementArrayBuffer, heightfieldVoxelIbo); var cellSize = heightfield.CellSize; var halfCellSize = cellSize * 0.5f; Matrix4 spanLoc, spanScale; for (int i = 0; i < heightfield.Length; i++) { for (int j = 0; j < heightfield.Width; j++) { var cellLoc = new Vector3(j * cellSize.X + halfCellSize.X + heightfield.Bounds.Min.X, heightfield.Bounds.Min.Y, i * cellSize.Z + halfCellSize.Z + heightfield.Bounds.Min.Z); var cell = heightfield[j, i]; foreach (var span in cell.Spans) { GL.PushMatrix(); Matrix4.CreateTranslation(cellLoc.X, ((span.Minimum + span.Maximum) * 0.5f) * cellSize.Y + cellLoc.Y, cellLoc.Z, out spanLoc); GL.MultMatrix(ref spanLoc); Matrix4.CreateScale(cellSize.X, cellSize.Y * span.Height, cellSize.Z, out spanScale); GL.MultMatrix(ref spanScale); GL.DrawElements(PrimitiveType.Triangles, voxelInds.Length, DrawElementsType.UnsignedByte, 0); GL.PopMatrix(); } } } GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.Disable(EnableCap.Light0); GL.Disable(EnableCap.Lighting); GL.DisableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.NormalArray); }
internal ScenarioStructureBspBlockBase(BinaryReader binaryReader) { this.importInfo = ReadGlobalTagImportInfoBlockArray(binaryReader); this.invalidName_ = binaryReader.ReadBytes(4); this.collisionMaterials = ReadStructureCollisionMaterialsBlockArray(binaryReader); this.collisionBSP = ReadGlobalCollisionBspBlockArray(binaryReader); this.vehicleFloorWorldUnits = binaryReader.ReadSingle(); this.vehicleCeilingWorldUnits = binaryReader.ReadSingle(); this.uNUSEDNodes = ReadUNUSEDStructureBspNodeBlockArray(binaryReader); this.leaves = ReadStructureBspLeafBlockArray(binaryReader); this.worldBoundsX = binaryReader.ReadRange(); this.worldBoundsY = binaryReader.ReadRange(); this.worldBoundsZ = binaryReader.ReadRange(); this.surfaceReferences = ReadStructureBspSurfaceReferenceBlockArray(binaryReader); this.clusterData = ReadData(binaryReader); this.clusterPortals = ReadStructureBspClusterPortalBlockArray(binaryReader); this.fogPlanes = ReadStructureBspFogPlaneBlockArray(binaryReader); this.invalidName_0 = binaryReader.ReadBytes(24); this.weatherPalette = ReadStructureBspWeatherPaletteBlockArray(binaryReader); this.weatherPolyhedra = ReadStructureBspWeatherPolyhedronBlockArray(binaryReader); this.detailObjects = ReadStructureBspDetailObjectDataBlockArray(binaryReader); this.clusters = ReadStructureBspClusterBlockArray(binaryReader); this.materials = ReadGlobalGeometryMaterialBlockArray(binaryReader); this.skyOwnerCluster = ReadStructureBspSkyOwnerClusterBlockArray(binaryReader); this.conveyorSurfaces = ReadStructureBspConveyorSurfaceBlockArray(binaryReader); this.breakableSurfaces = ReadStructureBspBreakableSurfaceBlockArray(binaryReader); this.pathfindingData = ReadPathfindingDataBlockArray(binaryReader); this.pathfindingEdges = ReadStructureBspPathfindingEdgesBlockArray(binaryReader); this.backgroundSoundPalette = ReadStructureBspBackgroundSoundPaletteBlockArray(binaryReader); this.soundEnvironmentPalette = ReadStructureBspSoundEnvironmentPaletteBlockArray(binaryReader); this.soundPASData = ReadData(binaryReader); this.markers = ReadStructureBspMarkerBlockArray(binaryReader); this.runtimeDecals = ReadStructureBspRuntimeDecalBlockArray(binaryReader); this.environmentObjectPalette = ReadStructureBspEnvironmentObjectPaletteBlockArray(binaryReader); this.environmentObjects = ReadStructureBspEnvironmentObjectBlockArray(binaryReader); this.lightmaps = ReadStructureBspLightmapDataBlockArray(binaryReader); this.invalidName_1 = binaryReader.ReadBytes(4); this.leafMapLeaves = ReadGlobalMapLeafBlockArray(binaryReader); this.leafMapConnections = ReadGlobalLeafConnectionBlockArray(binaryReader); this.errors = ReadGlobalErrorReportCategoriesBlockArray(binaryReader); this.precomputedLighting = ReadStructureBspPrecomputedLightingBlockArray(binaryReader); this.instancedGeometriesDefinitions = ReadStructureBspInstancedGeometryDefinitionBlockArray(binaryReader); this.instancedGeometryInstances = ReadStructureBspInstancedGeometryInstancesBlockArray(binaryReader); this.ambienceSoundClusters = ReadStructureBspSoundClusterBlockArray(binaryReader); this.reverbSoundClusters = ReadStructureBspSoundClusterBlockArray(binaryReader); this.transparentPlanes = ReadTransparentPlanesBlockArray(binaryReader); this.invalidName_2 = binaryReader.ReadBytes(96); this.vehicleSpericalLimitRadius = binaryReader.ReadSingle(); this.vehicleSpericalLimitCenter = binaryReader.ReadVector3(); this.debugInfo = ReadStructureBspDebugInfoBlockArray(binaryReader); this.decorators = binaryReader.ReadTagReference(); this.structurePhysics = new GlobalStructurePhysicsStructBlock(binaryReader); this.waterDefinitions = ReadGlobalWaterDefinitionsBlockArray(binaryReader); this.portalDeviceMapping = ReadStructurePortalDeviceMappingBlockArray(binaryReader); this.audibility = ReadStructureBspAudibilityBlockArray(binaryReader); this.objectFakeLightprobes = ReadStructureBspFakeLightprobesBlockArray(binaryReader); this.decorators0 = ReadDecoratorPlacementDefinitionBlockArray(binaryReader); }
public static JToken Serialize(this OpenTK.Vector3 vec) { var res = new JArray(); res.Add(vec.X); res.Add(vec.Y); res.Add(vec.Z); return(res); }
internal CsPointBlockBase(BinaryReader binaryReader) { this.name = binaryReader.ReadString32(); this.position = binaryReader.ReadVector3(); this.referenceFrame = binaryReader.ReadInt16(); this.invalidName_ = binaryReader.ReadBytes(2); this.surfaceIndex = binaryReader.ReadInt32(); this.facingDirection = binaryReader.ReadVector2(); }
internal StructureBspDebugInfoRenderLineBlockBase(BinaryReader binaryReader) { this.type = (Type)binaryReader.ReadInt16(); this.code = binaryReader.ReadInt16(); this.padThai = binaryReader.ReadInt16(); this.invalidName_ = binaryReader.ReadBytes(2); this.point0 = binaryReader.ReadVector3(); this.point1 = binaryReader.ReadVector3(); }
internal GlobalGeometryRawPointBlockBase(BinaryReader binaryReader) { this.position = binaryReader.ReadVector3(); this.nodeIndicesOLD = new [] { new NodeIndicesOLD(binaryReader), new NodeIndicesOLD(binaryReader), new NodeIndicesOLD(binaryReader), new NodeIndicesOLD(binaryReader), }; this.nodeWeights = new [] { new NodeWeights(binaryReader), new NodeWeights(binaryReader), new NodeWeights(binaryReader), new NodeWeights(binaryReader), }; this.nodeIndicesNEW = new [] { new NodeIndicesNEW(binaryReader), new NodeIndicesNEW(binaryReader), new NodeIndicesNEW(binaryReader), new NodeIndicesNEW(binaryReader), }; this.useNewNodeIndices = binaryReader.ReadInt32(); this.adjustedCompoundNodeIndex = binaryReader.ReadInt32(); }
internal GlobalStructurePhysicsStructBlockBase(BinaryReader binaryReader) { this.moppCode = ReadData(binaryReader); this.invalidName_ = binaryReader.ReadBytes(4); this.moppBoundsMin = binaryReader.ReadVector3(); this.moppBoundsMax = binaryReader.ReadVector3(); this.breakableSurfacesMoppCode = ReadData(binaryReader); this.breakableSurfaceKeyTable = ReadBreakableSurfaceKeyTableBlockArray(binaryReader); }
private void SetCamera(BoundingSphere boundingSphere) { float distance = ( float )(boundingSphere.Radius * 2f / Math.Tan(sFieldOfView)) + 0.75f; mCamPosition = new Vector3( boundingSphere.Center.X, boundingSphere.Center.Y, boundingSphere.Center.Z + distance); }
internal ErrorReportVectorsBlockBase(BinaryReader binaryReader) { this.position = binaryReader.ReadVector3(); this.nodeIndices = new [] { new NodeIndices(binaryReader), new NodeIndices(binaryReader), new NodeIndices(binaryReader), new NodeIndices(binaryReader), }; this.nodeWeights = new [] { new NodeWeights(binaryReader), new NodeWeights(binaryReader), new NodeWeights(binaryReader), new NodeWeights(binaryReader), }; this.color = binaryReader.ReadVector4(); this.normal = binaryReader.ReadVector3(); this.screenLength = binaryReader.ReadSingle(); }
public void Draw(Vector3 pos) { GL.Begin(BeginMode.Triangles); foreach (int index in indices) { GL.Vertex3(vertices[index] + pos); } GL.End(); }
internal DecoratorPlacementDefinitionBlockBase(BinaryReader binaryReader) { this.gridOrigin = binaryReader.ReadVector3(); this.cellCountPerDimension = binaryReader.ReadInt32(); this.cacheBlocks = ReadDecoratorCacheBlockBlockArray(binaryReader); this.groups = ReadDecoratorGroupBlockArray(binaryReader); this.cells = ReadDecoratorCellCollectionBlockArray(binaryReader); this.decals = ReadDecoratorProjectedDecalBlockArray(binaryReader); }
public vec3 phongShading(Material material, Material lightMaterial, vec3 hitPoint, vec3 surfaceNormal, vec3 lightDir, vec3 reflectDir, vec3 eyeDir, float distance) { float attenuation = 1.0f / (1.0f + lightMaterial.atenuation.X + distance * lightMaterial.atenuation.Y + distance * distance * lightMaterial.atenuation.Z); float diffuseCoef = max(0.0f, dot(surfaceNormal, lightDir)); float specularCoef = (float)Math.Pow(dot(eyeDir, reflectDir), material.shiness); return(material.ambient * lightMaterial.ambient + (material.diffuse * lightMaterial.emission * diffuseCoef + material.specular * lightMaterial.emission * specularCoef) * attenuation); }
internal ScenarioCutsceneCameraPointBlockBase(BinaryReader binaryReader) { this.flags = (Flags)binaryReader.ReadInt16(); this.type = (Type)binaryReader.ReadInt16(); this.name = binaryReader.ReadString32(); this.position = binaryReader.ReadVector3(); this.orientation = binaryReader.ReadVector3(); this.unused = binaryReader.ReadSingle(); }
public static OpenTK.Vector3 ScreenToWorld(OpenTK.Vector3 screencoord) { OpenTK.Vector3 worldcoord = new OpenTK.Vector3(); screencoord.Y = Instance.Height - screencoord.Y; screencoord.Z = 0; OpenTK.Graphics.Glu.UnProject(screencoord, Instance.matView, Instance.matProj, Instance.viewport, out worldcoord); return(worldcoord); }
public static void DrawBox(ref OpenTK.Vector3 bbMin, ref OpenTK.Vector3 bbMax, ref OpenTK.Matrix4 trans, OpenTK.Graphics.Color4 color) { using (debugProgram.Using("object_matrix", trans)) using (Box box = new Box(bbMin, bbMax)) { GL.VertexAttrib3(1, new[] { 1f, 1f, 1f }); box.Render(new[] { debugProgram }); } }
public bool isShadowed(vec3 hitPoint, int lightIndex, int lightType, vec3 transparency) { HitInfo hitInfoLight = new HitInfo(); hitInfoLight.hitDetected = false; Ray ray = new Ray(); if (lightType == TYPE_SPHERE) { Sphere light = spheres[lightIndex]; //????????????????????????? vec3 eps = normalize(light.position - hitPoint) * 0.01f; ray = new Ray(hitPoint + eps, normalize(light.position - hitPoint), TYPE_SHADOW); sphereIntersect(ray, spheres[lightIndex], hitInfoLight); //??????????????????? } if (lightType == TYPE_TRIANGLE) { //triangles } float distance = hitInfoLight.distance; HitInfo hitInfo = new HitInfo(); transparency = new vec3(1.0f); for (int i = 0; i < sphereCount; i++) { hitInfo.hitDetected = false; Material material = new Material(); int type = 0, index = 0; if (i < sphereCount) { index = i; material = spheres[index].material; type = TYPE_SPHERE; sphereIntersect(ray, spheres[index], hitInfo); } else { //triangle } if ((lightIndex != index || lightType != type) && hitInfo.hitDetected && hitInfo.distance < distance) { if (length(material.transparency) > 0) { transparency *= material.transparency; continue; } transparency = new vec3(0.0f); return(true); } } return(false); }
/// <summary> /// Checks if the vector has all values close to zero. /// </summary> public static bool eIsZero(this tk.Vector3 v) { if (Math.Abs(v.X) < Util.epsilon && Math.Abs(v.Y) < Util.epsilon && Math.Abs(v.Z) < Util.epsilon) { return(true); } return(false); }
internal UserHintLineSegmentBlockBase(BinaryReader binaryReader) { this.flags = (Flags)binaryReader.ReadInt32(); this.point0 = binaryReader.ReadVector3(); this.referenceFrame = binaryReader.ReadInt16(); this.invalidName_ = binaryReader.ReadBytes(2); this.point1 = binaryReader.ReadVector3(); this.referenceFrame0 = binaryReader.ReadInt16(); this.invalidName_0 = binaryReader.ReadBytes(2); }
internal UserHintWellPointBlockBase(BinaryReader binaryReader) { this.type = (Type)binaryReader.ReadInt16(); this.invalidName_ = binaryReader.ReadBytes(2); this.point = binaryReader.ReadVector3(); this.referenceFrame = binaryReader.ReadInt16(); this.invalidName_0 = binaryReader.ReadBytes(2); this.sectorIndex = binaryReader.ReadInt32(); this.normal = binaryReader.ReadVector2(); }
internal RenderModelMarkerBlockBase(BinaryReader binaryReader) { this.regionIndex = binaryReader.ReadByte(); this.permutationIndex = binaryReader.ReadByte(); this.nodeIndex = binaryReader.ReadByte(); this.invalidName_ = binaryReader.ReadBytes(1); this.translation = binaryReader.ReadVector3(); this.rotation = binaryReader.ReadQuaternion(); this.scale = binaryReader.ReadSingle(); }
internal FiringPositionsBlockBase(BinaryReader binaryReader) { this.positionLocal = binaryReader.ReadVector3(); this.referenceFrame = binaryReader.ReadInt16(); this.flags = (Flags)binaryReader.ReadInt16(); this.area = binaryReader.ReadShortBlockIndex1(); this.clusterIndex = binaryReader.ReadInt16(); this.invalidName_ = binaryReader.ReadBytes(4); this.normal = binaryReader.ReadVector2(); }
public GLVertex(OpenTK.Vector3 a_v3Position, System.Drawing.Color a_oColor, OpenTK.Vector2 a_v2UV) { m_v3Position = a_v3Position; // We order the color RGBA because this is the order expected by OpenGL/Graphics card. m_v4Color.X = (OpenTK.Half)(a_oColor.R * 8); m_v4Color.Y = (OpenTK.Half)(a_oColor.G * 8); m_v4Color.Z = (OpenTK.Half)(a_oColor.B * 8); m_v4Color.W = (OpenTK.Half)(a_oColor.A * 8); m_v2UV = a_v2UV; }
protected override void OnMouseWheel(MouseEventArgs e) { float cameraSpeed = (ModifierKeys & SPEED_UP_KEY) != 0 ? WHEEL_CAMERA_SPEED_FAST : (ModifierKeys & SLOW_DOWN_KEY) != 0 ? WHEEL_CAMERA_SPEED_SLOW : WHEEL_CAMERA_SPEED; mCamPosition += mCamDirection * cameraSpeed * e.Delta; mShouldRedraw = true; base.OnMouseWheel(e); }
public void DefaultSettings() { float scale = (float)Math.Max(Math.Min(maxz - minz, maxy - miny), maxx - minx) / 2f; camera = new OpenTK.Vector3(-0.4f, 0, 1) * scale + new Vector3((float)minx, (float)maxy, (float)minz); Yaw = -0.73; Pitch = -0.32; MoveSpeed = scale; clearColor = new OpenTK.Graphics.Color4(1.0f, 1, 1, 1); }
public Matrix4 GetViewMatrix() {//Returns target for camera view OpenTK.Vector3 lookat = new OpenTK.Vector3(); lookat.X = (float)(Math.Sin((float)Orientation.X) * Math.Cos((float)Orientation.Y)); lookat.Y = (float)Math.Sin((float)Orientation.Y); lookat.Z = (float)(Math.Cos((float)Orientation.X) * Math.Cos((float)Orientation.Y)); return(Matrix4.LookAt(Position, Position + lookat, OpenTK.Vector3.UnitY)); }
internal StructureBspClusterPortalBlockBase(BinaryReader binaryReader) { this.backCluster = binaryReader.ReadInt16(); this.frontCluster = binaryReader.ReadInt16(); this.planeIndex = binaryReader.ReadInt32(); this.centroid = binaryReader.ReadVector3(); this.boundingRadius = binaryReader.ReadSingle(); this.flags = (Flags)binaryReader.ReadInt32(); this.vertices = ReadStructureBspClusterPortalVertexBlockArray(binaryReader); }