C Board  

Go Back   C Board > General Programming Boards > Game Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-30-2006, 07:40 AM   #1
Registered User
 
Join Date: Aug 2004
Posts: 731
Lighting in Managed Direct3d

I am making this small little engine for my needs. I have implanted lighting lights, the lights seem to work 100% sence they where fallowed by the microsoft tutorials. But than I made a cube from triangles. My engine auto calculated the normals of each face like this:

Code:
        public static Face ConstructFace(Vector3 vec1, Vector3 vec2, Vector3 vec3, Color color)
        {
            ShapeVertex[] verts = new ShapeVertex[3];

//Normal is caluclated here
            Vector3 v1 = vec2 - vec1;
            Vector3 v2 = vec3 - vec1;
            Vector3 norm = Vector3.Cross(v1, v2);
            norm.Normalize();

            verts[0] = new ShapeVertex(vec1.X, vec1.Y, vec1.Z, norm.X, norm.Y, norm.Z, color);
            verts[1] = new ShapeVertex(vec2.X, vec2.Y, vec2.Z, norm.X, norm.Y, norm.Z, color);
            verts[2] = new ShapeVertex(vec3.X, vec3.Y, vec3.Z, norm.X, norm.Y, norm.Z, color);
            return new Face(verts);
        }
It is a pretty simple function. It takes 4 arguments, the first 3 being the points of the triangle than the fourth being a color. The aproach for finding the normals is what most people use and I belive works correctly but here is my problem:

The face is lit by the light. But if ANY part of the face (no matter how small or big) is out of the screen, the face becomes unlit and black.

I am using a simple point light that does reach the object fully, it has a large range. I have a big feeling this has nothing to do with my lights or normals at all, but rather somthing else. Anyone know anything on this?
Rune Hunter is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Direct3D Alpha Blend with Lighting ? rocketman03 Game Programming 10 07-07-2009 04:04 PM
passing params between managed c++ and unmanaged c++ cechen C++ Programming 11 02-03-2009 08:46 AM
Eliminating lighting "over-bright" psychopath Game Programming 1 05-31-2006 06:52 PM
Need help with getting DirectX 9.0 initilization DarkMortar Windows Programming 7 05-09-2006 08:58 PM
Lighting a Direct3D 9 mesh sphere bennyandthejets Game Programming 12 02-14-2005 01:19 AM


All times are GMT -6. The time now is 01:25 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22