private static void BuildFace(ref Face face, Primitive prim, List<Vertex> vertices, Path path, Profile profile, Primitive.TextureEntryFace teFace, bool isSculpted) { if (teFace != null) face.TextureFace = teFace; else throw new ArgumentException("teFace cannot be null"); face.Vertices.Clear(); if ((face.Mask & FaceMask.Cap) != 0) { if (((face.Mask & FaceMask.Hollow) == 0) && ((face.Mask & FaceMask.Open) == 0) && (prim.PrimData.PathBegin == 0f) && (prim.PrimData.ProfileCurve == ProfileCurve.Square) && (prim.PrimData.PathCurve == PathCurve.Line)) { CreateUnCutCubeCap(ref face, vertices, path, profile); } else { CreateCap(ref face, vertices, path, profile); } } else if ((face.Mask & FaceMask.End) != 0 || (face.Mask & FaceMask.Side) != 0) { CreateSide(ref face, prim, vertices, path, profile, isSculpted); } else { throw new RenderingException("Unknown/uninitialized face type"); } }
/// <summary> /// Compute a FFT (Fast Fourier Transform). /// </summary> /// <param name="real">An array of real values to calculate the FFT from.</param> /// <returns>An array of complex data (real amplitude and imaginary phase) or "FAILED". /// For each complex pair the index is the real part and the value is the imaginary part.</returns> public static Primitive FFTForward(Primitive real) { try { Type PrimitiveType = typeof(Primitive); Dictionary<Primitive, Primitive> dataMap; dataMap = (Dictionary<Primitive, Primitive>)PrimitiveType.GetField("_arrayMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance).GetValue(real); int length = dataMap.Count; Complex[] complex = new Complex[length]; int i = 0; foreach (KeyValuePair<Primitive, Primitive> kvp in dataMap) { double realData = double.Parse(kvp.Value); complex[i++] = new Complex(realData, 0); } Fourier.BluesteinForward(complex, FourierOptions.Default); string result = ""; for (i = 0; i < length; i++) { result += (i + 1).ToString() + "=" + (complex[i].Real.ToString(CultureInfo.InvariantCulture) + "\\=" + complex[i].Imaginary.ToString(CultureInfo.InvariantCulture) + "\\;") + ";"; } return Utilities.CreateArrayMap(result); } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return "FAILED"; } }
public bool Equals(Primitive primitive) { if (this.GetType().Equals(primitive.GetType())) { if (this is Activity) { Activity a = this as Activity; Activity target = primitive as Activity; if (a.PrID == target.PrID) return true; } else if (this is Event) { Event ev = this as Event; Event target = primitive as Event; if (ev.categ.Equals(target.categ)) return true; } else if (this is Flow) { Flow f = this as Flow; Flow target = primitive as Flow; if (f.categ.Equals(target.categ) && f.Condition.Equals(target.Condition) && f.SourceID == target.SourceID && f.TargetID == target.TargetID) return true; } } return false; }
/// <summary> /// Create an array of complex values from arrays of real and imaginary parts. /// </summary> /// <param name="real">An array of real data.</param> /// <param name="imaginary">An array of imaginary data.</param> /// <returns>An array of complex data (real amplitude and imaginary phase), "MISMATCH" or "FAILED". /// For each complex pair the index is the real part and the value is the imaginary part.</returns> public static Primitive FFTComplex(Primitive real, Primitive imaginary) { try { Type PrimitiveType = typeof(Primitive); Dictionary<Primitive, Primitive> dataReal, dataImaginary; dataReal = (Dictionary<Primitive, Primitive>)PrimitiveType.GetField("_arrayMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance).GetValue(real); dataImaginary = (Dictionary<Primitive, Primitive>)PrimitiveType.GetField("_arrayMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance).GetValue(imaginary); int length = dataReal.Count; if (length != dataImaginary.Count) return "MISMATCH"; List<double> realData = new List<double>(); foreach (KeyValuePair<Primitive, Primitive> kvp in dataReal) { realData.Add(kvp.Value); } List<double> imaginaryData = new List<double>(); foreach (KeyValuePair<Primitive, Primitive> kvp in dataImaginary) { imaginaryData.Add(kvp.Value); } string result = ""; for (int i = 0; i < length; i++) { result += (i + 1).ToString() + "=" + (realData[i].ToString(CultureInfo.InvariantCulture) + "\\=" + imaginaryData[i].ToString(CultureInfo.InvariantCulture) + "\\;") + ";"; } return Utilities.CreateArrayMap(result); } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return "FAILED"; } }
/// <summary> /// Remove a file (or directory with all sub files) from an existing zip archive. /// </summary> /// <param name="zipFile">The zip archive to remove a file from.</param> /// <param name="files"> /// An array of files to remove from the zip archive. /// A single file or directory may also be deleted. /// Any directories will be recursively removed from the zip. /// </param> /// <returns>An error message or "".</returns> public static Primitive Remove(Primitive zipFile, Primitive files) { try { using (ZipFile zip = ZipFile.Read(zipFile)) { if (SBArray.IsArray(files)) { Primitive indices = SBArray.GetAllIndices(files); int count = SBArray.GetItemCount(indices); for (int i = 1; i <= count; i++) { RemoveFromArchive(zip, files[indices[i]]); } } else { RemoveFromArchive(zip, files); } zip.Save(); } return ""; } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return Utilities.GetCurrentMethod() + " " + ex.Message; } }
public Container(Stream stream) { UInt16 stringLength = stream.ReadUInt16(); Name = stream.ReadAsciiString(stringLength); ContainerType = stream.ReadUInt8(); Flags = (ContainerFlags)stream.ReadUInt16(); PrimitiveCount = stream.ReadUInt16(); PackfileBaseOffset = stream.ReadUInt32(); CompressionType = stream.ReadUInt8(); stringLength = stream.ReadUInt16(); StubContainerParentName = stream.ReadAsciiString(stringLength); Int32 auxDataSize = stream.ReadInt32(); AuxData = new byte[auxDataSize]; stream.Read(AuxData, 0, auxDataSize); TotalCompressedPackfileReadSize = stream.ReadInt32(); Primitives = new List<Primitive>(); PrimitiveSizes = new List<WriteTimeSizes>(); for (UInt16 i = 0; i < PrimitiveCount; i++) { var sizes = stream.ReadStruct<WriteTimeSizes>(); PrimitiveSizes.Add(sizes); } for (UInt16 i = 0; i < PrimitiveCount; i++) { Primitive primitive = new Primitive(stream); Primitives.Add(primitive); } }
public void TransformTexCoords(List<Vertex> vertices, Vector3 center, Primitive.TextureEntryFace teFace) { float r = teFace.Rotation; float os = teFace.OffsetU; float ot = teFace.OffsetV; float ms = teFace.RepeatU; float mt = teFace.RepeatV; float cosAng = (float)Math.Cos(r); float sinAng = (float)Math.Sin(r); for (int i = 0; i < vertices.Count; i++) { Vertex vertex = vertices[i]; if (teFace.TexMapType == MappingType.Default) { TransformTexCoord(ref vertex.TexCoord, cosAng, sinAng, os, ot, ms, mt); } else if (teFace.TexMapType == MappingType.Planar) { Vector3 vec = vertex.Position; vec.X *= vec.X; vec.Y *= vec.Y; vec.Z *= vec.Z; TransformPlanarTexCoord(ref vertex.TexCoord, vertex, center, vec); } vertices[i] = vertex; } }
/// <summary> /// Create a cursor that can be set using SetUserCursor or SetShapeCursor. /// An ImageList image can be resized with LDImage.Resize. /// </summary> /// <param name="imageName">The file path or ImageList image.</param> /// <param name="xHotSpot">The x pixel to use as the hot spot.</param> /// <param name="yHotSpot">The y pixel to use as the hot spot.</param> /// <returns>A cursor.</returns> public static Primitive CreateCursor(Primitive imageName, Primitive xHotSpot, Primitive yHotSpot) { Type ShapesType = typeof(Shapes); Type ImageListType = typeof(ImageList); Dictionary<string, BitmapSource> _savedImages; BitmapSource img; string cursorName = ""; try { _savedImages = (Dictionary<string, BitmapSource>)ImageListType.GetField("_savedImages", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null); if (!_savedImages.TryGetValue((string)imageName, out img)) { imageName = ImageList.LoadImage(imageName); if (!_savedImages.TryGetValue((string)imageName, out img)) { return cursorName; } } MethodInfo method = ShapesType.GetMethod("GenerateNewName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase); cursorName = method.Invoke(null, new object[] { "Cursor" }).ToString(); Bitmap bmp = FastPixel.GetBitmap(img); Cursor cursor = createCursor(bmp, xHotSpot, yHotSpot); cursors[cursorName] = cursor; } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); } return cursorName; }
/// <summary> /// Initializes a new instance of the StateFactory /// </summary> /// <param name="device"></param> /// <param name="enumType"></param> /// <param name="ubershader"></param> /// <param name="vertexInputElements"></param> /// <param name="blendState"></param> /// <param name="rasterizerState"></param> private StateFactory ( Ubershader ubershader, Type enumType, Primitive primitive, VertexInputElement[] vertexInputElements ) : base(ubershader.GraphicsDevice) { this.ubershader = ubershader; Enumerate( enumType, ubershader, (ps,i) => { ps.VertexInputElements = vertexInputElements; ps.Primitive = primitive; } ); }
/// <summary> /// Do a Bing search for Web images. /// </summary> /// <param name="search">The search text.</param> /// <returns>An array of results, index url and value description.</returns> public static Primitive GetImage(Primitive search) { try { if (bNewAPI) { JsonWeb jsonWeb = cognitive.SearchRequest(search); if (null == jsonWeb.images) return ""; string result = ""; foreach (var site in jsonWeb.images.value) { result += Utilities.ArrayParse(site.contentUrl) + "=" + Utilities.ArrayParse(site.name) + ";"; } return Utilities.CreateArrayMap(result); } else { var query = bing.Image(search, null, cognitive.mkt, null, null, null, null); var sites = query.Execute(); string result = ""; foreach (var site in sites) { result += Utilities.ArrayParse(site.MediaUrl) + "=" + Utilities.ArrayParse(site.Title) + ";"; } return Utilities.CreateArrayMap(result); } } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return ""; } }
public void Render(Primitive primitive, SpriteBatch spriteBatch) { if (this.spriteBatch == null) { this.spriteBatch = new SpriteBatchWrapper(spriteBatch); } Render(primitive); }
private CachePrimitiveWrapper(SerializationInfo info, StreamingContext context) { this.Primitive = new Primitive { Type = (DynamoDBEntryType)info.GetValue("Type", typeof(DynamoDBEntryType)), Value = info.GetValue("Value", typeof(object)) }; }
public override void Initialize(string tableName, Type tableEntityType, Primitive hashKeyValue) { base.Initialize(tableName, tableEntityType, hashKeyValue); if (GetIndexListKeyInCache(_hashKeyValue).Length > MaxKeyLength) { throw new ArgumentException("The hash key value is too long for MemcacheD. Cannot use cache with that value."); } }
public Response startAllAccessTrial(int vismastersID, string acmID) { Hashtable vars = new Hashtable(); vars["action"] = "startAllAccessTrial"; vars["aid"] = vismastersID; vars["acmid"] = acmID; Primitive<string> prim = new Primitive<string>("trial"); return makePost(vars, new ResponseParser.DataParser(prim.fromResponseXml)); }
public override void Render(Primitive primitive) { if (primitive is BorderSprite) { DrawSpriteBorder((BorderSprite)primitive); } else if (primitive is TextureSprite) { DrawBlockSprite((TextureSprite)primitive); } else if (primitive is Sprite) { DrawSprite((Sprite)primitive); } else if (primitive is TextSprite) { DrawTextBlock((TextSprite)primitive); } else if (primitive is Placeholder) { return; } else throw new NotImplementedException("Unknown primitive type: " + primitive.GetType()); }
/// <summary> /// Create an MD5 hash of a file. /// This 32 character hash is for file data integrity checks (e.g. a file contents is unchanged). /// </summary> /// <param name="fileName">The full path to a file to get the hash.</param> /// <returns>The 32 character hex MD5 Hash.</returns> public static Primitive MD5HashFile(Primitive fileName) { if (!System.IO.File.Exists(fileName)) { Utilities.OnFileError(Utilities.GetCurrentMethod(), fileName); return ""; } return StringEncryption.CalculateMD5HashFile(fileName); }
public static void SetWallpaper(String assunto) { SmallBasicApplication.BeginProgram(); SmallBasicProgram.foto = Flickr.GetRandomPicture(assunto); Desktop.SetWallPaper(SmallBasicProgram.foto); GraphicsWindow.ShowMessage("Papel de parede mudado para" + SmallBasicProgram.assunto, "OK"); }
/// <summary> /// Starts the engine, trying to run at the given framerate. /// </summary> /// <param name="fps">The target framerate</param> public static void Start(Primitive fps) { try { SmallTK.GameEngine.Start(fps); } catch (Exception e) { TextWindow.Show(); Console.WriteLine(e); } }
public override void ChangePrimitive(Primitive primitive) { // Load sphere and apply effect to sphere. ResourceContentManager resourceContentManager = new ResourceContentManager(_serviceProvider, Resources.ResourceManager); Model model = resourceContentManager.Load<Model>(primitive.ToString()); foreach (ModelMesh mesh in model.Meshes) foreach (ModelMeshPart meshPart in mesh.MeshParts) meshPart.Effect = _effect; Model = model; }
//static HashSet<OperatorAction> alls_ = new HashSet<OperatorAction>(); //public OperatorAction (Operator op, Primitive left, Primitive right) //{ // if (this.Operator < Operator.__Binary) // this.Left = Primitive.Undefined; // this.Operator = op; // this.Left = left; // this.Right = right; // alls_.Add(this); //} //public static OperatorAction GetAction (Operator op, Primitive left, Primitive right) //{ // if (op < Operator.__Binary) // left = Primitive.Undefined; // foreach (OperatorAction action in alls_) { // if (op == action.Operator && left == action.Left && right == action.Right) // return action; // } // return null; //} //public Operator Operator { get; private set; } //public Primitive Left { get; private set; } //public Primitive Right { get; private set; } //public OperatorImplem Action { get; set; } //public override bool Equals (object obj) //{ // OperatorAction action = obj as OperatorAction; // if (action == null) // return false; // return this.Operator == action.Operator && this.Left == action.Left && this.Right == action.Right; //} //public override int GetHashCode () //{ // return (int)this.Operator ^ (int)this.Left ^ (int)this.Right; //} //public override string ToString () //{ // if (this.Operator < Operator.__Binary) // return this.Operator + " " + this.Right; // return this.Left + " " + this.Operator + " " + this.Right; //} public static OperatorImplem Get(Operator op, Primitive left, Primitive right) { if (op < Operator.__Binary) left = Primitive.Undefined; if (op == Operator.And) return OperatorAction.andLogic; if (op == Operator.Or) return OperatorAction.orLogic; if (left == Primitive.Error || right == Primitive.Error) return OperatorAction.isError; IOperations ops; if (Operand.TypeIsSigned(left) && Operand.TypeIsSigned(right)) ops = OperationsSigned.I; else if (Operand.TypeIsUnsigned(left) && Operand.TypeIsUnsigned(right)) ops = OperationsUnsigned.I; else if (Operand.TypeIsNumber(left) || Operand.TypeIsNumber(right)) ops = OperationsDecimal.I; else if (left == Primitive.Boolean || right == Primitive.Boolean) ops = OperationsBoolean.I; else throw new Exception("Undef operator"); switch (op) { case Operator.Add: return ops.Add; case Operator.Sub: return ops.Sub; case Operator.Mul: return ops.Mul; case Operator.Div: return ops.Div; case Operator.Equals: return ops.Equals; case Operator.NotEquals: return ops.NotEquals; case Operator.Less: return ops.Less; case Operator.LessEq: return ops.LessEq; case Operator.More: return ops.More; case Operator.MoreEq: return ops.MoreEq; case Operator.Not: return ops.Not; default: throw new Exception("Undef operator"); } throw new Exception("Undef operator"); }
/// <summary> /// Play DX7. /// </summary> /// <param name="channels">An array of values for each channel (values between 0 and 1, usually 8 channels).</param> public static void PlayDX7(Primitive channels) { Initialise(); try { int i, iServo; double duration = 0.0225; int sampleCount = (int)(duration * waveFormat.SamplesPerSecond); // buffer description SoundBufferDescription soundBufferDescription = new SoundBufferDescription(); soundBufferDescription.Format = waveFormat; soundBufferDescription.Flags = BufferFlags.Defer; soundBufferDescription.SizeInBytes = sampleCount * waveFormat.BlockAlignment; SecondarySoundBuffer secondarySoundBuffer = new SecondarySoundBuffer(directSound, soundBufferDescription); short[] rawsamples = new short[sampleCount]; int stopSamples = (int)(0.0004 * waveFormat.SamplesPerSecond); List<int> servoSamples = new List<int>(); Primitive indices = SBArray.GetAllIndices(channels); int servoCount = SBArray.GetItemCount(indices); for (iServo = 1; iServo <= servoCount; iServo++) { servoSamples.Add((int)((0.0007 + 0.0008 * channels[indices[iServo]]) * waveFormat.SamplesPerSecond)); } //Lead-in int leading = sampleCount - (servoCount + 1) * stopSamples - servoSamples.Sum(); int sample = 0; for (i = 0; i < leading; i++) rawsamples[sample++] = 0; //Servos for (i = 0; i < stopSamples; i++) rawsamples[sample++] = (short)(-amplitude); for (iServo = 0; iServo < servoCount; iServo++) { for (i = 0; i < servoSamples[iServo]; i++) rawsamples[sample++] = amplitude; for (i = 0; i < stopSamples; i++) rawsamples[sample++] = (short)(-amplitude); } //load audio samples to secondary buffer secondarySoundBuffer.Write(rawsamples, 0, LockFlags.EntireBuffer); //play audio buffer secondarySoundBuffer.Play(0, PlayFlags.None); //wait to complete before returning while ((secondarySoundBuffer.Status & BufferStatus.Playing) != 0); secondarySoundBuffer.Dispose(); } catch (Exception ex) { TextWindow.WriteLine(ex.Message); } }
/// <summary> /// Delay up to a maximum interval since the last time this is called. /// Useful in a game loop to maintain an even play speed. /// </summary> /// <param name="delay">The maximum delay in ms.</param> public static void DelayUpTo(Primitive delay) { if (null == delayWatch) { delayWatch = new Stopwatch(); delayWatch.Start(); } TimeSpan interval = TimeSpan.FromMilliseconds(delay) - delayWatch.Elapsed; if (interval > TimeSpan.Zero) Thread.Sleep(interval); delayWatch.Restart(); }
/// <summary> /// Perform a regex find and replace. /// </summary> /// <param name="input">The input string to perform the replacement on (unaltered).</param> /// <param name="pattern">The regex pattern string.</param> /// <param name="replacement">The regex replacement string.</param> /// <param name="caseSensitive">If the regex replace is case sensitive ("True" or "False").</param> /// <returns>A modified version of the input string after the regex replace.</returns> public static Primitive Replace(Primitive input, Primitive pattern, Primitive replacement, Primitive caseSensitive) { if (caseSensitive) { return Regex.Replace((string)input, (string)pattern, (string)replacement); } else { return Regex.Replace((string)input, (string)pattern, (string)replacement, RegexOptions.IgnoreCase); } }
/// <summary> /// Get the bit value in a number. /// </summary> /// <param name="var">The number to test.</param> /// <param name="bit">A bit to test (1 to 32).</param> /// <returns>0 (unset) or 1 (set).</returns> public static Primitive GetBit(Primitive var, Primitive bit) { try { return ((varType)var & (one << bit - 1)) == 0 ? 0 : 1; } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return ""; } }
/// <summary> /// Remove (and get) the value from the front of the specified queue. /// </summary> /// <param name="queueName"> /// The name of the queue. /// </param> /// <returns> /// The value from the queue. /// </returns> public static Primitive Dequeue(Primitive queueName) { lock (lockQ) { Queue<Primitive> queue; if (_queueMap.TryGetValue(queueName, out queue)) { return queue.Dequeue(); } return ""; } }
/// <summary> /// Gets the left co-ordinate of the specified shape. /// </summary> /// <param name="index"> /// The index (returned by ShapeIndex) of the shape. /// </param> /// <returns> /// The left co-ordinate of the shape. /// </returns> public static Primitive GetLeft(Primitive index) { try { return shapeProperties[index - 1].point.X; } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); } return 0; }
/// <summary> /// Initializes a new instance of the StateFactory /// </summary> /// <param name="device"></param> /// <param name="ubershader"></param> private StateFactory ( Ubershader ubershader, Type enumType, Primitive primitive, VertexInputElement[] vertexInputElements, BlendState blendState, RasterizerState rasterizerState ) : base(ubershader.GraphicsDevice) { this.ubershader = ubershader; Enumerate( enumType, ubershader, (ps,i) => { ps.Primitive = primitive; ps.VertexInputElements = vertexInputElements; ps.BlendState = blendState; ps.RasterizerState = rasterizerState; } ); }
/// <summary> /// The equality operator. /// Checks if value1 is equal to value2. /// It also works for strings, where a lexical comparison is made. /// </summary> /// <param name="value1">The first value.</param> /// <param name="value2">The second value.</param> /// <returns>"True" or "False".</returns> public static Primitive EQ(Primitive value1, Primitive value2) { decimal num1, num2; if (decimal.TryParse((string)value1, NumberStyles.Float, CultureInfo.InvariantCulture, out num1) && decimal.TryParse((string)value2, NumberStyles.Float, CultureInfo.InvariantCulture, out num2)) { return value1 == value2; } else { return string.Compare(value1, value2, stringComparison) == 0; } }
/// <summary> /// Lexically compare 2 text strings, the comparison is case insensitive and culture invariant. /// </summary> /// <param name="text1">The first string to compare.</param> /// <param name="text2">The second string to compare.</param> /// <returns>An integer: /// less than zero (text1 is less than text2) /// zero (strings are equal) /// greater than zero (text1 is greater than text2)</returns> public static Primitive Compare(Primitive text1, Primitive text2) { try { return string.Compare(text1, text2, true, CultureInfo.InvariantCulture); } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return 0; } }
/// <summary> /// Logically And 2 numbers. /// </summary> /// <param name="var1">The first number.</param> /// <param name="var2">The second number.</param> /// <returns>The And number (where both input bits are set).</returns> public static Primitive AndBits(Primitive var1, Primitive var2) { try { return (varType)var1 & (varType)var2; } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return ""; } }
/// <summary> /// Handle sound attached to an object /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Sound_AttachedSound(object sender, AttachedSoundEventArgs e) { // This event tells us the Object ID, but not the Prim info directly. // So we look it up in our internal Object memory. Simulator sim = e.Simulator; Primitive p = sim.ObjectsPrimitives.Find(p2 => p2.ID == e.ObjectID); if (p == null) { return; } // Only one attached sound per prim, so we kill any previous BufferSound.Kill(p.ID); // If this is stop sound, we're done since we've already killed sound for this object if ((e.Flags & SoundFlags.Stop) == SoundFlags.Stop) { return; } // We seem to get a lot of these zero sounds. if (e.SoundID == UUID.Zero) { return; } // If this is a child prim, its position is relative to the root. Vector3 fullPosition = p.Position; while (p != null && p.ParentID != 0) { Avatar av; if (sim.ObjectsAvatars.TryGetValue(p.ParentID, out av)) { p = av; fullPosition += p.Position; } else { if (sim.ObjectsPrimitives.TryGetValue(p.ParentID, out p)) { fullPosition += p.Position; } } } // Didn't find root prim if (p == null) { return; } new BufferSound( e.ObjectID, e.SoundID, (e.Flags & SoundFlags.Loop) == SoundFlags.Loop, true, fullPosition, e.Gain * ObjectVolume); }
public void AddPrimitive(Primitive primitive, MaterialProperties materialProperties) { this.collision.AddPrimitive(primitive, materialProperties); }
public EqualityRoutine(int size, Primitive primitive) : base(size) { _primitive = primitive; }
public static GameObject CreateUnique(Primitive type, string name = "", HideFlags hideFlags = HideFlags.HideAndDontSave, string shaderName = "Diffuse") { return(CreateUnique(name, @"Debug/" + type.ToString() + "Renderer", hideFlags, shaderName)); }
private PrimDisplayData ExtractPrimMesh(SceneObjectPart part, GroupLoader.LoaderParams parms, HashSet <UUID> fullPermTextures) { Primitive prim = part.Shape.ToOmvPrimitive(part.OffsetPosition, part.RotationOffset); //always generate at scale 1.0 and export the true scale for each part prim.Scale = new Vector3(1, 1, 1); FacetedMesh mesh; try { if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero) { if (prim.Sculpt.Type != SculptType.Mesh) { // Regular sculptie Image img = null; if (!LoadTexture(prim.Sculpt.SculptTexture, ref img, true)) { return(null); } mesh = _renderer.GenerateFacetedSculptMesh(prim, (Bitmap)img, DetailLevel.Highest); img.Dispose(); } else { // Mesh var meshAsset = _stratus.RequestAssetSync(prim.Sculpt.SculptTexture); if (!FacetedMesh.TryDecodeFromAsset(prim, new OpenMetaverse.Assets.AssetMesh(prim.Sculpt.SculptTexture, meshAsset.Data), DetailLevel.Highest, out mesh)) { return(null); } } } else { mesh = _renderer.GenerateFacetedMesh(prim, DetailLevel.Highest); } } catch { return(null); } // Create a FaceData struct for each face that stores the 3D data // in a OpenGL friendly format for (int j = 0; j < mesh.Faces.Count; j++) { Face face = mesh.Faces[j]; PrimFace.FaceData data = new PrimFace.FaceData(); // Vertices for this face data.Vertices = new float[face.Vertices.Count * 3]; data.Normals = new float[face.Vertices.Count * 3]; for (int k = 0; k < face.Vertices.Count; k++) { data.Vertices[k * 3 + 0] = face.Vertices[k].Position.X; data.Vertices[k * 3 + 1] = face.Vertices[k].Position.Y; data.Vertices[k * 3 + 2] = face.Vertices[k].Position.Z; data.Normals[k * 3 + 0] = face.Vertices[k].Normal.X; data.Normals[k * 3 + 1] = face.Vertices[k].Normal.Y; data.Normals[k * 3 + 2] = face.Vertices[k].Normal.Z; } // Indices for this face data.Indices = face.Indices.ToArray(); // Texture transform for this face Primitive.TextureEntryFace teFace = prim.Textures.GetFace((uint)j); //not sure where this bug is coming from, but in order for sculpt textures //to line up, we need to flip V here if (prim.Sculpt != null && prim.Sculpt.Type != SculptType.None && prim.Sculpt.Type != SculptType.Mesh) { teFace.RepeatV *= -1.0f; } _renderer.TransformTexCoords(face.Vertices, face.Center, teFace, prim.Scale); // Texcoords for this face data.TexCoords = new float[face.Vertices.Count * 2]; for (int k = 0; k < face.Vertices.Count; k++) { data.TexCoords[k * 2 + 0] = face.Vertices[k].TexCoord.X; data.TexCoords[k * 2 + 1] = face.Vertices[k].TexCoord.Y; } if (((parms.Checks & LoaderChecks.TexturesMustBeFullPerm) != 0)) { if (teFace.TextureID != UUID.Zero && !fullPermTextures.Contains(teFace.TextureID)) { teFace.TextureID = UUID.Zero; } } //store the actual texture data.TextureInfo = new PrimFace.TextureInfo { TextureID = teFace.TextureID }; // Set the UserData for this face to our FaceData struct face.UserData = data; mesh.Faces[j] = face; } var pos = part.IsRootPart() ? part.RawGroupPosition : part.OffsetPosition; return(new PrimDisplayData { Mesh = mesh, IsRootPrim = part.IsRootPart(), OffsetPosition = pos, OffsetRotation = part.RotationOffset, Scale = part.Scale, ShapeHash = _objectHasher.GetMeshShapeHash(part.Shape, DetailLevel.Highest), MaterialHash = _objectHasher.GetMeshMaterialHash(mesh, prim), LinkNum = part.LinkNum }); }
/// <summary> /// Set motors power to ports BC, then start motors. /// </summary> /// <param name="power">Speed value from -100 (full reverse) to 100 (full forward)</param> public static void StartPower(Primitive power) { }
public void SetPathRange(Vector3 pathRange) { _pathBegin = Primitive.PackBeginCut(pathRange.X); _pathEnd = Primitive.PackEndCut(pathRange.Y); }
public void SetPathRange(float begin, float end) { _pathBegin = Primitive.PackBeginCut(begin); _pathEnd = Primitive.PackEndCut(end); }
/// <summary>Modifies properties of an existing lnk/url shortcut link, like target path, arguments etc. (* for Urls) (IWshRuntimeLibrary).</summary> /// <param name="shortcut">The full path of an existing lnk/url shortcut link file.</param> /// <param name="target">* The full path of the target file/-folder resp. URL address.</param> /// <param name="args">Startparameter when launching the shortcut or "" (for url).</param> /// <param name="folder">The full path of the start folder or "" (for url).</param> /// <param name="desc">* Comment or description for the shortcut or "".</param> /// <param name="icon">* The full path (resp. path,Idx) of the icon for the shortcut link or "". 'Idx' is Index of the icon in in the file (default: 0, for .ico).</param> /// <param name="hotkey">* keys combination to launch the shortcut link (default: 0).</param> /// <param name="style">* Window style when launching the shortcut (default: 1 normal, 3 max, 7 min).</param> /// <returns>The full file path of the modified shortcut on success, else "FAILED".</returns> public static Primitive ShellLinkSet(Primitive shortcut, Primitive target, Primitive args, Primitive folder, Primitive desc, Primitive icon, Primitive hotkey, Primitive style) // wie LinkSetProperty, mit IWshRuntimeLibrary { string scPath = Environment.ExpandEnvironmentVariables(shortcut); if (!System.IO.File.Exists(scPath)) { return("FAILED"); } try { WshShell Shell = new WshShell(); IWshShortcut link = (IWshShortcut)Shell.CreateShortcut(scPath); if (!String.IsNullOrEmpty(target)) { link.TargetPath = target; } if (!String.IsNullOrEmpty(args)) { link.Arguments = args; } if (!String.IsNullOrEmpty(folder)) { link.WorkingDirectory = folder; } if (!String.IsNullOrEmpty(desc)) { link.Description = desc; } if (!String.IsNullOrEmpty(icon)) { link.IconLocation = icon; } if (!String.IsNullOrEmpty(hotkey)) { link.Hotkey = hotkey; } if (!String.IsNullOrEmpty(style)) { link.WindowStyle = style; } link.Save(); return(link.FullName); } catch { return("FAILED"); } }
private void LoadPrimPackage(string filename) { string tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName()); try { // Create a temporary directory Directory.CreateDirectory(tempPath); FastZip fastzip = new FastZip(); fastzip.ExtractZip(filename, tempPath, String.Empty); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } // Check for the prims.xml file string primsFile = System.IO.Path.Combine(tempPath, "prims.xml"); if (!File.Exists(primsFile)) { MessageBox.Show("prims.xml not found in the archive"); return; } OSD osd = null; try { osd = OSDParser.DeserializeLLSDXml(File.ReadAllText(primsFile)); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (osd != null && osd.Type == OSDType.Map) { List <Primitive> primList = Helpers.OSDToPrimList(osd); Prims = new List <FacetedMesh>(primList.Count); for (int i = 0; i < primList.Count; i++) { Primitive prim = primList[i]; FacetedMesh mesh = null; if (prim.Sculpt.SculptTexture != UUID.Zero) { Image sculptTexture = null; if (LoadTexture(tempPath, prim.Sculpt.SculptTexture, ref sculptTexture)) { mesh = Render.Plugin.GenerateFacetedSculptMesh(prim, (Bitmap)sculptTexture, DetailLevel.Highest); } } else { mesh = Render.Plugin.GenerateFacetedMesh(prim, DetailLevel.Highest); } if (mesh != null) { LoadMesh(mesh, tempPath); } } // Setup the dropdown list of prims PopulatePrimCombobox(); glControl.Invalidate(); } else { MessageBox.Show("Failed to load LLSD formatted primitive data from " + filename); } Directory.Delete(tempPath); }
public void SetProfileRange(Vector3 profileRange) { _profileBegin = Primitive.PackBeginCut(profileRange.X); _profileEnd = Primitive.PackEndCut(profileRange.Y); }
void Objects_OnNewPrim(object sender, PrimEventArgs e) { Primitive prim = e.Prim; if ((prim.Flags & PrimFlags.CreateSelected) == 0) { return; // We received an update for an object we didn't create } switch (state) { case ImporterState.RezzingParent: rootLocalID = prim.LocalID; goto case ImporterState.RezzingChildren; case ImporterState.RezzingChildren: if (!primsCreated.Contains(prim)) { // Need to set the textures first, and we have the old UUID's, which will work fine // for anyone who has the cached UUID for the texture in question. // TODO: Is there a way to set all of this at once, and update more ObjectProperties stuff? Client.Objects.SetPosition(e.Simulator, prim.LocalID, currentPosition); if (TextureUse == TextureSet.NewUUID) { if (Textures[currentPrim.Textures.DefaultTexture.TextureID] == UUID.Zero) { currentPrim.Textures.DefaultTexture.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; } else { currentPrim.Textures.DefaultTexture.TextureID = Textures[currentPrim.Textures.DefaultTexture.TextureID]; } for (int j = 0; j < currentPrim.Textures.FaceTextures.Length; j++) { if (currentPrim.Textures.FaceTextures[j] != null && currentPrim.Textures.FaceTextures[j].TextureID != Primitive.TextureEntry.WHITE_TEXTURE) { if (Textures[currentPrim.Textures.FaceTextures[j].TextureID] == UUID.Zero) { currentPrim.Textures.FaceTextures[j] = null; } else { currentPrim.Textures.FaceTextures[j].TextureID = Textures[currentPrim.Textures.FaceTextures[j].TextureID]; } } } } else if (TextureUse == TextureSet.WhiteUUID || TextureUse == TextureSet.SculptUUID) { currentPrim.Textures.DefaultTexture.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; for (int j = 0; j < currentPrim.Textures.FaceTextures.Length; j++) { currentPrim.Textures.FaceTextures[j] = null; } } Client.Objects.SetTextures(e.Simulator, prim.LocalID, currentPrim.Textures); if (currentPrim.Light != null && currentPrim.Light.Intensity > 0) { Client.Objects.SetLight(e.Simulator, prim.LocalID, currentPrim.Light); } if (currentPrim.Flexible != null) { Client.Objects.SetFlexible(e.Simulator, prim.LocalID, currentPrim.Flexible); } if (currentPrim.Sculpt != null && currentPrim.Sculpt.SculptTexture != UUID.Zero) { if (TextureUse == TextureSet.NewUUID || TextureUse == TextureSet.SculptUUID) { if (Textures[currentPrim.Sculpt.SculptTexture] == UUID.Zero) { currentPrim.Sculpt.SculptTexture = Primitive.TextureEntry.WHITE_TEXTURE; } else { currentPrim.Sculpt.SculptTexture = Textures[currentPrim.Sculpt.SculptTexture]; } } else if (TextureUse == TextureSet.WhiteUUID) { currentPrim.Sculpt.SculptTexture = Primitive.TextureEntry.WHITE_TEXTURE; } Client.Objects.SetSculpt(e.Simulator, prim.LocalID, currentPrim.Sculpt); } if (currentPrim.Properties != null && !String.IsNullOrEmpty(currentPrim.Properties.Name)) { Client.Objects.SetName(e.Simulator, prim.LocalID, currentPrim.Properties.Name); } if (currentPrim.Properties != null && !String.IsNullOrEmpty(currentPrim.Properties.Description)) { Client.Objects.SetDescription(e.Simulator, prim.LocalID, currentPrim.Properties.Description); } primsCreated.Add(prim); primDone.Set(); } break; case ImporterState.Linking: lock (linkQueue) { int indx = linkQueue.IndexOf(prim.LocalID); if (indx != -1) { linkQueue.RemoveAt(indx); if (linkQueue.Count == 0) { primDone.Set(); } } } break; } }
public void ImportFromFile(string filename) { ImportDirectory = Path.GetDirectoryName(filename); string xml; List <Primitive> prims; xml = File.ReadAllText(filename); prims = Helpers.OSDToPrimList(OSDParser.DeserializeLLSDXml(xml)); Dictionary <uint, Linkset> linksets = new Dictionary <uint, Linkset>(); for (int i = 0; i < prims.Count; i++) { Primitive prim = prims[i]; if (prim.ParentID == 0) { if (linksets.ContainsKey(prim.LocalID)) { linksets[prim.LocalID].RootPrim = prim; } else { linksets[prim.LocalID] = new Linkset(prim); } } else { if (!linksets.ContainsKey(prim.ParentID)) { linksets[prim.ParentID] = new Linkset(); } linksets[prim.ParentID].Children.Add(prim); } } primsCreated = new List <Primitive>(); foreach (Linkset linkset in linksets.Values) { if (linkset.RootPrim.LocalID != 0) { state = ImporterState.RezzingParent; currentPrim = linkset.RootPrim; linkset.RootPrim.Position = RezAt; currentPosition = RezAt; // Rez the root prim with no rotation Quaternion rootRotation = linkset.RootPrim.Rotation; linkset.RootPrim.Rotation = Quaternion.Identity; Client.Objects.AddPrim(Client.Network.CurrentSim, linkset.RootPrim.PrimData, UUID.Zero, linkset.RootPrim.Position, linkset.RootPrim.Scale, linkset.RootPrim.Rotation); if (!primDone.WaitOne(10000, false)) { throw new Exception("Rez failed, timed out while creating the root prim."); } Client.Objects.SetPosition(Client.Network.CurrentSim, primsCreated[primsCreated.Count - 1].LocalID, linkset.RootPrim.Position); state = ImporterState.RezzingChildren; // Rez the child prims foreach (Primitive prim in linkset.Children) { currentPrim = prim; currentPosition = prim.Position + linkset.RootPrim.Position; Client.Objects.AddPrim(Client.Network.CurrentSim, prim.PrimData, UUID.Zero, currentPosition, prim.Scale, prim.Rotation); if (!primDone.WaitOne(10000, false)) { throw new Exception("Rez failed, timed out while creating child prim."); } Client.Objects.SetPosition(Client.Network.CurrentSim, primsCreated[primsCreated.Count - 1].LocalID, currentPosition); } // Create a list of the local IDs of the newly created prims List <uint> primIDs = new List <uint>(primsCreated.Count); primIDs.Add(rootLocalID); // Root prim is first in list. if (linkset.Children.Count != 0) { // Add the rest of the prims to the list of local IDs) foreach (Primitive prim in primsCreated) { if (prim.LocalID != rootLocalID) { primIDs.Add(prim.LocalID); } } linkQueue = new List <uint>(primIDs.Count); linkQueue.AddRange(primIDs); // Link and set the permissions + rotation state = ImporterState.Linking; Client.Objects.LinkPrims(Client.Network.CurrentSim, linkQueue); if (primDone.WaitOne(1000 * linkset.Children.Count, false)) { Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation); } else { LogMessage("Warning: Failed to link {0} prims", linkQueue.Count); } } else { Client.Objects.SetRotation(Client.Network.CurrentSim, rootLocalID, rootRotation); } // Set permissions on newly created prims Client.Objects.SetPermissions(Client.Network.CurrentSim, primIDs, PermissionWho.Everyone | PermissionWho.Group | PermissionWho.NextOwner, PermissionMask.All, true); state = ImporterState.Idle; } else { LogMessage("WARNING: Skipping a linkset with a missing root prim"); } // Reset everything for the next linkset primsCreated.Clear(); } }
/// <summary> /// Set motors speed to ports BC, then start motors. /// </summary> /// <param name="speed">Speed value from -100 (full reverse) to 100 (full forward)</param> public static void StartSpeed(Primitive speed) { }
/// <summary>Modifies properties of an existing lnk/url shortcut link, like target path, arguments etc. (* for Urls).</summary> /// <param name="shortcut">The full path of an existing lnk/url shortcut link file.</param> /// <param name="target">* The full path of the target file/-folder resp. URL address.</param> /// <param name="args">Startparameter when launching the shortcut or "" (for url).</param> /// <param name="folder">The full path of the start folder or "" (for url).</param> /// <param name="desc">* Comment or description for the shortcut or "".</param> /// <param name="icoPath">* Full path of the icon file for the shortcut or "".</param> /// <param name="icoIdx">* Index of the icon in the icon file (default: 0, for .ico).</param> /// <param name="hotkey">* keys combination to launch the shortcut link (default: 0).</param> /// <param name="style">* Window style when launching the shortcut (default: 1 normal, 3 max, 7 min).</param> /// <returns>The full file path of the modified shortcut on success, else "FAILED".</returns> public static Primitive LinkSetProperty(Primitive shortcut, Primitive target, Primitive args, Primitive folder, Primitive desc, Primitive icoPath, Primitive icoIdx, Primitive hotkey, Primitive style) { string scPath = Environment.ExpandEnvironmentVariables(shortcut); if (!System.IO.File.Exists(scPath)) { return("FAILED"); } else { string scDir = Path.GetDirectoryName(scPath); string scFNameExt = Path.GetFileName(scPath); Shell32.Folder fold = GetShell32NameSpace(scDir); Shell32.FolderItem foldItem = fold.ParseName(scFNameExt); try { Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)foldItem.GetLink; link.Path = target; link.Arguments = args; link.WorkingDirectory = folder; link.Description = desc; link.Hotkey = hotkey; link.ShowCommand = style; link.SetIconLocation(icoPath, icoIdx); link.Save(scPath); return(scPath); } catch { return("FAILED"); } } }
public Linkset(Primitive rootPrim) { RootPrim = rootPrim; }
private PrimMesher.PrimMesh GeneratePrimMesh(Primitive prim, DetailLevel lod, bool viewerMode) { OMV.Primitive.ConstructionData primData = prim.PrimData; int sides = 4; int hollowsides = 4; float profileBegin = primData.ProfileBegin; float profileEnd = primData.ProfileEnd; bool isSphere = false; if ((OMV.ProfileCurve)(primData.profileCurve & 0x07) == OMV.ProfileCurve.Circle) { switch (lod) { case OMVR.DetailLevel.Low: sides = 6; break; case OMVR.DetailLevel.Medium: sides = 12; break; default: sides = 24; break; } } else if ((OMV.ProfileCurve)(primData.profileCurve & 0x07) == OMV.ProfileCurve.EqualTriangle) { sides = 3; } else if ((OMV.ProfileCurve)(primData.profileCurve & 0x07) == OMV.ProfileCurve.HalfCircle) { // half circle, prim is a sphere isSphere = true; switch (lod) { case OMVR.DetailLevel.Low: sides = 6; break; case OMVR.DetailLevel.Medium: sides = 12; break; default: sides = 24; break; } profileBegin = 0.5f * profileBegin + 0.5f; profileEnd = 0.5f * profileEnd + 0.5f; } if ((OMV.HoleType)primData.ProfileHole == OMV.HoleType.Same) { hollowsides = sides; } else if ((OMV.HoleType)primData.ProfileHole == OMV.HoleType.Circle) { switch (lod) { case OMVR.DetailLevel.Low: hollowsides = 6; break; case OMVR.DetailLevel.Medium: hollowsides = 12; break; default: hollowsides = 24; break; } } else if ((OMV.HoleType)primData.ProfileHole == OMV.HoleType.Triangle) { hollowsides = 3; } PrimMesher.PrimMesh newPrim = new PrimMesher.PrimMesh(sides, profileBegin, profileEnd, (float)primData.ProfileHollow, hollowsides); newPrim.viewerMode = viewerMode; newPrim.sphereMode = isSphere; newPrim.holeSizeX = primData.PathScaleX; newPrim.holeSizeY = primData.PathScaleY; newPrim.pathCutBegin = primData.PathBegin; newPrim.pathCutEnd = primData.PathEnd; newPrim.topShearX = primData.PathShearX; newPrim.topShearY = primData.PathShearY; newPrim.radius = primData.PathRadiusOffset; newPrim.revolutions = primData.PathRevolutions; newPrim.skew = primData.PathSkew; switch (lod) { case OMVR.DetailLevel.Low: newPrim.stepsPerRevolution = 6; break; case OMVR.DetailLevel.Medium: newPrim.stepsPerRevolution = 12; break; default: newPrim.stepsPerRevolution = 24; break; } if ((primData.PathCurve == OMV.PathCurve.Line) || (primData.PathCurve == OMV.PathCurve.Flexible)) { newPrim.taperX = 1.0f - primData.PathScaleX; newPrim.taperY = 1.0f - primData.PathScaleY; newPrim.twistBegin = (int)(180 * primData.PathTwistBegin); newPrim.twistEnd = (int)(180 * primData.PathTwist); newPrim.ExtrudeLinear(); } else { newPrim.taperX = primData.PathTaperX; newPrim.taperY = primData.PathTaperY; newPrim.twistBegin = (int)(360 * primData.PathTwistBegin); newPrim.twistEnd = (int)(360 * primData.PathTwist); newPrim.ExtrudeCircular(); } return(newPrim); }
private void glControl_Paint(object sender, PaintEventArgs e) { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); // Setup wireframe or solid fill drawing mode if (Wireframe) { Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE); } else { Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_FILL); } Vector3 center = Vector3.Zero; Glu.gluLookAt( center.X, (double)scrollZoom.Value * 0.1d + center.Y, center.Z, center.X, center.Y, center.Z, 0d, 0d, 1d); // Push the world matrix Gl.glPushMatrix(); Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY); Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY); // World rotations Gl.glRotatef((float)scrollRoll.Value, 1f, 0f, 0f); Gl.glRotatef((float)scrollPitch.Value, 0f, 1f, 0f); Gl.glRotatef((float)scrollYaw.Value, 0f, 0f, 1f); if (Prims != null) { for (int i = 0; i < Prims.Count; i++) { Primitive prim = Prims[i].Prim; if (i == cboPrim.SelectedIndex) { Gl.glColor3f(1f, 0f, 0f); } else { Gl.glColor3f(1f, 1f, 1f); } // Individual prim matrix Gl.glPushMatrix(); // The root prim position is sim-relative, while child prim positions are // parent-relative. We want to apply parent-relative translations but not // sim-relative ones if (Prims[i].Prim.ParentID != 0) { // Apply prim translation and rotation Gl.glMultMatrixf(Math3D.CreateTranslationMatrix(prim.Position)); Gl.glMultMatrixf(Math3D.CreateRotationMatrix(prim.Rotation)); } // Prim scaling Gl.glScalef(prim.Scale.X, prim.Scale.Y, prim.Scale.Z); // Draw the prim faces for (int j = 0; j < Prims[i].Faces.Count; j++) { if (i == cboPrim.SelectedIndex) { // This prim is currently selected in the dropdown //Gl.glColor3f(0f, 1f, 0f); Gl.glColor3f(1f, 1f, 1f); if (j == cboFace.SelectedIndex) { // This face is currently selected in the dropdown } else { // This face is not currently selected in the dropdown } } else { // This prim is not currently selected in the dropdown Gl.glColor3f(1f, 1f, 1f); } #region Texturing Face face = Prims[i].Faces[j]; FaceData data = (FaceData)face.UserData; if (data.TexturePointer != 0) { // Set the color to solid white so the texture is not altered //Gl.glColor3f(1f, 1f, 1f); // Enable texturing for this face Gl.glEnable(Gl.GL_TEXTURE_2D); } else { Gl.glDisable(Gl.GL_TEXTURE_2D); } // Bind the texture Gl.glBindTexture(Gl.GL_TEXTURE_2D, data.TexturePointer); #endregion Texturing Gl.glTexCoordPointer(2, Gl.GL_FLOAT, 0, data.TexCoords); Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, data.Vertices); Gl.glDrawElements(Gl.GL_TRIANGLES, data.Indices.Length, Gl.GL_UNSIGNED_SHORT, data.Indices); } // Pop the prim matrix Gl.glPopMatrix(); } } // Pop the world matrix Gl.glPopMatrix(); Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY); Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY); Gl.glFlush(); }
public void DrawGeometry(Brush brush, Pen pen, Geometry geometry) { // Ignore total transparent primitive if (Utility.IsTransparent(_opacity) || ((brush == null) && (pen == null || pen.Brush == null)) || (geometry == null)) { return; } // Split if having both pen and brush if ((brush != null) && (pen != null)) // if (!Utility.IsOpaque(_opacity) || (_opacityMask != null)) { // Push a canvas to handle geometry with brush + pen properly Push(Matrix.Identity, null, 1.0, null, Rect.Empty, false); DrawGeometry(brush, null, geometry); DrawGeometry(null, pen, geometry); Pop(); return; } AssertState(DeviceState.PageStarted, DeviceState.NoChange); GeometryPrimitive g = new GeometryPrimitive(); g.Geometry = geometry; g.Clip = _clip; g.Opacity = _opacity; g.OpacityMask = _opacityMask; int needBounds = 0; // 1 for fill, 2 for stroke if (brush != null) { // Fix bug 1427695: Need bounds for non-SolidColorBrushes to enable rebuilding Brush from BrushProxy. if (!(brush is SolidColorBrush)) { needBounds |= 1; } } if ((pen != null) && (pen.Brush != null)) { if (!(pen.Brush is SolidColorBrush)) { needBounds |= 2; } } if (g.OpacityMask != null) { if (g.OpacityMask.BrushList == null && !(g.OpacityMask.Brush is SolidColorBrush)) { if (pen != null) { needBounds |= 2; } else { needBounds |= 1; } } } Rect bounds = g.GetRectBounds((needBounds & 1) != 0); if (brush != null) { g.Brush = BrushProxy.CreateBrush(brush, bounds); } if ((needBounds & 2) != 0) { bounds = geometry.GetRenderBounds(pen); } if ((pen != null) && (pen.Brush != null)) { g.Pen = PenProxy.CreatePen(pen, bounds); } if (g.OpacityMask != null) { if (!g.OpacityMask.MakeBrushAbsolute(bounds)) { // Fix bug 1463955: Brush has become empty; replace with transparent brush. g.OpacityMask = BrushProxy.CreateColorBrush(Colors.Transparent); } } // Optimization: Unfold primitive DrawingBrush when possible to avoid rasterizing it. Primitive primitive = g.UnfoldDrawingBrush(); if (primitive != null) { _root.Children.Add(primitive); } }
public Constant VisitPrimitiveType(Primitive primitive) { throw new NotImplementedException(); }
public static SolvingNode AssertAndGetSingleGeneric(this FinalizationResults result, Primitive desc, Primitive anc, bool isComparable = false) { Assert.AreEqual(1, result.GenericsCount, "Incorrect generics count"); var genericNode = result.Generics.Single(); AssertGenericType(genericNode, desc, anc, isComparable); return(genericNode); }
/// <summary> /// Write a failure message to the display. This function should only be called if something has already failed in the program. /// </summary> /// <param name="message">Message to be displayed</param> public static void Failed(Primitive message) { TextWindow.WriteLine("ASSERT FAILED: " + message); }
public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2 && !(args.Length == 1 && SelectedObject != UUID.Zero)) { return("Usage: export uuid outputfile.xml"); } UUID id; uint localid; string file; if (args.Length == 2) { file = args[1]; if (!UUID.TryParse(args[0], out id)) { return("Usage: export uuid outputfile.xml"); } } else { file = args[0]; id = SelectedObject; } Primitive exportPrim; exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( delegate(Primitive prim) { return(prim.ID == id); } ); if (exportPrim != null) { if (exportPrim.ParentID != 0) { localid = exportPrim.ParentID; } else { localid = exportPrim.LocalID; } // Check for export permission first Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, id); GotPermissionsEvent.WaitOne(1000 * 10, false); if (!GotPermissions) { return("Couldn't fetch permissions for the requested object, try again"); } else { GotPermissions = false; if (Properties.OwnerID != Client.Self.AgentID && Properties.OwnerID != Client.MasterKey && Client.Self.AgentID != Client.Self.AgentID) { return("That object is owned by " + Properties.OwnerID + ", we don't have permission " + "to export it"); } } List <Primitive> prims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll( delegate(Primitive prim) { return(prim.LocalID == localid || prim.ParentID == localid); } ); bool complete = RequestObjectProperties(prims, 250); if (!complete) { Logger.Log("Warning: Unable to retrieve full properties for:", Helpers.LogLevel.Warning, Client); foreach (UUID uuid in PrimsWaiting.Keys) { Logger.Log(uuid.ToString(), Helpers.LogLevel.Warning, Client); } } string output = OSDParser.SerializeLLSDXmlString(Helpers.PrimListToOSD(prims)); try { File.WriteAllText(file, output); } catch (Exception e) { return(e.Message); } Logger.Log("Exported " + prims.Count + " prims to " + file, Helpers.LogLevel.Info, Client); // Create a list of all of the textures to download List <ImageRequest> textureRequests = new List <ImageRequest>(); lock (Textures) { for (int i = 0; i < prims.Count; i++) { Primitive prim = prims[i]; if (prim.Textures.DefaultTexture.TextureID != Primitive.TextureEntry.WHITE_TEXTURE && !Textures.Contains(prim.Textures.DefaultTexture.TextureID)) { Textures.Add(prim.Textures.DefaultTexture.TextureID); } for (int j = 0; j < prim.Textures.FaceTextures.Length; j++) { if (prim.Textures.FaceTextures[j] != null && prim.Textures.FaceTextures[j].TextureID != Primitive.TextureEntry.WHITE_TEXTURE && !Textures.Contains(prim.Textures.FaceTextures[j].TextureID)) { Textures.Add(prim.Textures.FaceTextures[j].TextureID); } } if (prim.Sculpt != null && prim.Sculpt.SculptTexture != UUID.Zero && !Textures.Contains(prim.Sculpt.SculptTexture)) { Textures.Add(prim.Sculpt.SculptTexture); } } // Create a request list from all of the images for (int i = 0; i < Textures.Count; i++) { textureRequests.Add(new ImageRequest(Textures[i], ImageType.Normal, 1013000.0f, 0)); } } // Download all of the textures in the export list foreach (ImageRequest request in textureRequests) { Client.Assets.RequestImage(request.ImageID, request.Type, Assets_OnImageReceived); } return("XML exported, began downloading " + Textures.Count + " textures"); } else { return("Couldn't find UUID " + id.ToString() + " in the " + Client.Network.CurrentSim.ObjectsPrimitives.Count + "objects currently indexed in the current simulator"); } }
public Linkset() { RootPrim = new Primitive(); }
public override string Execute(string[] args, LLUUID fromAgentID) { if (args.Length != 1) { return("Usage: exportparticles [prim-uuid]"); } LLUUID id; if (!LLUUID.TryParse(args[0], out id)) { return("Usage: exportparticles [prim-uuid]"); } lock (Client.Network.Simulators) { for (int i = 0; i < Client.Network.Simulators.Count; i++) { Primitive exportPrim = Client.Network.Simulators[i].ObjectsPrimitives.Find( delegate(Primitive prim) { return(prim.ID == id); } ); if (exportPrim != null) { if (exportPrim.ParticleSys.CRC != 0) { StringBuilder lsl = new StringBuilder(); #region Particle System to LSL lsl.Append("default" + Environment.NewLine); lsl.Append("{" + Environment.NewLine); lsl.Append(" state_entry()" + Environment.NewLine); lsl.Append(" {" + Environment.NewLine); lsl.Append(" llParticleSystem([" + Environment.NewLine); lsl.Append(" PSYS_PART_FLAGS, 0"); if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpColor) != 0) { lsl.Append(" | PSYS_PART_INTERP_COLOR_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.InterpScale) != 0) { lsl.Append(" | PSYS_PART_INTERP_SCALE_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Bounce) != 0) { lsl.Append(" | PSYS_PART_BOUNCE_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Wind) != 0) { lsl.Append(" | PSYS_PART_WIND_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowSrc) != 0) { lsl.Append(" | PSYS_PART_FOLLOW_SRC_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.FollowVelocity) != 0) { lsl.Append(" | PSYS_PART_FOLLOW_VELOCITY_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetPos) != 0) { lsl.Append(" | PSYS_PART_TARGET_POS_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.TargetLinear) != 0) { lsl.Append(" | PSYS_PART_TARGET_LINEAR_MASK"); } if ((exportPrim.ParticleSys.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.Emissive) != 0) { lsl.Append(" | PSYS_PART_EMISSIVE_MASK"); } lsl.Append(","); lsl.Append(Environment.NewLine); lsl.Append(" PSYS_SRC_PATTERN, 0"); if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Drop) != 0) { lsl.Append(" | PSYS_SRC_PATTERN_DROP"); } if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Explode) != 0) { lsl.Append(" | PSYS_SRC_PATTERN_EXPLODE"); } if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.Angle) != 0) { lsl.Append(" | PSYS_SRC_PATTERN_ANGLE"); } if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleCone) != 0) { lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE"); } if ((exportPrim.ParticleSys.Pattern & Primitive.ParticleSystem.SourcePattern.AngleConeEmpty) != 0) { lsl.Append(" | PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY"); } lsl.Append("," + Environment.NewLine); lsl.Append(" PSYS_PART_START_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartColor.A) + "," + Environment.NewLine); lsl.Append(" PSYS_PART_END_ALPHA, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndColor.A) + "," + Environment.NewLine); lsl.Append(" PSYS_PART_START_COLOR, " + exportPrim.ParticleSys.PartStartColor.ToStringRGB() + "," + Environment.NewLine); lsl.Append(" PSYS_PART_END_COLOR, " + exportPrim.ParticleSys.PartEndColor.ToStringRGB() + "," + Environment.NewLine); lsl.Append(" PSYS_PART_START_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartStartScaleY) + ", 0>, " + Environment.NewLine); lsl.Append(" PSYS_PART_END_SCALE, <" + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleX) + ", " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartEndScaleY) + ", 0>, " + Environment.NewLine); lsl.Append(" PSYS_PART_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.PartMaxAge) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_MAX_AGE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.MaxAge) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_ACCEL, " + exportPrim.ParticleSys.PartAcceleration.ToString() + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_BURST_PART_COUNT, " + String.Format("{0:0}", exportPrim.ParticleSys.BurstPartCount) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_BURST_RADIUS, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRadius) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_BURST_RATE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstRate) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_BURST_SPEED_MIN, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMin) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_BURST_SPEED_MAX, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.BurstSpeedMax) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_INNERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.InnerAngle) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_OUTERANGLE, " + String.Format("{0:0.00000}", exportPrim.ParticleSys.OuterAngle) + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_OMEGA, " + exportPrim.ParticleSys.AngularVelocity.ToString() + "," + Environment.NewLine); lsl.Append(" PSYS_SRC_TEXTURE, (key)\"" + exportPrim.ParticleSys.Texture.ToString() + "\"," + Environment.NewLine); lsl.Append(" PSYS_SRC_TARGET_KEY, (key)\"" + exportPrim.ParticleSys.Target.ToString() + "\"" + Environment.NewLine); lsl.Append(" ]);" + Environment.NewLine); lsl.Append(" }" + Environment.NewLine); lsl.Append("}" + Environment.NewLine); #endregion Particle System to LSL return(lsl.ToString()); } else { return("Prim " + exportPrim.LocalID + " does not have a particle system"); } } } } return("Couldn't find prim " + id.ToString()); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Initialize the device m_device.Init(panelOutput1.Handle, false, true); // Build cube primitive { float3 colorXp = new float3(1, 0, 0); float3 colorXn = new float3(1, 1, 0); float3 colorYp = new float3(0, 1, 0); float3 colorYn = new float3(0, 1, 1); float3 colorZp = new float3(0, 0, 1); float3 colorZn = new float3(1, 0, 1); VertexP3N3G3T2[] vertices = new VertexP3N3G3T2[6 * 4] { // +X new VertexP3N3G3T2() { P = new float3(1, 1, 1), N = new float3(1, 0, 0), T = colorXp, UV = new float2(0, 0) }, new VertexP3N3G3T2() { P = new float3(1, -1, 1), N = new float3(1, 0, 0), T = colorXp, UV = new float2(0, 1) }, new VertexP3N3G3T2() { P = new float3(1, -1, -1), N = new float3(1, 0, 0), T = colorXp, UV = new float2(1, 1) }, new VertexP3N3G3T2() { P = new float3(1, 1, -1), N = new float3(1, 0, 0), T = colorXp, UV = new float2(1, 0) }, // -X new VertexP3N3G3T2() { P = new float3(-1, 1, -1), N = new float3(-1, 0, 0), T = colorXn, UV = new float2(0, 0) }, new VertexP3N3G3T2() { P = new float3(-1, -1, -1), N = new float3(-1, 0, 0), T = colorXn, UV = new float2(0, 1) }, new VertexP3N3G3T2() { P = new float3(-1, -1, 1), N = new float3(-1, 0, 0), T = colorXn, UV = new float2(1, 1) }, new VertexP3N3G3T2() { P = new float3(-1, 1, 1), N = new float3(-1, 0, 0), T = colorXn, UV = new float2(1, 0) }, // +Y new VertexP3N3G3T2() { P = new float3(-1, 1, -1), N = new float3(0, 1, 0), T = colorYp, UV = new float2(0, 0) }, new VertexP3N3G3T2() { P = new float3(-1, 1, 1), N = new float3(0, 1, 0), T = colorYp, UV = new float2(0, 1) }, new VertexP3N3G3T2() { P = new float3(1, 1, 1), N = new float3(0, 1, 0), T = colorYp, UV = new float2(1, 1) }, new VertexP3N3G3T2() { P = new float3(1, 1, -1), N = new float3(0, 1, 0), T = colorYp, UV = new float2(1, 0) }, // -Y new VertexP3N3G3T2() { P = new float3(-1, -1, 1), N = new float3(0, -1, 0), T = colorYn, UV = new float2(0, 0) }, new VertexP3N3G3T2() { P = new float3(-1, -1, -1), N = new float3(0, -1, 0), T = colorYn, UV = new float2(0, 1) }, new VertexP3N3G3T2() { P = new float3(1, -1, -1), N = new float3(0, -1, 0), T = colorYn, UV = new float2(1, 1) }, new VertexP3N3G3T2() { P = new float3(1, -1, 1), N = new float3(0, -1, 0), T = colorYn, UV = new float2(1, 0) }, // +Z new VertexP3N3G3T2() { P = new float3(-1, 1, 1), N = new float3(0, 0, 1), T = colorZp, UV = new float2(0, 0) }, new VertexP3N3G3T2() { P = new float3(-1, -1, 1), N = new float3(0, 0, 1), T = colorZp, UV = new float2(0, 1) }, new VertexP3N3G3T2() { P = new float3(1, -1, 1), N = new float3(0, 0, 1), T = colorZp, UV = new float2(1, 1) }, new VertexP3N3G3T2() { P = new float3(1, 1, 1), N = new float3(0, 0, 1), T = colorZp, UV = new float2(1, 0) }, // -Z new VertexP3N3G3T2() { P = new float3(1, 1, -1), N = new float3(0, 0, -1), T = colorZn, UV = new float2(0, 0) }, new VertexP3N3G3T2() { P = new float3(1, -1, -1), N = new float3(0, 0, -1), T = colorZn, UV = new float2(0, 1) }, new VertexP3N3G3T2() { P = new float3(-1, -1, -1), N = new float3(0, 0, -1), T = colorZn, UV = new float2(1, 1) }, new VertexP3N3G3T2() { P = new float3(-1, 1, -1), N = new float3(0, 0, -1), T = colorZn, UV = new float2(1, 0) }, }; uint[] indices = new uint[3 * 2 * 6] { 4 * 0 + 0, 4 * 0 + 1, 4 * 0 + 2, 4 * 0 + 0, 4 * 0 + 2, 4 * 0 + 3, 4 * 1 + 0, 4 * 1 + 1, 4 * 1 + 2, 4 * 1 + 0, 4 * 1 + 2, 4 * 1 + 3, 4 * 2 + 0, 4 * 2 + 1, 4 * 2 + 2, 4 * 2 + 0, 4 * 2 + 2, 4 * 2 + 3, 4 * 3 + 0, 4 * 3 + 1, 4 * 3 + 2, 4 * 3 + 0, 4 * 3 + 2, 4 * 3 + 3, 4 * 4 + 0, 4 * 4 + 1, 4 * 4 + 2, 4 * 4 + 0, 4 * 4 + 2, 4 * 4 + 3, 4 * 5 + 0, 4 * 5 + 1, 4 * 5 + 2, 4 * 5 + 0, 4 * 5 + 2, 4 * 5 + 3, }; m_prim_cube = new Primitive(m_device, 6 * 4, VertexP3N3G3T2.FromArray(vertices), indices, Primitive.TOPOLOGY.TRIANGLE_LIST, VERTEX_FORMAT.P3N3G3T2); } // Build the shader to render the cube m_shader_renderCube = new Shader(m_device, new System.IO.FileInfo(@".\Shaders\RenderCube.hlsl"), VERTEX_FORMAT.P3N3G3T2, "VS", null, "PS"); // Build constant buffer to provide camera transform m_CB_Camera = new ConstantBuffer <CBCamera>(m_device, 0); Application.Idle += Application_Idle; }
private void CreatePrim(WarpRenderer renderer, ISceneChildEntity prim) { try { const float MIN_SIZE = 2f; if ((PCode)prim.Shape.PCode != PCode.Prim) { return; } if (prim.Scale.LengthSquared() < MIN_SIZE * MIN_SIZE) { return; } Primitive omvPrim = prim.Shape.ToOmvPrimitive(prim.OffsetPosition, prim.GetRotationOffset()); FacetedMesh renderMesh = null; // Are we dealing with a sculptie or mesh? if (omvPrim.Sculpt != null && omvPrim.Sculpt.SculptTexture != UUID.Zero) { // Try fetchinng the asset byte[] sculptAsset = m_scene.AssetService.GetData(omvPrim.Sculpt.SculptTexture.ToString()); if (sculptAsset != null) { // Is it a mesh? if (omvPrim.Sculpt.Type == SculptType.Mesh) { AssetMesh meshAsset = new AssetMesh(omvPrim.Sculpt.SculptTexture, sculptAsset); FacetedMesh.TryDecodeFromAsset(omvPrim, meshAsset, DetailLevel.Highest, out renderMesh); meshAsset = null; } else // It's sculptie { Image sculpt = m_imgDecoder.DecodeToImage(sculptAsset); if (sculpt != null) { renderMesh = m_primMesher.GenerateFacetedSculptMesh(omvPrim, (Bitmap)sculpt, DetailLevel.Medium); sculpt.Dispose(); } } sculptAsset = null; } } else // Prim { renderMesh = m_primMesher.GenerateFacetedMesh(omvPrim, DetailLevel.Medium); } if (renderMesh == null) { return; } warp_Vector primPos = ConvertVector(prim.GetWorldPosition()); warp_Quaternion primRot = ConvertQuaternion(prim.GetRotationOffset()); warp_Matrix m = warp_Matrix.quaternionMatrix(primRot); if (prim.ParentID != 0) { ISceneEntity group = m_scene.GetGroupByPrim(prim.LocalId); if (group != null) { m.transform(warp_Matrix.quaternionMatrix(ConvertQuaternion(group.RootChild.GetRotationOffset()))); } } warp_Vector primScale = ConvertVector(prim.Scale); string primID = prim.UUID.ToString(); // Create the prim faces for (int i = 0; i < renderMesh.Faces.Count; i++) { Face face = renderMesh.Faces[i]; string meshName = primID + "-Face-" + i.ToString(); warp_Object faceObj = new warp_Object(face.Vertices.Count, face.Indices.Count / 3); foreach (Vertex v in face.Vertices) { warp_Vector pos = ConvertVector(v.Position); warp_Vector norm = ConvertVector(v.Normal); if (prim.Shape.SculptTexture == UUID.Zero) { norm = norm.reverse(); } warp_Vertex vert = new warp_Vertex(pos, norm, v.TexCoord.X, v.TexCoord.Y); faceObj.addVertex(vert); } for (int j = 0; j < face.Indices.Count;) { faceObj.addTriangle( face.Indices[j++], face.Indices[j++], face.Indices[j++]); } Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace((uint)i); string materialName; Color4 faceColor = GetFaceColor(teFace); if (m_texturePrims && prim.Scale.LengthSquared() > 48 * 48) { materialName = GetOrCreateMaterial(renderer, faceColor, teFace.TextureID); } else { materialName = GetOrCreateMaterial(renderer, faceColor); } faceObj.transform(m); faceObj.setPos(primPos); faceObj.scaleSelf(primScale.x, primScale.y, primScale.z); renderer.Scene.addObject(meshName, faceObj); renderer.SetObjectMaterial(meshName, materialName); faceObj = null; } renderMesh.Faces.Clear(); renderMesh = null; } catch (Exception ex) { MainConsole.Instance.Warn("[Warp3D]: Exception creating prim, " + ex); } }
public void SetProfileRange(float begin, float end) { _profileBegin = Primitive.PackBeginCut(begin); _profileEnd = Primitive.PackEndCut(end); }