Exemple #1
0
 public Plane(Vector3f normal, Vector3f p)
 {
     a = normal.x;
     b = normal.y;
     c = normal.z;
     d = -1.0f * (normal * p);
 }
Exemple #2
0
 public void play(Vector3f position, bool relative)
 {
     Al.alSourcefv(sourceID, Al.AL_POSITION, position.vector);
     Al.alSourcei(sourceID, Al.AL_SOURCE_RELATIVE, relative ? Al.AL_TRUE : Al.AL_FALSE);
     Al.alSourcePlay(sourceID);
     Check("play");
 }
        public InstantExplosionWeapon(string defaultPath, Camera camera)
        {
            if (sound == null)
                sound = new Sound(defaultPath + "Audio/laserfire3.wav");

            this.reloadTime = 1000;
            this.damage = 10;

            Texture t = new BasicTexture(defaultPath + "Texture/Particle/p.png");
            this.position = new Vector3f();
            this.direction = new Vector3f();
            pe = new PointEmitter(position);

            Vector3f maxV = new Vector3f(10.0f, 10.0f, 10.0f);
            Vector3f minV = maxV * -1.0f;
            Vector3f g = new Vector3f(0.0f, -0.001f, 0.0f);

            Color4f minC = new Color4f(1.0f, 0.7f, 0.7f, 0.0f);
            Color4f maxC = new Color4f(1.0f, 1.0f, 1.0f, 1.0f);

            pf = new BillboardedParticleFactory(t, minV, maxV, g, 0.0f, 1.0f, minC, maxC, 0.2f);
            ps = new ParticleSystem(pe, pf, camera, false, 0.1f, 1000);
            pe.setActive(false);
            ps.reset();
        }
Exemple #4
0
 public GravityBall(Vector3f position, float size, float strength, float threshold)
 {
     this.position = position;
     this.size2 = size * size; // Faster to query against length2
     this.strength = strength;
     this.threshold2 = threshold * threshold;
 }
Exemple #5
0
        public Vector3f computeTrajectory(Vector3f vector)
        {
            Vector3f newTrajectory = new Vector3f(vector.x, 0 - vector.y, vector.z);
            newTrajectory.stretch(friction);

            return newTrajectory;
        }
Exemple #6
0
        public void update(float frameTime, List<CollisionSurface> listCollisionSurfaces, List<Manipulator> listManipulators)
        {
            Vector3f positionTemp = position.copy();
            velocity.add(gravity);
            positionTemp.add(velocity * frameTime);
            remainingLife -= frameTime;

            foreach (CollisionSurface cs in listCollisionSurfaces)
            {
                if (cs.getActive() && cs.collisionDetect(position, positionTemp))
                {
                    velocity = cs.computeTrajectory(velocity);
                    positionTemp = position.copy();
                    positionTemp.add(velocity * frameTime);
                }
            }

            foreach (Manipulator m in listManipulators)
            {
                if (m.getActive())
                {
                    Vector3f deltaVelocity = new Vector3f(0.0f, 0.0f, 0.0f);
                    Color4f deltaColor = new Color4f(0.0f, 0.0f, 0.0f, 0.0f);
                    float deltaLife = 0.0f;
                    m.manipulate(this, deltaVelocity, deltaColor, ref deltaLife);
                    velocity.add(deltaVelocity.stretch(frameTime));
                    color.add(deltaColor.multiply(frameTime));
                    remainingLife += deltaLife * frameTime;
                }
            }

            position.set(positionTemp);
        }
Exemple #7
0
 public Face(Vector3f[] vertices, Vector2f[] textureVertices, Vector3f[] normalVertices, int polygonType)
 {
     this.vertices = vertices;
     this.textureVertices = textureVertices;
     this.normalVertices = normalVertices;
     this.polygonType = polygonType;
 }
Exemple #8
0
        public override Particle emit(ParticleFactory particleFactory)
        {
            Vector3f tmp = new Vector3f(0.5f - random.NextDouble(), 0.5f - random.NextDouble(), 0.5f - random.NextDouble());
            tmp.stretch(new Vector3f((float)random.NextDouble() * side.x, (float)random.NextDouble() * side.y, (float)random.NextDouble() * side.z));
            tmp.add(position);

            return particleFactory.createParticle(tmp, false, null);
        }
Exemple #9
0
 public AnimatedQuad(Texture[] textures, Vector3f pos, float width, float height)
 {
     this.pos = pos;
     this.width = width;
     this.height = height;
     this.textures = textures;
     f = 0;
 }
Exemple #10
0
 public Light(Vector3f position, Color4f color, float start, float end, CalculationMode lightCalculation)
 {
     this.position = position;
     this.color    = color;
     this.start    = start;
     this.end      = end;
     this.len      = end - start;
     this.lightCalculation = lightCalculation;
 }
Exemple #11
0
 public Particle(Vector3f position, Vector3f velocity, Vector3f gravity, Color4f color, float life, float size)
 {
     this.position = position;
     this.velocity = velocity;
     this.gravity  = gravity;
     this.color    = color;
     startLife = remainingLife = life;
     this.size = size;
 }
Exemple #12
0
 public LoadableModel(Group[] groups)
 {
     this.groups = groups;
     position = new Vector3f(0, 0, 0);
     scaleX = 1.0f;
     scaleY = 1.0f;
     scaleZ = 1.0f;
     BuildLists();
 }
Exemple #13
0
        public override Particle emit(ParticleFactory particleFactory)
        {
            Vector3f tmp = new Vector3f(0.5f - random.NextDouble(), 0.5f - random.NextDouble(), 0.5f - random.NextDouble());
            tmp.Normalize();
            tmp.stretch(radius);
            tmp.add(position);

            return particleFactory.createParticle(tmp, false, null);
        }
Exemple #14
0
 public CenteredQuad(Texture texture, Vector3f pos, float width, float height, float tileX, float tileY)
 {
     this.pos = pos;
     this.w2 = width / 2.0f;
     this.h2 = height / 2.0f;
     u = tileX;
     v = tileY;
     this.texture = texture;
 }
Exemple #15
0
 public Cube(Color4f color, Vector3f pos, float width, float height, float depth)
 {
     this.pos = pos;
     this.color = color;
     this.width = width;
     this.height = height;
     this.depth = depth;
     rot = 0.0f;
 }
Exemple #16
0
        public BillboardedQuad(Texture texture, Camera activeCamera, Vector3f position, Vector2f size)
        {
            this.texture = texture;
            this.position = position;
            this.size = size;
            this.camera = activeCamera;

            if (displayList == -1)
                createDisplayList();
        }
Exemple #17
0
        public TexturedCube(Texture texture, Vector3f pos, float width, float height, float depth)
        {
            this.pos = pos;
            this.width = width;
            this.height = height;
            this.depth = depth;
            this.texture = texture;

            rotation = new Color4f(0.0f, 0.0f, 0.0f, 0.0f);
        }
Exemple #18
0
 public MultiTexturedCube(Texture t0, Texture t1, Texture t2, Vector3f pos)
 {
     this.pos = pos;
     this.width = 1.0f;
     this.height = 1.0f;
     this.depth = 1.0f;
     this.t0 = t0;
     this.t1 = t1;
     this.t2 = t2;
     c = new Color4f(1.0f, 1.0f, 1.0f, 1.0f);
 }
        public void Fire(Vector3f playerPosition, Vector3f crosshairPosition)
        {
            if (!canFire())
                return;

            sound.play(position);
            position.set(crosshairPosition);
            ps.reset();
            pe.setActive(true);
            lastFired = System.Environment.TickCount;
        }
Exemple #20
0
        public Color4f calculateColor(Vector3f v)
        {
            float d = position.length(v);

            if (d < start)
                return color.copy();
            else if (d > end)
                return new Color4f(0.0f, 0.0f, 0.0f, 0.0f);
            else
                return color.copy().multiply(calculate((d - start) / len));
        }
Exemple #21
0
 public void setOrientation(Vector3f frontVector, Vector3f upVector)
 {
     float[] orientation = new float[6];
     orientation[0] = frontVector.x;
     orientation[1] = frontVector.y;
     orientation[2] = frontVector.z;
     orientation[3] = upVector.x;
     orientation[4] = upVector.y;
     orientation[5] = upVector.z;
     Al.alListenerfv(Al.AL_ORIENTATION, orientation);
 }
Exemple #22
0
        public Plane(Vector3f p0, Vector3f p0A, Vector3f p0B)
        {
            Vector3f vecA = p0A - p0;
            Vector3f vecB = p0B - p0;
            Vector3f normal = vecA.Cross(vecB);

            a = normal.x;
            b = normal.y;
            c = normal.z;
            d = -1.0f * (normal * p0);
        }
Exemple #23
0
        public void play(Vector3f position)
        {
            Source source;
            if (sources.Count == 0 || sources.Peek().isPlaying())
                source = new Source(audioBuffer, 1.0f);
            else
                source = sources.Dequeue();

            source.play(position, false);

            sources.Enqueue(source);
        }
 public RotatableGroundPlane(Vector3f position, float deltaY_X, float deltaY_Z, float friction)
 {
     active = true;
     this.friction = friction;
     this.position = position;
     this.deltaY_X = deltaY_X;
     this.deltaY_Z = deltaY_Z;
     Vector3f vectorA = new Vector3f(1.0f, -deltaY_X, 0.0f);
     Vector3f vectorB = new Vector3f(0.0f, -deltaY_Z, 1.0f);
     normal = vectorA.Cross(vectorB);
     normal.Normalize();
 }
        public Particle createParticle(Vector3f emitterPosition, bool emitterUseDirection, Vector3f emitterDirection)
        {
            Color4f color = new Color4f((maximumColor.a - minimalColor.a) * random.NextDouble() + minimalColor.a,
                                        (maximumColor.r - minimalColor.r) * random.NextDouble() + minimalColor.r,
                                        (maximumColor.g - minimalColor.g) * random.NextDouble() + minimalColor.g,
                                        (maximumColor.b - minimalColor.b) * random.NextDouble() + minimalColor.b);
            Vector3f velocity = new Vector3f((maximumInitialVelocity.x - minimalInitialVelocity.x) * random.NextDouble(),
                                           (maximumInitialVelocity.y - minimalInitialVelocity.y) * random.NextDouble(),
                                           (maximumInitialVelocity.z - minimalInitialVelocity.z) * random.NextDouble());
            velocity.add(minimalInitialVelocity);
            float particleLife = minimalParticleLife;
            float t = (maximumParticleLife - minimalParticleLife);
            particleLife += t * (float)random.NextDouble();

            return new BillboardedParticle(emitterPosition.copy(), velocity, gravity, color, particleLife, size);
        }
        public BillboardedParticleFactory(Texture texture, Vector3f minimalInitialVelocity, Vector3f maximumInitialVelocity,
								  Vector3f gravity, float minimalParticleLife, float maximumParticleLife,
								  Color4f minimalColor, Color4f maximumColor, float size)
        {
            this.texture = texture;
            this.minimalInitialVelocity = minimalInitialVelocity;
            this.maximumInitialVelocity = maximumInitialVelocity;
            this.gravity = gravity;
            this.minimalParticleLife = minimalParticleLife;
            this.maximumParticleLife = maximumParticleLife;
            this.minimalColor = minimalColor;
            this.maximumColor = maximumColor;
            this.size = size;

            random = new Random();
        }
        public Vector3f computeTrajectory(Vector3f vector)
        {
            float len = vector.length();
            Vector3f newTrajectory = vector.copy();

            float projection = (vector * normal) / (normal * normal);

            Vector3f u = normal * projection;

            newTrajectory.subtract(u).subtract(u);

            newTrajectory.stretch(friction);

            //Console.Out.WriteLine("Got: " + vector.ToString() + " computed: " + newTrajectory.ToString());

            return newTrajectory;
        }
Exemple #28
0
        public GroundPlane(Texture texture, int tileU, int tileV, Vector3f pointA, Vector3f pointB, Vector3f pointC, Vector3f pointD)
        {
            this.texture = texture;

            this.tileU = tileU;
            this.tileV = tileV;

            this.pointA = pointA;
            this.pointB = pointB;
            this.pointC = pointC;
            this.pointD = pointD;

            Vector3f vectorA = pointA.diff(pointB);
            Vector3f vectorB = pointA.diff(pointD);

            normal = vectorA.Cross(vectorB);
            normal.Normalize();
        }
Exemple #29
0
        public GluSphere(CubeMapTexture texture, Vector3f position, float radius, int slices)
        {
            this.texture = texture;
            this.position = position;
            this.radius = radius;
            this.slices = slices;

            quad = Glu.gluNewQuadric();

            Glu.gluQuadricNormals(quad, Glu.GLU_SMOOTH);	// Create Smooth Normals ( NEW )
            Glu.gluQuadricTexture(quad, Gl.GL_TRUE);		// Create Texture Coords ( NEW )
            Glu.gluQuadricDrawStyle(quad, Glu.GLU_FILL);

            angle  = 0.0f;
            x_axis = 0.0f;
            y_axis = 0.0f;
            z_axis = 0.0f;
        }
Exemple #30
0
        public LightMapTexture(List<Light> lights, Vector3f center, Vector3f frontVector, Vector3f rightVector, int textureSize, float realSize)
        {
            size = textureSize;
            int halfSize  = size  / 2;
            float halfRealSize = realSize / 2.0f;

            System.Collections.Generic.List<float> data = new System.Collections.Generic.List<float>();
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    float x = halfRealSize * ((float)(halfSize - i) / (float)halfSize);
                    float y = halfRealSize * ((float)(halfSize - j) / (float)halfSize);
                    Vector3f v = frontVector * y + rightVector * x;
                    v.add(center);

                    float r, g, b;
                    r = g = b = 0.0f;
                    for (int l = 0; l < lights.Count; l++)
                    {
                        Color4f color = lights[l].calculateColor(v);
                        r += color.r;
                        g += color.g;
                        b += color.b;
                    }
                    r = r > 1.0f ? 1.0f : r;
                    g = g > 1.0f ? 1.0f : g;
                    b = b > 1.0f ? 1.0f : b;

                    data.Add(r);
                    data.Add(g);
                    data.Add(b);
                }
            }

            int[] TempGL = new int[1];

            Gl.glGenTextures(1, TempGL);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, TempGL[0]);

            Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, 3, size, size, Gl.GL_RGB, Gl.GL_FLOAT, data.ToArray());

            textureID = TempGL[0];
        }