private void ShowOneDebugPixelAt(Vector3 p, System.Drawing.Color c) { if (mNumPixelNodesUsed >= mPixelsToShow.numChildren()) { // need to create new ones UWB_Primitive prim = CreateSphereMesh(); prim.EnableLighting(false); UWB_SceneNode pNode = new UWB_SceneNode(); pNode.setPrimitive(prim); UWB_XFormInfo xf = pNode.getXFormInfo(); xf.SetTranslation(p); xf.SetScale(new Vector3(kPixelSize)); pNode.setXFormInfo(xf); prim.Material.Diffuse = Vector4.Zero; prim.Material.Specular = Vector4.Zero; prim.Material.Ambient = Vector4.Zero; prim.Material.Emissive = new Vector4(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, 1f); mPixelsToShow.insertChildNode(pNode); } else { // there are more to be reused ... UWB_SceneNode n = mPixelsToShow.getChildNode(mNumPixelNodesUsed); UWB_XFormInfo xf = n.getXFormInfo(); xf.SetTranslation(new Vector3(p.X, p.Y, p.Z)); UWB_Primitive prim = n.getPrimitive(); prim.setVisible(true); prim.Material.Diffuse = Vector4.Zero; prim.Material.Specular = Vector4.Zero; prim.Material.Ambient = Vector4.Zero; prim.Material.Emissive = new Vector4(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, 1f); } }
private void SetMeshMaterial(UWB_Primitive prim, RayTracer_552.RTMaterial mat) { prim.EnableLighting(true); prim.setShadeMode(eShadeMode.smGouraud); prim.Material.Emissive = new Vector4(Vector3.Zero, 1f); prim.Material.Ambient = new Vector4(mat.GetAmbientColor, 1f); prim.Material.Diffuse = new Vector4(mat.GetDiffuseColor, 1f); prim.Material.Specular = new Vector4(mat.GetSpecularColor, 1f); prim.Material.Power = mat.GetN; }
private UWB_SceneNode CreateNode(Vector3 at, float sx, float sy, float sz, UWB_Primitive prim) { UWB_SceneNode pNode = new UWB_SceneNode(); pNode.setPrimitive(prim); UWB_XFormInfo xf = pNode.getXFormInfo(); xf.SetTranslation(at); xf.SetScale(new Vector3(sx, sy, sz)); pNode.setXFormInfo(xf); m_SceneDatabase.insertChildNode(pNode); return(pNode); }
private void AddLights(RayTracer_552.SceneDatabase rtScene) { UWB_XNAGraphicsDevice.m_TheAPI.LightManager.ResetAllLights(); for (int l = 0; l < rtScene.GetNumLights(); l++) { RTLight lgt = rtScene.GetLight(l); Vector4 useColor = new Vector4(lgt.GetColor(new Vector3(0, 0, 0)), 1f); UWB_XNALight theLight = null; if (lgt.GetLightSourceType() == RTLightType.RTLightSourceType.RTLightSourceTypeDirection) { theLight = UWB_XNAGraphicsDevice.m_TheAPI.LightManager.CreateDirectionalLight(); } else if (lgt.GetLightSourceType() == RTLightType.RTLightSourceType.RTLightSourceTypeSpot) { theLight = UWB_XNAGraphicsDevice.m_TheAPI.LightManager.CreateSpotLight(); } else { theLight = UWB_XNAGraphicsDevice.m_TheAPI.LightManager.CreatePointLight(); } theLight.Ambient = Vector4.Zero; theLight.Diffuse = useColor; theLight.Specular = useColor; theLight.Position = lgt.GetLightPosition(); theLight.Direction = -lgt.GetNormalizedDirection(Vector3.Zero); theLight.Color = useColor; theLight.Attenuation = new Vector3(1f, 0.0f, 0.0f); theLight.Range = 10000f; theLight.SwitchOnLight(); UWB_Primitive prim = CreateSphereMesh(); SetMeshMaterial(prim, rtScene.GetMaterial(0)); float scale = 0.25f; CreateNode(lgt.GetLightPosition(), scale, scale, scale, prim); } }