当前位置: 首页>>代码示例>>C++>>正文


C++ Vector3函数代码示例

本文整理汇总了C++中Vector3函数的典型用法代码示例。如果您正苦于以下问题:C++ Vector3函数的具体用法?C++ Vector3怎么用?C++ Vector3使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Vector3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Vector3

Vector3 Vector3::Cross(Vector3 vect,Vector3 vect2){
	return Vector3( vect.y * vect.z - vect.z * vect.y, 
					vect.z * vect.x - vect.x * vect.z,
					vect.x * vect.y - vect.y * vect.x );
}
开发者ID:lukemonaghan,项目名称:YR01_03_Refactor_MathLibrary,代码行数:5,代码来源:Vector3.cpp

示例2: CrossProduct

	Vector3 CrossProduct(const Vector3& other) const
	{
		return Vector3((y * other.z) - (z * other.y), -((x * other.z) - (z * other.x)), (x * other.y) - (y * other.x));
	}
开发者ID:aleios,项目名称:temporalmist,代码行数:4,代码来源:Vector3.hpp

示例3: assert

 Vector3 Matrix4::operator[](int basisIdx) const
 {
    assert(0 <= basisIdx && basisIdx <= 3);
    return Vector3(m[0][basisIdx], m[1][basisIdx], m[2][basisIdx]);
 }
开发者ID:CrazyNinja,项目名称:Neural-Network,代码行数:5,代码来源:Matrix4.cpp

示例4: Vector3

Plane::Plane(FLOAT a, FLOAT b, FLOAT c, FLOAT d) 
{ 
	Normal = Vector3(a,b,c); 
	D = d; 
};
开发者ID:dgadens,项目名称:ActionEngine,代码行数:5,代码来源:Plane.cpp

示例5: move

Vector3 
ILocatable::move(float X,float Y,float Z)
			{return move(Vector3(X,Y,Z));}
开发者ID:KallePower,项目名称:AlphaKlang,代码行数:3,代码来源:Connectable.cpp

示例6: scale

Vector3 
ILocatable::scale(float X,float Y,float Z)
			{return scale(Vector3(X,Y,Z));}
开发者ID:KallePower,项目名称:AlphaKlang,代码行数:3,代码来源:Connectable.cpp

示例7: Chunk

Chunk *ChunkGenerator::generateChunk(City *city, const Vector2 &position) {
    // First we check if position is valid (if both X and Y are multiple of 1000)
    if ((int) position.x % 1000 != 0 || (int) position.y % 1000 != 0) {
        return nullptr;
    }
    // And also if this chunk doesn't already exists
    if (FileIO::fileExists(Chunk::getFileName(position))) {
        return nullptr;
    }

    Profiler::getTimer(3)->startMeasurement();

    /*
     * Generate Intersections and Roads
     */

    //TODO: Put this condition on the different grid layout generators. Each may have different limits
    int minDistanceIntersections = 50; // Minimum distance between intersections
    Chunk *chunk = new Chunk(position, city);
    std::vector<Chunk*> neighbourChunks = city->getNeighbourChunks(chunk, true);
    ManhattanGridLayout gridLayout = ManhattanGridLayout(Vector2(), Vector2());
    int numSubChunks = Chunk::CHUNK_SIZE / Chunk::SUBCHUNK_SIZE;
    float subChunkSize = (float) Chunk::SUBCHUNK_SIZE;
    for (int i = 0; i < numSubChunks; i++) {
        for (int j = 0; j < numSubChunks; j++) {
            // Calculate the position of the new intersection on this subchunk
            gridLayout.posMin = Vector2(i * subChunkSize, j * subChunkSize);
            gridLayout.posMax = Vector2((i + 1) * subChunkSize, (j + 1) * subChunkSize);
            Vector2 intersectionPos = gridLayout.getIntersectionPosition();
            float den = Perlin::getCityBlockDensity(intersectionPos.x + position.x, intersectionPos.y + position.y);
            if (intersectionPos.x > -99 && intersectionPos.y > -99 && den > 0.0f) {
                // If there's an intersection in this subchunk, check if it has enough distance from the others
                intersectionPos += position; // Convert to World Position
                auto it = chunk->getIntersections()->begin();
                auto itEnd = chunk->getIntersections()->end();
                bool tooClose = false;
                Vector3 newIntPos = Vector3(intersectionPos.x, 0, intersectionPos.y);
                for (; it != itEnd; it++) {
                    Intersection *intersection = (*it);
                    // Chunk position for the new intersection position (0 to 1000)
                    float length = (intersection->getPosition() - newIntPos).getLength();
                    //std::cout << length << std::endl;
                    if (length < minDistanceIntersections) {
                        tooClose = true;
                        break;
                    }
                }
                if (!tooClose) {
                    // If the new intersections is sufficiently distant from all the others, proceed
                    Intersection *newInter = nullptr;
                    Intersection *neighbourSubstitute = nullptr;
                    // Check if the new Intersection is too close to any Intersection on the neighbours
                    for (auto it = neighbourChunks.begin(); it != neighbourChunks.end(); it++) {
                        Intersection *closest = (*it)->getClosestIntersectionTo(newIntPos);
                        if (closest != nullptr) {
                            float distance = (closest->getPosition() - newIntPos).getLength();
                            if (distance < minDistanceIntersections) {
                                // The new Intersection is too close to an Intersection on an neighbour. Use the
                                // neighbour's Intersection instead
                                neighbourSubstitute = closest;
                                break;
                            }
                        }
                    }
                    if (neighbourSubstitute != nullptr) {
                        newInter = neighbourSubstitute;
                    } else {
                        newInter = new Intersection(newIntPos);
                    }
                    chunk->addIntersection(newInter);
                    gridLayout.generateRoads(chunk, newInter);
                }
            }
        }
    }

    //Profiler::getTimer(3)->finishMeasurement();
    //Profiler::getTimer(3)->resetCycle();
    //std::cout << chunk->getChunkPos() << " generated in " << Profiler::getTimer(3)->getAverageTime() << "ms" << std::endl;

    //return chunk;

    /*
     * Generate City Blocks and Buildings
     */

    auto itEnd = chunk->getIntersections()->end();
    for (auto it = chunk->getIntersections()->begin(); it != itEnd; it++) {
        CityBlock *cityBlock = gridLayout.generateCityBlock(chunk, (*it));

        if (cityBlock != nullptr) {
            // Check if this CityBlock has any Intersections that are in mutiple Chunks. If it does, add the CityBlock to
            // those Chunks
            /*Intersection *multiIntersection = nullptr;
            for (auto it = cityBlock->getVertices()->begin(); it != cityBlock->getVertices()->end(); it++) {
                if ((*it)->getNumChunksSharing() > 1) {
                    multiIntersection = *it;
                }
            }
            if (multiIntersection != nullptr) {
//.........这里部分代码省略.........
开发者ID:roooodcastro,项目名称:city-rendering-engine,代码行数:101,代码来源:ChunkGenerator.cpp

示例8: get_token

Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,int &line,String &r_err_str,ResourceParser *p_res_parser) {



/*	{
		Error err = get_token(p_stream,token,line,r_err_str);
		if (err)
			return err;
	}*/


	if (token.type==TK_CURLY_BRACKET_OPEN) {

		Dictionary d;
		Error err = _parse_dictionary(d,p_stream,line,r_err_str,p_res_parser);
		if (err)
			return err;
		value=d;
		return OK;
	} else if (token.type==TK_BRACKET_OPEN) {

		Array a;
		Error err = _parse_array(a,p_stream,line,r_err_str,p_res_parser);
		if (err)
			return err;
		value=a;
		return OK;

	} else if (token.type==TK_IDENTIFIER) {
/*
		VECTOR2,		// 5
		RECT2,
		VECTOR3,
		MATRIX32,
		PLANE,
		QUAT,			// 10
		_AABB, //sorry naming convention fail :( not like it's used often
		MATRIX3,
		TRANSFORM,

		// misc types
		COLOR,
		IMAGE,			// 15
		NODE_PATH,
		_RID,
		OBJECT,
		INPUT_EVENT,
		DICTIONARY,		// 20
		ARRAY,

		// arrays
		RAW_ARRAY,
		INT_ARRAY,
		REAL_ARRAY,
		STRING_ARRAY,	// 25
		VECTOR2_ARRAY,
		VECTOR3_ARRAY,
		COLOR_ARRAY,

		VARIANT_MAX

*/
		String id = token.value;
		if (id=="true")
			value=true;
		else if (id=="false")
			value=false;
		else if (id=="null")
			value=Variant();
		else if (id=="Vector2"){

			Vector<float> args;
			Error err = _parse_construct<float>(p_stream,args,line,r_err_str);
			if (err)
				return err;

			if (args.size()!=2) {
				r_err_str="Expected 2 arguments for constructor";
			}

			value=Vector2(args[0],args[1]);
			return OK;
		} else if (id=="Rect2"){

			Vector<float> args;
			Error err = _parse_construct<float>(p_stream,args,line,r_err_str);
			if (err)
				return err;

			if (args.size()!=4) {
				r_err_str="Expected 4 arguments for constructor";
			}

			value=Rect2(args[0],args[1],args[2],args[3]);
			return OK;
		} else if (id=="Vector3"){

			Vector<float> args;
			Error err = _parse_construct<float>(p_stream,args,line,r_err_str);
			if (err)
//.........这里部分代码省略.........
开发者ID:skugga1302,项目名称:godot,代码行数:101,代码来源:variant_parser.cpp

示例9: Vector3

Vector3 Printer::getLetterBaseLocalization(char letter) {
    return Vector3(0.0, 0.0, 0.0);
}
开发者ID:xathanex,项目名称:analiza,代码行数:3,代码来源:Printer.cpp

示例10: glClearColor

void SceneTexture::Init()
{
	// Init VBO here

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Set background color
	glEnable(GL_DEPTH_TEST); // Enable depth buffer and depth testing
	glEnable(GL_CULL_FACE); // Enable back face culling

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Default to fill mode
	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	// Generate a default VAO for now
	glGenVertexArrays(1, &m_vertexArrayID);
	glBindVertexArray(m_vertexArrayID);
	m_programID = LoadShaders("Shader//Texture.vertexshader", "Shader//Texture.fragmentshader");

	m_parameters[U_MVP] = glGetUniformLocation(m_programID, "MVP");
	m_parameters[U_MODELVIEW] = glGetUniformLocation(m_programID, "MV");
	m_parameters[U_MODELVIEW_INVERSE_TRANSPOSE] = glGetUniformLocation(m_programID, "MV_inverse_transpose");
	m_parameters[U_MATERIAL_AMBIENT] = glGetUniformLocation(m_programID, "material.kAmbient");
	m_parameters[U_MATERIAL_DIFFUSE] = glGetUniformLocation(m_programID, "material.kDiffuse");
	m_parameters[U_MATERIAL_SPECULAR] = glGetUniformLocation(m_programID, "material.kSpecular");
	m_parameters[U_MATERIAL_SHININESS] = glGetUniformLocation(m_programID, "material.kShininess");
	m_parameters[U_LIGHT0_POSITION] = glGetUniformLocation(m_programID, "lights[0].position_cameraspace");
	m_parameters[U_LIGHT0_COLOR] = glGetUniformLocation(m_programID, "lights[0].color");
	m_parameters[U_LIGHT0_POWER] = glGetUniformLocation(m_programID, "lights[0].power");
	m_parameters[U_LIGHT0_KC] = glGetUniformLocation(m_programID, "lights[0].kC");
	m_parameters[U_LIGHT0_KL] = glGetUniformLocation(m_programID, "lights[0].kL");
	m_parameters[U_LIGHT0_KQ] = glGetUniformLocation(m_programID, "lights[0].kQ");
	m_parameters[U_LIGHTENABLED] = glGetUniformLocation(m_programID, "lightEnabled");
	m_parameters[U_NUMLIGHTS] = glGetUniformLocation(m_programID, "numLights"); //in case you missed out practical 7

	// Get a handle for our "colorTexture" uniform
	m_parameters[U_COLOR_TEXTURE_ENABLED] = glGetUniformLocation(m_programID, "colorTextureEnabled");
	m_parameters[U_COLOR_TEXTURE] = glGetUniformLocation(m_programID, "colorTexture");
	glUseProgram(m_programID);

	//variable to rotate geometry

	//Initialize camera settings
	camera.Init(Vector3(4, 3, 3), Vector3(0, 0, 0), Vector3(0, 1, 0));

	meshList[GEO_AXES] = MeshBuilder::GenerateAxes("AXES", 1000, 1000, 1000);

	Mtx44 projection;
	projection.SetToPerspective(45.f, 4.f / 3.f, 0.1f, 1000.f);
	projectionStack.LoadMatrix(projection);


	light[0].position.Set(0, 20, 0);
	light[0].color.Set(1, 1, 1);
	light[0].power = 1;
	light[0].kC = 1.f;
	light[0].kL = 0.01f;
	light[0].kQ = 0.001f;
	// Make sure you pass uniform parameters after glUseProgram()
	glUniform3fv(m_parameters[U_LIGHT0_COLOR], 1, &light[0].color.r);
	glUniform1f(m_parameters[U_LIGHT0_POWER], light[0].power);
	glUniform1f(m_parameters[U_LIGHT0_KC], light[0].kC);
	glUniform1f(m_parameters[U_LIGHT0_KL], light[0].kL);
	glUniform1f(m_parameters[U_LIGHT0_KQ], light[0].kQ);
	glUniform1i(m_parameters[U_NUMLIGHTS], 1);

	meshList[GEO_LIGHTBALL] = MeshBuilder::GenerateSphere("LIGHT", Color(1, 1, 1), 36, 36);

	meshList[GEO_QUAD] = MeshBuilder::GenerateQuad("quad", Color(1, 1, 1));
	meshList[GEO_QUAD]->textureID = LoadTGA("Image//color2.tga");

}
开发者ID:HighwindEasy,项目名称:Compg,代码行数:69,代码来源:SceneTexture.cpp

示例11: _cull_aabb_for_body

bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer::MotionResult *r_result) {

	//give me back regular physics engine logic
	//this is madness
	//and most people using this function will think
	//what it does is simpler than using physics
	//this took about a week to get right..
	//but is it right? who knows at this point..

	if (r_result) {
		r_result->collider_id = 0;
		r_result->collider_shape = 0;
	}
	AABB body_aabb;

	for (int i = 0; i < p_body->get_shape_count(); i++) {

		if (i == 0)
			body_aabb = p_body->get_shape_aabb(i);
		else
			body_aabb = body_aabb.merge(p_body->get_shape_aabb(i));
	}

	// Undo the currently transform the physics server is aware of and apply the provided one
	body_aabb = p_from.xform(p_body->get_inv_transform().xform(body_aabb));
	body_aabb = body_aabb.grow(p_margin);

	Transform body_transform = p_from;

	{
		//STEP 1, FREE BODY IF STUCK

		const int max_results = 32;
		int recover_attempts = 4;
		Vector3 sr[max_results * 2];

		do {

			PhysicsServerSW::CollCbkData cbk;
			cbk.max = max_results;
			cbk.amount = 0;
			cbk.ptr = sr;

			PhysicsServerSW::CollCbkData *cbkptr = &cbk;
			CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk;

			bool collided = false;

			int amount = _cull_aabb_for_body(p_body, body_aabb);

			for (int j = 0; j < p_body->get_shape_count(); j++) {
				if (p_body->is_shape_set_as_disabled(j))
					continue;

				Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
				ShapeSW *body_shape = p_body->get_shape(j);
				for (int i = 0; i < amount; i++) {

					const CollisionObjectSW *col_obj = intersection_query_results[i];
					int shape_idx = intersection_query_subindex_results[i];

					if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) {
						collided = cbk.amount > 0;
					}
				}
			}

			if (!collided) {
				break;
			}

			Vector3 recover_motion;

			for (int i = 0; i < cbk.amount; i++) {

				Vector3 a = sr[i * 2 + 0];
				Vector3 b = sr[i * 2 + 1];
				recover_motion += (b - a) * 0.4;
			}

			if (recover_motion == Vector3()) {
				collided = false;
				break;
			}

			body_transform.origin += recover_motion;
			body_aabb.position += recover_motion;

			recover_attempts--;

		} while (recover_attempts);
	}

	real_t safe = 1.0;
	real_t unsafe = 1.0;
	int best_shape = -1;

	{
		// STEP 2 ATTEMPT MOTION

//.........这里部分代码省略.........
开发者ID:Ranakhamis,项目名称:godot,代码行数:101,代码来源:space_sw.cpp

示例12: Vector3

#include "Vector3.h"
#include "Vector4.h"
#include "Matrix.h"

#include "Converter.h"

const Vector3 Vector3::zero = Vector3(0, 0, 0);
const Vector3 Vector3::one = Vector3(1, 1, 1);

const Vector3 Vector3::right = Vector3(1, 0, 0);
const Vector3 Vector3::up = Vector3(0, 1, 0);
const Vector3 Vector3::forward = Vector3(0, 0, 1);

const Vector3 Vector3::left = -Vector3::right;
const Vector3 Vector3::down = -Vector3::up;
const Vector3 Vector3::back = -Vector3::forward;


Vector3::Vector3() : D3DXVECTOR3(0, 0, 0) {}
Vector3::Vector3(D3DVECTOR v) : D3DXVECTOR3(v.x, v.y, v.z) {}
Vector3::Vector3(float f) : D3DXVECTOR3(f, f, f) {}
Vector3::Vector3(float x, float y, float z) : D3DXVECTOR3(x, y, z) {}
Vector3::Vector3(const D3DXVECTOR3& v) : D3DXVECTOR3(v) {}
Vector3::Vector3(const Vector2& v) : D3DXVECTOR3(v.x, v.y, 1) {}
Vector3::Vector3(const D3DCOLORVALUE& v) : D3DXVECTOR3(v.r, v.g, v.b) {}

Vector3 Vector3::v;


Vector3::operator D3DCOLORVALUE() const
{
开发者ID:sp-alex-osou,项目名称:LuckyLeprechauns,代码行数:31,代码来源:Vector3.cpp

示例13: Vector3

 // Cross product
 Vector3 Vector3::cross(const Vector3& v) const
 {
     return Vector3(y * v.z - z * v.y,
                    z * v.x - x * v.z,
                    x * v.y - y * v.x);
 }
开发者ID:UCAPA,项目名称:ucapa,代码行数:7,代码来源:vector3.cpp

示例14: rotate

 Vector3 
ILocatable::rotate(float X,float Y,float Z)
			{return rotate(Vector3(X,Y,Z));}
开发者ID:KallePower,项目名称:AlphaKlang,代码行数:3,代码来源:Connectable.cpp

示例15: magnitude

 Vector3 Vector3::normalized() const
 {
     float m = magnitude();
     return Vector3(x/m, y/m, z/m);
 }
开发者ID:UCAPA,项目名称:ucapa,代码行数:5,代码来源:vector3.cpp


注:本文中的Vector3函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。