private float mThetaRange; // range from 0 to this value (mPeroid * 2PI) #endregion Fields #region Constructors /// <summary> /// Constrcuts from the commandfile. /// DO NOT change the pasing loop unless you know what you are doing. /// </summary> /// <param name="parser"></param> public RTTextureType_Sine(CommandFileParser parser) { mPeriod = 1f; mDirection = Vector2.UnitX; while (!parser.IsEndElement("texture")) { if (parser.IsElement() && (!parser.IsElement("texture"))) { if (parser.IsElement("period")) mPeriod = parser.ReadFloat(); else if (parser.IsElement("direction")) mDirection = parser.ReadVector2(); else if (parser.IsElement("color1")) mColor1 = parser.ReadVector3(); else if (parser.IsElement("color2")) mColor2 = parser.ReadVector3(); else parser.ParserError("TextureType_Sine"); } else parser.ParserRead(); } mThetaRange = mPeriod * (float) Math.PI * 2f; mDirection = Vector2.Normalize(mDirection); }
private int mXResolution, mYResolution; // parse result from resolution #endregion Fields #region Constructors /// <summary> /// Constructor from parser. /// Please DO NOT change the parser, unless you really know what you are doing!! /// </summary> /// <param name="parser"></param> public ImageSpec(CommandFileParser parser) { mXResolution = 64; mYResolution = 64; mSamplesPerPixel = 1; parser.ParserRead(); while (!parser.IsEndElement("imagespec")) { if (parser.IsElement() && (!parser.IsElement("imagespec"))) { if (parser.IsElement("samples")) mSamplesPerPixel = parser.ReadInt(); else if (parser.IsElement("resolution")) { Vector2 n = parser.ReadVector2(); mXResolution = (int)n.X; mYResolution = (int)n.Y; } else parser.ParserError("ImageSpec"); } else parser.ParserRead(); } }
private int mXResolution, mYResolution; // parse result from resolution /// <summary> /// Constructor from parser. /// Please DO NOT change the parser, unless you really know what you are doing!! /// </summary> /// <param name="parser"></param> public ImageSpec(CommandFileParser parser) { mXResolution = 64; mYResolution = 64; mSamplesPerPixel = 1; parser.ParserRead(); while (!parser.IsEndElement("imagespec")) { if (parser.IsElement() && (!parser.IsElement("imagespec"))) { if (parser.IsElement("samples")) { mSamplesPerPixel = parser.ReadInt(); } else if (parser.IsElement("resolution")) { Vector2 n = parser.ReadVector2(); mXResolution = (int)n.X; mYResolution = (int)n.Y; } else { parser.ParserError("ImageSpec"); } } else { parser.ParserRead(); } } }
private Vector3[] mVertices; // always 3 vertices #endregion Fields #region Constructors /// <summary> /// Constructs from parsing file and then intialize for intersection computation. /// </summary> /// <param name="parser"></param> public RTTriangle(CommandFileParser parser) { mType = RTGeometryType.Triangle; // do we have a transform? bool hasTransform = false; Matrix xform = Matrix.Identity; mVertices = new Vector3[3]; mVertexUV = new Vector2[3]; mMaterialIndex = 0; int count = 0; parser.ParserRead(); while (!parser.IsEndElement("triangle")) { if (parser.IsElement() && (!parser.IsElement("triangle"))) { if (parser.IsElement("vertices")) { mVertices[count] = parser.ReadVector3(); } else if (parser.IsElement("uv")) { mVertexUV[count] = parser.ReadVector2(); count++; } else if (parser.IsElement("xform")) { hasTransform = true; xform = ParseTransform(parser); } else if (parser.IsElement("material")) mMaterialIndex = parser.ReadInt(); else parser.ParserError("Triangle"); } else parser.ParserRead(); } if (count != 3) { parser.ParserError("Triangle: vertex indexPtr = " + count); } else { if (hasTransform) { mVertices[0] = Vector3.Transform(mVertices[0], xform); mVertices[1] = Vector3.Transform(mVertices[1], xform); mVertices[2] = Vector3.Transform(mVertices[2], xform); } InitializeTriangle(); } }
/// <summary> /// Constrcuts from the commandfile. /// DO NOT change the pasing loop unless you know what you are doing. /// </summary> /// <param name="parser"></param> public RTTextureType_Sine(CommandFileParser parser) { mPeriod = 1f; mDirection = Vector2.UnitX; while (!parser.IsEndElement("texture")) { if (parser.IsElement() && (!parser.IsElement("texture"))) { if (parser.IsElement("period")) { mPeriod = parser.ReadFloat(); } else if (parser.IsElement("direction")) { mDirection = parser.ReadVector2(); } else if (parser.IsElement("color1")) { mColor1 = parser.ReadVector3(); } else if (parser.IsElement("color2")) { mColor2 = parser.ReadVector3(); } else { parser.ParserError("TextureType_Sine"); } } else { parser.ParserRead(); } } mThetaRange = mPeriod * (float)Math.PI * 2f; mDirection = Vector2.Normalize(mDirection); }
private Vector2 mD02, mD12; // delta UV between vertex-0 and 2; and vertex-1 and 2 /// <summary> /// Constructs from parsing file and then intialize for intersection computation. /// </summary> /// <param name="parser"></param> public RTTriangle(CommandFileParser parser) { mType = RTGeometryType.Triangle; // do we have a transform? bool hasTransform = false; Matrix xform = Matrix.Identity; mVertices = new Vector3[3]; mVertexUV = new Vector2[3]; mMaterialIndex = 0; int count = 0; parser.ParserRead(); while (!parser.IsEndElement("triangle")) { if (parser.IsElement() && (!parser.IsElement("triangle"))) { if (parser.IsElement("vertices")) { mVertices[count] = parser.ReadVector3(); } else if (parser.IsElement("uv")) { mVertexUV[count] = parser.ReadVector2(); count++; } else if (parser.IsElement("xform")) { hasTransform = true; xform = ParseTransform(parser); } else if (parser.IsElement("material")) { mMaterialIndex = parser.ReadInt(); } else { parser.ParserError("Triangle"); } } else { parser.ParserRead(); } } if (count != 3) { parser.ParserError("Triangle: vertex indexPtr = " + count); } else { if (hasTransform) { mVertices[0] = Vector3.Transform(mVertices[0], xform); mVertices[1] = Vector3.Transform(mVertices[1], xform); mVertices[2] = Vector3.Transform(mVertices[2], xform); } InitializeTriangle(); } }