Topic: Showroom and viewer mesh !!

it is possible to make a viewer (showroom)! pan, rotate and zoom the camera around an object with mouse.
thank you. I want to submit a design object.
If anyone has any examples, I'd be happy.

Last edited by eric007 (2011-05-04 05:52:00)

Re: Showroom and viewer mesh !!

Hi,

yes, you can do that quite easily on script,
here is an example to rotate your object around the Z axis using the mouse :

(you can use the same idea to translate your object on X and Z for the pan)


-- get objects
Object = getObject("Object")

dx = 0.0
dy = 0.0

centerCursor()
mx = getAxis("MOUSE_X")
my = getAxis("MOUSE_Y")

-- scene update
function onSceneUpdate()

    -- rotate Object (X mouse)
    rotate(Object, {0, 0, -1}, dx*100)
   
    -- get mouse direction
    dx = getAxis("MOUSE_X") - mx
    dy = getAxis("MOUSE_Y") - my

    -- center cursor
    centerCursor()
   
    mx = getAxis("MOUSE_X")
    my = getAxis("MOUSE_Y")   
   
end

Re: Showroom and viewer mesh !!

Thank Anael;

It's simple for you. But for me ... ! : (
In addition I will use two functions for the mouse right click +  move mouse = rotation. left click + move mouse = pan. And zoom with the wheel mouse.
That's why I was hoping an example already.

Re: Showroom and viewer mesh !!

You can use isKeyPressed(MOUSE_BUTTON1), isKeyPressed(MOUSE_BUTTON2) and isKeyPressed(MOUSE_BUTTON3)
to know if there is left click, middle click or right clic.

Something like that :
(set your camera oriented toward Y)

if isKeyPressed(MOUSE_BUTTON3) then
    rotate(Object, {0, 0, -1}, dx*100)
elseif isKeyPressed(MOUSE_BUTTON1) then
    translate(Object, {dx*100, 0, -dy*100})
end

Re: Showroom and viewer mesh !!

Sorry my English is very bad I use a translator. !. To use both the mouse click and the mouse movement. is the same code.
thanks

Re: Showroom and viewer mesh !!

In this piece of code, you have to move the mouse and to click the mouse button.
What is your natural language ?

Re: Showroom and viewer mesh !!

French. thanks

Re: Showroom and viewer mesh !!

Ok, si j'ai bien compris le code devrait fonctionner pour ce que tu veux faire,
commence par importer ton objet dans la scene et place une camera orientée vers Y,
l'idée est de déplacer l'objet et pas la camera (plus simple).

Ensuite utilise ce script, modifie-le si besoin,
il permet de faire tourner l'objet sur l'axe Z lorsque la souris bouge et que le bouton droit est enfoncé.
L'objet est déplacé (similaire au pan) lorsque la souris bouge et que le bouton gauche est enfoncé :

-- get objects
Object = getObject("Object")

dx = 0.0
dy = 0.0

centerCursor()
mx = getAxis("MOUSE_X")
my = getAxis("MOUSE_Y")

-- scene update
function onSceneUpdate()

    if isKeyPressed(MOUSE_BUTTON3) then
        rotate(Object, {0, 0, -1}, dx*100)
    elseif isKeyPressed(MOUSE_BUTTON1) then
        translate(Object, {dx*100, 0, -dy*100})
    end
   
    -- get mouse direction
    dx = getAxis("MOUSE_X") - mx
    dy = getAxis("MOUSE_Y") - my

    -- center cursor
    centerCursor()
   
    mx = getAxis("MOUSE_X")
    my = getAxis("MOUSE_Y")   
   
end

Re: Showroom and viewer mesh !!

Ok , je te remercie je vais essayer ce soir. Il faut que je cherche un peu.
Merci encore.
Ce projet c'est pour faire une sorte de présentation à la wirefusion. Et présenter mes créations 3D aux gens.
a+

Last edited by eric007 (2011-05-04 16:04:03)