• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
WiredCat

Problem with construction of two vectors from one [opengl]

4 posts in this topic

hello, i am trying to create a 3d box from on screen. (from a specified modelview)

 

 

here is what i do:

 

get from modelview 3 vectors (front, right and up) (they're versors)

then i check when i clicked at the beggining and i make a vertex (the first box vertex) call it A (red dot)

after that i check where actually mouse pos is and create a second vertex (the last box front face vertex) call it B (green dot)

 

 

i make a vector from first vertex to last vertex (AB)

 

and then project it onto 2 versors (right and up)

 

then i make a depth vector (from front versor)

 

but i does not work : )

 

here is a vid:

http://www.youtube.com/watch?v=TgtNoCIx5Qs&feature=youtu.be

 

 

I am using the formula from wikipedia

 

result = lengthof(projected_vec) * cosine_between_those_2_vectors * versor_direction_of_vec_that_will_be projected_on

vec_projection.jpg

 

 

please look at my code it looks fine but maybe i can't find bug there

 

and here is code with (stage 2 - green dot and rest of box creation)

 

 





void __fastcall TModelGroupHandler::ResizeBox(int X, int Y, HWND hwnd)
{
if (n2ddistance(float(lastx), float(lasty), float(X), float(Y) ) < 10.0f) return;
if (insert_box_first_stage_completed == false) return;


double * m_PickInfo_ModelView = new double[16];
t3dpoint vX; t3dpoint vY;

glGetDoublev(GL_MODELVIEW_MATRIX, m_PickInfo_ModelView);
		/*

			AIR_MATRIX[0] = rr.x; //right
			AIR_MATRIX[1] = rr.y;
			AIR_MATRIX[2] = rr.z;
			AIR_MATRIX[3] = 0.0f;
			AIR_MATRIX[4] = ru.x; //up
			AIR_MATRIX[5] = ru.y;
			AIR_MATRIX[6] = ru.z;
			AIR_MATRIX[7] = 0.0f;
			AIR_MATRIX[8]  = -rf.x; //front
			AIR_MATRIX[9]  = -rf.y;
			AIR_MATRIX[10] = -rf.z;
			AIR_MATRIX[11] = 0.0f;
			AIR_MATRIX[12] =  0.0f;  //point
			AIR_MATRIX[13] =  0.0f;
			AIR_MATRIX[14] =  0.0f;
			AIR_MATRIX[15] = 1.0f;

        */

vX.x = float(m_PickInfo_ModelView[0]);
vX.y = float(m_PickInfo_ModelView[1]);
vX.z = float(m_PickInfo_ModelView[2]);


vY.x =	float(m_PickInfo_ModelView[4]);
vY.y =	float(m_PickInfo_ModelView[5]);
vY.z =	float(m_PickInfo_ModelView[6]);
  //vector projection onto another vector
  

  
t3dpoint nX = vX;
t3dpoint nY = vY;

vX = vector_multiple(vX, 10000.0f);
vY = vector_multiple(vY, 10000.0f);

delete m_PickInfo_ModelView;

t3dpoint res;        t3dpoint res2;  

res = GetPositionFromSpaceDepth(X, Y, hwnd); //GREEN DOT

//==================================================================================
//right vector projection
t3dpoint projected_vec;     projected_vec = vectorAB(base->p1, res);

float cos_angle = RadToDeg(   AngleBetweenVectors(vX,projected_vec)  );      //ssh

cos_angle = cos(cos_angle*imopi);                                 //ssh



float magni;
magni = magnitude( projected_vec );

float fp; /* floating point */
 fp = magni * cos_angle;

t3dpoint proper_right_vec = vector_multiple(nX, fp);
//==================================================================================
//down vector projection
//==================================================================================

projected_vec = vectorAB(base->p1, res);



cos_angle = RadToDeg(   AngleBetweenVectors(vY,projected_vec)  );      //vY should be reversed now but i does not matter now because box right vector is wrong too)




cos_angle = cos(cos_angle*imopi);                                 //ssh

fp = magni * cos_angle;

t3dpoint proper_down_vec = vector_multiple(vY, fp);

proper_down_vec = reverse_point( proper_down_vec );
 
//==================================================================================
t3dpoint depth_v = vectorAB(base->eyepos, base->eyepointingpos);    depth_v = Normalize( depth_v );

depth_v = vector_multiple(depth_v, 50.0f); //default 50 meters depth


//*************************************************
//** proper_down_vec
//** proper_right_vec
//** depth_v
//**
//**  p1    p2       p5  p6
//**
//**   front          back
//**  p4    p3       p8  p7
//**
//**
//**
//*************************************************

base->p5 = 	vectors_add(base->p1, depth_v);

base->p3 = res;
base->p7 = 	vectors_add(base->p3, depth_v);

base->p2 	=  vectors_add(base->p1, proper_right_vec);
base->p6 	=  vectors_add(base->p2, depth_v);

base->p4 	= vectors_add(base->p1, proper_down_vec);
base->p8 	= vectors_add(base->p4, depth_v);



box_can_be_drawn = true;
}

 

cheers

Edited by ___
0

Share this post


Link to post
Share on other sites

I realize this is a late reply, and you may have moved on from this post. In any case...

 

I would first comment that the term versor isn't that commonly used, and it can mean different things. A versor is a unit quaternion. But sometimes, for some reason, versor is used to denote a set of unit length basis vectors aligned with the axes of a coordinate system...and this is how you are using the term. I've been involved in modeling and geometric representations and coordinate space representations for some 30 years, on the practical side rather than theoretical, and I had never seen the word used before in this context. Not that this is a problem, but it confused me.

 

So, I would like to help on this problem, but your code isn't particularly intuitive. It would help to better understand the outcome that you are looking for. Can you repost your video? It does not seem to exist on YouTube. I can envision a much simpler way to create such a box, but it would help to know what you expect to happen as you move the mouse around.

 

Graham

0

Share this post


Link to post
Share on other sites

apatriarca,

 

Thank you for the comment. Its interesting how we come to learn different terminologies. Somehow my path just never crossed with versor. The Wikipedia page specific to versor, http://en.wikipedia.org/wiki/Versor, introduces the quaternion use case, but also mentions the unit vector use case. There has to be some origin point for this word! I think I agree with your view.

 

Graham

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0