Hi mate!
In first please try this code (media attached):
Sync On
Sync Rate 60
Autocam Off
Position Camera 0, 50, -100
Point Camera 0, 0, 0
DYN START
DYN SET PARAMETER NX_VISUALIZATION_SCALE, 5
DYN SET PARAMETER NX_VISUALIZE_COLLISION_SHAPES, 1
DYN SET PARAMETER NX_VISUALIZE_JOINT_WORLD_AXES, 1.0
DYN SET PARAMETER NX_VISUALIZE_JOINT_LIMITS, 1.0
DYN MAKE GROUND PLANE
DYN SET GRAVITY 0, -9.8, 0
add_height# = 10
add_x# = 0
add_z# = 0
rem ************************** LEFT WING.
load object "ala_aereo_scaled4.x",9000
scale object 9000,33.3 , 33.3, 33.3
color object 9000,rgb(200,200,200)
position object 9000, 3.53+add_x#, 1.31+add_height#, -7.87+add_z#
rem ************************** FLAP
make object box 9071,10.2,0.3,2.4
color object 9071,rgb(200,200,200)
position object 9071,-9.53+add_x#,1.91+add_height#,-8+add_z#
rotate object 9071,0.73, -3.47, 0.78
rem LEFT WING
DYN COOK CONVEX MESH 9000, 2
DYN MAKE CONVEX MESH 9000, 2, 4.0
rem FLAP
DYN MAKE BOX 9071, 2.0
rem JOINING THE FLAP ON THE WING!
makeJointRevolute(3, 9000, 9071, add_x#-14, add_height#+1.6, add_z#-6.8)
makeJointRevolute(4, 9000, 9071, add_x#-6, add_height#+1.6, add_z#-6.3)
DYN SIMULATE
do
DYN FETCH RESULTS
DYN UPDATE
DYN DEBUG RENDER
if SpaceKey ()
rem DYN ADD FORCE 1, 0, 50000.0, 0
DYN ADD FORCE 9000, 0, 40000.0, 0
endif
DYN SIMULATE
rem CAMERA
if mouseclick()=1 then cf#=10
if mouseclick()=2 then cf#=-10
cx#=wrapvalue(cx#+mousemovey()*0.5) rem velocità spostamento laterale mouse
cy#=wrapvalue(cy#+mousemovex()*0.5) rem velocità spostamento verticale mouse
if cx#<=290 and cx#>180 then cx#=290
if cx#>=70 and cx#<=180 then cx#=70
acx#=curveangle(cx#,acx#,5.1) rem inerzia movimento laterale camera
acy#=curveangle(cy#,acy#,5.1) rem inerzia movimento verticale camera
rotate camera acx#,acy#,0
acf#=curvevalue(cf#,acf#,20) rem inerzia movimento avanti/indietro
move camera acf#
cf#=0
Center Text Screen Width() / 2, 0, "SPACE - apply upward force"
Sync
loop
DYN FETCH RESULTS
DYN STOP
rem ----------------------------------
//-- Revolute allows rotation only along one axis, can be used for door hinge etc.
function makeJointRevolute(jointID, objectA, objectB, gAnchorX#, gAnchorY#, gAnchorZ#)
//-- Create descriptor data structure.
DYN MAKE JOINT DESC 1
//-- Locked motion and swing.
DYN JOINT DESC SET MOTION X 1, NX_D6JOINT_MOTION_LOCKED
DYN JOINT DESC SET MOTION Y 1, NX_D6JOINT_MOTION_LOCKED
DYN JOINT DESC SET MOTION Z 1, NX_D6JOINT_MOTION_LOCKED
DYN JOINT DESC SET SWING1 MOTION 1, 1 rem Y
DYN JOINT DESC SET SWING2 MOTION 1, NX_D6JOINT_MOTION_FREE rem Z
//-- Free twist
DYN JOINT DESC SET TWIST MOTION 1, NX_D6JOINT_MOTION_FREE rem X
DYN JOINT DESC SET SWING1 LIMIT 1, 20.0, 0, 0, 0
rem DYN JOINT DESC SET TWIST LIMIT HIGH 1, 1.0, 0, 0, 0
rem DYN JOINT DESC SET TWIST LIMIT LOW 1, 10.0, 0, 0, 0
//-- What actors are involved?
DYN JOINT DESC SET ACTOR A 1, objectA
DYN JOINT DESC SET ACTOR B 1, objectB
//-- Must set this after actors have been set.
DYN JOINT DESC SET GLOBAL ANCHOR 1, gAnchorX#, gAnchorY#, gAnchorZ#
//-- Actors should have collision enabled plus debug visualisation
DYN JOINT DESC SET FLAGS 1, NX_JF_VISUALIZATION || NX_JF_COLLISION_ENABLED
//-- Create joint.
DYN MAKE JOINT jointID, 1
//-- No longer need descriptor.
DYN DELETE JOINT DESC 1
endfunction
Using this code you can obtain a flap with a UP limit and a DOWN limit too (same degrees for both).
All that using two makeJointRevolute joints (that seems to be the most appropriate way to simulate a flap)
My first objective is near to be reached.
I would just to obtain my flap UP limit is "NO DEGREES" (so as a real flap, following the wing shape) and the DOWN limit is 20° or over.
Since now the flap can rotate UP and DOWN of the same quantity of degrees.
My second objective is to obtain my flap in a stopped position, for example 20° down.
Your words:
Quote: "However, make sure you're not over complicating things. If this flap is just there to look nice then it maybe doesn't have to be a dynamics object.You could perhaps manually make your flap and keep it out of the physics simulation all together. This will also run a lot faster than adding 2 joints and another actor to the simulation. All you need to do is:"
Ehh I would to follow your method but my FLAP will be a damn physical flap that will hit the air particles.. so I must to have my flap with physic
Quote: "You could look at adding a 'drive' to the joint which tries to force it back into place, or drives it in the direction you want it to go."
Ahh, this seems a very good idea! I already taken a rapid look to drive commands but not yet tested.
I am pretty certain that my 2 objectives can be reached, and I think I am not too far but damn.. already 2 full testing days and not again won the war!