Skip to content

irtviewerの明るさの変え方 #646

@nakane11

Description

@nakane11

デフォルトのirtviewerは明るすぎるため,家具など白系の物体だと面の境界がわかりづらいという問題があり,解決策を共有します.

irtviewerの光源は:create内gl::*light0*~gl::*light3*の4つが設定されており,#141 でPR2とHRP2用に調整されています.各光源の当たり方は下図のようになります (左上から右下がx軸方向).
Image

これらはgl::lightsourceのグローバル変数なので,外からもambient, diffuse, specular, positionなどのパラメータを変更可能です.変え方のサンプルコードと比較画像を以下に示します.

明るさを変える関数

(defun change-scale-light
  (lightsource scale-light)
  (let ((default-ambient (float-vector 0.1 0.1 0.1 1.0))
        (default-diffuse (float-vector 1.0 1.0 1.0 1.0))
        (default-specular (float-vector 0.1 0.1 0.1 1.0)))
    (send lightsource :ambient (scale scale-light default-ambient))
    (send lightsource :diffuse (scale scale-light default-diffuse))
    (send lightsource :specular (scale scale-light default-specular))
    (send lightsource :opengl)))

明るさのデフォルト値

(scale-light0 1.00)
(scale-light1 0.70)
(scale-light2 0.40)
(scale-light3 0.25)

使い方

(load "jaxon_red.l")
(load "hrp2jsk.l")
(load "room610-scene.l")
(jaxon_red)
(hrp2jsk)
(room610)

(send *jaxon_red* :locate #f(7400 0 986) :world)
(send *hrp2jsk* :locate #f(7400 1000 650) :world)
(send *room610* :remove-object "room610-external-wall-3")
(send *room610* :remove-object "room610-external-wall-4")
  
(unless (boundp '*irtviewer*)
  (make-irtviewer))
(send *irtviewer* :viewer :viewing :look #f(21745.7 -3738.4 4577.18) #f(323.027 2001.78 266.14) #f(0.0 0.0 1.0))
(send *irtviewer* :objects (list *jaxon_red* *room610* *hrp2jsk*))

(change-scale-light gl::*light0* 0.6)
(change-scale-light gl::*light1* 0.6)
(change-scale-light gl::*light3* 0.4)
(send *irtviewer* :draw-objects)

デフォルト (左)と変更後 (右)のviewer

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions