Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
Page 1 of 8 1 2 3 4 5 6 7 8
#3325465 - 06/22/11 09:15 PM OK, so what do we know about Normals?  
Joined: Jun 2001
Posts: 13,341
Col. Gibbon Offline
A nobody
Col. Gibbon  Offline
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:

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. wink


Supports EAW 1.29.exe, Drop in and Play Technology. wink

1.29 download
Inline advert (2nd and 3rd post)

#3325478 - 06/22/11 09:25 PM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Jun 2001
Posts: 13,341
Col. Gibbon Offline
A nobody
Col. Gibbon  Offline
A nobody
Veteran

Joined: Jun 2001
Posts: 13,341
Seems Gurney's Norms calc is not complete, as I get a Compile error, Method or data member not found


Supports EAW 1.29.exe, Drop in and Play Technology. wink

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 Offline
Member
sydbod  Offline
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.

Quote:


Code:
   ^ (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 VECTOR
The 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 EQUATION
Note 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. smile

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 Offline
A nobody
Col. Gibbon  Offline
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.

smile


Supports EAW 1.29.exe, Drop in and Play Technology. wink

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 Offline
Member
sydbod  Offline
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. smile


"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 Offline
A nobody
Col. Gibbon  Offline
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. wink

1.29 download
#3326756 - 06/24/11 12:49 PM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Jun 2001
Posts: 13,341
Col. Gibbon Offline
A nobody
Col. Gibbon  Offline
A nobody
Veteran

Joined: Jun 2001
Posts: 13,341
OK enabled the code and I get an compile error "Method or Data member not found"


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
Highlighted the error shown


Supports EAW 1.29.exe, Drop in and Play Technology. wink

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 Offline
Member
sydbod  Offline
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 Offline
Member
sydbod  Offline
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. frown

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."
#3326878 - 06/24/11 03:42 PM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Jun 2001
Posts: 13,341
Col. Gibbon Offline
A nobody
Col. Gibbon  Offline
A nobody
Veteran

Joined: Jun 2001
Posts: 13,341
Hi Sydbod.

I'm on XP Pro, and Mark is on Win 7, and he can run VB6 without a hitch. He had problems running the older exe's like the calculator, and he installed the Virtual Computer to get over that issue.

I've tried to convert the Studio to compile under VB8 but no luck as there was no way to convert the project successfully. VB8 just did not like the program at all, and as I had the set up from compiling EAW.exe's, it was not a problem to switch to VB6.


Supports EAW 1.29.exe, Drop in and Play Technology. wink

1.29 download
#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 Offline
Member
sydbod  Offline
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. frown


"Peace, love and eternal grooviness, man."
#3327022 - 06/24/11 05:43 PM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Jun 2001
Posts: 13,341
Col. Gibbon Offline
A nobody
Col. Gibbon  Offline
A nobody
Veteran

Joined: Jun 2001
Posts: 13,341
Always moaning! hahaha


Supports EAW 1.29.exe, Drop in and Play Technology. wink

1.29 download
#3327289 - 06/24/11 09:53 PM Re: OK, so what do we know about Normals? [Re: sydbod]  
Joined: Jun 2011
Posts: 12
maj3091 Offline
Junior Member
maj3091  Offline
Junior Member

Joined: Jun 2011
Posts: 12
Lancs, UK
Originally Posted By: sydbod
OK John ... I have VB6 compiler now working on Win7.
I had totally forgotten what a crap IDE it has. frown


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 Offline
Junior Member
maj3091  Offline
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:

Quote:
[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.

#3327553 - 06/25/11 04:29 AM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Jan 2006
Posts: 1,506
Brit44 'Aldo' Offline
Every Human is Unique
Brit44 'Aldo'  Offline
Every Human is Unique
Member

Joined: Jan 2006
Posts: 1,506
Peter, you are a saint!

Does this mean we are allowed to do this in public?

I might not be the most active, but I'm willing to help people lean.


TPA who TWI
"The 10th Amendment simply says that any powers that aren’t mentioned in the Constitution as belonging to the government belong to the states themselves."
#3327556 - 06/25/11 04:31 AM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Jan 2006
Posts: 1,506
Brit44 'Aldo' Offline
Every Human is Unique
Brit44 'Aldo'  Offline
Every Human is Unique
Member

Joined: Jan 2006
Posts: 1,506
wink and al can't spell

LEARN


TPA who TWI
"The 10th Amendment simply says that any powers that aren’t mentioned in the Constitution as belonging to the government belong to the states themselves."
#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 Offline
Member
sydbod  Offline
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."
#3327721 - 06/25/11 01:57 PM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Apr 2002
Posts: 12,497
MrJelly Offline
Veteran
MrJelly  Offline
Veteran

Joined: Apr 2002
Posts: 12,497
Montagnac, L'Herault, France
John- if it's OK by everyone then please zip the VB6 code and put it in my folder at Coders, including your version of Gurney's remmed out code. I might be able to spot the problem.

wink Jel


Fly EAW online at GameRanger: GameRanger Site

FaceBook Pages
UAW 160 downloads
EAW Club

Mark Twain: I am quite sure now that often, very often, in matters concerning religion and politics a man's reasoning powers are not above the monkey's.

I am now of an age at which I no longer need to suffer fools gladly
#3327730 - 06/25/11 02:20 PM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Jun 2001
Posts: 13,341
Col. Gibbon Offline
A nobody
Col. Gibbon  Offline
A nobody
Veteran

Joined: Jun 2001
Posts: 13,341
Hi Tony.

It's there waiting for you. wink


Supports EAW 1.29.exe, Drop in and Play Technology. wink

1.29 download
#3327757 - 06/25/11 02:54 PM Re: OK, so what do we know about Normals? [Re: Col. Gibbon]  
Joined: Apr 2002
Posts: 12,497
MrJelly Offline
Veteran
MrJelly  Offline
Veteran

Joined: Apr 2002
Posts: 12,497
Montagnac, L'Herault, France
Got it- just had a quick look and there is a heap of "method or data not found" thingis- yours spat the dummy on the first. This is possibly why Gurney gave up on this bit, some more declarations are needed- but finding where to put them is tricky.

wink Jel


Fly EAW online at GameRanger: GameRanger Site

FaceBook Pages
UAW 160 downloads
EAW Club

Mark Twain: I am quite sure now that often, very often, in matters concerning religion and politics a man's reasoning powers are not above the monkey's.

I am now of an age at which I no longer need to suffer fools gladly
Page 1 of 8 1 2 3 4 5 6 7 8

Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
Carnival Cruise Ship Fire....... Again
by F4UDash4. 03/26/24 05:58 PM
Baltimore Bridge Collapse
by F4UDash4. 03/26/24 05:51 PM
The Oldest WWII Veterans
by F4UDash4. 03/24/24 09:21 PM
They got fired after this.
by Wigean. 03/20/24 08:19 PM
Grown ups joke time
by NoFlyBoy. 03/18/24 10:34 PM
Anyone Heard from Nimits?
by F4UDash4. 03/18/24 10:01 PM
RIP Gemini/Apollo astronaut Tom Stafford
by semmern. 03/18/24 02:14 PM
10 years after 3/8/2014
by NoFlyBoy. 03/17/24 10:25 AM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0