instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
January 22, 2018, 09:02:22 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: CollectionCollisionSensor - after unrender an object, there is still a collision  (Read 1715 times)
biggy
Newbie
*
Posts: 2


View Profile
« on: February 08, 2013, 04:49:34 pm »

Hey all,

like in this thread http://forum.instantreality.org/index.php?topic=266.0 if have issues with the collisionsensor after unrender an object (sensor isnt updated - if you update via script, nothing happens) Angry

I work in a scene if you press m - a yellow teapot is rendered on the right.. the red teapot follow your mouse. ... if you go through a teapot, the red teapot doesn't get the translation until the collision is over. (an invisble box makes the detection). If you collide teapot red with white, it works, you can also go through where the invisible yellow teapot is. If you render the yellow teapot via m, it works also, but if you unrender the yellow teapot, it still thinks, that the object is there and collides.. some important codelines:
Code:
...
<Transform DEF='TBox1' translation='-2 0 0' rotation='0 0 0 -1.5' render='true'>
      <Shape DEF='Box1'>
        <Appearance>
          <Material diffuseColor='1 0 0' transparency='1'/>
        </Appearance>
        <Box size ='1 0.5 0.7'/>
      </Shape>
</Transform>
...
<Transform DEF='TBox2' translation='2 0 0' rotation='0 0 0 -1.5' render='false'>
      <Shape DEF='Box2'>
        <Appearance>
          <Material diffuseColor='1 1 0' transparency='1'/>
        </Appearance>
        <Box size='1 0.5 0.7'/>
      </Shape>
</Transform>

<CollectionCollisionSensor DEF='FIXCOLLISION_SENSOR3'>
<Transform USE='TBox1'/>
<Transform USE='TBox2'/>
</CollectionCollisionSensor>
<KeySensor DEF='keyboardinput'/>
...
<Script DEF="test_script">
<field name='box1translation' type='SFVec3f' accessType='inputOnly'/>
<field accessType='inputOnly' name='setCollideFix3' type='SFBool'/>

<field accessType='inputOnly' name='handleKeyEvent' type='SFString'/>
<![CDATA[javascript:

var tpot1 = Browser.currentScene.getNamedNode('TPot1');
var tbox2 = Browser.currentScene.getNamedNode('TBox2');
var collisionSensor3 = Browser.currentScene.getNamedNode('FIXCOLLISION_SENSOR3');

var collideFix3 = SFBool();

function initialize()
        {
collide=false;
collideFix3=false;
         }

function setCollideFix3( value ){
collideFix3=value;
print( 'COLLISION_SCRIPT\tcollideFix3 = ' + value );
}

function handleKeyEvent(key){
if (key == "m" || key == "M"){
if (tbox2.render==true){
 tbox2.render=false;
 tpot2.render=false;
 }
 else{
 tbox2.render=true;
 tpot2.render=true;
 }
}
}

]]>
</Script>

<ROUTE fromNode='keyboardinput' fromField='keyPress' toNode='test_script' toField='handleKeyEvent'/>
<ROUTE fromNode='FIXCOLLISION_SENSOR3' fromField='collide' toNode='test_script' toField='setCollideFix3'/>

Is there a way to "update" the Collisionsensor?
collisionSensor3.enabled=false; if the yellow teapot not rendered and .enabled=true if the teapot is rendered doens'nt work..

I have one work around, but it feels like cheating Smiley:

Code:
function handleKeyEvent(key){
if (key == "m" || key == "M"){
if (tbox2.render==true){
tbox2.render=false;
tpot2.render=false;
tbox2.translation=new SFVec3f(2, 0, -10);
tpot2.translation=new SFVec3f(2, 0, -10);
}
else{
tbox2.render=true;
tpot2.render=true;
tbox2.translation=new SFVec3f(2, 0, 0);
tpot2.translation=new SFVec3f(2, 0, 0);
}
}
}

The scene is attached...

Thank you very very much!

Best regards
Dennis
« Last Edit: February 08, 2013, 05:52:39 pm by biggy » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines