Skip to content

Commit

Permalink
working on intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
bgpoythress committed May 22, 2018
1 parent e74035e commit 1261685
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 73 deletions.
16 changes: 15 additions & 1 deletion DrawableObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
//Written by Brandon Poythress
//01MAY2018

function DrawableObject(colorIn){
function DrawableObject(colorIn, parentDirtyListCallbackIn){
this.graphicsMemoryAddress = null;
this.killMe = false;
this.passDirtyToParent = parentDirtyListCallbackIn;

this.color = new Color(colorIn.r, colorIn.g, colorIn.b, colorIn.a);

//points, lines and faces define how the object draws itself
this.pointList = [];
this.lineList = [];
this.surfaceList = [];

//the renderlist is the list of children that need to draw themselves
//after the object is finished drawing itself
this.renderList = [];
}

//setter to change the color
Expand All @@ -15,4 +25,8 @@ DrawableObject.prototype.setColorByObject = function(colorIn){
this.color.g = colorIn.g;
this.color.b = colorIn.b;
this.color.a = colorIn.a;
};

ModelObject.prototype.dirtyListCallback = function(dirtyObject){
this.passDirtyToParent(dirtyObject);
};
13 changes: 5 additions & 8 deletions LabScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@

function LabScene(idIn, parentIdIn, parentDirtyListCallbackIn){

ModelObject.call(this, "Scene", idIn, parentIdIn, true, parentDirtyListCallbackIn);
ModelObject.call(this, "Scene", idIn, parentIdIn, true);

console.log(this.type);
console.log(this.usesRenderList);
DrawableObject.call(this, null, parentDirtyListCallbackIn);




// this.type = "Scene";
// this.id = idIn;
// this.parent = parentIdIn;
Expand Down Expand Up @@ -81,14 +78,14 @@ function LabScene(idIn, parentIdIn, parentDirtyListCallbackIn){



LabScene.prototype = Object.create(ModelObject.prototype);
LabScene.prototype = Object.create(DrawableObject.prototype);

LabScene.prototype.constructor = LabScene;

LabScene.prototype.update = function(lastUpdate){

};

LabScene.prototype.constructor = LabScene;

LabScene.prototype.onMouseUp = function(eyeX, eyeY, eyeZ, worldRay){


Expand Down
10 changes: 5 additions & 5 deletions Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
//Line object

//Line class
function Line(idIn, parentIdIn, parentDirtyListCallbackIn, point1In, point2In, colorIn){
function Line(idIn, parentIdIn, parentDirtyListCallbackIn, vertex1In, vertex2In, colorIn){

//Line inherits properties from ModelObject but not methods
ModelObject.call(this, "Line", idIn, parentIdIn, false, parentDirtyListCallbackIn);
ModelObject.call(this, "Line", idIn, parentIdIn);

//Line is a drawable object
DrawableObject.call(this, colorIn);
DrawableObject.call(this, colorIn, parentDirtyListCallbackIn);

this.point1 = point1In;
this.point2 = point2In;
this.vertex1 = vertex1In;
this.vertex2 = vertex2In;


}
Expand Down
9 changes: 2 additions & 7 deletions ModelObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
//in terms of Model-View-Controller organization.

function ModelObject(typeIn, idIn, parentIdIn,
usesRenderListIn, parentDirtyListCallbackIn){
usesRenderListIn){
this.type = typeIn;
this.id = idIn;
this.parent = parentIdIn;
this.usesRenderList = usesRenderListIn;
this.passDirtyToParent = parentDirtyListCallbackIn;
this.idGen = new IdGenerator();
this.renderList = [];

}

ModelObject.prototype.dirtyListCallback = function(dirtyObject){
this.passDirtyToParent(dirtyObject);
};
11 changes: 10 additions & 1 deletion ModelState.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ function ModelState(){
//it does not use id, parentId, or parentDirtyListCallback so they
//are set to null. It also does not need ModelObject methods,
//so ModelState doesnt grab its prototypes.
ModelObject.call(this, "State", null, null, true, null);
ModelObject.call(this, "State", null, null, true);

//The model state needs many things from the drawable object class.
//the color and parentCallback functions are set to null
//because it has no color or parent. Also, there is no
//need to inherit any methods from this class so its prototypes are
//not taken.
DrawableObject.call(this, null, null);

//the state object manages its own model matrix
//and view matrix. The renderer handles proj
Expand Down Expand Up @@ -91,6 +98,8 @@ function ModelState(){
// this.portal.draw(gl, renderer);
// }



ModelState.prototype.dirtyListCallback = function(dirtyObject){
this.dirtyList.push(dirtyObject);
};
Expand Down
51 changes: 20 additions & 31 deletions Plane.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,30 @@
//Description:
//This class represents a plane.

function Plane(idIn, parentIdIn, parentDirtyListCallback, xIn, yIn, zIn, normalXIn, normalYIn, normalZIn, upXIn, upYIn, upZIn){
function Plane(idIn, parentIdIn, parentDirtyListCallbackIn, xIn, yIn, zIn, normalXIn, normalYIn, normalZIn, upXIn, upYIn, upZIn){

//basic information about the plane
this.type = "Plane";
this.id = idIn;
this.parent = parentIdIn;
this.idGen = new IdGenerator();

//rendering information
this.usesRenderList = true;
this.renderList = [];

//color of the plane
this.color = GREEN;
//callback function to the parent
//used to inform about children that need
//to be updated in the GPU because they have
//changed
this.passDirtyToParent = parentDirtyListCallback;
ModelObject.call(this, "Plane", idIn, parentIdIn);

DrawableObject.call(this, GREEN, parentDirtyCallbackIn);

//location of the plane's center point
this.x = xIn;
this.y = yIn;
this.z = zIn;
this.planePointVector = new Vector3();
this.planePointVector.elements[0] = xIn;
this.planePointVector.elements[1] = yIn;
this.planePointVector.elements[2] = zIn;

//normal vector components
this.normalX = normalXIn;
this.normalY = normalYIn;
this.normalZ = normalZIn;
this.nVector = new Vector3();
this.nVector.elements[0] = normalXIn;
this.nVector.elements[1] = normalYIn;
this.nVector.elements[2]= normalZIn;

//Local Y axis vector components
this.upX = upXIn;
this.upY = upYIn;
this.upZ = upZIn;

this.upVector = new Vector3();
this.upVector.elements[0] = upXIn;
this.upVector.elements[1] = upYIn;
this.upVector.elements[2]= upZIn;

//size of the plane in mm. May be better
//to pass this into the constructor
//but for now I will hard code it
Expand Down Expand Up @@ -129,9 +118,9 @@ function Plane(idIn, parentIdIn, parentDirtyListCallback, xIn, yIn, zIn, normalX

}

Plane.prototype.dirtyListCallback = function(dirtyObject){
this.passDirtyToParent(dirtyObject);
};
Plane.prototype = Object.create(DrawableObject.prototype);

Plane.prototype.constructor = Plane;

Plane.prototype.update = function(){

Expand Down
17 changes: 0 additions & 17 deletions Vertex.js

This file was deleted.

21 changes: 18 additions & 3 deletions freedom.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,41 @@
Please use a browser that supports "canvas"
</canvas>

<!--Libraries-->
<script src="lib/webgl-utils.js"></script>
<script src="lib/webgl-debug.js"></script>
<script src="lib/cuon-utils.js"></script>
<script src="lib/cuon-matrix.js"></script>
<script src = "lib/IntersectionMath.js"></script>

<!--Primatives and Interfaces-->
<script src="Triangle.js"></script>

<script src="Color.js"></script>
<script src="ModelObject.js"></script>
<script src="DrawableObject.js"></script>
<script src="Vertex.js"></script>

<!--Drawables-->
<script src="Point.js"></script>
<script src="Line.js"></script>
<script src="Surface.js"></script>
<script src="Sketch.js"></script>
<script src="Plane.js"></script>

<!--Event Handling-->
<script src="EventHandler.js"></script>

<!--Upper Level Objects-->
<script src="GPUMemManager.js"></script>
<script src="IdGenerator.js"></script>
<script src="LabScene.js"></script>
<script src="ModelState.js"></script>
<script src="Plane.js"></script>

<script src="Portal.js"></script>
<script src="Renderer.js"></script>
<script src="Sketch.js"></script>


<!--Main File-->
<script src="Freedom.js"></script>
</body>

Expand Down

0 comments on commit 1261685

Please sign in to comment.