Skip to main content
GameDev.net gamedev.net
🔒 Locked

Please HELP

Started by pimstead Jun 20, 2002 at 1:15 AM 0 replies 250+ views
Original Post
pimstead
pimstead
Please help with this culling code. I have a left-handed coordinate system with counter-clockwise vertex ordering. My culling code acts very haywire. Somebody please help... Thanks void Cull(ObjectPtr *DispList, int Size) { int ObjCounter, PolyCounter; Vector Vert0, Vert1, Vert2; Vector u, v, Normal, Sight; ObjectPtr TempObj; for(ObjCounter=0; ObjCounterPolyCount; PolyCounter++) { Vert0 = TempObj->PolyList[PolyCounter].VertList[0]; Vert1 = TempObj->PolyList[PolyCounter].VertList[1]; Vert2 = TempObj->PolyList[PolyCounter].VertList[2]; Vert0.x += TempObj->X_World; Vert1.x += TempObj->X_World; Vert2.x += TempObj->X_World; Vert0.y += TempObj->Y_World; Vert1.y += TempObj->Y_World; Vert2.y += TempObj->Y_World; Vert0.z += TempObj->Z_World; Vert1.z += TempObj->Z_World; Vert2.z += TempObj->Z_World; VectorCreate(&Vert0, &Vert1, &u); VectorCreate(&Vert0, &Vert2, &v); CrossProduct(&v, &u, &Normal); // camera is at 0,0,0 looking down z Sight.x = Vert0.x-0; Sight.y = Vert0.y-0; Sight.z = Vert0.z-0; if((DotProduct(&Normal, &Sight))>0.0) TempObj->PolyList[PolyCounter].Visible = 1; else TempObj->PolyList[PolyCounter].Visible = 0; } } } void VectorCreate(VectorPtr Init, VectorPtr Term, VectorPtr Result) { Result->x = Term->x - Init->x; Result->y = Term->y - Init->y; Result->z = Term->z - Init->z; } float DotProduct(VectorPtr u, VectorPtr v) { return ((u->x * v->x) + (u->y * v->y) + (u->z * v->z)); } void CrossProduct(VectorPtr u, VectorPtr v, VectorPtr Normal) { Normal->x = (u->y * v->z) - (u->z * v->y); Normal->y = (u->z * v->x) - (u->x * v->z); Normal->z = (u->x * v->y) - (u->y * v->x); }
Yann L
Yann L
You already have an open thread about exactly the same topic. I don''t see the need for a second one. Closed.

/ Yann

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.