public static void readCameraSettings(XElement x3d_or_xenv_element) { CustomXMLDocumentOperations X = new CustomXMLDocumentOperations(); Scientrace.Vector cameraviewpoint = Scientrace.TraceJournal.Instance.cameraviewpoint; Scientrace.Vector camrotationvec = Scientrace.TraceJournal.Instance.camrotationvector; Scientrace.TraceJournal.Instance.labelaxes = X.getXBool(x3d_or_xenv_element, "DrawAxes", Scientrace.TraceJournal.Instance.labelaxes); double camrotationangle = Scientrace.TraceJournal.Instance.camrotationangle; XElement camfrom = (x3d_or_xenv_element == null? null:x3d_or_xenv_element.Element("CameraFrom")); XElement camrot = (x3d_or_xenv_element == null? null:x3d_or_xenv_element.Element("CameraRotation")); if (camfrom != null) { cameraviewpoint = X.getXNzVector(camfrom); Scientrace.Vector camdirvec = cameraviewpoint.negative(); Scientrace.NonzeroVector defvec = new Scientrace.NonzeroVector(0, 0, -1); camrotationangle = defvec.angleWith(camdirvec); camrotationvec = defvec.crossProduct(camdirvec); } if (camrot != null) { camrotationvec = X.getXVectorByName(camrot, "Vector"); camrotationangle = X.getXAngleByName(camrot, "Angle"); } Scientrace.TraceJournal.Instance.cameraviewpoint = X.getXVectorByName(x3d_or_xenv_element, "CameraViewpoint", cameraviewpoint); Scientrace.TraceJournal.Instance.camrotationangle = camrotationangle; if (camrotationvec != null) { Scientrace.TraceJournal.Instance.camrotationvector = camrotationvec; } }
/* Classes supporthing the creation of the lightsource */ public Scientrace.LightSource setRandomCylinderLightFromXData(XElement xlight, Scientrace.Object3dEnvironment env) { //Reading LightSource parameters from XML-element /* "RandomCylinder" * d class.radius, d distance, i beamcount, i maxinteractions, d minintensity * str spectrum, vec location, vec direction */ double radius = this.X.getXDouble(xlight.Attribute("Radius")); if (radius <= 0) { throw new ArgumentOutOfRangeException("Radius " + radius + " out of range"); } double distance = this.X.getXDouble(xlight.Attribute("Distance"), 0); int beamcount = this.X.getXInt(xlight.Attribute("RayCount"), this.X.getXInt(xlight.Attribute("BeamCount"))); //int maxinteractions = this.X.getXInt(xlight.Attribute("MaxInteractions"), 8); //default value max_interactions -> 8 double minintensity = this.X.getXDouble(xlight.Attribute("MinIntensity"), 0.01); //default minimum intensity for tracing set to 1% Scientrace.Vector light_direction = this.X.getXVector(xlight.Element("Direction")); Scientrace.Location centerloc = this.X.getXVector(xlight.Element("Location")).toLocation(); Scientrace.Location locoffset = (light_direction.negative() * distance).toLocation(); //distance cm above surface Scientrace.Location loc = locoffset + centerloc; XMLSpectrumParser xsp = new XMLSpectrumParser(); Scientrace.LightSpectrum spectrum = xsp.parseLightSpectrum(xlight.Element("Spectrum")); Scientrace.LightSource retlight = new Scientrace.RandomCircleLightSource(env, loc, light_direction.tryToUnitVector(), new Scientrace.Plane(new Scientrace.Location(0, 0, 0), new Scientrace.NonzeroVector(1, 0, 0), new Scientrace.NonzeroVector(0, 0, 1)), radius, beamcount, spectrum); //retlight.max_interactions = maxinteractions; retlight.minimum_intensity_fraction = minintensity; return(retlight); }