• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Simple Collision problem

2 posts in this topic

You can try putting a collision flag on your camera and not moving it until the view to the character is clear again. Then you can pan it around while testing to find a good view point. This should eliminate the shaking (as its not moving until the view is clear) and the move-through problem (its obviously finding the conflicting tri if its shaking).

Most likely you are moving back and forth in front of the tri and one of the calcs goes over the border for the tri moving towards it so it fails the collision test and you just keep moving.



Share this post

Link to post
Share on other sites
I'm having problems with my collision, i usually refrain from asking..but i'm a bit lost, if anyone could help.

I've got a line in poly collision test(code below), which backs the camera up gently if it is colliding with the triangle.
I have two problems with this code:
1)When i touch the triangle, and keep moving forward, the camera shakes badly, depending on the speed i approached.
2)If i keep heading forwards, i eventually pass right through the triangle!
Which i can't understand, because i test the line(last_camera position to current camera position), so there is no way i could pass the triangle,
without the function noticing!!

My other two solutions are:
1)Just use camera=last_camera, on a collision..but this is far too inaccurate for fast objects
2)camera=intersection-dir; so my camera will always be the same distance away from the poly when it collides..
this would stop a jittery camera..?

I have included a very cut-down source code below(i thought it would just confuse matters adding the whole code..
as my problem is simple logic, and not dependant on much else in the engine)
If you need clarifacation on any bit, just post, and i will update.

/*Globals not shown here:
*camera=a D3DVECTOR holding the position of the camera
*dir= a normalized D3DVECTOR holding the camera direction
*speed= a float containing the camera speed
*triangle[]=a single triangle we are using for the collision test, it is an array of 3 D3DVECTORs
void UpdateCamera(){
static D3DVECTOR last_camera=camera;//dummy value
D3DVECTOR intersection;//storage for intersection point
camera+=(dir*speed);//Update the camera position

/* Check if we have passed through a triangle, and if so..back up, until the line(last_camera->camera) is no
longer crossing the triangle*/

return 1;

last_camera=camera;//update last_camera

/*Update screen etc*/

A Line Plane Intersection function...
Parameter: Name should make it pretty self explanatory
bool LinePlaneIntersect( D3DVECTOR *IntersecPoint,
D3DVECTOR LinePoint,
D3DVECTOR LineVector,
D3DVECTOR *Polygon)//3 vertices
//first we get the plain constant and normal
D3DVECTOR pnormal,pq, pr,pn,px; // Difference vectors
pq= Polygon[1]-Polygon[0] ;
pr= Polygon[2]-Polygon[0] ;
pnormal = CrossProduct( pq, pr);

float pconstent=DotProduct(pnormal,Polygon[0]);

//now we get the intersection point
float lambda = (pconstent - DotProduct(pnormal,LinePoint))
/(float)(DotProduct(pnormal,LineVector) + 1e-7);

IntersecPoint->x = LinePoint.x + lambda * LineVector.x;
IntersecPoint->y = LinePoint.y + lambda * LineVector.y;
IntersecPoint->z = LinePoint.z + lambda * LineVector.z;
//first we check if lamda is positive
if(lambda<0)return false;
float u0,u1,u2,v0,v1,v2,beta,alpha;//,xy,xz,yz;
//calculate the dominate Axis of Alignment
float x1=Polygon[1].x-Polygon[0].x;
float x2=Polygon[2].x-Polygon[0].x;

float y1=Polygon[1].y-Polygon[0].y;
float y2=Polygon[2].y-Polygon[0].y;

float z1=Polygon[1].z-Polygon[0].z;
float z2=Polygon[2].z-Polygon[0].z;

if(pnormal.x<0)pnormal.x*= -1;
if(pnormal.y<0)pnormal.y*= -1;
if(pnormal.z<0)pnormal.z*= -1;

if((pnormal.x<=pnormal.z)&&(pnormal.y<=pnormal.z)) {
u1=x1; u2=x2;
v1=y1; v2=y2;
if((pnormal.x<=pnormal.y)&&(pnormal.z<=pnormal.y)) {
u1=x1; u2=x2;
v1=z1; v2=z2;
u1=y1; u2=y2;
v1=z1; v2=z2;

if((0<=beta)&&(beta<=1)) alpha =(v0-(beta *v2))/v1; }
if((0<=beta)&&(beta<=1)) alpha =(u0-(beta *u2))/u1; }
//if point is inside the poly then all condition will be met.
return (((alpha>=0)&&(beta>=0))&&((alpha+beta)<=1));


Share this post

Link to post
Share on other sites
Are you using even numbers for the speed?

You keep moving the camera back with dir, a normalized vector(which obviously is equal to distance of one), so if speed is say 1.7 you collide, move back to 0.7 units from the original camera position and then on the next frame the speed of 1.7 + 0.7 = 2.4 from original camera. If that collides you end up at 0.4 from camera. Next frame 2.1, end up at 0.1 from original camera, etc, etc, and then you shake.

So in four frames the cameras jumped from (along the vector) 0.0, 0.7, 0.4, 0.1.

Hope that makes sense.

Maybe you could have the SPEED slow down if the camera would collide (dividing the speed by an arbitrary number) and then speed up(multipying by the same number) if doesn't collide until it reaches a maximum speed.

[This message has been edited by logistix (edited December 15, 1999).]


Share this post

Link to post
Share on other sites