Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

using PlaneSensor to move the object
 

Lucia




quote this post edit post

IP Loged report this post

Old Post  01-07-05 - 12:19 AM  
Hallo,

I've written one vrml file which provide user with the possibility to
move object using mouse. The problem is that I can just move the
object in the xy layer. Can someone help me to check the vrml file and
tell me, where I made a mistake?

Thanks a lot

Lucia

Here is the source code:


#VRML V2.0 utf8

PROTO SpaceSensor [
eventOut     SFVec3f translation_changed
eventOut	    SFRotation rotation_changed
eventOut	    SFVec3f	scale_changed
eventIn      MFNode  addChildren
eventIn      MFNode  removeChildren
exposedField MFNode  children []
field        SFVec3f bboxCenter 0 0 0
field        SFVec3f bboxSize 2 2 2
]
{

DEF SPACE Transform {

children [

DEF TOUCH TouchSensor {
}

DEF T Transform {
addChildren    IS addChildren
removeChildren IS removeChildren
children       IS children
bboxCenter     IS bboxCenter
bboxSize       IS bboxSize
}

DEF SWITCH_ALL Switch {
choice[

DEF MODE_MOVE Group {
children[
DEF	Axis_X Transform{
children[
Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 1.0 1.0
}
}
geometry IndexedLineSet {
coord Coordinate {
point [
0.0 0.0 0.0, 1.0 0.0 0.0, 0.0 1.0 0.0,
0.0 0.0 1.0
]
}
coordIndex [
0, 1, -1
]
}
}

Transform{
children[

DEF	X_Axis_Sensor PlaneSensor {}

Transform{
translation 1.0 0.0 0.0
rotation 0.0 0.0 -1.0 1.57
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 0.0 0.0
}
}
geometry Cone{
height 0.15
bottomRadius 0.05
}
}
]
}
]
}
]
}

DEF	Axis_Y Transform{
children[
Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 1.0 1.0
}
}
geometry IndexedLineSet {
coord Coordinate {
point [
0.0 0.0 0.0, 1.0 0.0 0.0, 0.0 1.0 0.0,
0.0 0.0 1.0
]
}
coordIndex [
0, 2, -1
]
}
}

Transform{
children[

DEF	Y_Axis_Sensor PlaneSensor {}

Transform{
translation 0.0 1.0 0.0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.0 1.0 0.0
}
}
geometry Cone{
height 0.15
bottomRadius 0.05
}
}
]
}
]
}
]
}

DEF	Axis_Z Transform{
children[
Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 1.0 1.0
}
}
geometry IndexedLineSet {
coord Coordinate {
point [
0.0 0.0 0.0, 1.0 0.0 0.0, 0.0 1.0 0.0,
0.0 0.0 1.0
]
}
coordIndex [
0, 3, -1
]
}
}

Transform{
children[

DEF	Z_Axis_Sensor PlaneSensor {}

Transform{
translation 0.0 0.0 1.0
rotation 1.0 0.0 0.0 1.57
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.0 0.0 1.0
}
}
geometry Cone{
height 0.15
bottomRadius 0.05
}
}
]
}
]
}
]
}
]
}


]
}

]
}




DEF OUT_MOVE Script {
eventIn SFVec3f translation_X_in
eventIn SFVec3f translation_Y_in
eventIn SFVec3f translation_Z_in
eventOut SFVec3f translation_changed IS translation_changed
field SFVec3f trans 0 0 0
field SFInt32 i 0
url "vrmlscript:
function out() {
Browser.setDescription('INFO: ' + trans[0]+ ' ' + trans[1]+ ' '+
trans[2]);
translation_changed[0]=trans[0];
translation_changed[1]=trans[1];
translation_changed[2]=trans[2];
}
function translation_X_in(val) {
trans[0]=val[0];
out();
}
function translation_Y_in(val) {
trans[1]=val[1];
out();
}
function translation_Z_in(val) {
trans[2]=val[2];
out();
}
"
}


DEF ACTIVATE Script {
eventIn SFBool bool_in
eventOut SFInt32 choice_out
field SFInt32 choice_status -1

url "vrmlscript:
function initialize() {
choice_out=-1;
}
function bool_in(val) {
if (val) {
if (choice_out==1) choice_out=-1;
else choice_out=choice_out+1;
}
}
"
}

# Detect translation
ROUTE X_Axis_Sensor.translation_changed TO
OUT_MOVE.translation_X_in
ROUTE Y_Axis_Sensor.translation_changed TO
OUT_MOVE.translation_Y_in
ROUTE Z_Axis_Sensor.translation_changed TO
OUT_MOVE.translation_Z_in
# give back translation
ROUTE OUT_MOVE.translation_changed TO SPACE.translation

# activate and deactivate Sensor
ROUTE TOUCH.isActive TO ACTIVATE.bool_in
ROUTE ACTIVATE.choice_out TO SWITCH_ALL.whichChoice

}

SpaceSensor {
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1 0 1
transparency 0.5
}
}
geometry Sphere {
radius 0.5
}
}
]
bboxSize 3 3 3
}


Post Follow-Up to this message ]
Re: using PlaneSensor to move the object
 

bensmyth




quote this post edit post

IP Loged report this post

Old Post  01-07-05 - 04:16 AM  
> I've written one vrml file which provide user with the possibility to
> move object using mouse. The problem is that I can just move the
> object in the xy layer. Can someone help me to check the vrml file and
> tell me, where I made a mistake?

I haven't looked at the code..... BUT.....

A PlaneSensor is designed to move things around a plane (ie. xy) thus your
code is functioning as it should!!

I assume you'd like to be able to move in xy AND z...... effectively you'd
like to move in two planes, xy and xz. This can be achieved through
scripting - simply map the y movement to z.


Regards,

Ben




Post Follow-Up to this message ]
Re: using PlaneSensor to move the object
 

Joerg Scheurich aka MUFTI




quote this post edit post

IP Loged report this post

Old Post  01-07-05 - 04:16 AM  
> I've written one vrml file which provide user with the possibility to
> move object using mouse. The problem is that I can just move the
> object in the xy layer. Can someone help me to check the vrml file and
> tell me, where I made a mistake?

You can try/use a already implemented Spacesensor

http://www.csv.ica.uni-stuttgart.de...SpaceSensor.wrl

http://www.csv.ica.uni-stuttgart.de...r/extension.wrl

so long
MUFTI
--
Die Leistung des Spieles kann verlangsamt werden durch
eine schwer zerlegbare Festplatte.


Post Follow-Up to this message ]
Re: using PlaneSensor to move the object
 

bensmyth




quote this post edit post

IP Loged report this post

Old Post  01-10-05 - 05:19 PM  
> I've written one vrml file which provide user with the possibility to
> move object using mouse. The problem is that I can just move the
> object in the xy layer. Can someone help me to check the vrml file and
> tell me, where I made a mistake?

I haven't looked at the code..... BUT.....

A PlaneSensor is designed to move things around a plane (ie. xy) thus your
code is functioning as it should!!

I assume you'd like to be able to move in xy AND z...... effectively you'd
like to move in two planes, xy and xz. This can be achieved through
scripting - simply map the y movement to z.


Regards,

Ben




Post Follow-Up to this message ]
Re: using PlaneSensor to move the object
 

Joerg Scheurich aka MUFTI




quote this post edit post

IP Loged report this post

Old Post  01-10-05 - 05:19 PM  
> I've written one vrml file which provide user with the possibility to
> move object using mouse. The problem is that I can just move the
> object in the xy layer. Can someone help me to check the vrml file and
> tell me, where I made a mistake?

You can try/use a already implemented Spacesensor

http://www.csv.ica.uni-stuttgart.de...SpaceSensor.wrl

http://www.csv.ica.uni-stuttgart.de...r/extension.wrl

so long
MUFTI
--
Die Leistung des Spieles kann verlangsamt werden durch
eine schwer zerlegbare Festplatte.


Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 04:19 AM. Post New Thread   
  Previous Last Thread   Next Thread next
VRML archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top