Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Strange (?) shadows
Topic Started: Mar 24 2009, 04:01 PM (483 Views)
kapturzak
Member
[ *  * ]
Hey,
I've got a problem with this example of attaching a weapon to hand: http://forum.ultimate3d.org/topic/173239/1/ .
Everything is working fine but now I've got a problem with shadows. When I stay in front of a light source, my character model has correct shadows, but sword and head (which I tried to attach to neck too :) ) have inversed shadows. I Dunno how to clearly explain this so here are few screenies (don't be afraid of my naked, test model) :
Posted Image


Posted Image
Edited by kapturzak, Mar 24 2009, 04:02 PM.
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Find the flip normals option in the modeling software of your choice and apply it to the triangles, which look wrong.
Offline Profile Quote Post Goto Top
 
Satyr
Member Avatar
Captain Gobblecoque
[ *  *  *  *  *  * ]
NAAAAKEEEEDDDD, but yeah, it seems like the normals are off for either the head or the body, just try flipping the normals of either the head or the body, one of them is probably inverted.
The feeling of homesickness never goes away when you return to your parents home from years of being away.

same goes with the smell of ash and smoke from the day you set it ablaze.
Offline Profile Quote Post Goto Top
 
kapturzak
Member
[ *  * ]
Thanks for reply, but its not working :(. I think that problem is in that mathod of attaching models to bones (http://forum.ultimate3d.org/topic/173239/1/) because when i replace my character model with head model it receives shadows correctly. When i attach anything to a bone and when i stand in front of light source the attached model is getting bright on the wrong side. Have you got any ideas left? Please help me :(
Edited by kapturzak, Mar 25 2009, 04:17 PM.
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
kapturzak
Mar 25 2009, 04:12 PM
Thanks for reply, but its not working :(. I think that problem is in that mathod of attaching models to bones (http://forum.ultimate3d.org/topic/173239/1/) because when i replace my character model with head model it receives shadows correctly. Have you got any ideas left? Please help me :(
The head's normals has clearly been flipped incorrectly as Dr.Best posted (it's obvious by looking at the screenshot) so make sure you flip them correctly. You have probably failed to flip them right.
Edited by Despellanion, Mar 25 2009, 04:16 PM.
Offline Profile Quote Post Goto Top
 
kapturzak
Member
[ *  * ]
Ah, no thats not it. Maybe on a first screen it really looks like normals of head are wrong flipped, but its only a color of shadowed skin.
Edited by kapturzak, Mar 25 2009, 07:05 PM.
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Ok, I've got the reason for the issue.

For several file formats (including *.an8, *.ms3d and *.x) Ultimate 3D uses bones with negative scaling to convert between different coordinate systems. If you use matrix functions to retrieve the transformation of a bone of such a model, this matrix will also contain a negative scaling. A negative scaling causes problems, because it flips the front sides and the back sides of the triangles (they are defined through the vertex order). This is why setting up the matrices leads to wrong backface culling in your case.

Fixing this will be tricky. The normals of a model with negative scaling will never mach to the backface culling, because they are computed before the scaling is applied. For models for which Ultimate 3D uses negative scaling on purpose it corrects the normals by inverting them, but it does not do that if the negative scaling comes from a user specified transformation as in your case.

The easiest and most efficient way to fix this would be to remove the negative scaling from the matrices before they are set up for attached models. To do so you would first mirror the attached models in your modeling software. Then you would create a matrix in Ultimate 3D, which undoes this mirroring (so this matrix would have a negative scaling). Finally you would combine this matrix with the transformation matrix you got from the bone and would set it up for the object. Since both matrices used to create this final matrix contain a negative scaling the resulting matrix will not have one. Minus times minus makes plus, you know ^_^ ?

The code for this could look similar to the following. Try to understand the meaning of undefined variables from their names:
Code:
 
bone_transformation=GetBoneTransformation(-1,bone_index);
x_axis_mirroring=CreateScalingMatrix(-1,-1,1,1);
TransformMatrix(GetObjectTransformation(attached_object),x_axis_mirroring,bone_transformation);
ReleaseMatrix(x_axis_mirroring);
ReleaseMatrix(bone_transformation);
Offline Profile Quote Post Goto Top
 
kapturzak
Member
[ *  * ]
Thank You So Much Mr. Best !!! :mad: :yahoo: :mad:
You guys are really awesome :U3D: rulez :clapping:
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply