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

Convert tabs to spaces #385

Merged
merged 7 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
46 changes: 23 additions & 23 deletions uni/3d/animationcontroller.icn
Original file line number Diff line number Diff line change
Expand Up @@ -22,77 +22,77 @@ class AnimationController(
#animation_track := []
animation_step := 1
end

method set_skeleton(skl)
skeleton := skl
end

method init_timer()
a_clock:=0
end

method set_timer(t)
a_clock := t
a_clock := t
end

method get_timer()
return a_clock
end

method faster()
animation_step +:= 1
DEBUGW("animation_step:", animation_step)
return animation_step
end

method slower()
if animation_step > 1 then{
animation_step -:= 1
DEBUGW("animation_step:", animation_step)
}
animation_step -:= 1
DEBUGW("animation_step:", animation_step)
}
return animation_step
end

# Do we need trk ?
method set_animation_track(anim_set, trk)
local bone, anim
animation_track := anim_set
#animation_step := anim_set.maxKey/120
a_clock := 0
DEBUGW("anim track set to:", anim_set.label)

DEBUGW("mapping... animation to bones")

every anim := ! anim_set.lsAnimation do{
bone := skeleton.get_bone_by_label(anim.boneName)
bone.animation := anim
DEBUGW("bone:", bone.label, " TO anim:", anim.boneName)
}
DEBUGW("done!")
end

method calc_animation(curious)
if /animation_track then fail
if a_clock > animation_track.get_max_key() then{
a_clock := 0
#CalcAnimation(Skeletton)
a_clock := 0
#CalcAnimation(Skeletton)
}
DEBUGW("controller clock:", a_clock)
skeleton.calc_animation(a_clock, curious)
a_clock +:= animation_step

end

method update_animation()
a_clock +:= animation_step
if a_clock > animation_track.get_max_key() then{
a_clock := 0
#CalcAnimation(_Skeletton)
#CalcAttitude(_Skeletton,0)
#SkinMesh(_Skeletton)
a_clock := 0
#CalcAnimation(_Skeletton)
#CalcAttitude(_Skeletton,0)
#SkinMesh(_Skeletton)
}
end
end

initially
init()
end
16 changes: 8 additions & 8 deletions uni/3d/animationset.icn
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ class AnimationSet(
method get_label()
return label
end

method is_name(nam)
if label==name then return self
end
method addAnimation(anim)

method addAnimation(anim)
lsAnimation[anim.boneName]:=anim
end
method get_animation_for_bone(bname)
if member(lsAnimation, bname) then return lsAnimation[bname]

method get_animation_for_bone(bname)
if member(lsAnimation, bname) then return lsAnimation[bname]
end

method get_max_key()
return maxKey
end


initially
init()
end
96 changes: 48 additions & 48 deletions uni/3d/basicobject3d.icn
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,46 @@ class BasicObject3D(
label, # string
loc, # Vector3
orientation_angles, # Vector3 , Orientation in the 3D space
# which are the angles around x, y, z axises
# which are the angles around x, y, z axises
scalexyz,
color,
color,
radius, # aproximation of the bounding sphere radius
reference, # Vector3 a refrence point in the 3D space
bb_max, # max vector and min vector four bounding box calcs
bb_min, #
visible_section, # Unicon WSection Record
Txyz, # Unicon Translation Record
Rx, #

reference, # Vector3 a refrence point in the 3D space

bb_max, # max vector and min vector four bounding box calcs
bb_min, #

visible_section, # Unicon WSection Record
Txyz, # Unicon Translation Record
Rx, #
Ry, # Unicon Rotation Records
Rz, #
Rz, #

Sxyz,
render_func # rendering function if supplied



render_func # rendering function if supplied
)

# render Template for all 3D objects
method render()
method render()
visible_section := WSection( label )
PushMatrix()
PushMatrix()
Txyz:=Translate (loc.x, loc.y, loc.z)
Sxyz:=Scale(scalexyz.x, scalexyz.y, scalexyz.z)
Rx:=Rotate(orientation_angles.x, 1.0, 0.0, 0.0)
Ry:=Rotate(orientation_angles.y, 0.0, 1.0, 0.0)
Rz:=Rotate(orientation_angles.z, 0.0, 0.0, 1.0)

render_details() # this is the real render


PopMatrix()
WSection()
end

# every object will override this method to customize
# its look in the way it likes
method render_details()
Expand All @@ -65,7 +65,7 @@ class BasicObject3D(
method set_render_func(new_render)
render_func := new_render
end

method refreshLoc()
if /Txyz then fail
Txyz.x:=loc.x
Expand All @@ -79,40 +79,40 @@ class BasicObject3D(
Sxyz.y:=scalexyz.y
Sxyz.z:=scalexyz.z
end

method refreshRot()
if /Rx then fail
Rx.angle := orientation_angles.x
Ry.angle := orientation_angles.y
Rz.angle := orientation_angles.z
end

method set_location (v)
loc.set (v)
refreshLoc()
end

method set_locationxyz (x, y, z)
loc.setxyz (x, y, z)
refreshLoc()
refreshLoc()
end

#
# param count: 1(vector) OR 3(reals)
#
method move(dx, dy, dz)
if numeric(dx) then
loc.addxyz(dx, dy, dz)
else
loc.add(dx)
loc.add(dx)
refreshLoc()
end

method set_orientation(v)
orientation_angles.set(v)
refreshRot()
end

method set_orientationxyz(x, y, z)
orientation_angles.setxyz(x, y, z)
refreshRot()
Expand All @@ -125,7 +125,7 @@ class BasicObject3D(
method set_referencexyz(x, y, z)
reference.setxyz(x, y, z)
end

method rotate(rx, ry, rz)
if numeric(rx) then
orientation_angles.addxyz(rx, ry, rz)
Expand All @@ -137,49 +137,49 @@ class BasicObject3D(
method show()
visible_section.skip:=0
end

method hide()
visible_section.skip:=1
end

method is_hidden()
return visible_section.skip=1
end

method calc_bounding_box()
end

method is_colliding( another_object )
if loc.distance_to( another_object.loc ) <
method is_colliding( another_object )
if loc.distance_to( another_object.loc ) <
radius + another_object.radius then return
end

method set_size_to(val)
local d, dx, dy, dz, mesh, tx, ty, tz

calc_bounding_box()

/val := 1.0

dx := bb_max.x - bb_min.x
dy := bb_max.y - bb_min.y
dz := bb_max.z - bb_min.z

tx := -dx / 2.0 - bb_min.x
ty := -bb_min.y
tz := -dz / 2.0 - bb_min.z


if dx>dy & dx>dz then
d:=dx
d:=dx
else if dy>dz then
d:=dy
d:=dy
else
d:=dz
d:=dz

scalexyz.x := scalexyz.y := scalexyz.z := real(val) / d
scalexyz.x := scalexyz.y := scalexyz.z := real(val) / d
refreshScale()

end

initially(myname )
Expand All @@ -190,4 +190,4 @@ class BasicObject3D(
radius := 1.0
bb_min := Vector3(-1,-1,-1)
bb_max := Vector3( 1, 1, 1)
end
end
Loading
Loading