Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove python2 #80

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ if (CollisionOBBCapsule_FOUND)
endif()

# Config files and install rules for pythons scripts
sofa_install_pythonscripts(PLUGIN_NAME ${PROJECT_NAME} PYTHONSCRIPTS_SOURCE_DIR "python")

sofa_install_pythonscripts(PLUGIN_NAME ${PROJECT_NAME} PYTHONSCRIPTS_SOURCE_DIR "python3")

find_file(SofaPython3Tools NAMES "SofaPython3/lib/cmake/SofaPython3/SofaPython3Tools.cmake")
Expand All @@ -117,11 +115,11 @@ if(SofaPython3Tools OR SofaPython3_FOUND)
endif()
message("-- Python3 packages will be installed in: ${SP3_PYTHON_PACKAGES_DIRECTORY}.")
SP3_add_python_package(
SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python3/mor
SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/mor
TARGET_DIRECTORY mor
)
SP3_add_python_package(
SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python3/morlib
SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/morlib
TARGET_DIRECTORY morlib
)
endif()
Expand Down
6 changes: 3 additions & 3 deletions python/mor/animation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@

"""
__all__=["shakingAnimations"]
from shakingAnimations import defaultShaking
from shakingAnimations import shakingSofia
from shakingAnimations import shakingInverse
from mor.animation.shakingAnimations import defaultShaking
from mor.animation.shakingAnimations import shakingSofia
from mor.animation.shakingAnimations import shakingInverse
54 changes: 47 additions & 7 deletions python/mor/animation/shakingAnimations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@

def upDateValue(actualValue,actuatorMaxPull,actuatorIncrement):
if actualValue < actuatorMaxPull:
print "INCREMENT ++"
print ("INCREMENT ++")
return actualValue + actuatorIncrement
else:
print "Done"
print ("Done")
return actualValue

def rotationPoint(Pos0, angle, brasLevier):
print ("In rotation POint")
size0 = len(Pos0);
posOut = [0.0]*3*size0;

for i in range(size0):

posOut[3*i] = Pos0[i][0]- brasLevier*cos(angle);
posOut[3*i+1] = Pos0[i][1] - brasLevier*sin(angle);
posOut[3*i+2] = Pos0[i][2]
print(posOut)

return posOut

Expand Down Expand Up @@ -69,15 +70,54 @@ def defaultShaking( objToAnimate, dt, factor, **param):
writeCurrent = True

if (writeCurrent):

print("For Actuator : "+objToAnimate.location)

actualValue = objToAnimate.item.findData(objToAnimate.params["dataToWorkOn"]).value[0][0]
actualValue = objToAnimate.item.findData(objToAnimate.params["dataToWorkOn"]).value[0]#[0]
actualValue = upDateValue(actualValue,objToAnimate.params['rangeOfAction'],objToAnimate.params['incr'])
objToAnimate.item.findData(objToAnimate.params["dataToWorkOn"]).value = actualValue
objToAnimate.item.findData(objToAnimate.params["dataToWorkOn"]).value = [float(actualValue)]

print ("Updated Value :"+str(actualValue)+'\n')

def shakingLiver( objToAnimate, dt, factor, **param):
"""
**Animation function made specifically to apply deformation on the liver scene.

It's an example of what can be a custom shaking animation.
The animation consist on taking a position in entry, rotate it, and then update it in the component.

To use it the **params** parameters of :py:class:`.ObjToAnimate` which is a dictionnary will need 6 keys:

**Keys:**

+---------------+-------+-----------------------------------------------------------------------+
| argument | type | definition |
+===============+=======+=======================================================================+
| dataToWorkOn | str | Name of the Sofa datafield we will work on here it will be *position* |
+---------------+-------+-----------------------------------------------------------------------+
| incrPeriod | float | Period between each increment |
+---------------+-------+-----------------------------------------------------------------------+
| incr | float | Value of each increment |
+---------------+-------+-----------------------------------------------------------------------+
| rangeOfAction | float | Until which value the data will increase |
+---------------+-------+-----------------------------------------------------------------------+
| angle | float | Initial angle value in radian |
+---------------+-------+-----------------------------------------------------------------------+
| rodRadius | float | Radius Lenght of the circle |
+---------------+-------+-----------------------------------------------------------------------+
"""
moduloResult = int( round( (factor * objToAnimate.duration)*1000 ) ) % int( dt * objToAnimate.params['incrPeriod']*1000 )
# print("currentTime - startTime : "+str(factor * objToAnimate.duration))
if moduloResult == 0:
currentPositions = objToAnimate.item.findData(objToAnimate.params["dataToWorkOn"]).value

objToAnimate.params['angle'] = upDateValue( objToAnimate.params['angle'],
objToAnimate.params['rangeOfAction'],
objToAnimate.params['incr'])

with objToAnimate.item.position.writeable() as positions:
newPositions = rotationPoint(positions, -objToAnimate.params['angle'], objToAnimate.params['rodRadius'])
for i in range(11):
positions[i] = newPositions[3*i:3*i+3]

def shakingSofia( objToAnimate, dt, factor, **param):
"""
**Animation function made specifically to shake the leg of
Expand Down
Loading
Loading