Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > Open Discussion
help needed for 1st 3d game + copperlicht questions

flocsy
Registered User
Quote
2011-08-04 10:34:34

Hi,

I'm new here, and new in 3d and new in games. What I'd like to do is a very simple game/demo:
phase 1: throw a ball into basketball backboard in a room.
phase 2: detect whether the ball went through the backboard ring
phase 3: detect collisions on the wall, backboard, and rebound

What I managed to do so far is this: I can move in the room, turn around with the mouse, and when I hit space I can throw the ball (currently a cube) to the direction I am facing.

What I managed to do currently (phase 1--) is that at the moment the space key is hit I calculate a path with the parabola and the cube moves on it. The path ends when the cube collides with the wall.

phase1:
I have a feeling that calculating the movement of the thrown ball and using a PathSceneNode is not the best way. I'd guess that it would be better to calculate the movement of the ball frame-by-frame. How can I add my callback function that calculates the position of the ball to the renderer's loop? Should I just use requestAnimationFrame? Is there a function in CopperLicht for this?

phase2:
how do I detect when the ball went through the ring?

phase3:
I'd like to add collision detection and rebound. I do know where the cube hits the wall (getCollisionPointWithLine), but I don't know how to calculate the "new direction" after the rebound. I don't really know with what surface the ball collided (for example if it's close to the corner of the room it can be 3 different walls, and probably it will rebound from one wall, and immediately after it rebound on another wall)

phase3++: how do I do this collision a bit more general? It is easy to see that as the scene gets more complicated things will be much more difficult. Even with only the room walls it's not simple, but when I'd like to collide with the backboard (or even harder: the ring) or later added other objects, it's getting hard. Is there a way to get not only the collisionPoint, but also the "direction of the surface" we collided with?


niko
Moderator
Quote
2011-08-04 15:52:56

1: In CopperLicht, there are several callbacks for this, all in the CL3D.copperlicht class. Use for example OnAfterDrawAll or OnBeforeDrawAll.

2: maybe check it's position? If the position before some time was before the ring, and the position now is behind the ring, it probably went through.

3: getCollisionPointWithLine() also stores the triantle the line hit against. There, you've got your wall :)

3++: see 3


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact