Commit fae3c7f5 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

saving and parsing marks for multiple models orientation

parent 1fdcdb59
......@@ -426,6 +426,6 @@ html, body, #x3d_wrapper {
text-align:right;
}
#mpr_save{
margin: 5px;
#mpr_save, #mpr_save_marks{
margin: 0px 5px 5px 5px;
}
This diff is collapsed.
......@@ -38,7 +38,10 @@
var Data = {
camera:{},
markers:[],
extra_models:[]
extra_models:[],
mpr:{
markers:[]
}
};
var Scene;
......@@ -54,6 +57,8 @@ var SETTINGS = {
'moreinfo': true,
'crosshair': false,
'shiftspeed' : 0.01,
// for relative size
'markersize_k': 0.025,
'markersize' : 1,
'markercolor': "#1f1",
'slidingdrag': true,
......@@ -92,12 +97,17 @@ var AUTOCOLORS_COUNTER = 0;
var MARKER_PREFIX = "my-sph-";
// Manual Position & Orientation mode
// x,y - canvas coordinates - click position
// counter - helper counter
var MPR = {
counter: 0,
x: null,
y: null
};
// recorded marks restored
var MPR_MARKS_LOADED = false;
// no comments
function parseURL(){
var parameters=location.href.replace(/\?/ig,"&").split("&");
......@@ -458,6 +468,7 @@ function deep_init(){
x3d_setShiftSpeed();
if (!MPR_MARKS_LOADED) mpr_marks_load();
}
// loading extra models?
......@@ -612,7 +623,7 @@ function x3d_events(){
}else{
// place align marker here
// for alignment? do nothing
}
......
......@@ -356,6 +356,24 @@ function zNear_bug_correction(xyz){
}
// shoot ray with zNear correction
function x3dom_shootRay_fixed(x,y){
var ray = Scene.element.runtime.shootRay(x,y);
// missed
if (ray.pickPosition==null){
return -1;
}
var tmp = zNear_bug_correction([ray.pickPosition.x,ray.pickPosition.y,ray.pickPosition.z]);
ray.pickPosition = new x3dom.fields.SFVec3f(tmp[0],tmp[1],tmp[2]);
return ray;
}
// this upright is for world coordinates, not the camera's
// the up vector should be taken from the initial camera orientation in kml.
function x3dom_setUpRight(){
......@@ -872,3 +890,51 @@ function x3dom_setViewpoint(m){
Data.camera.Matrices.RC_w = m;
}
function x3dom_markersize(x,y,z){
if (SETTINGS.markersize<0){
var d = x3dom_3d_distance(x,y,z,true);
res = -SETTINGS.markersize*SETTINGS.markersize_k*d;
}else{
res = SETTINGS.markersize;
}
return res;
}
function x3dom_getTransorm(element){
var tra_str = $(element).attr("translation");
var rot_str = $(element).attr("rotation");
var mr = x3dom.fields.Quaternion.parseAxisAngle(rot_str).toMatrix();
var tra = x3dom.fields.SFVec3f.parse(tra_str);
var mt = x3dom.fields.SFMatrix4f.translation(tra);
var mtn = x3dom.fields.SFMatrix4f.translation(tra.negate());
var m = mr.mult(mt);
return m;
}
function x3dom_getTransorm_from_2_parents(element){
var m1 = x3dom_getTransorm(element.parent());
var m2 = x3dom_getTransorm(element.parent().parent());
return m1.mult(m2);
}
function x3dom_autocolor(){
var color = SETTINGS.markercolor;
color = AUTOCOLORS[AUTOCOLORS_COUNTER%AUTOCOLORS.length];
AUTOCOLORS_COUNTER++;
return color;
}
......@@ -64,6 +64,7 @@ var X3DOMObject = function(element,data,options){
// status vars
this._X3DOM_SCENE_INIT_BACK_DONE = false;
this._X3DOM_SCENE_INIT_DONE = false;
this._ctrlKey = false;
this._shiftKey = false;
this._stored_x3dom_event = null;
......@@ -515,7 +516,7 @@ X3DOMObject.prototype.createMarker = function(x,y,z,id){
var index = null;
var color = convert_color_l2x(SETTINGS.markercolor);
var size = SETTINGS.markersize/2;
var size = x3dom_markersize()/2;
if ((id=="")||(id==undefined)){
sph_class = "my-markers";
......@@ -1014,7 +1015,7 @@ X3DOMObject.PointerMarker.updatePars = function(){
// place pointer marker
$("#sliding_sphere").find('material').attr("diffuseColor",convert_color_l2x(SETTINGS.markercolor));
$("#sliding_sphere").find('material').attr("transparency","0.2");
$("#sliding_sphere").find('Sphere').attr("radius",SETTINGS.markersize/2);
$("#sliding_sphere").find('Sphere').attr("radius",((SETTINGS.markersize<0)?-1:1)*SETTINGS.markersize/2);
}
......@@ -1515,9 +1516,7 @@ X3DOMObject.createNewMarker = function(x,y,z){
var Camera = Map.marker;
// Create marker for Data
var color = SETTINGS.markercolor;
color = AUTOCOLORS[AUTOCOLORS_COUNTER%AUTOCOLORS.length];
AUTOCOLORS_COUNTER++;
var color = x3dom_autocolor();
var xyz_real = x3dom_scene_to_real(x,y,z);
......@@ -1526,7 +1525,7 @@ X3DOMObject.createNewMarker = function(x,y,z){
y: y || 0,
z: z || 0,
color: color,
size: SETTINGS.markersize,
size: x3dom_markersize(x,y,z)
});
mark.d_x3d = Math.sqrt(Math.pow(xyz_real.x,2)+Math.pow(xyz_real.z,2));
......
<?php
/*
*! -----------------------------------------------------------------------------**
*! FILE NAME : store_marks.php
*! REVISION : 1.0
*! DESCRIPTION: save marks for manual position and orientation
*! Copyright (C) 2017 Elphel, Inc.
*!
*! -----------------------------------------------------------------------------**
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*!
*! It means that the program's users have the four essential freedoms:
*!
*! * The freedom to run the program, for any purpose (freedom 0).
*! * The freedom to study how the program works, and change it to make it do what you wish (freedom 1).
*! Access to the source code is a precondition for this.
*! * The freedom to redistribute copies so you can help your neighbor (freedom 2).
*! * The freedom to distribute copies of your modified versions to others (freedom 3).
*!
*! By doing this you can give the whole community a chance to benefit from your changes.
*! Access to the source code is a precondition for this.
*! -----------------------------------------------------------------------------**
*/
require_once("call_filter.php");
$model = $_GET['model'];
$marks_file = "models/$model/marks.xml";
$contents = file_get_contents('php://input');
if (!preg_match("/\//",$model)){
$result = file_put_contents($marks_file,$contents);
if (!$result) {
die("-1");
}else{
die("0");
}
}else{
die("-2");
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment