Jump to content

regarding collision detection


Recommended Posts

Hi Vahith!  Um, nice indenting.  :)  You'll get more love from helpers... with better indenting.

Vahith, are you wanting collision-checking to happen WHILE you are drawing the walls?  I bet so.  You don't want the user to be able to draw a wall THROUGH a wall, right?


Use that function instead of moveWithCollisions.  What's that you say?  .scaleWithCollisions() doesn't exist?  hehe.  Yeah, I know.  Neither does .rotateWithCollisions(). 

See line 184?  You are using .scaling to draw the wall, and thus... .moveWithCollisions isn't being used during wall-drawing, and thus... you have no collision checking during wall drawing.

Now stop asking such difficult-to-answer questions and get back to work! :D

If you buy Deltakosh a pair of baby noise-canceling headphones and a decent home-cooked meal, he MIGHT write .scaleWithCollisions() for you.  But I think he'd rather have one of us do it.  It won't be easy.

Here's an early "first step".  See line 184, the line that should be .scaleWithCollisions?  ADD a line after that... like this...

myWall.ellipsoid.x = myWall.scaling.x;

That scales the collider WITH the wall.  Now you at least have a CHANCE for a collision-while-scaling.  But really, you need scaleWithCollisions(); 


See line 185?  It is some kind of rotater.  With your new line above, you made the collider the same length as the wall.  So watch out when you rotate it around, or you will knock stuff off the shelves.  :)  It's like trying to turn around a 4m board inside a phone booth.  Thank goodness rotateWithCollisions() hasn't been coded yet, eh?

By the way, if you haven't noticed... .moveWithCollisions should have been named .positionWithCollisions... but wasn't.  I want it changed, but I suspect there will be resistance to that idea.  :/  Rename it in your code... for more coding clarity.  .position, .rotation, .scaling... the big three!  You will need collision detecting for all three... in your project.  (be afraid)  :)

It's a fun scene, V.  I experimented with detaching the camera during drawing, and re-attaching it after the drawing.  It works nice for setting the camera closer, and with a perspective view.  You can draw walls without the camera moving all over the place while drawing. 

The scene seems boggy, though.  Maybe you have too much code in your animation loop (registerBeforeRender).  But that is a different subject.  This is an interesting challenge.

"Creating ground once room shape is completed" is fairly easy.  It might be easiest by doing some kind of DONE button that the user would click.  You might put it next to an EDIT button.  In DONE mode, the scene is "decorated" with pretty ground and wall textures, etc.  In EDIT mode... the scene un-decorates and goes back to wall-drawing look.

Just some thoughts.

Link to comment
Share on other sites

moveWithCollisions is not planned for what you speak Wingnut. this function makes it possible to detect the collisions during the displacement of an object/character. With this function, which is a vector3 in paramettre, you can enter a value of rotation, scaling and position if you want it.

Link to comment
Share on other sites

Hi d72.  Um, moveWithCollisions will not work.... if there is no .position change.  If we only want to rotate (or scale) an object (around Y axis for example), moveWithCollisions cannot do it, correct?  MoveWithCollisions MUST have .position change... to detect collision, I think.  Maybe.  :)


So, I think we're in agreement.  scaleWithCollisions and rotateWithCollisions... are needed for detecting collisions when no change of .position is wanted.  As you stated, moveWithCollisions was not designed to check for rotation and scaling collisions.  It only does .position collisions, yes?  *scratch scratch*  :)

Link to comment
Share on other sites

movewithCollision method adds a vector3 to the existing vector3 position of the mesh and to the mesh ellipsoid. So if he wants to scale instead of translate it will be hard to use movewithCollision (i think), since there's not actual movement. I have to agree with Wingy on this scalewithCollision would be cool stuff :D

I played a bit with his playground demo, and i don't see a way to do it with movewithCollision (but i'm a newbie), although... there's some peeps that may code a good "work around". Not me for sure, I'm still struggling with collisions also ;)

Link to comment
Share on other sites

Yep, yep, yep, well-pondered, guys.


Yeah, dad72... good point.  (about rotate and scaling being "moves").


So, maybe the wise move... is to IMPROVE .moveWithCollisions so that it handles rotations and scalings.  Try not to break backward compat, but add power to that function.  I think that would be a good idea... maybe.  :)


I dunno.  *scratch scratch*.  I keep coming back to what Deltakosh once said.  Something like "I can code BJS to generate a collision event".


IF an event was generated, it would trigger a func called .onCollision(eventObj).  It would then be the project coder's problem to figure out if it is a rotation, position, or scaling collision.  Some folks would not use .moveWithCollisions, and instead use simple .translate(), and rotate(), and scale(), if wanted. 


If any object in the scene with .checkCollisions = true... collided... then .onCollision() would be called (with an event object to get collision info from).


Just thinkin'.  :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...