예제 #1
0
static GMVector3D intersectionPoint(const GMPlane& a, const GMPlane& b, const GMPlane& c)
{
    double f = -a.normalVec.dot(b.normalVec.cross(c.normalVec));

    GMVector3D v1 = a.distance * b.normalVec.cross(c.normalVec);
    GMVector3D v2 = b.distance * c.normalVec.cross(a.normalVec);
    GMVector3D v3 = c.distance * a.normalVec.cross(b.normalVec);

    return GMVector3D(v1.x + v2.x + v3.x, v1.y + v2.y + v3.y, v1.z + v2.z + v3.z) / f;
}
예제 #2
0
void SKBlock::objectDraw(int i_x, int i_y){

    int nameNum = 4;
    
    GMDraw::Begin();
    gPlayScene->getCurrentEffect()->setTexture(m_scene->getTexMan()->get(Texture_blockName));
    GMDraw::FillQuad(GMVector3D(i_x, i_y, 10), GMVector3D(i_x+mass_size+1, i_y, 10),
                     GMVector3D(i_x+mass_size+1, i_y+mass_size+1, 10), GMVector3D(i_x, i_y+mass_size+1, 10),
                     GMVector3D(0, 0, 1), GMVector3D(0, 0, 1),
                     GMVector3D(0, 0, 1), GMVector3D(0, 0, 1),
                     GMVector2D(1.0/7*nameNum, 0), GMVector2D(1.0/7*(nameNum+1), 0),
                     GMVector2D(1.0/7*(nameNum+1), 1), GMVector2D(1.0/7*nameNum, 1));
    GMDraw::End();
}
예제 #3
0
void SKItem::objectDraw(int i_x, int i_y){
    GMDraw::Begin();
    gPlayScene->getCurrentEffect()->setTexture(m_scene->getTexMan()->get(Texture_itemName));
    int x = m_itemNum%xNum;
    int y = m_itemNum/xNum;
    GMDraw::FillQuad(GMVector3D(i_x, i_y, 10), GMVector3D(i_x+mass_size+1, i_y, 10),
                     GMVector3D(i_x+mass_size+1, i_y+mass_size+1, 10), GMVector3D(i_x, i_y+mass_size+1, 10),
                     GMVector3D(0, 0, 1), GMVector3D(0, 0, 1),
                     GMVector3D(0, 0, 1), GMVector3D(0, 0, 1),
                     GMVector2D(1.0/xNum*x, 1.0/yNum*y), GMVector2D(1.0/xNum*(x+1), 1.0/yNum*y),
                     GMVector2D(1.0/xNum*(x+1), 1.0/yNum*(y+1)), GMVector2D(1.0/xNum*x, 1.0/yNum*(y+1)));
    GMDraw::End();
    
}
예제 #4
0
GMVector3D GMViewport::unproject(const GMVector3D& source, const GMMatrix& projection, const GMMatrix& view, const GMMatrix& world)
{
    GMVector4D result;
    result.x = ((source.x - x) * 2 / width) - 1;
    result.y = 1 - ((source.y - y) * 2 / height);
    result.z = source.z - minDepth;
    if (fabs(maxDepth - minDepth) < GMMathHelper::DoubleEqThreshold) {
        result.z = 0.0;
    } else {
        result.z /= (maxDepth - minDepth);
    }
    result.w = 1.0;
    result = result.transform(projection.invert());
    result = result.transform(view.invert());
    result = result.transform(world.invert());
    result /= result.w;
    return GMVector3D(result.x, result.y, result.z);
    
}
예제 #5
0
GMVector3D GMVector3D::transform(const GMQuat& quat) const
{
    GMVector4D v4(*this, 1.0);
    v4 = v4.transform(quat);
    return GMVector3D(v4.x, v4.y, v4.z);    
}
예제 #6
0
GMVector3D GMVector3D::operator/(const GMVector3D& vec) const
{
    return GMVector3D(x / vec.x, y / vec.y, z / vec.z);
}
예제 #7
0
GMVector3D GMVector3D::normal() const
{
    return GMVector3D(*this).normalize();
}
예제 #8
0
GMVector3D GMVector3D::transform(const GMMatrix& matrix) const
{
    GMVector4D v4(*this, 1.0);
    v4 = v4.transform(matrix);
    return GMVector3D(v4.x, v4.y, v4.z);
}
예제 #9
0
GMVector3D operator*(double value, const GMVector3D& vec)
{
    return GMVector3D(vec.x * value, vec.y * value, vec.z * value);
}
예제 #10
0
GMVector3D GMVector3D::cross(const GMVector3D& vec) const
{
    return GMVector3D(y * vec.z - z * vec.y, z * vec.x - x * vec.z, x * vec.y - y * vec.x);
}
예제 #11
0
//  GMVector3D.cpp
//  Game Framework
//
//  Created by numata on Jan 10, 2011.
//  Copyright 2011 Sazameki and Satoshi Numata, Ph.D. All rights reserved.
//

#include "GMVector2D.h"
#include "GMVector3D.h"
#include "GMVector4D.h"
#include "GMMathHelper.h"

#include <cmath>


const GMVector3D& GMVector3D::Backward  = GMVector3D(0.0, 0.0, 1.0);
const GMVector3D& GMVector3D::Down      = GMVector3D(0.0, -1.0, 0.0);
const GMVector3D& GMVector3D::Forward   = GMVector3D(0.0, 0.0, -1.0);
const GMVector3D& GMVector3D::Left      = GMVector3D(-1.0, 0.0, 0.0);
const GMVector3D& GMVector3D::One       = GMVector3D(1.0, 1.0, 1.0);
const GMVector3D& GMVector3D::Right     = GMVector3D(1.0, 0.0, 0.0);
const GMVector3D& GMVector3D::UnitX     = GMVector3D(1.0, 0.0, 0.0);
const GMVector3D& GMVector3D::UnitY     = GMVector3D(0.0, 1.0, 0.0);
const GMVector3D& GMVector3D::UnitZ     = GMVector3D(0.0, 0.0, 1.0);
const GMVector3D& GMVector3D::Up        = GMVector3D(0.0, 1.0, 0.0);
const GMVector3D& GMVector3D::Zero      = GMVector3D(0.0, 0.0, 0.0);


GMVector3D GMVector3D::Barycentric(const GMVector3D& v1, const GMVector3D& v2, const GMVector3D& v3, double t1, double t2)
{
    return ((1.0 - t1 - t2) * v1) + (t1 * v2) + (t2 * v3);
예제 #12
0
GMVector3D GMVector3D::operator/(double value) const
{
    return GMVector3D(x / value, y / value, z / value);
}
예제 #13
0
GMVector3D GMVector3D::SmoothStep(const GMVector3D& vec1, const GMVector3D& vec2, double t)
{
    return GMVector3D(GMMathHelper::SmoothStep(vec1.x, vec2.x, t),
                      GMMathHelper::SmoothStep(vec1.y, vec2.y, t),
                      GMMathHelper::SmoothStep(vec1.z, vec2.z, t));
}
예제 #14
0
GMVector3D GMVector3D::operator*(const GMVector3D& vec) const
{
    return GMVector3D(x * vec.x, y * vec.y, z * vec.z);
}
예제 #15
0
GMVector3D GMVector3D::operator-(const GMVector3D& vec) const
{
    return GMVector3D(x - vec.x, y - vec.y, z - vec.z);
}
예제 #16
0
GMVector3D GMVector3D::operator+(const GMVector3D& vec) const
{
    return GMVector3D(x + vec.x, y + vec.y, z + vec.z);
}
예제 #17
0
GMVector3D GMVector3D::operator-() const
{
    return GMVector3D(-x, -y, -z);
}
예제 #18
0
GMVector3D GMVector3D::operator*(double value) const
{
    return GMVector3D(x * value, y * value, z * value);
}
예제 #19
0
GMVector3D GMColor::toVector3D() const
{
    return GMVector3D(r, g, b);
}