1 #region Using Statements
3 using System.Collections.Generic;
6 using System.Windows.Forms;
7 using Microsoft.Xna.Framework;
8 using Microsoft.Xna.Framework.Graphics;
9 using Microsoft.Xna.Framework.Audio;
10 using Microsoft.Xna.Framework.Content;
11 using Microsoft.Xna.Framework.GamerServices;
12 using Microsoft.Xna.Framework.Graphics;
13 using Microsoft.Xna.Framework.Input;
14 using Microsoft.Xna.Framework.Media;
15 using Microsoft.Xna.Framework.Net;
16 using Microsoft.Xna.Framework.Storage;
17 using Microsoft.Xna.Framework.Graphics.PackedVector;
32 #region Render Targets
33 private RenderTarget2D frontTarget;
34 private RenderTarget2D backTarget;
35 private RenderTarget2D sceneTarget;
36 private RenderTarget2D dvrTarget;
38 private Texture2D dvrTexture;
40 private RenderTarget2D cvdTarget;
43 ContentManager content;
44 SpriteBatch spriteBatch;
45 SpriteFont spriteBatchFont;
50 Viewport defaultViewport;
57 private Model cubeModel;
97 Texture2D frameworkInfo;
99 private bool debugShader;
100 Texture2D rgbTestTex;
107 set { input = value; }
108 get {
return input; }
120 #region create cameras
124 for (
int i = 1; i < 4; i++)
126 cameras[i] =
new Camera();
135 lastSize =
new int[] {this.Size.Width, this.Size.Height};
141 Console.WriteLine(
"ENGINE STARTED");
161 content = Services.
GetService(typeof(ContentManager)) as ContentManager;
164 content =
new ContentManager(Services,
"Content");
165 Services.AddService<ContentManager>(content);
169 spriteBatch =
new SpriteBatch(GraphicsDevice);
170 Services.AddService<SpriteBatch>(spriteBatch);
197 #region init control points
198 setInitialControlPoints();
204 #region LoadContent()
212 spriteBatchFont = content.Load<SpriteFont>(
"Fonts\\spriteFont1");
214 frameworkInfo = content.Load<Texture2D>(
"Texture\\framework_info");
220 rgbTestTex = content.Load<Texture2D>(
"Texture\\schiff");
227 defaultViewport = GraphicsDevice.Viewport;
228 defaultViewport.Width = this.Size.Width;
229 defaultViewport.Height = this.Size.Height;
233 #region create Render Targets
235 PresentationParameters pp = GraphicsDevice.PresentationParameters;
236 SurfaceFormat format = pp.BackBufferFormat;
238 int width = pp.BackBufferWidth;
239 int height = pp.BackBufferHeight;
240 DepthFormat depthStecilFormat = pp.DepthStencilFormat;
241 int multiSample = pp.MultiSampleCount;
244 frontTarget =
new RenderTarget2D(GraphicsDevice, width, height,
false, format,
245 depthStecilFormat, multiSample, RenderTargetUsage.DiscardContents);
247 backTarget =
new RenderTarget2D(GraphicsDevice, width, height,
false, format,
248 depthStecilFormat, multiSample, RenderTargetUsage.DiscardContents);
250 sceneTarget =
new RenderTarget2D(GraphicsDevice, width, height,
false, format,
251 depthStecilFormat, multiSample, RenderTargetUsage.DiscardContents);
253 dvrTarget =
new RenderTarget2D(GraphicsDevice, width, height,
false, format, depthStecilFormat, multiSample, RenderTargetUsage.DiscardContents);
255 cvdTarget =
new RenderTarget2D(GraphicsDevice, width, height,
false, SurfaceFormat.Rgba64, depthStecilFormat, multiSample, RenderTargetUsage.DiscardContents);
260 Console.WriteLine(
"RENDERTARGETS created!");
263 #region create all shader
267 Console.WriteLine(
"trying to create shader");
271 shader =
new VolumeShader(GraphicsDevice, content.Load<Effect>(
"Effects\\volumeShader"),
false);
275 CVDshader =
new VolumeShader(GraphicsDevice, content.Load<Effect>(
"Effects\\volumeCVDShader"),
true);
276 tfWeightsShader =
new TFWeightsShader(GraphicsDevice, content.Load<Effect>(
"Effects\\TFWeights"));
280 #region recolor shader
282 rGBtoLab_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\RGBtoLab"),
"convertToLab");
283 contrastLoss_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\ContrastLoss"),
"ContrastLoss");
284 predominantComponent_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\PredominantComponent"),
"PredominantComponent");
285 eigenVector_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\EigenVector"),
"EigenVector");
286 projection_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\Proj"),
"Project");
287 maxProjectionEffect_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\MaxProjectionEffect"),
"MaxProjectionEffect");
288 enhanceContrast_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\EnhanceContrast"),
"EnhanceContrast");
289 labToRGB_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\LabtoRGB"),
"convertToRGB");
293 #region simulation shader
295 sim_RGBtoLab_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\RGBtoLab"),
"convertToLab");
296 lMSShader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\LMS"),
"LMS");
297 sim_LabToRGB_Shader =
new RecolorShader(GraphicsDevice, content.Load<Effect>(
"Effects\\LabtoRGB"),
"convertToRGB");
303 cubeModel = content.Load<Model>(
"Models/box");
311 #region UnloadContent()
339 Console.WriteLine(
"Engine Update Call number " + drawcount);
347 if (input != null && this.Controls.Count > 0)
349 foreach (Control c
in Controls)
351 if (c.GetType().Equals(
"Data"))
353 this.Controls.Remove(c);
360 setInitialControlPoints();
362 this.Controls.Add(input);
364 #region init camera for 3d view
366 Vector4 factor = input.scaleFactor;
367 Vector3 scale =
new Vector3(factor.X, factor.Y, factor.Z);
368 Vector3 target =
new Vector3(0.5f, 0.5f, 0.5f) * scale;
369 target = Vector3.Transform(target, input.worldMatrix);
371 cameras[0].
CameraPosition =
new Vector3(target.X, target.Y, 2.0f);
380 shader.
SetEffectParameter(input.VolumeData, input.volumeGradients,
GameProperties.Instance.directLightPos, input.stepSize * input.scaleSteps,
GameProperties.Instance.baseSampleDist, input.scaleSteps, input.iterations, 0, input.scaleFactor,
new Vector2(input.DataDimensions.X, input.DataDimensions.Y), input.slice);
387 Console.WriteLine(
"load data done");
393 #region set view mode and camera
398 #region set camera to current view
401 Console.WriteLine(
"SETTING CAMERA");
430 if (currentView == 0)
436 cameras[currentView].
Update();
444 input.Camera = cameras[currentView];
445 input.CurrentCamera = currentView;
453 cameras[0].
SetClientSize =
new int[] { viewports[0].Width, viewports[0].Height };
457 cvdCamera.
SetClientSize =
new int[] { viewports[2].Width, viewports[2].Height };
464 cvdCamera.
SetClientSize =
new int[] { viewports[2].Width, viewports[2].Height };
469 for (
int i = 1; i < cameras.Length; i++)
472 cameras[i].
SetClientSize =
new int[] { viewports[i].Width, viewports[i].Height };
482 Console.WriteLine(
"CAMERA SET");
488 if (
GameProperties.Instance.engineState.updateData && input != null)
490 #region front and backfaces
494 #region set shader parameters for rendering
495 GraphicsDevice.BlendState = BlendState.Additive;
496 shader.CurrentTechnique = shader.Techniques[
"RenderPosition"];
505 Console.WriteLine(
"don't draw frontfaces or backfaces or volume");
511 #region Draw Frontfaces
514 Console.WriteLine(
"1 DRAWING FRONTFACES");
516 GraphicsDevice.SetRenderTarget(frontTarget);
517 GraphicsDevice.Clear(Color.Black);
518 GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
522 GraphicsDevice.SetRenderTarget(null);
528 #region Draw Backfaces
531 Console.WriteLine(
"2 DRAWING BACKFACES");
533 GraphicsDevice.SetRenderTarget(backTarget);
534 GraphicsDevice.Clear(Color.Black);
535 GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
539 GraphicsDevice.SetRenderTarget(null);
543 #region pass textures to shader
554 #region pass textures to shader
570 Console.WriteLine(
"data updated");
576 #region optimize tf for cvd
585 #region calculate new?
599 #region instanciate Image class
600 if (recoloredImage == null)
606 #region assign shader
607 if (recoloredImage.RGBtoLab_Shader == null)
609 recoloredImage.RGBtoLab_Shader = rGBtoLab_Shader;
610 recoloredImage.ContrastLoss_Shader = contrastLoss_Shader;
611 recoloredImage.PredominantComponent_Shader = predominantComponent_Shader;
612 recoloredImage.EigenVector_Shader = eigenVector_Shader;
613 recoloredImage.Projection_Shader = projection_Shader;
614 recoloredImage.MaxProjectionEffect_Shader = maxProjectionEffect_Shader;
615 recoloredImage.EnhanceContrast_Shader = enhanceContrast_Shader;
616 recoloredImage.LabToRGB_Shader = labToRGB_Shader;
620 #region debug: set test image to recolor
623 recoloredImage.ReferenceImageRGB = rgbTestTex;
629 recoloredImage.ReferenceImageRGB = dvrTexture;
634 recoloredImage.ReferenceImageRGB = sceneTarget;
640 recoloredImage.Recolor(GraphicsDevice);
649 #region calculate cvd tf
654 cvdtf.selectRecoloredPixels();
663 tfWeightsShader.
SetEffectParameter(input.volumeData,
GameProperties.Instance.directLightPos, input.stepSize * input.scaleSteps,
GameProperties.Instance.baseSampleDist, input.scaleSteps, input.iterations, 0, input.scaleFactor,
new Vector2(input.DataDimensions.X, input.DataDimensions.Y), input.slice);
666 tfWeightsShader.CurrentTechnique = tfWeightsShader.Techniques[
"CalculateColorWeights"];
669 #region set render graphics device
671 GraphicsDevice.BlendState = BlendState.AlphaBlend;
672 GraphicsDevice.RasterizerState = RasterizerState.CullNone;
675 #region calculate weights
677 List<TransferControlPoint> cpList =
GameProperties.Instance.colorControlPoints;
681 for (
int i = 0; i < cpList.Count; i++)
684 float currCp;
float prevCp;
float nextCp;
688 currCp = (float)cpList[i].isoValue;
690 nextCp = (float)cpList[i + 1].isoValue;
692 else if (i == (cpList.Count - 1))
694 currCp = (float)cpList[i].isoValue;
695 prevCp = (float)cpList[i - 1].isoValue;
700 currCp = (float)cpList[i].isoValue;
701 prevCp = (float)cpList[i - 1].isoValue;
702 nextCp = (float)cpList[i + 1].isoValue;
706 GraphicsDevice.SetRenderTarget(cvdTarget);
707 GraphicsDevice.Clear(Color.Black);
710 Console.WriteLine(
"GraphicsDevice Render Target set to cvd target");
715 foreach (ModelMesh mesh
in cubeModel.Meshes)
717 foreach (ModelMeshPart mmp
in mesh.MeshParts)
719 mmp.Effect = tfWeightsShader;
721 Console.WriteLine(
"drawing...side.." + currentView);
728 Console.WriteLine(
"ERROR: " + e);
732 GraphicsDevice.SetRenderTarget(null);
734 cvdtf.setTFWeights(cvdTarget, i);
737 saveScreenshot(cvdTarget,
"cpweights" + i,
"png");
743 #region calculate and set cvd transfer function
753 #region simulate perception
755 #region calculate new?
771 #region instanciate Image class
772 if (simulatedImage == null)
778 #region assign shader
779 if (simulatedImage.RGBtoLab_Shader == null)
781 simulatedImage.RGBtoLab_Shader = sim_RGBtoLab_Shader;
782 simulatedImage.LMSShader = lMSShader;
783 simulatedImage.LabToRGB_Shader = sim_LabToRGB_Shader;
787 #region debug: set test image to simulate perception
793 simulatedImage.ImageToSimulate = dvrTexture;
797 simulatedImage.ImageToSimulate = sceneTarget;
804 simulatedImage.ImageToSimulate = dvrTexture;
809 simulatedImage.ImageToSimulate = sceneTarget;
815 simulatedImage.SimulatePerception(GraphicsDevice);
830 private void DrawSprite(Texture2D tex)
832 GraphicsDevice.Clear(Color.Black);
833 GraphicsDevice.BlendState = BlendState.Additive;
835 spriteBatch.Begin(0, BlendState.Additive, null, null, null, null);
837 spriteBatch.Draw(tex,
new Rectangle(0, 0, tex.Width, tex.Height), Color.Black);
848 protected override void Draw()
853 Console.WriteLine(
"Engine Draw Call " + drawcount);
857 GraphicsDevice.SetRenderTarget(null);
858 GraphicsDevice.Viewport = defaultViewport;
859 GraphicsDevice.Clear(Color.Black);
861 #region draw info text on start
862 if (GameProperties.Instance.showInfoText)
870 if (GameProperties.Instance.engineState.drawData && input != null)
873 #region save screenshot or recolor or simulate perception: set render target
874 if (GameProperties.Instance.saveView || GameProperties.Instance.recolor || GameProperties.Instance.simulate)
876 GraphicsDevice.SetRenderTarget(sceneTarget);
879 Console.WriteLine(
"GraphicsDevice Render Target set to scenetarget");
888 if (GameProperties.Instance.viewportMode.Equals(
ViewportMode.Split4))
891 if (GameProperties.Instance.enableCVDView)
894 #region top left->3d view
896 if(!GameProperties.Instance.recoloredView){
897 GraphicsDevice.SetRenderTarget(dvrTarget);
898 GraphicsDevice.Viewport = defaultViewport;
901 #region set parameters for rendering
902 GraphicsDevice.Clear(Color.Black);
903 GraphicsDevice.BlendState = BlendState.Additive;
904 GraphicsDevice.RasterizerState = RasterizerState.CullNone;
907 if (GameProperties.Instance.maximumIntensityProjection ==
true)
909 shader.CurrentTechnique = shader.Techniques[
"MaximumIntensity"];
913 GraphicsDevice.BlendState = BlendState.AlphaBlend;
914 GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
915 shader.CurrentTechnique = shader.Techniques[
"RayCastSimple"];
920 GraphicsDevice.SetRenderTarget(null);
921 dvrTexture = dvrTarget;
924 #region draw 3d sprite for the split screen
926 GraphicsDevice.Clear(Color.Black);
928 GraphicsDevice.Viewport = defaultViewport;
929 GraphicsDevice.DepthStencilState = DepthStencilState.None;
930 spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
931 spriteBatch.Draw(dvrTexture,
new Rectangle(viewports[0].X, viewports[0].Y, viewports[0].Width, viewports[0].Height), Color.White);
933 GraphicsDevice.DepthStencilState = DepthStencilState.Default;
964 #region top right-> recolored
966 if (GameProperties.Instance.recoloredView && recoloredImage.
RecoloredImage != null)
968 GraphicsDevice.Viewport = defaultViewport;
969 GraphicsDevice.DepthStencilState = DepthStencilState.None;
970 spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
971 spriteBatch.Draw(recoloredImage.
RecoloredImage,
new Rectangle(viewports[1].X, viewports[1].Y, viewports[1].Width, viewports[1].Height), Color.White);
973 GraphicsDevice.DepthStencilState = DepthStencilState.Default;
981 #region bottom left-> cvd
983 GraphicsDevice.Viewport = viewports[2];
984 if (GameProperties.Instance.cvdView && GameProperties.Instance.CVDTFOptimized)
986 GraphicsDevice.SetRenderTarget(null);
987 #region draw cvd friendly volume
988 GraphicsDevice.BlendState = BlendState.AlphaBlend;
989 GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
992 foreach (ModelMesh mesh
in cubeModel.Meshes)
994 foreach (ModelMeshPart mmp
in mesh.MeshParts)
996 mmp.Effect = CVDshader;
997 CVDshader.SetEffectParameter_CVD(input.VolumeData,
998 input.volumeGradients,
999 input.stepSize * input.scaleSteps,
1002 new Vector2(input.DataDimensions.X, input.DataDimensions.Y),
1003 recoloredImage.RotationToLMS,
1004 recoloredImage.RotationFromLMS);
1005 CVDshader.
SetEffectParameter(input.worldMatrix * cameras[0].ViewProjection, input.worldMatrix);
1009 initializeTextureFilter();
1015 Console.WriteLine(
"ERROR: " + e);
1023 #region bottom right-> simulated
1025 if (simulatedImage != null)
1027 GraphicsDevice.Viewport = defaultViewport;
1028 GraphicsDevice.DepthStencilState = DepthStencilState.None;
1029 spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
1030 spriteBatch.Draw(simulatedImage.
RecoloredImage,
new Rectangle(viewports[3].X, viewports[3].Y, viewports[3].Width, viewports[3].Height), Color.White);
1032 GraphicsDevice.DepthStencilState = DepthStencilState.Default;
1036 GraphicsDevice.Viewport = viewports[0];
1038 GraphicsDevice.Viewport = viewports[1];
1040 GraphicsDevice.Viewport = viewports[2];
1042 GraphicsDevice.Viewport = viewports[3];
1044 GraphicsDevice.Viewport = defaultViewport;
1053 #region set parameters for rendering
1054 GraphicsDevice.Clear(Color.Black);
1055 GraphicsDevice.BlendState = BlendState.Additive;
1056 GraphicsDevice.RasterizerState = RasterizerState.CullNone;
1059 for (
int current = 0; current < 4; current++)
1061 GraphicsDevice.Viewport = viewports[current];
1063 #region set correct shader technique
1066 input.slice = GameProperties.Instance.ySliceValue;
1067 shader.CurrentTechnique = shader.Techniques[
"RenderSlice"];
1069 else if (current == 2)
1071 input.slice = GameProperties.Instance.xSliceValue;
1072 shader.CurrentTechnique = shader.Techniques[
"RenderSlice"];
1074 else if (current == 3)
1076 input.slice = GameProperties.Instance.zSliceValue;
1077 shader.CurrentTechnique = shader.Techniques[
"RenderSlice"];
1081 if (GameProperties.Instance.maximumIntensityProjection ==
true)
1083 shader.CurrentTechnique = shader.Techniques[
"MaximumIntensity"];
1087 GraphicsDevice.BlendState = BlendState.AlphaBlend;
1088 GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
1089 shader.CurrentTechnique = shader.Techniques[
"RayCastSimple"];
1103 GraphicsDevice.Viewport = defaultViewport;
1116 else if(GameProperties.Instance.viewportMode.Equals(
ViewportMode.Single))
1121 Console.WriteLine(
"DRAWING DATA!");
1127 #region set parameters for rendering
1128 GraphicsDevice.Clear(Color.Black);
1129 GraphicsDevice.BlendState = BlendState.Additive;
1130 GraphicsDevice.RasterizerState = RasterizerState.CullNone;
1135 #region set correct shader technique
1136 if (currentView == 1)
1138 input.slice = GameProperties.Instance.ySliceValue;
1139 shader.CurrentTechnique = shader.Techniques[
"RenderSlice"];
1141 else if (currentView == 2)
1143 input.slice = GameProperties.Instance.xSliceValue;
1144 shader.CurrentTechnique = shader.Techniques[
"RenderSlice"];
1146 else if (currentView == 3)
1148 input.slice = GameProperties.Instance.zSliceValue;
1149 shader.CurrentTechnique = shader.Techniques[
"RenderSlice"];
1153 if (GameProperties.Instance.maximumIntensityProjection ==
true)
1155 shader.CurrentTechnique = shader.Techniques[
"MaximumIntensity"];
1159 GraphicsDevice.BlendState = BlendState.AlphaBlend;
1160 GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
1161 shader.CurrentTechnique = shader.Techniques[
"RayCastSimple"];
1167 Console.WriteLine(shader.CurrentTechnique.Name);
1176 if (!(GameProperties.Instance.recolor || GameProperties.Instance.simulate))
1186 #region save screenshot
1187 if (GameProperties.Instance.saveView)
1189 if (
string.IsNullOrEmpty(GameProperties.Instance.saveFilename))
1191 throw new ArgumentNullException(GameProperties.Instance.saveFilename);
1193 GraphicsDevice.SetRenderTarget(null);
1194 saveScreenshot(sceneTarget, GameProperties.Instance.saveFilename,
"png");
1195 GameProperties.Instance.saveView =
false;
1196 this.swapBuffers =
false;
1201 GameProperties.Instance.engineState.drawData =
false;
1205 Console.WriteLine(
"end of drawing");
1212 #region DrawVolume()
1223 Console.WriteLine(
"DrawVolume()");
1228 #region draw original volume
1231 foreach (ModelMesh mesh
in cubeModel.Meshes)
1233 foreach (ModelMeshPart mmp
in mesh.MeshParts)
1235 mmp.Effect = shader;
1236 shader.
SetEffectParameter(input.VolumeData, input.volumeGradients, input.stepSize * input.scaleSteps, input.iterations, side, input.scaleFactor, input.slice);
1237 shader.
SetEffectParameter(input.worldMatrix * cameras[side].ViewProjection, input.worldMatrix);
1242 Console.WriteLine(
"drawing...side.." + side);
1251 Console.WriteLine(
"ERROR: " + e);
1259 #region save screenshot
1260 private void saveScreenshot(Texture2D texture, String name, String ext)
1269 Console.WriteLine(
"saving " + name);
1273 if (!name.ElementAt(name.Length - 4).Equals(
".")) name = name +
"." + ext;
1274 FileStream stream = File.OpenWrite(name);
1278 texture.SaveAsPng(stream, texture.Width, texture.Height);
1281 texture.SaveAsJpeg(stream, texture.Width, texture.Height);
1284 if (name.ElementAt(name.Length - 4).Equals(
".")) name = name.Substring(0, name.Length - 4);
1285 name = name +
".png";
1286 texture.SaveAsPng(stream, texture.Width, texture.Height);
1293 Console.WriteLine(
"Save Screenshot: ");
1294 Console.WriteLine(e);
1301 private void drawText()
1305 Console.WriteLine(
"DRAWING TEXT!");
1307 GraphicsDevice.DepthStencilState = DepthStencilState.None;
1309 spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
1311 switch ((
int)GameProperties.Instance.viewMode)
1314 spriteBatch.DrawString(spriteBatchFont, (
"3D View"),
1315 new Vector2(50, 50), Color.Silver);
1318 spriteBatch.DrawString(spriteBatchFont, (
"Top View"),
1319 new Vector2(50, 50), Color.Silver);
1322 spriteBatch.DrawString(spriteBatchFont, (
"Side View"),
1323 new Vector2(50, 50), Color.Silver);
1326 spriteBatch.DrawString(spriteBatchFont, (
"Front View"),
1327 new Vector2(50,50), Color.Silver);
1330 spriteBatch.DrawString(spriteBatchFont, (
"3d View"),
1331 new Vector2(50, 50), Color.Silver);
1336 GraphicsDevice.DepthStencilState = DepthStencilState.Default;
1340 private void drawText(
int viewMode)
1344 Console.WriteLine(
"DRAWING TEXT!");
1346 GraphicsDevice.DepthStencilState = DepthStencilState.None;
1348 spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
1353 spriteBatch.DrawString(spriteBatchFont, (
"3D View"),
1354 new Vector2(50, 50), Color.Silver);
1357 spriteBatch.DrawString(spriteBatchFont, (
"Top View"),
1358 new Vector2(50, 50), Color.Silver);
1361 spriteBatch.DrawString(spriteBatchFont, (
"Side View"),
1362 new Vector2(50, 50), Color.Silver);
1365 spriteBatch.DrawString(spriteBatchFont, (
"Front View"),
1366 new Vector2(50, 50), Color.Silver);
1369 spriteBatch.DrawString(spriteBatchFont, (
"Recolored Image"),
1370 new Vector2(50, 50), Color.Silver);
1373 spriteBatch.DrawString(spriteBatchFont, (
"CVD View"),
1374 new Vector2(50, 50), Color.Silver);
1377 spriteBatch.DrawString(spriteBatchFont, (
"Simulated Perception"),
1378 new Vector2(50, 50), Color.Silver);
1381 spriteBatch.DrawString(spriteBatchFont, (
"3d View"),
1382 new Vector2(50, 50), Color.Silver);
1387 GraphicsDevice.DepthStencilState = DepthStencilState.Default;
1391 #region draw framework info
1392 private void drawInfo()
1399 Console.WriteLine(
"DRAWING INFO!");
1402 GraphicsDevice.Clear(Color.Black);
1403 GraphicsDevice.DepthStencilState = DepthStencilState.None;
1405 spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
1409 spriteBatch.Draw(frameworkInfo,
new Rectangle(0, 0, defaultViewport.Width, defaultViewport.Height), Color.White);
1416 spriteBatch.DrawString(spriteBatchFont, (
"Load model: File -> Open"),
1417 new Vector2(30, (Height * 0.5f)), Color.Black);
1418 spriteBatch.DrawString(spriteBatchFont, (
"Save Screenshot: File -> Save"),
1419 new Vector2(30, (Height * 0.5f) + 30), Color.Black);
1420 spriteBatch.DrawString(spriteBatchFont, (
"Load or Save TF: Functions -> Transferfunction->"),
1421 new Vector2(30, (Height * 0.5f) + 60), Color.Black);
1422 spriteBatch.DrawString(spriteBatchFont, (
"CVD DVR: Extended Features -> CVD"),
1423 new Vector2(30, (Height * 0.5f) + 90), Color.Black);
1424 spriteBatch.DrawString(spriteBatchFont, (
"3d View Camera: Left mouse button -> rotate, right mouse button->zoom"),
1425 new Vector2(30, (Height * 0.5f) + 120), Color.Black);
1428 GraphicsDevice.DepthStencilState = DepthStencilState.Default;
1436 #region additional Methods
1439 #region set initial control points
1440 void setInitialControlPoints()
1443 GameProperties.Instance.colorControlPoints.Clear();
1444 GameProperties.Instance.alphaControlPoints.Clear();
1445 GameProperties.Instance.colorControlPoints.Add(
new TransferControlPoint(0.0f, 0.0f, 0.0f, 20));
1446 GameProperties.Instance.colorControlPoints.Add(
new TransferControlPoint(0.0f, 0.0f, 0.0f, 250));
1447 GameProperties.Instance.colorControlPoints.Add(
new TransferControlPoint(1.0f, 0.0f, 0.0f, 50));
1448 GameProperties.Instance.colorControlPoints.Add(
new TransferControlPoint(0.0f, 1.0f, 0.0f, 150));
1449 GameProperties.Instance.colorControlPoints.Add(
new TransferControlPoint(0.0f, 0.0f, 1.0f, 200));
1450 GameProperties.Instance.alphaControlPoints.Add(
new TransferControlPoint(0.0f, 20));
1451 GameProperties.Instance.alphaControlPoints.Add(
new TransferControlPoint(0.0f, 250));
1452 GameProperties.Instance.alphaControlPoints.Add(
new TransferControlPoint(0.8f, 50));
1453 GameProperties.Instance.alphaControlPoints.Add(
new TransferControlPoint(1.0f, 150));
1454 GameProperties.Instance.alphaControlPoints.Add(
new TransferControlPoint(0.8f, 200));
1458 #region Initialize Texture Filter -> NEED THIS???
1459 private void initializeTextureFilter()
1466 Console.WriteLine(
"INITIALIZING TEXTURE FILTER");
1479 SamplerState stAnisotropic =
new SamplerState();
1480 stAnisotropic.Filter = TextureFilter.Anisotropic;
1481 GraphicsDevice.SamplerStates[0] = stAnisotropic;
1482 GraphicsDevice.SamplerStates[1] = stAnisotropic;
1483 GraphicsDevice.SamplerStates[2] = stAnisotropic;
1484 GraphicsDevice.SamplerStates[3] = stAnisotropic;
1485 GraphicsDevice.SamplerStates[4] = stAnisotropic;
1492 Console.WriteLine(
"-----------LOOK HERE:" + e);
1508 #region Control Properties Events
1509 protected override void OnSizeChanged(EventArgs e)
1511 if (this.Size.Width != lastSize[0] ||
this.Size.Height != lastSize[1])
1514 for (
int i = 0; i < cameras.Length; i++)
1516 lastSize[0] = this.Size.Width;
1517 lastSize[1] = this.Size.Height;
1518 defaultViewport.Width = this.Size.Width;
1519 defaultViewport.Height= this.Size.Height;
1526 Console.WriteLine(
"Size:" + Size);
1531 GameProperties.Instance.engineState.updateCamera =
true;
1532 GameProperties.Instance.engineState.updateData =
true;
1533 GameProperties.Instance.engineState.drawData =
true;
1535 base.OnSizeChanged(e);
1541 private void setViewports()
1543 viewports =
new Viewport[4];
1545 viewports[0] = defaultViewport;
1548 viewports[0].Width = defaultViewport.Width / 2;
1549 viewports[0].Height = defaultViewport.Height / 2;
1551 viewports[1] = defaultViewport;
1552 viewports[1].X = defaultViewport.Width / 2; ;
1554 viewports[1].Width = defaultViewport.Width / 2;
1555 viewports[1].Height = defaultViewport.Height / 2;
1557 viewports[2] = defaultViewport;
1559 viewports[2].Y = defaultViewport.Height / 2;
1560 viewports[2].Width = defaultViewport.Width / 2;
1561 viewports[2].Height = defaultViewport.Height / 2;
1563 viewports[3] = defaultViewport;
1564 viewports[3].X = defaultViewport.Width / 2;
1565 viewports[3].Y = defaultViewport.Height / 2;
1566 viewports[3].Width = defaultViewport.Width / 2;
1567 viewports[3].Height = defaultViewport.Height / 2;