Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Go Back  Xtreme Visual Basic Talk > > > Exploring 3D graphics with VB.Net, but without using DirectX or XNA


Reply
 
Thread Tools Display Modes
  #81  
Old 04-06-2015, 01:08 AM
passel's Avatar
passelExploring 3D graphics with VB.Net, but without using DirectX or XNA passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default


These extra flips in the processing I believe cloud the issue when trying to understand how the x,y,z values from the file relate to what you see on the screen.
For the purpose of investigation, I wanted Y in from the file to map directly to screen Y coordinates, and X from the file to map directly to X coordinates on the screen.
So initially before you do any rotations, you see the model's positive Y coordinates going down the screen as the screen coordinates do, and the negative and positive X values drawing to the left (smaller values) and right on the screen.
Z is impossible to tell, unrotated, but if you rotate around the X axis a bit, and move the selected vertex and see its value compared to the highlighted vertext location on the screen, you can determine that Z is positive toward you, which also appears to be "up", if you are looking at a model you can recognize as having an orientation associates with up, such as the impreza or astronaut.
Since the goal wast to try to make clearer how the x,y,z inputs got rotated to new x,y,z values, I commeneted out the existing code in Sub applyProjection(), which used quasi matrix pre-multiplication to lessen the amount of math in the loop.


There were some display issues which I fixed. Looke at the code below, from the Sub FillListBox().
Code:
      IniFile.MyArray.Add("V" & ": (" & Format(VertexObj.X, "##,##0.00") & _
           ", " & Format(VertexObj.X, "##,##0.00") & ", " & Format(VertexObj.X, "##,##0.00") & ")")
The above code is from the mod2c version, which has carried through form earlier. The early version had the same error. The coordinates should be X,Y,Z, but it actually prints out X,X,X.
Also, somewhere along the line, it lost the j index printing, "V" & j & ": (", the "& j" part is missing.
If you select to show points only, the code adds the vertex numbers and triangle numbers for the selected subobject on the screen.
Since the triangles are numbered stating at 1, not 0 in that display, I changed the List to also add 1 to the index, so the lists starts with T1.
I modified the position of the creation of the font, and have it select a size based on the scale factor. This worked well with the default image loaded from the resource, but makes the numbers too large if you have a small scale model to begin with, that needs a lot of scaling to get it up to a viewable size.
It would take more time to workout how to replicate those combined matrix values without the coordinate flipping things that might be in there, so I just reverted to the simple three sequential axis rotations.
A rotation around any axis is really just a 2d rotation, but with different pairs of coordinates being rotated.
So, I modified the code to to the three rotations separately.
Also, added code to translate the points in and out so that rotation around a subobject is an option.
Code:
  Public Sub applyProjection()
    Dim CR1 As Double = Cos(xTheta)      'Rotation around Z axis  (yaw)
    Dim SR1 As Double = Sin(xTheta)
    Dim CR2 As Double = 1 ' Cos(xTheta)   'Rotation around  Y axis  (roll in this case because of 3ds orientation
    Dim SR2 As Double = 0 ' Sin(xTheta)   'We're not doing roll rotations so, leave with "Identity" (no effect) values
    Dim CR3 As Double = Cos(yTheta)       'Rotation around X axis (pitch)
    Dim SR3 As Double = Sin(yTheta)       '

    Dim xi As Double        '  Hold Intermediate value of X
    Dim yi As Double        '  Hold Intermediate value of Y
    Dim zi As Double        '  Hold Intermediate value of Z

    Dim x, y, z As Double
    Dim xScr, yScr As Double

    points2DArray.Clear()
    For i = 0 To points3DArray.Count - 1 Step 1
      '  If i = 318 Then Stop
      VertexObj = points3DArray.Item(i)
      With VertexObj
        .X -= dx     'if we're rotationg around a subobject, dx,dy,dz will be set 
        .Y -= dy     'to translate the points, relative to the subobject (making subobject 0,0,0)
        .Z -= dz

        'Rotate X,Y around the Z axis (Yaw), same as 2D rotation of X,Y
        xi = CR1 * .X - SR1 * .Y
        yi = SR1 * .X + CR1 * .Y

        'Rotate x,z around the Y axis
        x = CR2 * xi + SR2 * .Z
        zi = CR2 * .Z - SR2 * xi

        'rotate y,z around the x axis
        y = CR3 * yi - SR3 * zi
        z = SR3 * yi + CR3 * zi

        .X += dx       'translate the input points back out to their original locations
        .Y += dy
        .Z += dz
      End With

      x += dx     'apply the same translation to the calculated output 2d point
      y += dy
      xScr = x * scaleFactor + xOffset
      yScr = y * scaleFactor + yOffset
      PointFObj.X = xScr
      PointFObj.Y = yScr
      points2DArray.Add(PointFObj)
    Next
  End Sub
To also support rotating around a subobject, added a center vertex to the SubObject3D class. The center vertex is calculated by picking the center point between the min and max coordinate found in each subobject axis.
Also, once the center vertex was calculated, it is added to the end of the Vertex array, so it will be rotated and translated along with all the rest of the points that make up the subobject.

Now, for a model moving off the screen when zooming, that is easily fixed. Since the zooming is done on the 2d array of points so increasing the zoom value will cause points to move outward from the 0,0 coordinate and if that 0,0 point is offset from the center of the screen then points will appear to move off in a direction as the model expands.
If you would rather always zoom around the middle of the screen you just need to determine how far the xOffset and yOffset are from the center drawing point before you zoom. Then after you zoom, multiply the distance by the current zoomfactor, and move the center position to that point. This will keep whatever point is in the center, in the center, as you move the 0,0 offset to keep the center window point in the center of the window.
Code:
'before-----
  Private Sub NumericUpDown_Scale_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown_Scale.ValueChanged
    scaleFactor = NumericUpDown_Scale.Value
    PictureBox_Render.Invalidate()
  End Sub

'after-----
   Private Sub NumericUpDown_Scale_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown_Scale.ValueChanged
    Dim dx As Single = (xOffset - DrawingCenter.X) / scaleFactor
    Dim dy As Single = (yOffset - DrawingCenter.Y) / scaleFactor

    scaleFactor = NumericUpDown_Scale.Value
    xOffset = DrawingCenter.X + dx * scaleFactor
    yOffset = DrawingCenter.Y + dy * scaleFactor
    renderProcess()
  End Sub
Also changed the renderProcess to be called outside the Paint event, but have it call the Picture.Invalidate to redraw whenever we call it.
Changed the highlighting color from yellow, to a semi-transparent yellow, so that the object isn't fully saturated when highlighted.
Added the hightlighting of the object to also happen in the "points only" mode, to better identify the shape if looking at a particular subobject in points only mode.
Set the minimum value on the NumericUpDown to 0.1 to prevent scrolling down to 0 and causing errors.
Whenever you click in the picturebox, automatically set focus to numericUpDown so scrollwheel is able to zoom without having to go out and click on the Scale Control first.

Didn't care for having to go out and click on the radio buttons to switch between "moving mode" mouse dragging, and "rotation mode" mouse dragging.
If you drag with the left mouse button you're moving the xOffset,yOffset.
If you drag with the right mouse button, you're changing the rotation values (xTheta,yTheta).
Since it draws faster (less things to draw), defaulted BackFace Culling to checked.


In the attached image, the labeling capability that was already there (with some updates) is shown.
You can see the drawing zoomed in on box20, with "View points only" selection and "Object Selection Highlighting".
In "view points only" mode, the triangles are numbered and will be highlighted when selected from the Triangle menu.
You can see which vetexes are associated with the triangle in the triangle menu, and if you select the vertices in the vertices menu, the vertex will be marked with a small blue circle.
In the image you can see Triangle 1 (T1) is selected and highlighted in the render. The three corners for triangle 1 are vetices 8,2 and 0, and 2 is selected in the Vertices menu, and marked with a small blue circle.
If you run the program you can see the adjacent triangles are 11,13 and 14, and that triangles 1, 13 and 14 should all show vertex 8 as one of their vertices.

Actually, a week ago, I did add a quick test of using .Net Serialization to output an XML file of the subObjectArray just as an exercise since I hadn't used XML serialization before. I left the code in (Sub SaveXmlXfer) but it isn't connected to anything. To test it, I just called it in place of SaveTransfer call in the btnSaveIni_Click event handler.
It was a lot less code of course, but has two major drawbacks.
1. It is a lot larger in size than the more compact ini (and Json I presume) files.
2. If you wanted to hand edit the file, the large array of identical vertex nodes (not content of the node) would make finding where you wanted make changes difficult. To make it practical, you would have to add another member to the vertex class, like an Integer, that could be set to an incrementing number as the vertices were read in. They would then be in the XML file and could be found. but at the cost of extra data in the class.

I guess I also left the code to read the XML back in (Sub Button1_Click) although I later removed the button. Got a big Red X when I tried to render, so there are probably other things that need to be filled in. Didn't pursue it any further.
Attached Images
File Type: png 3dsFile_box20.png (70.0 KB, 5 views)
Attached Files
File Type: zip 3DS_file_to_Ini_file_converter2e1.zip (364.6 KB, 14 views)
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 04-06-2015 at 04:52 PM. Reason: Forgot to add the picture
Reply With Quote
  #82  
Old 04-06-2015, 07:18 AM
passel's Avatar
passelExploring 3D graphics with VB.Net, but without using DirectX or XNA passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default

Quote:
Originally Posted by dotnetwrassler View Post
...
You are right that WPF (Windows Presentation Foundation) can do 3D (including texture wrapping), but I've heard all these rumors about WPF dying off for some time now..
I wonder how quickly it will die off. A lot of old MS stuff is still hanging out, and there is some software most of us use everyday that is built on WPF.
Quote:
Visual Studio has had support for High-DPI modes for some time. Visual Studio 2010 adopted WPF as its primary UI framework, which addressed many existing high-DPI issues.
http://blogs.msdn.com/b/visualstudio...udio-2013.aspx
On the other hand, it does appear to be another Latin language, in that support might be there, if can be read and written, but is not undergoing any active development. I guess I wouldn't hesitate to use it, if I had the interest or need, but haven't gone there yet.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #83  
Old 04-06-2015, 02:46 PM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default passel - triple post!

Quote:
Originally Posted by passel
One of the main issues with posting is the large amount of things that could be posted about coordinates systems, rotations, problems with the code, etc. and it is hard for me to decide what do I really have the energy to get into.
But, as it is the start of another week, I need to choose at least a few things and get them posted, and let other stuff go, or I'll put off posting indefinitely.
Plus the fact is coordinate systems is just such a huge topic - both in terms of math and coding.
I have been researching this off and on for several weeks but I still feel I have barely brushed against the surface of the topic.

Quote:
Originally Posted by passel
Now, for a model moving off the screen when zooming, that is easily fixed.
As always - easy for you!
I looked at the Baffle Calculator code that CodeCruncher worked on and it didn't seem an easy fix for him either.

Quote:
These extra flips in the processing I believe cloud the issue when trying to understand how the x,y,z values from the file relate to what you see on the screen.
There was some definite clouding for me..

Quote:
If you wanted to do rotations similar to the Import3DS code, that would be just using the mouse to do the same adjustments to the "Rotate scene" capabilities as was done in posts #28/29.
What I really (ultimately) want is quaternion rotation (to break the "lock" between world coordinates and device coordinates),
but this is helpful info because 3DSImport and boops boops code will eventually (hopefully) be merged..

Quote:
Originally Posted by passel
Actually, a week ago, I did add a quick test of using .Net Serialization to output an XML file of the subObjectArray
just as an exercise since I hadn't used XML serialization before.
It's hard for me to imagine there is anything visual basic related you haven't done before.

I will download the attachment and try to relate it to the two long posts.
It may take me some time to understand what you have done (are doing).


Re: WPF
As for WPF, I think tying it in with Silverlight was the biggest longevity issue.

Many people (like developers) saw Silverlight as equaling "Microsoft Flash", and they really didn't see a reason for Microsoft
to be duplicating what already existed (what Adobe had already made successful).
Microsoft "me-too-ism" doesn't always work successfully (e.g. Zune as the "iPod Killer").

Personally if Microsoft had to duplicate something of Adobe's - try "Microsoft Photoshop",
so we can get a good Gaussian Blur and bicubic resampling code (inside some Microsoft Windows dlls).

Anyway, the trend I see now is for HTML5 (and CSS3) to supplant Flash long term.


Right now I heads down into attempting new gFill classes for boops boops code and (you guessed it) things aren't going well.
I keep getting shadowing errors (something I've never really had to deal with before).


Wrapping up (before I have to get to work):
It makes me very happy to see you've "come back" to posting in this thread (even if you hadn't posted any code).

I thought it was because you were getting disgusted with slow pace/efforts that you were staying away.
Thanks.

Last edited by dotnetwrassler; 04-06-2015 at 02:53 PM.
Reply With Quote
  #84  
Old 04-06-2015, 05:04 PM
passel's Avatar
passelExploring 3D graphics with VB.Net, but without using DirectX or XNA passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default

Quote:
Originally Posted by passel View Post
...
In the attached image, the labeling capability that was already there (with some updates) is shown.
You can see the drawing zoomed in on box20, with "View points only" selection and "Object Selection Highlighting".
...
I realized when looking back I had a paragraph referring to the "attached image" and I hadn't attached the image.
So, I've now fixed that

But, now, this post seems too short just for that, so I should throw something in for entertainment value.

Since you were showing the Rubik's cube type setup in one of the posts, I dug around in some old drives looking for some VB3 that I played around with doing some 3-D type stuff. It was a follow on to the original VB3 code version (before the plgblt was added in the VB6 version) of the code found in this post almost 10 years ago. Since the vb6 version is in the neighborhood of 10 years or more old, I'm not sure when I did the original VB3 versions.
That code was "Matrix3", and the attached code is "Matix4".

Instead of having the blocks in a plane as the original code did, I set up the 3x3x3 setup of the original Rubik's cube. I also scattered some points randomly around in a "spherical shell", and played with changing color, and size based on depth. A basic mish-mash of different ideas. I added buttons to rotate a couple of the 3x3 cubes around in a single plane. The axis rotated around for those two tiers of cubes was easy because all the points that make up the "quads" are contiguous. But later, I played around with rotating around another axis, and that was more challenging since the points were not contiguous. And if you rotated around one axis and then another, that wouldn't work at all since the infrastructure to track the motion of individual cubes was not there. The method of manipulating the cubes needs to be completely reworked if really trying to emulate a Rubik's cube motion.

Anyway, the VB3 version of the code was a little inconvenient to work with, since I had to run an older operating system in a Virtual machine to execute the 16-bit code. So I ported the VB3 to VB6 a few weeks ago, to remember how I did the rotations in that code, and whether I would overhaul it into .Net and actually figure out how to model a Rubik's cube motion. I don't know, probably won't any time soon.

But I can attach the VB6 version so you can be entertained by the old VB3 mess that it is. The code had the three drag area from the other code for rotation, but had dragging in the window itself to spin the block around. Right mouse button to stop the spinning. (little buttons at the end of the bars to stop spinning in one axis). I added to the VB6 version, that when you drag on the bottom bar, it increments the "vertex" index, and draws a spot at that point, as I was investigating what points I would have to rotated to move the blocks around the other two axis, which had dis-contiguous points in the array.
I also liked turning off the block drawing, and turning on a Circle, and change the background to Gray or black to get the impression of circles orbiting a sphere, with light being projected on them from the sphere (so were dark in front, and light behind the sphere). Just playing around.
Attached Files
File Type: zip Matrix4_vb3Port.zip (9.8 KB, 9 views)
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 04-06-2015 at 05:56 PM.
Reply With Quote
  #85  
Old 04-06-2015, 11:47 PM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default Passel's attempts to produce 3D graphics using VB go way back..

Quote:
Originally Posted by passel
But later, I played around with rotating around another axis, and that was more challenging since the points were not contiguous. And if you rotated around one axis and then another, that wouldn't work at all since the infrastructure to track the motion of individual cubes was not there. The method of manipulating the cubes needs to be completely reworked if really trying to emulate a Rubik's cube motion.
Thanks for posting your efforts at 3D under VB3.
I'm always glad when your old projects finally see the light of day.

I knew about the matrix3 attachment, but this is definitely more advanced (refined).

So even back in VB3/6 time you were playing around with 3D!
I bet you even tried 3D texturemapping with plgblt.


So couldn't you get the 'Sub rotateTop()' to work at all (due to cube tracking inadequacies or "dis-contiguous points in the array"?

--if you make the Command2(2) Top button visible and try to use it some strange things happen.

I see these lines inside that Sub:
Code:
      For r = 0 To 2    'update the local matrix
        For c = 0 To 2
          matT(c, r) = matZt(c, 0) * matYt(0, r) + matZt(c, 1) * matYt(1, r) + matZt(c, 2) * matYt(2, r)
        Next
      Next
..and yet there is also an 'Sub UpdateMatrix()' that looks like it was gnarly to figure out.

The interesting thing for me is the z-sorting of points that make up the individual sub-cubes,
because you would have had to make this all up yourself --there was nothing in-built to VB3-6 to build on to do this..


Based on a quick look, it doesn't look like it has any hidden surface removal, though (unless I'm mistaken).


Quote:
Originally Posted by passel

To make it practical, you would have to add another member to the vertex class, like an Integer, that could be set to an incrementing number as the vertices were read in.

They would then be in the XML file and could be found. but at the cost of extra data in the class.
This reading in the incrementing vertices is just what I'm having trouble with right now.

I want to make it a List<T>, but it just feels to me as if an array would be easier.

The array index would be the vertex index (you know what I mean)..so instead of using For Each..Next to loop through a collection
you could just to an incrementing integer loop through the array.

Maybe I'm just stuck in old VB6 retro mode for thinking that though..

As regards the screenshot - I already knew about that code being built in - but your latest update now gives it new meaning because
of the new Sub-Model pivot rotation capability.

Which brings up a question (probably a stupid one):
If you had to rotate by a precise amount - say 47.5 degrees in any of the axis of rotation - how would you do it?
Would you use one of your "picturebox controls as un-ranged sliders" setups, but with a floating label over the slider thumb to allow an exact setting?

I know the ApplyProjection is using Trig (it has Sin/Cos), but there is no code right now to output degrees/radians.
I know it's probably just a simple conversion, but..

Another slight tweak I thought of looking at the code (and using the cone.3ds model):
Putting an If..then in to clamp the font (which is tied in with the scale factor) so it doesn't get too scaled up (big).

I also noticed (for the first time) that the cone model has a center vertex that is not being used in connection with making a triangle face.

It's just sitting there in the middle of the model - free floating.
Maybe it was used by the model maker to visualize the center of rotation?


A final thought - based on the scalefactor the model can appear too small (just a blob of color) or too large (zoomed in to much to see anything but a few vertices/faces).

Unless there is some way to "smart scale" (based on how what scale factor
it takes for the model's "bounding box" to take up 90% of the picturebox area),
it might be prudent to include the scale factor with the serialization.



I'm glad you got the big red X when you tried deserialization.

I'm reading all this stuff about how you have to "decorate" with attributes (like "<Serializable()> _").

Do I need to worry about "Attributes That Control XML Serialization"?

The example here doesn't seem to bad, but I could imagine where deserializing objects could be tricky because it involves some casting to type, right?

Give me a simple flat (non-hierarchical) ini file to serialize to any day.

Last edited by dotnetwrassler; 04-06-2015 at 11:58 PM.
Reply With Quote
  #86  
Old 04-07-2015, 07:20 AM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default Had a couple notions last night..

Now that the centering when scaling issue has been solved, it upgrades the viability (and future potential) of the 3DSImport code tremendously.

In fact I think the next version should be called 3DS-VE (Viewer-Editor) or something else.
After all the current coding is no longer just importing/viewing,
it's also exporting/serializing as well at this point.

Here's the lines I'm looking at:
Code:
If currentSubObjectIndex = ComboBox_SubObjects.SelectedIndex And CheckBox_Selection.Checked Then
	Dim curvePointsa As PointF() = {PointFObj1, PointFObj2, PointFObj3}
	e.Graphics.FillPolygon(TransLucentFillBrush, curvePointsa, Drawing2D.FillMode.Alternate)
	If ListBox_Triangle.SelectedIndex = i Then
		e.Graphics.FillPolygon(New SolidBrush(Color.Aquamarine), curvePointsa)
		e.Graphics.DrawLine(penSelectedTriangle, PointFObj1, PointFObj2)
		e.Graphics.DrawLine(penSelectedTriangle, PointFObj2, PointFObj3)
		e.Graphics.DrawLine(penSelectedTriangle, PointFObj3, PointFObj1)
	End If
	Dim tmpPoint As PointF = points2DArray.Item(ListBox_Vertex.SelectedIndex)
	Dim dif As Integer = 3
	e.Graphics.FillEllipse(New SolidBrush(Color.Blue), New RectangleF(tmpPoint.X - dif, tmpPoint.Y - dif, 2 * dif, 2 * dif))
End If 
Especially the FillPolygon and FillEllipse lines.


So to move away from a wireframe-based render:
Couldn't FillPolygon be use as an alpha tint fill for all the triangles in the model (still keeping a slightly darker hue for the selected triangle)?
Sort of like the boops boops code alpha tints all its 3D Faces?


To potentially add some editing capability:
The FillEllipse (which makes the blue "dot" representing the selected vertex)...couldn't that be used as an edit point?

For instance if you use the ALT key as a detectable hot key (e.Alt in Form1_KeyDown to set blnAllowEdit),
couldn't you do a crude GetPixel detect to allow dragging:
Code:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, _
           ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
      Dim color1 As System.Drawing.Color
      color1 = CType(PB1.Image, Bitmap).GetPixel(e.X, e.Y)
      If color = Color.Blue
        'allow dragging here - maybe change cursor to crosshairs..
      End If
End Sub
..that allows adjusting the vertex to a new value internally (points2DArray)?

If you didn't want the crosshairs, then maybe the blue dot could turn into some kind of
regular cursor draggable graphic (a small rect or slightly larger circle-ellipse).

Anyway..nothing pressing..just some brainstorming notes for maybe later..


Quote:
Edit1:
I was thinking (a little later --after posting the above), about how far we've come in transitioning from VB6 to VB.Net.

I've attached some old VB6 code for "waggling" of 3D color-filled cubes.
Back in the day it stood out as "advanced" 3D graphics.

Compare it (and the VB6 code passel posted above) with what this thread has been able to accomplish.

These two VB6 code examples don't:
1.) Use alpha (partially transparent) color tinting
2.) Use any shapes but cubes
3.) Use texturemapping (like this VB6 texture mapped cube code)
4.) Use a spherical coordinate system
5.) Use any multi-threading code (parallel-for, BackgroundWorker/Async tasks, BufferedGraphics, etc)

Back when the transition from VB6 to VB.Net I resisted the change because it just didn't seem to be a "value-added" proposition.

It's only now..ten years or more down the road..that I finally realize (see) a bit of the potential that VB.Net opened up for VB programmers.

The realization of that potential is happening.
Right here. Right now --in this thread.

Things like:
Texture-mapping a tetrahedron (with 4 point distortion), spherical wrapping, quaternion rotation, alpha tinting all 5 platonic solids..and still have drag-editable points!

Loading models (with thousands of vertices/faces) of dragons and DNA molecules! (screenshots attached)

It's a shame that the xvbt forum is so slow (hollowed out?) that few are around to participate
in what could be one of the most significant VB.Net graphics threads in the forum's history.

Maybe that's overblown..but I still had to take a moment to appreciate how far things have come.

Last edited by dotnetwrassler; 04-07-2015 at 01:25 PM.
Reply With Quote
  #87  
Old 04-08-2015, 01:07 AM
passel's Avatar
passelExploring 3D graphics with VB.Net, but without using DirectX or XNA passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default

Quote:
Originally Posted by dotnetwrassler View Post
...
I knew about the matrix3 attachment, but this is definitely more advanced (refined).
Different anyway. Since this started with the matrix3 baseline, there is an amount of dead code in matrix4 that was only applicable to the matrix3 baseline, but not removed.
Quote:
Originally Posted by dotnetwrassler View Post
...
So even back in VB3/6 time you were playing around with 3D!
I bet you even tried 3D texturemapping with plgblt.
Actually, the Matrix3 code has that texturemapping using plgblt.
The VB3 version didn't of course, but since plgblt was available when I ported to VB6, and it supported masks, the matrix3 port was a good place to try a few textures and a mask for the sides of the blocks.

Quote:
Originally Posted by dotnetwrassler View Post
...
So couldn't you get the 'Sub rotateTop()' to work at all (due to cube tracking inadequacies or "dis-contiguous points in the array"?
I think what it does now is probably worse than my first version. I only played with it for awhile and decided the effort in its current state wasn't really worth it, so hid the button. Just figuring out how to manage keeping track of the small cube's positions and orientations as they move around within the big cube's area is a challenge in itself, without even considering the rendering. So the decision is to not spend anymore time on it the way it is. First figure out how to keep track of which cubes are moving around what positions as the twist and turn between different planes is a good problem to work out first. Then worry about the rendering method.
Quote:
Originally Posted by dotnetwrassler View Post
...
...and yet there is also an 'Sub UpdateMatrix()' that looks like it was gnarly to figure out.
I don't really remember if it was fairly difficult to work out originally. But from the number of versions of lines commented out, I know that even if the basic rotations came together quickly, the extra lines are there from experiments to try to see if there were better ways, or to try to work around glitches.
Essentially you have the three "2D" rotations around the X,Y and Z axis, then UpdateMatrix, combines those three into a single matrix to convert all the points from their original locations, xo, yo... to the final rotated positions (new) xn, yn, etc.
Quote:
Originally Posted by dotnetwrassler View Post
...
Based on a quick look, it doesn't look like it has any hidden surface removal, though (unless I'm mistaken).
In matrix3, all the blocks had the same orientation, and was an isometric projection, so at most you could only see three sides of a block, and the side you could see were the same for all blocks (no perspective projection, so you can't see the right side of blocks on the left, and left side of blocks on the right).
Given that was the case, an arbitrary block (cube) tested before drawing to see which three sides could be seen, and flag those as needing be drawn.
If you could see the top, you don't draw the bottom. If you see the left, you don't draw the right, if you see the back, don't draw the front.
So, there were three sets of test like the one below, which checked the depth of opposite sides of the cube (left/right, top/bottom, front/back), and the one closest was the one you could see (so set True) and the other false.
Code:
'...
  If zn(1) > zn(2) Then
    drquad(0) = True
    drquad(4) = False
  Else
    drquad(0) = False
    drquad(4) = True
  End If
'...
In the case of matrix4, now with two sections of cubes that can rotate, that code (even though still there) is not used. The decision of which "quads" to draw has to be done in the draw routine before drawing each quad. So, this is along the lines of a traditional culling method, although the code I had may not look that familiar.
In the DrawTree sub, before drawing the quad, it picks three corners of the quad and then does a series of tests to determine the orientation of the three corners to determine if they are in clockwise or counter-clockwise order and sets "drawit" to True if the quad should be drawn (forward facing).
Code:
  X0 = xn(QuadList(pidx).corner(0))
  X1 = xn(QuadList(pidx).corner(1))
  X2 = xn(QuadList(pidx).corner(2))
  Y0 = yn(QuadList(pidx).corner(0))
  Y1 = yn(QuadList(pidx).corner(1))
  Y2 = yn(QuadList(pidx).corner(2))

  If (X0 - X1) <> 0 Then
    
    d = Sgn(X0 - X1)
    s = (Y1 - Y0) / (X1 - X0)
    yt = Y0 + ((X2 - X0) * s)
    If s > 0 Then
      If d > 0 Then
        If Y2 < yt Then drawit = True
      Else
        If Y2 > yt Then drawit = True
      End If
    Else
      If d > 0 Then
        If Y2 < yt Then drawit = True
'....etc..
Of course, I liked the short bit of code that Import3DS does to cull the backsides, so I put that in in place of the above logic, and it worked fine.
Code:
  X0 = xn(QuadList(pidx).corner(0))
  X1 = xn(QuadList(pidx).corner(1))
  X2 = xn(QuadList(pidx).corner(2))
  Y0 = yn(QuadList(pidx).corner(0))
  Y1 = yn(QuadList(pidx).corner(1))
  Y2 = yn(QuadList(pidx).corner(2))

 Dim db As Double
 db = (X0 - X2) * (Y1 - Y2) - (Y0 - Y2) * (X1 - X2)
 drawit = db > 0#
Much nicer code. And its easy to change that one line to "drawit = db < 0#" to reverse the case to see all the stuff you weren't drawing. That actually looks kind of interesting.
Quote:
Originally Posted by dotnetwrassler View Post
...
I want to make it a List<T>, but it just feels to me as if an array would be easier.
The array index would be the vertex index (you know what I mean)..so instead of using For Each..Next to loop through a collection
you could just to an incrementing integer loop through the array.
...
Actually you can still increment through the list like that, and the code is doing that (I didn't change the way the code was accessing the arraylist when I converted the arrayList to a List(Of T).
Code:
    points2DArray.Clear()
    For i = 0 To points3DArray.Count - 1 Step 1
      '  If i = 318 Then Stop
      VertexObj = points3DArray.Item(i)
'....
The way the code was using i to loop the arrayList still works for a List(Of T). In the above, you can see that at some point in an investigation I wanted to break when I started processing Vertex 318.
But, while still compatible and convenient, I believe that it is much slower than using For Each. The list is a linked list, and using For Each the code knows to just zip through each item one after the other. If you specify the index, I think for each access it has to trace through the links from the beginning to get to the index specified.
I was already thinking that using the List(Of T) was good for gathering the data into a list, but since the list wouldn't normally be changed in size, the SubObject type could actually contain an array, and the List(Of T).ToArray method would be used to copy the list to the array for faster indexed access. But I think in .Net, even using For Each on an array of objects is quicker than looping by index, since there may be some calculation involved with a index subscript access. Probably should just keep the List(Of T), use For Each everywhere, but still have index access when needed, at the cost of some loss in speed.
Quote:
Originally Posted by dotnetwrassler View Post
...
Which brings up a question (probably a stupid one):
If you had to rotate by a precise amount - say 47.5 degrees in any of the axis of rotation - how would you do it?
Would you use one of your "picturebox controls as un-ranged sliders" setups, but with a floating label over the slider thumb to allow an exact setting?
Whatever floats your boat. Right now only two axis are being rotated. The values of xTheta and yTheta could be converted from radians to degrees and displayed to show what the current rotations are for whichever two axis they are manipulating. You can also set them in whatever manner you choose.
Quote:
Originally Posted by dotnetwrassler View Post
...
Another slight tweak I thought of looking at the code (and using the cone.3ds model):
Putting an If..then in to clamp the font (which is tied in with the scale factor) so it doesn't get too scaled up (big).
...A final thought - based on the scalefactor the model can appear too small (just a blob of color) or too large (zoomed in to much to see anything but a few vertices/faces)...
I believe I mentioned the Font issue. The original code didn't scale the font, just used 6 point, which look very small when zoomed out. But I also realize that the range of values for the model needs to be considered, not just the scale factor. I almost set the font back to a fixed 8 point before posting, but obviously didn't.
Yes, it should be simple to just track the maximum extents of the model coordinates (probably only need to do X and Y) when read in (already doing that for the SubObjects), then set the scale factor based on the min/max delta and window area. Also once you have the min/max delta for the whole model, set a "model center" value and offset the 0,0 point initially to put that model center in the center of the window. The main reason I didn't do that is I wanted to know if the model's 0,0,0 point was "out in left field", since that would be the point rotations occur. Don't know why some models would be offset from 0,0,0 that far. Of course, if we displayed these values, then we could show that we were currently not rotating around 0,0,0, but some other point in the model's coordinate space.
Quote:
Originally Posted by dotnetwrassler View Post
...
..that allows adjusting the vertex to a new value internally (points2DArray)?
points2DArray is "ephemeral". It is regenerated all the time from the original points whenever you manipulate the image (scaling, rotations). It used to be regenerated everytime you painted the picturebox, but I moved the renderpoints call out of the paint event so that it could be called directly to modify the points in certain cases. In other cases (various drawing option selection), there is no need to regenerate the points...10000 limit
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 04-08-2015 at 01:21 AM.
Reply With Quote
  #88  
Old 04-08-2015, 10:55 AM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default Re: passel's comments

Thanks for the 10,000 post.
I really wasn't expecting that detailed a reply.

Quote:
Of course, I liked the short bit of code that Import3DS does to cull the backsides, so I put that in in place of the above logic, and it worked fine.

Much nicer code. And its easy to change that one line to "drawit = db < 0#" to reverse the case to see all the stuff you weren't drawing. That actually looks kind of interesting.
So the Import3DS code helped you --I knew if you really took a look at the code you find something interesting parts.

Quote:
Originally Posted by passel [edited
But, while still compatible and convenient...probably should just keep the List(Of T), use For Each everywhere, but still have index access when needed, at the cost of some loss in speed.
I could days and days reading through the MSDN and not get an analysis like that!
When you say "I believe" and I think, it sounds like you wish you knew more about these .Net structures work internally.
Have you ever used that Reflector tool?
I've heard it using it can be used to "probe" for detailed information about .Net internals,
but it requires just as detailed an "understanding" of such things to make any heads or tails of what it is trying to tell you.

Quote:
Originally Posted by passel
The values of xTheta and yTheta could be converted from radians to degrees and displayed to show what the current rotations are for whichever two axis they are manipulating.
That's the code I was looking for(the conversion code)..but didn't find. I guess I have to look around for a radians to degrees code snippet.

Quote:
Originally Posted by passel
But I also realize that the range of values for the model needs to be considered, not just the scale factor.
That's why I (with purpose) picked the model I did, so you would realize that.
I also adjusted the source code to get some the screenshots I posted.
The font would have been much bigger if I had not.

Quote:
Originally Posted by passel
Yes, it should be simple to just track the maximum extents of the model coordinates (probably only need to do X and Y) when read in (already doing that for the SubObjects), then set the scale factor based on the min/max delta and window area.
As always, "simple" for you..

Quote:
Originally Posted by passel
Also once you have the min/max delta for the whole model, set a "model center" value and offset the 0,0 point initially to put that model center in the center of the window. The main reason I didn't do that is I wanted to know if the model's 0,0,0 point was "out in left field", since that would be the point rotations occur. Don't know why some models would be offset from 0,0,0 that far.
I'm still trying to understand how "model space" differs from world coordinate space,
but please don't try to explain...I just have to keep working with the both sets of codes (Imprt3DS and boops boops code) and eventually I hope things may sort themselves out in my head.

Quote:
Originally Posted by passel
Of course, if we displayed these values, then we could show that we were currently not rotating around 0,0,0, but some other point in the model's coordinate space.
Displaying at least some values would help with whoever looks at this code and has to figure out what manipulations are going on with it's model space.
I even though of putting one of the twisty triangles debug panels I added to the PS6 attachment to the 3DS code just to have some room to actively display some debug values at runtime.

Quote:
Originally Posted by passel

points2DArray is "ephemeral"... I moved the renderpoints call out of the paint event so that it could be called directly to modify the points in certain cases.
I realize it's sort of "icing on the cake" (and not tied in with the actual vertices information displayed in the listbox).

So if I wanted to drag one of the blue points I have to modify the vertices information directly...some models have thousands of points--I guess I will have to pick my model carefully if I hope to attempt this..

However, yes, I didn't wonder what the purpose of the points2DArray code modification was..thanks for clarifying your intent (it's not always obvious).

Last edited by dotnetwrassler; 04-08-2015 at 11:12 AM.
Reply With Quote
  #89  
Old 04-08-2015, 11:07 AM
PlausiblyDamp's Avatar
PlausiblyDampExploring 3D graphics with VB.Net, but without using DirectX or XNA PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Unless it has changed in recent versions the List(Of ...) uses arrays internally so most access is similar in performance to arrays - including the hit of resizing (although the List type doesn't resize on every addition).

There is a LinkedList(Of ...) generic type that is a doubly linked list so adding, inserting etc. all give very good performance and linear access is also very good. Random access on the other hand would suffer due to the internal structure but that isn't likely to be an issue in this case as nearly all (all?) of the access is done sequentially anyway.

The LinkedList class is also serializable using the built in XML and JSON support
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #90  
Old 04-08-2015, 11:17 AM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default Re: PD's info

Quote:
Originally Posted by PlausiblyDamp
There is a LinkedList(Of ...) generic type that is a doubly linked list..
I saw the LinkedList Class as I was exploring the MSDN, and from what passel said: that List<T> is a linked list (internally)...it left me wondering
what the difference was between them --one is doubly linked. Good info.
Part of dealing with "managed code" is that it's hard to see/understand (a lot of times) what's going on inside .Net.

Passel, in the past, has had several VB6 projects that have used linked lists.
He seems to like using them.
Based on his VB6 code is my only working knowledge of how they function up to this point.


Quote:
Originally Posted by PlausiblyDamp
The LinkedList class is also serializable using the built in XML..
From the serialization links I've posted in past posts (hopefully you are reading through, and trying to keep up with, all those verbose thread posts),
I hope you know (realize) I've gone through most of the MSDN pages dealing with XML serialization and even looked at some of the associated vbHelper code.

So far things aren't really "sinking in", though.

So if you have any links to simple tutorials on this that could help serialize (to xml)
the 3D classes that boops boops code is using, I might be willing to consider xml versus ini
if I can get deal with angle bracketed nesting hierarchy that is generated..

Last edited by dotnetwrassler; 04-08-2015 at 11:33 AM.
Reply With Quote
  #91  
Old 04-08-2015, 03:16 PM
passel's Avatar
passelExploring 3D graphics with VB.Net, but without using DirectX or XNA passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default

Quote:
Originally Posted by dotnetwrassler View Post
...
When you say "I believe" and I think, it sounds like you wish you knew more about these .Net structures work internally.
Have you ever used that Reflector tool?
I've heard it using it can be used to "probe" for detailed information about .Net internals,
but it requires just as detailed an "understanding" of such things to make any heads or tails of what it is trying to tell you.
...
In this case I said I believe and I think because I'm depending on recollections that haven't been confirmed, so could be wrong. I'm remembering some discussions on updating Lists and Listboxes, and Dictionaries, and speed differences, but some of that could be VB6 related, and not VB.Net.
And, as PlausiblyDamp has indicated, I was incorrect in the case of Simple List(Of T) case. It is an array.
But you don't have to use Reflector to investigate that. A number of months ago Microsoft said they were making .Net Framework (2013 Community) open, so you can actually just look at the source code for a lot of the .Net System classes (for Framework 4.5.2) (which are written in C# for the most part).
For instance, the aforementioned List(Of T) class:
http://referencesource.microsoft.com...eneric/list.cs
Quote:
// Implements a variable-size List that uses an array of objects to store the
// elements. A List has a capacity, which is the allocated length
// of the internal array. As elements are added to a List, the capacity
// of the List is automatically increased as required by reallocating the
// internal array.
Of course, it is a list of Objects, so I'm assuming some amount of overhead involved there, as was the case with VB6 Variant types.

Quote:
Originally Posted by dotnetwrassler View Post
... I guess I have to look around for a radians to degrees code snippet.
That is such a common requirement, since you need Radians for all Trig functions in BASIC and most every other language, I assumed you were already familiar with doing the conversions back and forth.
360 degrees = 2 PI in radians. so 180 degrees is PI in radians.
Usually just set up a couple of constants to multiply by to convert from one to the other.
Radians are small (0 to 6.28...) compared to Degrees (0 to 360), so to go from Radians to Degrees you want to make the number larger, so you want to multiply by a value > 1, so 180/PI would be > 1.
Degrees to Radians is "Big" to "Small", so PI/180 is a < 1 value.
That is my thinking process when I need to remember which is which.
Const RadToDeg As Double = 180 / Math.PI
Const DegToRad as Double = Math.PI / 180

Dim degVal as Double = xTheta * RadToDeg
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 04-08-2015 at 03:47 PM.
Reply With Quote
  #92  
Old 04-08-2015, 04:19 PM
PlausiblyDamp's Avatar
PlausiblyDampExploring 3D graphics with VB.Net, but without using DirectX or XNA PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Quote:
Originally Posted by dotnetwrassler View Post
From the serialization links I've posted in past posts (hopefully you are reading through, and trying to keep up with, all those verbose thread posts),
I hope you know (realize) I've gone through most of the MSDN pages dealing with XML serialization and even looked at some of the associated vbHelper code.

So far things aren't really "sinking in", though.

So if you have any links to simple tutorials on this that could help serialize (to xml)
the 3D classes that boops boops code is using, I might be willing to consider xml versus ini
if I can get deal with angle bracketed nesting hierarchy that is generated..
Not being all that familiar with 3D stuff I am finding the ini file part just seems the least interesting bit of this thread. The actual graphics code is far more interesting....

In regards to using the built in XML support it could be as simple as changing the start to the Import3ds.vb file to
Code:
Imports System.Xml.Serialization

Public Class Import3DS

	Public SubObjectArray As List(Of SubObject3D)
	<XmlIgnore>
 Public CurrentIndex As Integer, CurrentJunkId As Integer, NextJunkOffset As Integer
	<XmlIgnore> Public ByteArray As Byte()
	Dim i As Integer, j As Integer
	Dim x As Double, y As Double, z As Double
	Dim EndOfStream As Boolean
	Dim VertexObj As Vertex
	Dim TriangleObj As Triangle
	Dim SubObject3DObj As SubObject3D
	Dim TextStr As String, TmpStr As String
	Dim TotalSubObjects As Integer, TotalVertices As Integer, TotalTriangles As Integer
	Dim foundSubObject As Integer, foundVertices As Integer, foundTriangles As Integer
	Dim splitedString As String(), splitedVertexString As String(), splitedTriangleString As String()
While the saving code would be
Code:
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
    Dim myStream As Stream
    Dim saveFile As New SaveFileDialog

    saveFile.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"
    saveFile.RestoreDirectory = True
		
    If saveFile.ShowDialog() = DialogResult.OK Then
       myStream = saveFile.OpenFile()
       If Not (myStream Is Nothing) Then
           Dim ser As New XmlSerializer(GetType(Import3DS))
           ser.Serialize(myStream, Import3DSObject)
           myStream.Close()
       End If
     End If
End Sub
and the loading code would be
Code:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim myStream As Stream
Dim openFile As New OpenFileDialog

openFile.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"
openFile.RestoreDirectory = True

If openFile.ShowDialog() = DialogResult.OK Then
    myStream = openFile.OpenFile()
    If Not (myStream Is Nothing) Then
        Dim ser As New XmlSerializer(GetType(Import3DS))
            Import3DSObject = DirectCast(ser.Deserialize(myStream), Import3DS)
            myStream.Close()
    End If
 End If

currentSubObjectIndex = 0
initRenderScene()
Show3DSFileinfo()
RenderFlag = True
renderProcess()
End Sub
<edit: passel> Added setting currentSubObjectIndex = 0. Don't know if there are any other "gotcha"s in there. </edit>
<edit: passel> That didn't fix the invalid index problem. Had to put initRenderScene() before Show3DSFileinfo() </edit>
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags

Last edited by passel; 04-08-2015 at 06:03 PM.
Reply With Quote
  #93  
Old 04-08-2015, 06:08 PM
passel's Avatar
passelExploring 3D graphics with VB.Net, but without using DirectX or XNA passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default

Had an index error when going between some models, loading from the XML.
currentSubObjectIndex was reported as out of range, and I set it to 0, but that wasn't the problem.
It was the array currentSubObjectIndex was indexing into was old data.
Had to call initRenderScene before calling Show3DSFileinfo.
I fixed "both" issues in PD's post, although setting the currentSubObjectIndex to 0 is actually probably not necessary, as it is being used and incremented as part of the initialization so is probably set back to 0 at some other point in the process.
Setting it to 0 before it is used is a NOP in this case.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #94  
Old 04-09-2015, 09:53 AM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default Let's add a menu..

With all this reading and writing to multiple file types
I figure it's about time to add a menu to the interface
(no more using buttons for opening/saving).

I also added an Options menu to toggle the Anti-aliasing
(which I expect most users would elect keep checked so it's on all the time)

Added an About box based on the CodeProject here.

It uses info from the projects .Net Assembly, so I guess it's the ".Net-friendly" way to do such things..
(need to make a new icon though when I get time)

The rest of the changes you can see in the attached screenshot.
Also cleaned up the code in this update (by deleting a bunch of commented out code) as well.

Note: The attached code update (with project now renamed simply "3D Viewer")
includes PlausiblyDamp's XML open/save code (with passel's fix).
(Thanks for the xml serialization help, both of you..)

I noticed something curious when I opened up the xml file in WebMatrix, though.

It had a fairly chunky byte array appended to the bottom.
Is that normal for xml serialization?
Just wondering if it's needed..or if there is an option slim down the file
a bit by (optionally) trimming it from the save routine?
Attached Images
File Type: jpg screenshot-3D_Viewer-updated_user_interface.JPG (161.1 KB, 3 views)
File Type: jpg screenshot_WebMatrix--bytearray_info_added_to_end_of_xml_file.JPG (358.8 KB, 3 views)
Attached Files
File Type: zip !_3D_Viewer.zip (973.0 KB, 16 views)

Last edited by dotnetwrassler; 04-09-2015 at 09:59 AM.
Reply With Quote
  #95  
Old 04-09-2015, 02:07 PM
PlausiblyDamp's Avatar
PlausiblyDampExploring 3D graphics with VB.Net, but without using DirectX or XNA PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

By default it will serialise any public properties, the ByteArray is simply the ByteArray property being serialised. If you look at the code I posted I marked several properties with the <XmlIgnore> attribute - this will prevent them from being written out.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #96  
Old 04-09-2015, 02:08 PM
passel's Avatar
passelExploring 3D graphics with VB.Net, but without using DirectX or XNA passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default

Where was the xml generated from?
If you generate it from the file you zipped, it isn't there.
PD specifically marked those items (CurrentIndex, CurrentJunkId, NextJunkOffset and ByteArray) with <xmlIgnore> tags so that they wouldn't be added to the file.
I just did a xml save with the unaltered !_3D_Viewer and those fields were not put in the file I generated, and I see the tags are in there, which is why I ask.

Which reminds me. I originally noticed that a number of variables refer to Junk, instead of Chunk, so makes me wonder if the original coder wasn't native English speaking, as those two words do sound similar, but usually have different meanings.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 04-09-2015 at 02:14 PM.
Reply With Quote
  #97  
Old 04-10-2015, 12:21 AM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default XMLIgnore attributes, chunk/junk, and a bit of roadmapping..

Quote:
I just did a xml save with the unaltered !_3D_Viewer and those fields were not put in the file I generated, and I see the tags are in there, which is why I ask.
To passel,
Yes, You are correct.
Everything is (and should be) good with XML files saving using the 3D Viewer code/project attachment to post #94.

I hope everyone will download that 3D viewer attachment.
It's stable.
It works (as far as it goes within it's limitations).

To PlausiblyDamp,
Yes, your code snippet was correct (I didn't mean to imply that it wasn't),
but I must have exported that xml file before I properly finished copying and pasting the <XMLIgnore> tags into Public Class Import3DS of the revised 3D Viewer.

Quote:
Originally Posted by passel
Which reminds me. I originally noticed that a number of variables refer to Junk, instead of Chunk,
so makes me wonder if the original coder wasn't native English speaking,
as those two words do sound similar, but usually have different meanings.
I believe you are correct about this also.

I gave the original author credit in the about box (hopefully you had a change to look at that part of the 3D Viewer as well).
Just for the record -- it's a guy named "Samir Solanki" from India (1, 2).

Probably part of the "Junk" (chunk) file header contains information/offsets about the graphic fills/textures used in the models.

I have looked at the models in other viewers and there should be more information in some of the 3DS files than just the triangle/geometry data.

I can even assign UV wrapping materials in 3D Studio Max and save out a .3DS file and the 3D Viewer doesn't see them when it loads the .3DS file data.

The original author of the code probably wasn't worried about this,
but I definitely want to be able to save texture info with the xml (even
if it's just a path to a texture file).



Right I'm just worried that if I work up a separate gFill class that it will not be serialized to the xml file "correctly".

I thinking though it should be as easy as adding into 'mnuSaveToXML_Click' something like these two lines before 'myStream.Close()':
Code:
Dim ser2 As New XmlSerializer(GetType(gFill))
 ser2.Serialize(myStream, gFillObject)


We'll see how it goes as this new class develops.

I definitely need to add a twisty triangle debug panel to the 3D Viewer's MainForm to play around with
filling (maybe texturing) the triangles and altering the picbox background to put gradients and images.

Then find some way to drag-edit the blue dot (representing the selected vertex), hopefully..maybe I can even
get the lines connected to the blue dot to be thickened when in "edit mode" by using a different (thicker) pen.



I also don't want to abandon boops boops work developing the platonic solids as 3D primitives,
so somehow (perhaps) merge the polyhedra class (and the five platonic solids) into the 3D Viewer.
We need primitives to be able to start new models (File > Open New..).
The screenshot attachment to post #94 also proves that I can get it to display 3D text (i.e. the name "passel").
Each letter will be it's own primitive.
Of course it would be nice to be able to extrude any OpenType/TrueType font character glyph into a 3D object at runtime (but let's not get ahead of ourselves).

This is my short term road map.

Quote:
I know passel and PlausiblyDamp probably expect some type of code refactoring to "clean-up" things,
maybe even offload as much code as possible off the MainForm.
This is not my priority, though.
I'm focusing on piling on new features.

No one (strangely) has been pushing incorporating parallel fors and multi-threading.
The larger .3DS models take more than a second to load, during which the GUI (for all intensive purposes) is frozen,
Of course this using some 'DoEvents', but I don't think that's the optimal way to handle this.

Async threading with callback(s) would seem to be the optimal choice,
but I don't want the project as a whole to be too "off-putting" (as in:
"you're not a super expert..then don't even think of trying to rework the code").


Longer term, maybe be able to move/re-position the vertices of sub-models (collectively) into different positions,
in relation to the other model sub-objects (not just in terms of doing a "model space" transform for viewing purposes).

Then boolean AND/OR joins/unions/intersects would be potentially be possible
(like joining the handle onto a coffee cup or a cone union with a torus)

The project could also benefit from some Delaunay triangulations code.
Here is what it looks like when a model containing polygons with 4 or more points (like some of the Platonic solids do) are converted to a mesh of triangles.

This is a working C# CodePlex code that demonstrates this called Triangle.Net.

It even does Voronoi Diagramming (see screenshot).
I have started translating it to VB.Net and I have to see how "resistive" it is.

I also have bookmarked some C# code for phong and gouraud shading (wish there was some VB.Net code
lying around that did the same..even "fake" phong shading or "toon"/cel shading.)

If you compare the two, phong definitely looks better I would take toon shading as a starting point.

There is also flat shading.
Here is picture comparing it with phong shading.

I have to work this Friday/Saturday, so I don't know how much I will be able to get done, but we'll see..
Attached Images
File Type: jpg screenshot-triangle_dot_net_voroni.JPG (75.6 KB, 5 views)

Last edited by dotnetwrassler; 04-10-2015 at 01:41 AM.
Reply With Quote
  #98  
Old 04-11-2015, 05:33 PM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default Voronoi, vorony, baloney..

Wow, that Triangle.Net code is giving me a lot of headwinds in the translation.

I found another C# 'Vorony' example (with Delaunay --I'll attach the code/screenshot) that may be easier.

As I struggle this weekend, here's an old translator guide I made up for myself.
Maybe others will get some amusement out of it..

dnw's guide for C# to VB.Net translation

1.) For a a whole project (versus a snippet), try the bulk translator first.
developerFusion - Convert .NET projects between C# and VB.NET
http://www.developerfusion.com/tools/convert/bulk/

2.) If it works - great. Download the processed file and open it in the .Net IDE,
then comment any code causing errors.

3.) If it doesn't work, try breaking apart the project & submitting it a piece at a time.
Sometimes even this doesn't work if the developerfusion bulk translator server is having a bad day,
in which case proceed to step 4

4.) Recreate and missing files manually, either by right clicking on the project name
in Solution Explorer and selecting Add > New Item, or, in worse case scenario,
create a whole new VB.Net project, then using Add > New Item to manually add in all forms
and classes (or in rare cases even modules) as needed.

5.) Save the original C# code to separate .txt (Notepad/NotePad++) files.
This allows having a single central source for copying/pasting
to multiple online code-snippet-only translators).


6.) I usually start with the Telerik translator first (http://converter.telerik.com/)
then systematically go through the other ones:
http://www.carlosag.net/tools/codetranslator/
http://www.developerfusion.com/tools.../csharp-to-vb/
http://converter.atomproject.net/
http://www.dotnetspider.com/convert/Csharp-To-Vb.aspx

You can even try some of the off-line tools:
http://www.tangiblesoftwaresolutions.com/Demo.htm
http://vbconversions.com/download/version-3-11/
(15 day trial period, 2000 line limitation per project converted.)

..or maybe one of the .Net IDE extension plugins, like MatGabs's Language Convert:
https://visualstudiogallery.msdn.mic...7-c820bd57298c

Concerning the LanguageConvert extension:
a.) It's accessed using View menu > Other Windows > LanguageConverter
b.) Even though it's an internal .Net IDE tool it still loads the files
one by one using an OpenDialog box (not from the Solution Explorer list) - awkward!
c.) The VB.Net output code replaces (appears in the same window)
as the loaded C# code, instead of a separate side-by-side window - again, awkward!
d.) It has no way to save the outputted VB.Net code to a file - triple bummer!
e.) It's conversion quality is only on par with the online developerFusion or carlosag conversion tools
linked to above (that is --not really great )

7.) When you are completed you should have .txt files for each of the converted
code sets (forms, classes, and possibly modules).

8.) Important tip - think about deleting (or commenting out to the end of the conversion)
any 'Namespace ...' lines.
Why? Most of the time they are not needed and (based on my experience)
they make clearing the errors later a lot harder.

9.) Online converter issues:
a.) Failing to integrate control events in with controls (because of a lack of "Handles" in the event code).

Let's give an example...

So you have a form named 'MainForm' in a C# projects.
It has a command button labelled 'Regenerate'
Click on the button takes you to this Click event code:
Code:
private void btnRebuild_Click(object sender, EventArgs e)
 {
    RegenerateDiagram();
    if (rbtDelaunay.Checked == true)
    {
        Bitmap bmp = Fortune.GetDelaunayTriangulation(640, 480, points);
        pbxVisialization.Image = bmp;
    }
    else
    {
        Bitmap bmp = Fortune.GetVoronoyMap(640, 480, points);
        pbxVisialization.Image = bmp;
    }

 }
....so you run it through one of the online translators and out pops this VB.Net code:
Code:
Private Sub btnRebuild_Click(sender As Object, e As EventArgs)
	RegenerateDiagram()
	If rbtDelaunay.Checked = True Then
		Dim bmp As Bitmap = Fortune.GetDelaunayTriangulation(640, 480, points)
		pbxVisialization.Image = bmp
	Else
		Dim bmp As Bitmap = Fortune.GetVoronoyMap(640, 480, points)
		pbxVisialization.Image = bmp
	End If

End Sub
Do you see the issue?

If you copy and paste the btnRebuild command button from the C# project to a
newly created VB.Net project (yes controls will cleanly copy between projects written/coded in
different languages), then click on the button inside the VB.Net project it will give you:
Code:
Private Sub btnRebuild_Click(sender As System.Object, e As System.EventArgs) Handles btnRebuild.Click

End Sub
That's the control Click event code that actually works!
(because it has 'Handles btnRebuild.Click" at the end)

So the workaround for the 9a issue is to either let the button create it's own event code
(after clicking on it following the copying and pasting from C# to VB.Net project),
or try manually adding the needed 'Handles' code.


Other Form events (Form1_Load, Form1_Activated, etc) may need to be
manually re-created or patched as need, as well as other control events (Paint, CheckChanged, etc.)

Then you get to step 10.

10.) Slowly uncomment lines and deal with the errors that pop-up.
Why not just uncomment everything at once?

First of all there is a limit on how many error the .Net IDE will display (101),
after which you get the dreaded:
warning BC42206: Maximum number of warnings has been exceeded.

You may thinking:
Didn't they eliminate that in VB11 and beyond?
Not exactly..

Per this page:
http://blogs.msdn.com/b/vbteam/archi...-download.aspx
a quote:
Quote:
Limitless (Command-line) Errors!
This is actually a good thing, let me explain.
For performance reasons, the Visual Basic IDE maxes out at 101 errors
(with error #102 being “Maximum number of errors exceeded.”)
This can make it difficult to estimate the amount of work remaining
in certain situations, particularly in upgrade scenarios.

We have removed this limit from the command-line compiler in this release, though it still there in the IDE.

What this means is if you want to know exactly how many errors there are for a project,
just invoke the compiler through msbuild.exe or vbc.exe and you’ll get your answer.
Of course developers still complained (through the Microsoft Connect feedback site).
The stock answer they got:
Quote:
While this issue does [still] exist, the Visual Basic Compiler Team has decided to leave the hard limit to the reported errors because it helps with performance.


Personally I get very depressed going through solving hundreds of errors and it's still giving me the BC42206 warning.

So what I do (instead) is work my way through the form "life cycle":
https://msdn.microsoft.com/en-us/lib...=vs.60%29.aspx

..then through the order of form events:
https://msdn.microsoft.com/en-us/lib...vs.110%29.aspx

Unfortunately there is no "order of importance of control events", but in terms of Control Events:
  • The Paint event is first (I'm a graphics' guy first you know ).
  • The non-mousedown related events are second (MouseMove, MouseEnter, MouseLeave, etc.).
  • The Click event is third (along with MouseDown and MouseUp)
  • Then it's a toss-up based on the control and what your code is doing (that is most important) with
    the control (changing Text or background images, validating, toggling visibility, Got/Lost focus, KeyPress events, etc.).

Uncommenting piecemeal will also help you understand what is linking to (or inter-linking with) what --for instance
to functions/methods in classes/modules, or dealing with variable scoping issues (both on and outside the form).


11.) What if none of the translators is coming up with anything that is even close to working?
a.) Check your imports and external/internal libraries referencing
b.) Check the project dependencies (all sub-project pieces should be built first,
or another way to put it,
the part of the solution that contains the project with the main form inside
should be "Set as Startup Project"
(using right click on the Project name to get to this setting).
c.) If all that is right, trying copy and pasting the line of C# code
that is "resisting" translation
into google and add (in quotes) "VB.Net", to search for workarounds.

12.) Regarding: C# code with pointers (Unsafe, fixed memory code)
Yes, some of those curly brackets jockeys sometimes are jealous of the C/C++ coders and
despite the fact that C# code is supposed to be "managed" sometimes go a little crazy (strictly for "performance reasons", of course).
Here's a list of "What in C# that has no equivalent is VB":
http://www.codeproject.com/Articles/...eConverter#CS1

13.) Be careful of the old (backward compatibility) legacy Microsoft.VisualBasic namespace.
Sometimes it pops up in this online translators.
For instance: 'Microsoft.VisualBasic.FileAttribute' is not the same as 'System.IO.FileAttributes'.

14.) Good Luck!
..and remember if Microsoft actually cared about VB.Net code (as much as C#)
the VS.Net IDE would have built-in translators/convertors,
but of course C# is the Microsoft "favored" language for .Net.
Always has been and probably always will be..
Attached Images
File Type: jpg screenshot-Vorony-Delaunay_visualization.JPG (77.6 KB, 5 views)
Attached Files
File Type: zip BasicVoronoyTest.zip (90.9 KB, 14 views)

Last edited by dotnetwrassler; 04-11-2015 at 06:11 PM.
Reply With Quote
  #99  
Old 04-11-2015, 08:47 PM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default VoronoiTest - the (almost) working VB.Net version

Okay, I think I'm close.
I've managed to (mostly) convert the BasicVorony C# attachment from the last post into VB.Net.

At first there were over a hundred errors.
Now I'm down to a couple handfuls.

They are all related to the class in Vector.vb.

There errors are basically all the same:
Quote:
Operator '=' is not defined for types 'VoroniTestVB.Vector' and 'VoroniTestVB.Vector'
The code in Vector.vb starts out with:
Code:
Imports System
Imports System.Collections
Imports VoroniTestVB

Public Class Vector
  Implements IEnumerable
  Implements IComparable


..and I think the IComparable is were things are going awry.


Here's what I found out:
In C# code you can define a whole bunch of ISomethingOrOthers all together

..things like Enumerable, I Comparable, IList, etc.


However when you go to use the online translators, you try to feed it something like this:
Code:
public interface IPriorityQueue : ICollection, ICloneable, IList
	{
		int Push(object O);
		object Pop();
		object Peek();
		void Update(int i);
	}
	public class BinaryPriorityQueue : IPriorityQueue, ICollection, ICloneable, IList
	{
.and it doesn't really know what to do.

For instance, implementing iList.

What needs to happen with that is you have to define a number of things as private
and then IList in VB.Net seems to require a whole bunch of Public Read only properties,
where each property declaration is like:
Code:
   Public ReadOnly Property Something() As Boolean Implements IList.Something
      Get
         Something = _Something
      End Get
   End Property


So for example the online translators should be outputting:
Code:
Public ReadOnly Property IsSynchronized() As Boolean Implements IList.IsSynchronized
  Get
    Return InnerList.IsSynchronized
  End Get
End Property



..but instead is outputting:
Code:
Public ReadOnly Property IsSynchronized() As Boolean
  Get
    Return InnerList.IsSynchronized
  End Get
End Property


Do you see the difference?
No 'Implements IList.IsSynchronized' tacked on to the first line.

It's like the 'Handles' translation goofup I describe in my last post.

Fortunately someone created a very nice snippet code showing templating for IList here:
http://www.a1vbcode.com/snippet-2801.asp

Using that I was able to clean up all the IList Implements of errors!


However it seems like for IComparible it's not quite so cut and dry.
It has to be more customized (I think)..but I don't know quite how???


One of the errors is highlighting:
Code:
Public Sub AddVertex(V As Vector)
  If VVertexA = Fortune.VVUnkown Then
	VVertexA = V
  ElseIf VVertexB = Fortune.VVUnkown Then
	VVertexB = V
  Else
    Throw New Exception("Tried to add third vertex!")
  End If
End Sub

..with the error highlighting the '=' sign.
Essentially it's trying to add on a vertex, but doesn't really understand adding
(or comparing the types so it know how to add, maybe???).

There is this code in Vector.vb:
Code:
''' <summary>
  ''' Add two vectors
''' </summary>
Public Shared Operator +(A As Vector, B As Vector) As Vector
	If A.[Dim] <> B.[Dim] Then
	  Throw New Exception("Vectors of different dimension!")
	End If
	Dim Erg As New Vector(A.[Dim])
	Dim i As Integer
	For i = 0 To A.[Dim] - 1
	  Erg(i) = A(i) + B(i)
	Next
	Return Erg
End Operator
Is this supposed to hooked into IComparable somehow?
Maybe with an Implements IComparible.SomethingOrOther?

Anyway, maybe PlausiblyDamp can look at project if he has time next week..
Quote:

Edit1 (later):
My plan was always to merge boops boops code with the 3D Viewer code (that imports .3ds models) at some point...

How about now?

Since I needed the twisty triangle panel it just seemed easier to merge the Import3DS stuff into the PS6 project --thus is born PS7 (with everything merged into one).

I know - call me crazy (the mouse dragging may have to be adjusted..right now
it drags the platonic solids along with the 3DS models.

Might have to work in a KeyPreview to use ALT, CTRL or something to differential the dragging from the polyhedra Point editing.

..and maybe work in some XML serialization for the platonic solids as well..
Attached Images
File Type: jpg screenshot-PS7_with_3D_Viewer_code_merged.JPG (133.4 KB, 4 views)
File Type: jpg screenshot-PS7-with-3D_Viewer_code_merged.JPG (104.1 KB, 4 views)
Attached Files
File Type: zip VoroniTestVB.zip (34.4 KB, 9 views)
File Type: zip PS7_with_3D_Viewer_code_merged.zip (1.06 MB, 15 views)

Last edited by dotnetwrassler; 04-12-2015 at 07:23 PM.
Reply With Quote
  #100  
Old 04-19-2015, 06:08 PM
dotnetwrassler dotnetwrassler is offline
Regular
 
Join Date: Sep 2014
Location: USA (Pacific/West Coast)
Posts: 71
Default Is everyone scared away...or maybe just "thread fatique", though..

It looks like I scared everyone away with my abortive attempt to do some C# translation.


That's alright though, because it gave me some time to do some more research on xml serialization.

It's a huge subject on MSDN (many, many pages).

Here's are a few things ("gotchas") I found out:
1.) Not all of the types of the properties may be serializable
(in which case you may need to go further by manually writing serialization routines for those types..and possibly those type's properties)
2.) Because of the way VB.NET implements events, when you serialize an object, its events get serialized too
(because events are actually implemented using hidden multicast delegate fields).

A side effect of this is that any object which handles events raised by the object being serialized
will be considered part of the object graph and will be serialized too.

There is some workaround VB.Net code for this here.

3.) You can take control of the xml serialization process by using an ISerializable Interface.

However from days and days of reading, this can (possibly) get rather involved.


There is also the a special warning ("CA2240") that I have run into trying to write code
to use this interface in a way in which it probably wasn't designed.

I'm not much liking GetObjectData (and it doesn't seem to like me either).

Under #3 of the Serialization Guidelines it says:
Quote:
CONSIDER using the serialization callbacks for initialization of deserialized instances.

Constructors are not called when objects are deserialized.
Therefore, any logic that executes during normal construction needs to be implemented as one of the serialization callbacks.
I would consider it but I didn't find enough good examples (that seemed applicable to what I'm trying to do..)


So one might ask:
"Exactly what is it you are trying to do?"

In the merged PS7 working attachment to the last post, it saves the .3DS model data to xml just fine (and loads it fine as well).

Great.
But what if I want to save to xml the triangle strip that I've modified by dragging one or more of the points?

If I just add <Serializable()> to the the TriangleStrip class (which inherits from the PolyhedraBase class) then it should save everything
(including the Point3D class defined data) into the xml file (along with the Import3DS model data).

That's not what I want though.

Supposed I only want to save one or more of the faces (handled by the Face3D class).

Whether I select a TriangleStrip object or a something created from the Dodecahedron class, it's going to save all the faces (not just some of them).

...and (of course) I would want to save one or more of the faces separate from the current loaded .3DS model.



So basically I want to do selective xml serialization without using the ISerializable Interface --is there a (relatively) easy way?



Possibly...not with the faces, though (there is no way to select the faces or the edges in the current PS7 code)
But what about one of the active polyhedra solids stored as a List in the Scene class..they are individually mouse selectable/draggable.


Here is an MSDN page which has some special code for "Public Function CreateOverrider()".

If you are like me you are going to have to read over the page several times to figure out what these lines are doing:
Code:
' Setting XmlIgnore to false overrides the XmlIgnoreAttribute 
' applied to the Comment field. Thus it will be serialized.
    attrs.XmlIgnore = False
    xOver.Add(GetType(Group), "Comment", attrs)


You are telling it to ignore something..
..then telling it to ignore the ignore.
How bizarre you say!?


But could one use this to save the selected Solid (polyhedabase object) --and how?

They are selected (with the Point generated by the PictureBox1 Move event) using the GetSelectedSolid function:
Code:
Private Function GetSelectedSolid(p As Point) As PolyhedronBase
  For Each solid In Scene1.Solids
    If solid.Bounds.Contains(p) Then Return solid
  Next
  Return Nothing
End Function


Theoretically one could mark all the platonic classes that inherit from PolyhedraBase class with <XmlIgnoreAttribute()>,
then override the xml ignore for the solid that is selected (maybe)?


From looking at this Sub:
Quote:
Private Sub MarkSelectedSolid(g As Graphics)
'draw a selection rectangle round the selected polyhedron:
If selectedSolid IsNot Nothing Then
Dim r As Rectangle = selectedSolid.Bounds(8)
Using pn As New Pen(Brushes.Navy) With {.DashStyle = Drawing2D.DashStyle.Dash}
g.DrawRectangle(pn, r)
End Using
End If
End Sub
I imagine one could use the form level declared:
Code:
Private selectedSolid As PolyhedronBase



So something like:
Quote:
' Return an XmlSerializer used for overriding.
Public Function CreateOverrider() As XmlSerializer
' Create the XmlAttributeOverrides and XmlAttributes objects.
Dim xOver As New XmlAttributeOverrides()
Dim attrs As New XmlAttributes()
' Setting XmlIgnore to false overrides the XmlIgnoreAttribute
' applied to the Comment field. Thus it will be serialized.
If selectedSolid IsNot Nothing Then 'Added
attrs.XmlIgnore = False
xOver.Add(GetType(Group), "Comment", attrs)
End If 'Added
Dim xSer As New XmlSerializer(GetType(Group), xOver)
Return xSer
End Function
..except I'm not using Type Group Comments I'm using Polyhedrabase Solids.
Hmmm...

Quote:
[Edit1:
found something else --the ShouldSerialize method,
but this conditional object serialization technique only seems to apply to Form properties..or maybe just properties of classes). ]

Then there is the question of how to deserialize and get it to show only the selected solid?

I probably need to make some checkboxes to turn off displaying the polyhedra and 3DS model "virtual layers" at runtime with
some "If..Then" code in the picturebox1 paint, before I can go any further to test things.



So I guess I'll spend some time working on another update for the PS7 code by my lonesome (offline).
Note: this potentially represents an important new capability--the ability to save something that is edited at runtime.

In the meantime I'll put the thread (which has now reached 100 posts)
on "hiatus" for a while (since no one has posted in the last week anyway),
and hopefully come back with something in May..
Attached Images
File Type: png Splitting_facets_chart2.png (217.5 KB, 4 views)
File Type: jpg post_merger-future_guidance_diagram.jpg (145.1 KB, 6 views)

Last edited by dotnetwrassler; 04-19-2015 at 07:19 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
 
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
Exploring 3D graphics with VB.Net, but without using DirectX or XNA
 
-->