// Use this for initialization void Start() { water = GameObject.FindGameObjectWithTag("Water").GetComponent <MeshCreator>(); body = GetComponent <Rigidbody>(); col = GetComponent <BoxCollider>(); corners = GetColliderVertexPositions(); }
private void FillTexture(MeshCreator p_Instance) { MeshRenderer l_MeshRenderer = p_Instance.GetComponent <MeshRenderer>(); if (l_MeshRenderer != null) { Texture2D l_Texture = l_MeshRenderer.sharedMaterial.mainTexture as Texture2D; if (l_Texture != null) { int l_Width = l_Texture.width; int l_Height = l_Texture.width; int l_Width1 = 64; int l_Height1 = 64; for (int x = 0; x < l_Width; x += l_Width1) { for (int y = 0; y < l_Height; y += l_Height1) { var colors = l_Texture.GetPixels(x, y, l_Width1, l_Height1); Texture2D l_NewTexture = new Texture2D(l_Width1, l_Height1); l_NewTexture.SetPixels(colors); l_NewTexture.Apply(); m_Textures.Add(l_NewTexture); } } } } }
void Awake() { // We will create a cube, so we set 12 triangles (6 sides á 2 triangles) and 8 vertices. // To do a cube with proper shading, we should actually create 4 vertices per side and have // normals pointing outwards, but for this example let's keep it simple. meshCreator = new MeshCreator(12, 8); // Create the vertices var behindUpperLeft = new MeshVertex(new Vector3(-1, 1, 1), Vector3.zero, Color.white); var behindUpperRight = new MeshVertex(new Vector3(1, 1, 1), Vector3.zero, Color.white); var behindLowerLeft = new MeshVertex(new Vector3(-1, -1, 1), Vector3.zero, Color.white); var behindLowerRight = new MeshVertex(new Vector3(1, -1, 1), Vector3.zero, Color.white); var frontUpperLeft = new MeshVertex(new Vector3(-1, 1, -1), Vector3.zero, Color.white); var frontUpperRight = new MeshVertex(new Vector3(1, 1, -1), Vector3.zero, Color.white); var frontLowerLeft = new MeshVertex(new Vector3(-1, -1, -1), Vector3.zero, Color.white); var frontLowerRight = new MeshVertex(new Vector3(1, -1, -1), Vector3.zero, Color.white); // Create the quads meshCreator.AddQuad(frontUpperLeft, frontUpperRight, frontLowerRight, frontLowerLeft); meshCreator.AddQuad(behindUpperRight, behindUpperLeft, behindLowerLeft, behindLowerRight); meshCreator.AddQuad(frontUpperRight, behindUpperRight, behindLowerRight, frontLowerRight); meshCreator.AddQuad(frontUpperLeft, frontLowerLeft, behindLowerLeft, behindUpperLeft); meshCreator.AddQuad(frontUpperLeft, behindUpperLeft, behindUpperRight, frontUpperRight); meshCreator.AddQuad(frontLowerLeft, frontLowerRight, behindLowerRight, behindLowerLeft); // Create a new mesh and set it in the mesh filter meshFilter = GetComponent <MeshFilter>(); meshFilter.sharedMesh = meshCreator.CreateMesh(); meshFilter.sharedMesh.RecalculateNormals(); }
private MeshBase BuildMesh(MeshCreator meshCreator) { var mesh = GetChoosenMesh(meshCreator); Undo.RegisterCreatedObjectUndo(mesh.gameObject, mesh.name); return(mesh); }
/// <summary> /// Render context implementation. /// </summary> /// <param name="graphicsDeviceManager"></param> /// <param name="renderTarget">The render target to use. Set null if it should directly render to backbuffer.</param> /// <param name="content"></param> public RenderTargetBasedRenderContext(GraphicsDeviceManager graphicsDeviceManager, RenderTarget2D renderTarget, ContentManager content) { if (graphicsDeviceManager == null) { throw new ArgumentNullException(nameof(graphicsDeviceManager)); } if (graphicsDeviceManager.GraphicsDevice == null) { throw new ArgumentNullException(nameof(graphicsDeviceManager)); } if (content == null) { throw new ArgumentNullException(nameof(content)); } GraphicsDevice = graphicsDeviceManager.GraphicsDevice; GraphicsDeviceManager = graphicsDeviceManager; RenderTarget = renderTarget; Content = content; _renderContext2D = new SpriteBatchRenderContext2D(this); _renderContext3D = new RenderContext3D(this); MeshCreator = new MeshCreator(GraphicsDevice); }
public void SetMeshVerticesPosition(RectTransform rtParent, bool elevate, float zAxis) { float elvation = elevate ? this.Height : 0; transform.SetParent(rtParent); transform.localPosition = new Vector3(this.Location.x, this.Location.y, zAxis); MeshCreator meshCreator = new MeshCreator(); MeshRenderer meshRenderer = (MeshRenderer)gameObject.AddComponent(typeof(MeshRenderer)); MeshFilter meshFilter = (MeshFilter)gameObject.AddComponent(typeof(MeshFilter)); meshFilter.mesh.Clear(); meshFilter.mesh = meshCreator.CreateMesh2(elvation, this.AgentCoordinate.GetVector2Coordinates(), this.InitialLocation); meshFilter.mesh.name = "CustomMesh"; Material mat = new Material(Shader.Find("Specular")) { color = this.Color.GetRgb() }; meshRenderer.material = mat; //meshCollider.sharedMesh = meshFilter.mesh; transform.localRotation = Quaternion.Euler(0, 0, 180); gameObject.AddComponent <MeshCollider>(); }
private Storyboard CreatetAnimation(GenieEffectType effectType) { double aspect = transitionContrainer.ActualWidth / transitionContrainer.ActualHeight; MeshGeometry3D mesh = MeshCreator.CreateMesh(SidePoints, SidePoints); mesh.Positions = new RectangularMeshFiller().FillMesh(SidePoints, SidePoints, aspect); _slidingScreen.Geometry = mesh; _slidingScreen.Material = new DiffuseMaterial(CreateBrush(contentContrainer)); PerspectiveCamera camera = _viewport.Camera as PerspectiveCamera; double angle = camera.FieldOfView / 2; double cameraZPos = (aspect / 2) / Math.Tan(angle * Math.PI / 180); camera.Position = new Point3D(0, 0, cameraZPos); Storyboard storyboard = (_viewport.Resources["GenieAnim"] as Storyboard).Clone(); GenieAnimation anim = storyboard.Children[0] as GenieAnimation; anim.Duration = new Duration(TimeSpan.FromSeconds(1)); anim.EffectType = effectType; anim.AspectRatio = aspect; animationContainer.Children.Add(_viewport); animationContainer.Visibility = Visibility.Visible; transitionContrainer.Visibility = Visibility.Hidden; return(storyboard); }
public MeshCreator(MeshCreator mesh) { Mesh = mesh.Mesh; Vertices = mesh.Vertices; Uv = mesh.Uv; Triangles = mesh.Triangles; }
public void SpawnTerrainPiece() { GameObject terrainObject; MeshCreator meshCreator; if (meshList.Count == 0) { terrainObject = Instantiate(terrainPiecePrefab, transform.position, Quaternion.identity); meshCreator = terrainObject.GetComponent <MeshCreator>(); } else { xPos += lastMesh.xValue; terrainObject = Instantiate(terrainPiecePrefab, new Vector3(xPos, transform.position.y, transform.position.z), Quaternion.identity); meshCreator = terrainObject.GetComponent <MeshCreator>(); } //Set Mesh Properties meshCreator.vertexCount = meshProperty.vertexCount; meshCreator.bottomPoint = meshProperty.bottomPoint; meshCreator.Xspacing = meshProperty.Xspacing; meshCreator.Yspacing = meshProperty.Yspacing; meshCreator.verticalVertexCount = meshProperty.verticalVertexCount; meshCreator.scale = meshProperty.scale; meshCreator.height = meshProperty.height; meshCreator.xValue = meshProperty.xValue; meshCreator.GetComponent <MeshRenderer>().material = meshProperty.material; meshList.Add(meshCreator); lastMesh = meshCreator; }
public void Mesh_has_correct_size() { var mesh = MeshCreator.CreateXZGrid(10, 10); Assert.AreEqual(11 * 11, mesh.Vertices.Length); Assert.AreEqual(10 * 10 * 2, mesh.Faces.Length); }
void Update() { Vector3[] vertices = new Vector3[latitudeLineCount * longitudeLineCount]; int vtxIndex = 0; for (int j = 0; j < latitudeLineCount; j++) { float lat = 180 * ((float)(j + 1) / latitudeLineCount); for (int i = 0; i < longitudeLineCount; i++) { float lon = 360 * ((float)i / longitudeLineCount); Vector3 cartesian = new Vector3( radius * Mathf.Cos(lat) * Mathf.Cos(lon), radius * Mathf.Cos(lat) * Mathf.Sin(lon), radius * Mathf.Sin(lat) ); vertices[vtxIndex++] = cartesian; } } MeshCreator mc = new MeshCreator(); for (int i = 2; i < vertices.Length; i++) { mc.BuildTriangle(vertices[i - 2], vertices[i - 1], vertices[i]); } meshFilter.mesh = mc.CreateMesh(); }
protected override void OnCreate() { base.OnCreate(); // Default types ComponentType[] componentTypes = new ComponentType[] { typeof(RenderMesh), typeof(LocalToWorld), typeof(Translation), typeof(RenderBounds), typeof(MainColorMaterialProperty), }; // Add additional if (AdditionalArchetypeTypes.Length > 0) { var oldSize = componentTypes.Length; Array.Resize(ref componentTypes, oldSize + AdditionalArchetypeTypes.Length); for (int i = oldSize; i < componentTypes.Length; i++) { componentTypes[i] = AdditionalArchetypeTypes[i - oldSize]; } } // Create archetype _meshArchetype = EntityManager.CreateArchetype(componentTypes); if (CreateDefaultMesh) { _mesh = MeshCreator.Quad(Extends, quaternion.Euler(new float3(math.radians(90), 0, 0))); } }
public void create(SceneData data) { this.data = data; mesh = new MeshCreator(); if (projection == null) { projection = new GameObject(); projection.name = gameObject.name + "_proj"; projectionFilter = (MeshFilter)projection.AddComponent(typeof(MeshFilter)); projection.AddComponent(typeof(MeshRenderer)); projectionFilter.sharedMesh = new Mesh(); projection.transform.position = offset; projection.transform.parent = transform.parent; //projection.hideFlags = HideFlags.NotEditable; } mesh.fill(ref projectionFilter); subdivisions = 2; }
private void FixedUpdate() { timer += Time.deltaTime * timeMod; if (timer > 255) { timer = 0; } MeshFilter meshFilter = this.GetComponent <MeshFilter>(); // one submesh for each face MeshCreator mc = new MeshCreator(); Vector3 cubeSize = size * 0.5f; float noiseValueT0 = Perlin.Noise((pos.x + cubeSize.x) / posMod, (pos.y - cubeSize.z) / posMod, timer); float noiseValueT1 = Perlin.Noise((pos.x - cubeSize.x) / posMod, (pos.y - cubeSize.z) / posMod, timer); float noiseValueT2 = Perlin.Noise((pos.x - cubeSize.x) / posMod, (pos.y + cubeSize.z) / posMod, timer); float noiseValueT3 = Perlin.Noise((pos.x + cubeSize.x) / posMod, (pos.y + cubeSize.z) / posMod, timer); //float noiseValueT0 = Perlin.Noise((pos.x + cubeSize.x) * posMod, (pos.y - cubeSize.z) * posMod, timer); //float noiseValueT1 = Perlin.Noise((pos.x - cubeSize.x) * posMod, (pos.y - cubeSize.z) * posMod, timer); //float noiseValueT2 = Perlin.Noise((pos.x - cubeSize.x) * posMod, (pos.y + cubeSize.z) * posMod, timer); //float noiseValueT3 = Perlin.Noise((pos.x + cubeSize.x) * posMod, (pos.y + cubeSize.z) * posMod, timer); // top of the cube // t0 is top left point Vector3 t0 = new Vector3(cubeSize.x, cubeSize.y + modifier * noiseValueT0, -cubeSize.z); Vector3 t1 = new Vector3(-cubeSize.x, cubeSize.y + modifier * noiseValueT1, -cubeSize.z); Vector3 t2 = new Vector3(-cubeSize.x, cubeSize.y + modifier * noiseValueT2, cubeSize.z); Vector3 t3 = new Vector3(cubeSize.x, cubeSize.y + modifier * noiseValueT3, cubeSize.z); // bottom of the cube Vector3 b0 = new Vector3(cubeSize.x, -cubeSize.y, -cubeSize.z); Vector3 b1 = new Vector3(-cubeSize.x, -cubeSize.y, -cubeSize.z); Vector3 b2 = new Vector3(-cubeSize.x, -cubeSize.y, cubeSize.z); Vector3 b3 = new Vector3(cubeSize.x, -cubeSize.y, cubeSize.z); // Top square mc.BuildTriangle(t0, t1, t2); mc.BuildTriangle(t0, t2, t3); // Bottom square mc.BuildTriangle(b2, b1, b0); mc.BuildTriangle(b3, b2, b0); // Back square mc.BuildTriangle(b0, t1, t0); mc.BuildTriangle(b0, b1, t1); mc.BuildTriangle(b1, t2, t1); mc.BuildTriangle(b1, b2, t2); mc.BuildTriangle(b2, t3, t2); mc.BuildTriangle(b2, b3, t3); mc.BuildTriangle(b3, t0, t3); mc.BuildTriangle(b3, b0, t0); meshFilter.mesh = mc.CreateMesh(); }
void FillTextures(MeshCreator world) { MeshRenderer mr = world.GetComponent <MeshRenderer>(); if (mr != null) { Texture2D tx = (Texture2D)mr.material.mainTexture; if (tx != null) { int width = tx.width; int height = tx.height; for (int x = 0; x < width; x += 64) { for (int y = 0; y < height; y += 64) { var colors = tx.GetPixels(x, y, 64, 64); Texture2D newTexture = new Texture2D(64, 64); newTexture.SetPixels(colors); newTexture.Apply(); // NE PAS OUBLIER SINON IL NE PREND PAS EN COMPTE LES MODIFS m_textures.Add(newTexture); } } } } }
private void DrawSplineInspector(MeshCreator meshCreator, List <Vector2> points, bool isClosed) { meshCreator.splineResolution = EditorGUILayout.Slider("Resolution", meshCreator.splineResolution, CatmullRomSpline.MIN_RESOLUTION, 0.25f); meshCreator.splineSimplification = (SplineSimplification.Type)EditorGUILayout.EnumPopup("Simplify spline", meshCreator.splineSimplification); if (meshCreator.splineSimplification == SplineSimplification.Type.None) { return; } float area = CatmullRomSpline.BoundingBoxArea(points); if (meshCreator.splineSimplification == SplineSimplification.Type.ByRelativeBoundingBoxArea) { meshCreator.minRelativeSplineArea = EditorGUILayout.Slider("Minimal shape area percentage", meshCreator.minRelativeSplineArea, 0, 1, null); meshCreator.minAbsoluteSplineArea = meshCreator.minRelativeSplineArea * area; EditorGUI.BeginDisabledGroup(true); meshCreator.minAbsoluteSplineArea = EditorGUILayout.Slider("Minimal absolute area", meshCreator.minAbsoluteSplineArea, 0, area, null); EditorGUI.EndDisabledGroup(); } else { meshCreator.minAbsoluteSplineArea = EditorGUILayout.Slider("Minimal absolute area", meshCreator.minAbsoluteSplineArea, 0, area, null); meshCreator.minRelativeSplineArea = Mathf.Clamp01(meshCreator.minAbsoluteSplineArea / area); EditorGUI.BeginDisabledGroup(true); meshCreator.minRelativeSplineArea = EditorGUILayout.Slider("Minimal shape area percentage", meshCreator.minRelativeSplineArea, 0, 1, null); EditorGUI.EndDisabledGroup(); } var simplifiedPoints = GetSimplifiedSplinePoints(meshCreator, points, isClosed); if (points.Count != simplifiedPoints.Count) { EditorGUILayout.HelpBox("Point count: " + simplifiedPoints.Count + "/" + points.Count, MessageType.Info); } }
public void create(SceneData data) { this.data = data; mesh = new MeshCreator(); if (projection == null) { projection = new GameObject(); projection.name = gameObject.name + "_proj"; projectionFilter = (MeshFilter)projection.AddComponent(typeof(MeshFilter)); projection.AddComponent(typeof(MeshRenderer)); projectionFilter.sharedMesh = new Mesh(); projection.transform.position = offset; projection.transform.parent = transform.parent; //projection.hideFlags = HideFlags.NotEditable; } mesh.fill(ref projectionFilter); subdivisions = 2; }
public void Init(CharacterAction.Direction myDirection, float length, Vector3 position, float scale) { m_scale = scale; Vector3 positionOffset = Vector3.zero; if (myDirection == CharacterAction.Direction.Down) { transform.eulerAngles = new Vector3(0, 0, 0); positionOffset = Vector3.down * positionOffsetFactor; } else if (myDirection == CharacterAction.Direction.Left) { transform.eulerAngles = new Vector3(0, 0, -90); positionOffset = Vector3.left * positionOffsetFactor; } else if (myDirection == CharacterAction.Direction.Up) { transform.eulerAngles = new Vector3(0, 0, 180); positionOffset = Vector3.up * positionOffsetFactor; } else if (myDirection == CharacterAction.Direction.Right) { transform.eulerAngles = new Vector3(0, 0, 90); positionOffset = Vector3.right * positionOffsetFactor; } transform.position = position + positionOffset; targetScale = (length / GetComponent <SpriteRenderer>().sprite.bounds.size.y) * m_scale; //print(GetComponent<SpriteRenderer>().sprite.bounds.size); transform.localScale = new Vector3(m_scale, 0, m_scale); startTime = Time.fixedTime; m_world = MeshCreator.instance; }
public Mesh3V3N Create(Bounds2D bounds) { var meshDimensions = 128; var implicintHeightMap = new ImplicitChunkHeightMap(bounds, meshDimensions, meshDimensions, new ScaledNoiseGenerator()); return(MeshCreator.CreateFromHeightMap(meshDimensions, meshDimensions, implicintHeightMap)); }
public static Mesh CreateMesh(String key, MeshCreator creator) { Mesh mesh = creator.Create(); SetMesh(key, mesh); return mesh; }
private MeshBase GetChoosenMesh(MeshCreator meshCreator) { switch (meshCreator.meshType) { case MeshCreator.MeshType.Triangle: return(TriangleMesh.AddTriangle(meshCreator.transform.position, meshCreator.triangleVertex1, meshCreator.triangleVertex2, meshCreator.triangleVertex3, Space.World, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Rectangle: return(RectangleMesh.AddRectangle(meshCreator.transform.position, meshCreator.boxSize, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Circle: return(CircleMesh.AddCircle(meshCreator.transform.position, meshCreator.circleRadius, meshCreator.circleSides, meshCreator.circleUseCircleCollider, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Quadrangle: Vector2[] verts = new Vector2[4] { meshCreator.quadrangleVertex1, meshCreator.quadrangleVertex2, meshCreator.quadrangleVertex3, meshCreator.quadrangleVertex4 }; return(QuadrangleMesh.AddQuadrangle(meshCreator.transform.position, verts, Space.World, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Ellipse: return(EllipseMesh.AddEllipse(meshCreator.transform.position, meshCreator.ellipseHorizontalRadius, meshCreator.ellipseVerticalRadius, meshCreator.ellipseSides, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.PointedCircle: return(PointedCircleMesh.AddPointedCircle(meshCreator.transform.position, meshCreator.pointedCircleRadius, meshCreator.pointedCircleSides, meshCreator.pointedCircleShift, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Cake: return(CakeMesh.AddCakeMesh(meshCreator.transform.position, meshCreator.cakeRadius, meshCreator.cakeSides, meshCreator.cakeSidesToFill, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Convex: return(ConvexMesh.AddConvexMesh(meshCreator.transform.position, MeshHelper.ConvertVec2ToVec3(meshCreator.convexPoints), Space.World, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Star: return(StarMesh.AddStar(meshCreator.transform.position, meshCreator.starRadiusA, meshCreator.starRadiusB, meshCreator.starSides, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Gear: return(GearMesh.AddGear(meshCreator.transform.position, meshCreator.gearInnerRadius, meshCreator.gearRootRadius, meshCreator.gearOuterRadius, meshCreator.gearSides, meshCreator.material, meshCreator.attachRigidbody)); case MeshCreator.MeshType.Line: return(LineMesh.AddLine(meshCreator.transform.position, meshCreator.linePoints.ToArray(), meshCreator.lineWidth, meshCreator.lineUseDoubleCollider, Space.World, meshCreator.material, meshCreator.attachRigidbody)); } return(null); }
private Dictionary <IVertexArrayObject, int> PrepareVAOs(IEnumerable <Entity> entities) { Dictionary <IVertexArrayObject, int> simulatorVAOs = new Dictionary <IVertexArrayObject, int>(); Dictionary <Enums.EntityType, IVertexArrayObject> simVAOs = new Dictionary <Enums.EntityType, IVertexArrayObject>(); Dictionary <Enums.EntityType, List <Matrix4x4> > transformations = new Dictionary <Enums.EntityType, List <Matrix4x4> >(); Dictionary <Enums.EntityType, List <Vector4> > colors = new Dictionary <Enums.EntityType, List <Vector4> >(); Dictionary <Enums.EntityType, int> instanceCounts = new Dictionary <Enums.EntityType, int>(); foreach (var entity in entities) { if (!simVAOs.ContainsKey(entity.Type)) { Mesh mesh = null; switch (entity.Type) { case Enums.EntityType.Triangle: mesh = MeshCreator.CreateTriangle(); break; case Enums.EntityType.Tetrahedron: mesh = MeshCreator.CreateteTrahedron(); break; } if (mesh != null) { switch (_wrapper) { case RenderSimulator _: simVAOs.Add(entity.Type, VAOLoader.FromMesh <SimulatorVAO>(mesh, new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), new object[] { _wrapper })); break; case RenderTranslator _: simVAOs.Add(entity.Type, VAOLoader.FromMesh <TranslatorVAO>(mesh, new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), new object[] { _wrapper })); break; } transformations.Add(entity.Type, new List <Matrix4x4>()); colors.Add(entity.Type, new List <Vector4>()); instanceCounts.Add(entity.Type, 0); } } if (transformations.ContainsKey(entity.Type)) { transformations[entity.Type].Add(entity.Transformation); colors[entity.Type].Add(entity.Color); instanceCounts[entity.Type]++; } } foreach (var key in simVAOs.Keys) { simVAOs[key].SetAttribute("InstanceTransformation", new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), transformations[key], true); simVAOs[key].SetAttribute("Color", new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), colors[key], true); simulatorVAOs.Add(simVAOs[key], instanceCounts[key]); } return(simulatorVAOs); }
private void OnSceneGUI() { MeshCreator mc = target as MeshCreator; Vector2 p2 = mc.transform.position; Vector3 p3 = mc.transform.position; DrawHandles(mc, p2, p3); }
public static MeshCreator GetMeshCreator() { if (null == m_MeshCreator) { m_MeshCreator = new MeshCreator(); } return(m_MeshCreator); }
private void LateUpdate() { CheckSurrounding(); var points = FOVUtils.GetPointsFromFOV(visionAngle, visionDistance, resolution, (transform.eulerAngles.z + 90) % 360, transform.position, visionMask); points.Insert(0, (Vector2)transform.position); MeshCreator.GetIrregularArcFromPoints(ref fovMesh, points.ToArray(), transform); }
public void GenerateUnwalkableMesh(Location location, List <ClusterPoint> points) { this.location = location; this.points = points; //StopCoroutine("IGenerateMesh"); MeshCreator mesh = FindObjectOfType <MeshCreator>(); mesh.GenerateMesh(location, points); }
void OnEnable() { myMeshCreator = (MeshCreator)target; myMeshCreator.sortingOrder = myMeshCreator.GetComponent <MeshRenderer>().sortingOrder; if (myMeshCreator.IsLoaded == false) { myMeshCreator.LoadMeshData(); } }
void UpdateChunk() { rendered = true; MeshInfo mesh_info = new MeshInfo(); mesh_info = MeshCreator.CreateMesh(this, mesh_info); RenderMesh(mesh_info); }
public void Vertices_has_correct_positions() { var mesh = MeshCreator.CreateXZGrid(1, 1); Assert.AreEqual(new Vector3(-0.5f, 0, -0.5f), mesh.Vertices[0].Position); Assert.AreEqual(new Vector3(-0.5f, 0, 0.5f), mesh.Vertices[1].Position); Assert.AreEqual(new Vector3(0.5f, 0, -0.5f), mesh.Vertices[2].Position); Assert.AreEqual(new Vector3(0.5f, 0, 0.5f), mesh.Vertices[3].Position); }
void Start() { if (!HighLogic.LoadedSceneIsFlight) { return; } engine = new FSengineWrapper(part); // Create the mesh disc. Particles spawn inside this mesh on the ground washDisc.transform.parent = transform; meshFilter = washDisc.AddComponent <MeshFilter>(); meshFilter.mesh = MeshCreator.createDisc(emissionDiscSize, 100); //KSP 1.8 // fetch the particle texture from KSP's Game Database //particleTexture = GameDatabase.Instance.GetTexture(particleTextureName, false); //if (particleTexture == null) //{ // Debug.Log("FSgroundParticles: particle texture loading error"); // // it should use the default particle in this case, or just some pink crap maybe //} //else //{ // //Setting the values for the particle system. the animator is never doing anything exciting, all particle motion is handled in the late update code // particleFX = new FSparticleFX(washDisc, particleTexture); // // particles change color and alpha over time. // particleFX.AnimatorColor0 = getColorFromV4(particleColor0); // particleFX.AnimatorColor1 = getColorFromV4(particleColor1); // particleFX.AnimatorColor2 = getColorFromV4(particleColor2); // particleFX.AnimatorColor3 = getColorFromV4(particleColor3); // particleFX.AnimatorColor4 = getColorFromV4(particleColor4); // particleFX.EmitterMinSize = particleSize.x; // particleFX.EmitterMaxSize = particleSize.y; // particleFX.EmitterMinEnergy = particleEnergy.x; // particleFX.EmitterMaxEnergy = particleEnergy.y; // particleFX.EmitterMinEmission = 0f; // particleFX.EmitterMaxEmission = 0f; // particleFX.AnimatorSizeGrow = particleSizeGrow; // particleFX.EmitterLocalVelocity = new Vector3(0f, 0f, 0f); // particleFX.EmitterRndVelocity = new Vector3(0f, 0f, 0f); // // creates the emitters etc and assigns the above values // particleFX.setupFXValues(); // //particleFX.pEmitter.rndRotation = true; // // Can't turn on Interpolate Triangles on the emitter, casue it's not exposed to code. REALLY?!? WHY? //} //KSP 1.8 thrustTransform = part.FindModelTransform(thrustTransformName); }
protected override void Start() { base.Start(); Turn(Direction.Right); AIThinkTimeRest = 0; lastPosition = GetNextMoveDirectionGrillPosition(); lifeCount = life; lifeRegTimeCount = lifeRegTime; m_world = MeshCreator.instance; }
private List <Vector2> GetSimplifiedSplinePoints(MeshCreator meshCreator, List <Vector2> points, bool isClosed) { if (meshCreator.splineSimplification == SplineSimplification.Type.None) { return(points); } else { return(SplineSimplification.Simplify(points, meshCreator.minAbsoluteSplineArea, isClosed)); } }