Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (AndrewAMD, fairtrader, 3run), 599 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
ent_fixnormals / moved bones #387069
11/13/11 22:49
11/13/11 22:49
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Hi, is that right that ent_fixnormals don't work for models, which were modified by moved bones? I move some bones and execute ent_fixnormals on frame 0, but nothing happens?

Here is the model with bones in MED:


Each bone is independent and assigned to a vertex "ring". In the engine, I move them up and down to make a parametrized flattened sphere cap like this:



But as you can see, the right image is wrong, the cap is not smooth by gouraud shading... it should look similar to this (the shape is not yet right, but you can see that the cap must be smoothed):



The model is no multimesh model, has only one group and only one frame. It is named "pTank.mdl".

confused

Best regards,
-Christian

Last edited by HeelX; 11/13/11 22:50.
Re: ent_fixnormals / moved bones [Re: HeelX] #387080
11/14/11 02:51
11/14/11 02:51
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Dude, give this a TRY. For me its often been a 'blind' fix,
but thats better than nothing, eh?

Where you have the frame number zero in your c_updatehull's,
try changing them to ...
Code:
c_updatehull(entity, entity.frame);


Just to see if it makes a difference.

I was having a similar issue with terrains. Un-animated as you can expect...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: ent_fixnormals / moved bones [Re: EvilSOB] #387087
11/14/11 09:42
11/14/11 09:42
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
This fix doesn't make a difference. I tried ent_fixnormals(e, e->frame);, I also tried to do c_updatehull(e, e->frame); before I call ent_fixnormals - but it doesn't help. Thanks anyways smile

Re: ent_fixnormals / moved bones [Re: HeelX] #387105
11/14/11 13:40
11/14/11 13:40
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
ent_fixnormals has nothing to do with bones. It's only for fixing normals of a 3D mesh that point in a wrong direction when vertex coordinates were changed.

http://manual.3dgamestudio.net/aent_fixnormals.htm



Re: ent_fixnormals / moved bones [Re: jcl] #387106
11/14/11 13:44
11/14/11 13:44
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Yes, I can read. But it doesn't work for me, as described. Or have I missed something important?

Re: ent_fixnormals / moved bones [Re: HeelX] #387107
11/14/11 13:49
11/14/11 13:49
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
How do you know that it doesn't work?

Re: ent_fixnormals / moved bones [Re: jcl] #387109
11/14/11 14:06
11/14/11 14:06
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: jcl
How do you know that it doesn't work?

Because I can see it:



source code:

Code:
ENTITY* eRef0  = ent_create("refTank0.mdl", vector(0,100,0), NULL);
ENTITY* e      = ent_create("pTank_0.mdl", vector(0,0,0), NULL);
ENTITY* eRef16 = ent_create("refTank16.mdl", vector(0,-100,0), NULL);

float radius = 32, height = 64, cap = 16;

while (1)
{
    radius = maxv(1, radius + key_force.x * 5 * time_step);
    height = maxv(1, height + key_force.y * 5 * time_step);
    cap = minv(maxv(0, cap + (key_g-key_f) * 5 * time_step), minv(height/2, radius));
    
    char strDebug [128];
    sprintf(strDebug, "key left, right: RADIUS = %.2f\nkey up, down: HEIGHT = %.2f\nkey F,G: CAP HEIGHT = %.2f", (double)radius, (double)height, (double)cap);
    draw_text(strDebug, 10, 25, COLOR_WHITE);
    
    draw_text("Left and right models are reference models with radius = 32, height = 64.\nLeft model has cap height = 0, right model has cap height = 16.\n\nThe dynamically adjusted model (middle) does not get correct gouraud shading when\ncap height is > 0 and ent_fixnormals was called.", 10, screen_size.y - 120, COLOR_RED);
    
    ent_bonereset_all(e);
    vec_set(e->scale_x, vector(1,1,1));
    c_setminmax(e);
    
    e->scale_z = height / (e->max_z - e->min_z);
    e->scale_x = e->scale_y = (2 * radius) / (e->max_x - e->min_x);
    
    char boneUp [32], boneDown [32];
    VECTOR vBoneUp, vBoneDown;
    
    int i;
    for (i = 1; i <= 8; i++)
    {
        sprintf(boneUp, "up%d", i);
        sprintf(boneDown, "down%d", i);
        
        vec_for_bone(&vBoneUp, e, boneUp);
        vec_for_bone(&vBoneDown, e, boneDown);
        
        float nx = ((absv(vBoneUp.x) + absv(vBoneDown.x)) / (e->max_x - e->min_x)) / e->scale_x;
        float ny = 1-cos(asin(nx));
        
        float m = ny * (cap/e->scale_z);
        
        ent_bonemove(e, boneUp, vector(0,0,-m));
        ent_bonemove(e, boneDown, vector(0,0,m));
    }
    
    ent_fixnormals(e, 0); // doesn't work?
    c_setminmax(e);
    
    wait(1);
}



Re: ent_fixnormals / moved bones [Re: HeelX] #387111
11/14/11 14:19
11/14/11 14:19
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
Your code does only bones animation. As far as I see, it does nothing with any vertices or normals - so what normals do you want to fix here?

To clarify: Animation is when a model moves its limbs due to a frame or bone sequence. Animation has no effect on the coordinates of the vertices or normals. Those coordinates are stored in the model's 3D structure, which is called the "mesh".

For manipulating the mesh, there's the ent_setvertex function, and for adjusting normals there's the ent_fixnormals function. When you don't change those coordinated, you don't need to fix them. And when you do it nevertheless, you only see a change when some normal was wrong before, which shouldn't happen. I hope this helps to understand.

Re: ent_fixnormals / moved bones [Re: jcl] #387115
11/14/11 14:39
11/14/11 14:39
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Hm. The bones are independent and the vertex-"rings" (as you can see above in the very first image) are assigned to it - I use the bones to move vertices as a group. I do this, so that LOD stages are shaped the same and I don't need to clone the mesh for each instance of a differently parametrized entity.

Isn't it somehow possible to generate the normals depending to the animation-transformed mesh?

Last edited by HeelX; 11/14/11 14:40.
Re: ent_fixnormals / moved bones [Re: HeelX] #387117
11/14/11 14:46
11/14/11 14:46
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
This is possible, but you must do it manually. You're normally not supposed to change the normal coordinates during bones animation. But if you do this for a special purpose, you must NOT call ent_fixnormals. Otherwise the normals are adapted to Gouraud shading again and your changes are lost.

Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1