#3325465 - 06/22/11 09:15 PM
OK, so what do we know about Normals?
|
Joined: Jun 2001
Posts: 13,341
Col. Gibbon
A nobody
|
A nobody
Veteran
Joined: Jun 2001
Posts: 13,341
|
Hi Guys. Normals are the last hurdle to having a fully automated Studio. I found this code REM'ed out by Gurney in the 3dz Studio code: Public Sub RecalcNormal(num As Integer)
'On Error GoTo errorhandler
'' Recalculate this normal
'Dim v1(3) As Integer
'Dim v2(3) As Integer
'Dim normal(3) As Integer
'Dim length As Double
'Dim d As Integer
'
' With M_3DZ(m_curr3dz)
' If .elem(num).crn >= 3 Then
' v1(0) = .node(.elem(num).nod(0)).X
' v1(1) = .node(.elem(num).nod(0)).Y
' v1(2) = .node(.elem(num).nod(0)).z
'
' v2(0) = .node(.elem(num).nod(1)).X
' v2(1) = .node(.elem(num).nod(1)).Y
' v2(2) = .node(.elem(num).nod(1)).z
'
' normal(0) = (v1(1) * v2(2)) - (v1(2) * v2(1))
' normal(1) = (v1(2) * v2(0)) - (v1(0) * v2(2))
' normal(2) = (v1(0) * v2(1)) - (v1(1) * v2(0))
'
' length = Sqr(normal(0) ^ 2 + normal(1) ^ 2 + normal(2) ^ 2)
'
' normal(0) = normal(0) / length * 16384
' normal(1) = normal(1) / length * 16384
' normal(2) = normal(2) / length * 16384
'
' d = -(v1(0) * normal(0) + v1(1) * normal(1) + v1(2) * normal(2))
' End If
'
' .normal(num).X = normal(0)
' .normal(num).Y = normal(1)
' .normal(num).z = normal(2)
' .normal(num).d = d
' End With
'
' WriteInfo TAB_ELEMENTS
'
'Exit Sub
'errorhandler:
' Debug.Print length
' Debug.Print normal(0)
' Debug.Print normal(1)
' Debug.Print normal(2)
End Sub I'm going to test this code by compiling it and see what happens.
Supports EAW 1.29.exe, Drop in and Play Technology. 1.29 download
|
|
#3325752 - 06/23/11 04:49 AM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Oct 2004
Posts: 1,460
sydbod
Member
|
Member
Joined: Oct 2004
Posts: 1,460
Sydney Australia
|
Hi John, Here is all the theory information that you require to determine the: 1) equation of a polygon plane based on 3 points(EAW nodes). 2) how to determine if those 3 points are not colinear and therefor suitable candidates. 3) determine a NON-normalised normal for that plane. All computations will be in integer format and thus no rounding off error will be created. Only rounding off error will be introduced when you Normalise the data values for the normals. http://paulbourke.net/geometry/planeeq/Will copy the important contents in case the link one day goes off line. ^ (A,B,C) normal
|
/|
/ |\
/ | \ plane
\ /
\ /
\/ The standard equation of a plane in 3 space is Ax + By + Cz + D = 0 // THIS GIVES YOU THE NORMAL VECTORThe normal to the plane is the vector (A,B,C). // THIS LETS YOU CREATE THE EQUATION FOR THE PLANE AND DETERMINE THE NORMAL VECTOR.Given three points in space (x1,y1,z1), (x2,y2,z2), (x3,y3,z3) the equation of the plane through these points is derived with: A = y1 (z2 - z3) + y2 (z3 - z1) + y3 (z1 - z2) B = z1 (x2 - x3) + z2 (x3 - x1) + z3 (x1 - x2) C = x1 (y2 - y3) + x2 (y3 - y1) + x3 (y1 - y2) - D = x1 (y2 z3 - y3 z2) + x2 (y3 z1 - y1 z3) + x3 (y1 z2 - y2 z1) // THIS LETS YOU DETERMINE IF CHOSEN POINTS ARE SUITABLE FOR THE CREATION OF THE PLANE EQUATIONNote that if the points are colinear (and therefor unsuitable) then the normal (A,B,C) as calculated above will be (0,0,0).// THIS LETS YOU TEST THAT NODES OF POLYGON ARE ALL ON THE SAME PLANE (POLYGON NOT WARPED)The sign of s = Ax + By + Cz + D determines which side the point (x,y,z) lies with respect to the plane. If s > 0 then the point lies on the same side as the normal (A,B,C). If s < 0 then it lies on the opposite side, if s = 0 then the point (x,y,z) lies on the plane. Now you have all the required information in a simple format. Regards sydbod
"Peace, love and eternal grooviness, man."
|
|
#3326668 - 06/24/11 08:54 AM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Jun 2001
Posts: 13,341
Col. Gibbon
A nobody
|
A nobody
Veteran
Joined: Jun 2001
Posts: 13,341
|
Hi Sydbod So, do we know enough to finish Gurney's Normals calc? There seems to be most of the code in the Studio already. We seem to have the RSC working well now, and it would be the icing on the cake to have the Normals calc working too, so every time you check your 3dz it adds RS and Normals, ready for testing in game. With this investment, I'm sure others will want to try making 3dz's, because it will be easy to do, without all that cutting and pasting we currently do, in and out of text files.
Supports EAW 1.29.exe, Drop in and Play Technology. 1.29 download
|
|
#3326726 - 06/24/11 11:55 AM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Oct 2004
Posts: 1,460
sydbod
Member
|
Member
Joined: Oct 2004
Posts: 1,460
Sydney Australia
|
Hi John, I was under the impresssion that maj3091 is now working on the code. I am sure he should have no problems getting the current normals calculation code to work. The reason I posted the above information was that it cleany and simply explains how all the functional calculations that are being used in the 3DZ studio fit together. As you may remember, Visual Basic and I are not happy friends.
"Peace, love and eternal grooviness, man."
|
|
#3326747 - 06/24/11 12:28 PM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Jun 2001
Posts: 13,341
Col. Gibbon
A nobody
|
A nobody
Veteran
Joined: Jun 2001
Posts: 13,341
|
Hi Sydbod.
I've not even dared to raise the subject of the Normals. Seeing as the code is there, it just needs to be activated, which can't be too hard as long as it's correct, and add a command to get it to do all the Normals in one go, not just the one on screen as it is now.
I know your not friends with VB6, and I'm only a passing acquaintance, but with what Mark has done for us, this is the really the last major part of Gurney's project that has been left unfinished.
OK there are lots of tweaks to do, but adding the RS and Normals to the studio cover the basic needs of any 3dz modder.
I'm hoping once we get rid of the need to work in and out of text, for the major jobs, more people will try to make models.
Supports EAW 1.29.exe, Drop in and Play Technology. 1.29 download
|
|
#3326793 - 06/24/11 02:11 PM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Oct 2004
Posts: 1,460
sydbod
Member
|
Member
Joined: Oct 2004
Posts: 1,460
Sydney Australia
|
LOL ..... you will be the death of me.
OK, let me look over the problem during the weekend and see what I can find.(I need an excuse to avoid mowing the grass again) I think I still have VB6 on one of the machines and probably still have the 3DZstudioX source files here.(the last ones that I worked on) If I can sort the normals problem out on this version, I will forward the relevent changes so you can pop it into your version.
"Peace, love and eternal grooviness, man."
|
|
#3326818 - 06/24/11 02:33 PM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Oct 2004
Posts: 1,460
sydbod
Member
|
Member
Joined: Oct 2004
Posts: 1,460
Sydney Australia
|
Uggggg!!!! Have VB6 installed on my Win7 machine. Things wont compile since some "vbogl.tlb" file is missing. John, what operating system are you compiling on? WinXP or Win7 ? EDIT: dammm it is the OpenGL library file that is missing, and the directory structure for Win7 is different to WinXP, so even if the file was in the system32 folder the VB6 compiler would not find it. John, have you tried compiling the code under a later version of VB?
Last edited by sydbod; 06/24/11 02:57 PM.
"Peace, love and eternal grooviness, man."
|
|
#3327007 - 06/24/11 05:22 PM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Oct 2004
Posts: 1,460
sydbod
Member
|
Member
Joined: Oct 2004
Posts: 1,460
Sydney Australia
|
OK John ... I have VB6 compiler now working on Win7. I had totally forgotten what a crap IDE it has.
"Peace, love and eternal grooviness, man."
|
|
#3327289 - 06/24/11 09:53 PM
Re: OK, so what do we know about Normals?
[Re: sydbod]
|
Joined: Jun 2011
Posts: 12
maj3091
Junior Member
|
Junior Member
Joined: Jun 2011
Posts: 12
Lancs, UK
|
OK John ... I have VB6 compiler now working on Win7. I had totally forgotten what a crap IDE it has. Grab yourself a copy of MZTools and CodeHelp addins. Makes the IDE more bearable.
|
|
#3327293 - 06/24/11 09:59 PM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Jun 2011
Posts: 12
maj3091
Junior Member
|
Junior Member
Joined: Jun 2011
Posts: 12
Lancs, UK
|
I think this might be the right post to raise this in. John has asked me to look at reproducing a text file from a 3DZ, similar to what converter does. I've been having a look at the file structure that is used in studio with a loaded 3DZ file and the same file in text format that has been through converter and there are some areas that i'm struggling to figure out, so hopefully you can help. The text file has the following for each normal: [NORMAL] ;N000= _y0 _z0 _x0 _d _c _f N000= 0 0 -16384 0 -29 0 The file structure has the following for each normal: I can see entries for XYZDF in the file. XYZF always match. D never matches and there is no C. Any suggestions? Thanks.
|
|
#3327590 - 06/25/11 06:19 AM
Re: OK, so what do we know about Normals?
[Re: Col. Gibbon]
|
Joined: Oct 2004
Posts: 1,460
sydbod
Member
|
Member
Joined: Oct 2004
Posts: 1,460
Sydney Australia
|
Hey maj3091 ...... Aldo thinks you are a saint and that your name is Peter. I know his comment is not directed at me ..... as I am just an "outer western suburbs low life".
******************************************************** Just to clear things up so there is no confusion.
1) Any code we are talking about here has nothing to do with the code from within EAW source. It is just code basically created by "Gurney" for a model editor and has been given freely and openly to the community.
2)YES we can talk about this and its source code freely and openly. ********************************************************
@ maj, I am not sure about the data structure you are looking at. The data structures are named very inconsistently and have been changed while the code was being created. That is why the normals code would not compile for John. I think we have to sit down and re-document all the 3DZ data structures properly so we can understand what is going on.
@ Aldo, Any help is always appreciate.
QUESTION TO BE ASKED: This 3DZ studio project is a bit messy to work through and people are going from one cludge fix to another to try to get some functionality out of it. Would it maybe be better if the project was re-created under a newer IDE and maybe using C/C++ (VS2010 express).
Aldo, maj, Would the 2 of you (with me included) be interested in properly documenting and recreating a new 3DZ studio? Maybe around 3 months time frame sounds about right to do it. I know I would learn a lot from doing it, but to do it by one person takes too much time.
I just hate going through other peoples code that I have trouble understanding.
"Peace, love and eternal grooviness, man."
|
|
|
|