|
@@ -3641,6 +3641,7 @@ tnsCamera *tnsCreateCamera(tnsObject *under, char *Name, real FOV,
|
|
|
c->ZMax = 200.0f;
|
|
|
c->FocusDistance = FocusDistance;
|
|
|
c->OrthScale = 1.0f;
|
|
|
+ if(under && under->Type==TNS_OBJECT_ROOT){ memAssignRef(under,&((tnsRootObject*)under)->ActiveCamera,c); }
|
|
|
|
|
|
return c;
|
|
|
}
|
|
@@ -3813,39 +3814,26 @@ void tnsLookAt(tnsObject *o, tnsVector3d Target, tnsVector3d Up){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
void tnsDrawCamera(tnsObject *o){
|
|
|
tnsCamera *c = o;
|
|
|
- real fov_2 = c->FOV / 2;
|
|
|
- real ex, ey, ez; ey = 10 * sin(fov_2); ex = ey; ez = 10 * cos(fov_2);
|
|
|
-
|
|
|
- tnsColor4d(1, 1, 1, 1);
|
|
|
+ real fov_2 = c->FOV / 2; real len=1;
|
|
|
+ real ex, ey, ez; ey = len * sin(fov_2); ex = ey; ez = len * cos(fov_2);
|
|
|
|
|
|
tnsVertex3d(ex, ey, -ez); tnsVertex3d(ex, -ey, -ez); tnsVertex3d(0.0, 0.0, 0.0);
|
|
|
tnsVertex3d(ex, ey, -ez); tnsVertex3d(-ex, ey, -ez); tnsVertex3d(0.0, 0.0, 0.0);
|
|
|
tnsVertex3d(-ex, -ey, -ez); tnsVertex3d(-ex, ey, -ez);
|
|
|
-
|
|
|
tnsPackAs(GL_LINE_STRIP);
|
|
|
- tnsFlush();
|
|
|
+ tnsVertex3d(ex,ey*1.25,-ez); tnsVertex3d(0,ey*2,-ez); tnsVertex3d(-ex,ey*1.25,-ez);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+ tnsVertex3d(-ex, -ey, -ez); tnsVertex3d(ex, -ey, -ez);
|
|
|
+ tnsPackAs(GL_LINES);
|
|
|
}
|
|
|
void tnsDrawCross(real x,real y,real z,real x1,real x2,real y1,real y2,real z1,real z2){
|
|
|
tnsVertex3d(x+x1, y+0.0, z+0.0); tnsVertex3d(x+x2, y+0.0, z+0.0);
|
|
|
tnsVertex3d(x+0.0,y+ y1, z+0.0); tnsVertex3d(x+0.0,y+ y2, z+0.0);
|
|
|
tnsVertex3d(x+0.0,y+ 0.0,z+ z1); tnsVertex3d(x+0.0,y+ 0.0,z+ z2);
|
|
|
}
|
|
|
-void tnsDrawPlaceholder(tnsObject* o, tnsEvaluateData* ed){
|
|
|
- if(T->BindedShader==T->SelectionShader){
|
|
|
- int i=o->SelectID; real color[4]={0,0,0,1}; TNS_ID_TO_COLOR(color,i); tnsColor4dv(color);
|
|
|
- }else{
|
|
|
- if(ed->FillOutline && (!(o->Flags&TNS_OBJECT_FLAGS_SELECTED))) return;
|
|
|
- if(!ed->FillOutline && (o->Flags&TNS_OBJECT_FLAGS_SELECTED)) return;
|
|
|
- if(o==ed->Active){ tnsColor4dv(laAccentColor(LA_BT_TEXT_ACTIVE)); }
|
|
|
- elif(o->Flags&TNS_OBJECT_FLAGS_SELECTED){ tnsColor4dv(laAccentColor(LA_BT_NORMAL)); }
|
|
|
- else tnsColor4dv(laThemeColor(_LA_THEME_3D_VIEW,LA_BT_BORDER));
|
|
|
- }
|
|
|
- tnsDrawCross(0,0,0,-0.2,1,-0.2,1,-0.2,1);
|
|
|
- tnsPackAs(GL_LINES);
|
|
|
- tnsFlush();
|
|
|
-}
|
|
|
|
|
|
void tnsDrawEmptySelectionID(tnsEvaluatedInstance* ei, void* unused){
|
|
|
int i=ei->InstanceSelectionID; real color[4]={0,0,0,1}; TNS_ID_TO_COLOR(color,i); tnsColor4dv(color);
|
|
@@ -3860,6 +3848,7 @@ void tnsDrawEmptyObject(tnsEvaluatedInstance* ei, void* unused){
|
|
|
tnsDrawCross(0,0,0,-0.2,1,-0.2,1,-0.2,1);tnsLineWidth(3); tnsPackAs(GL_LINES); tnsLineWidth(1); tnsFlush();
|
|
|
}
|
|
|
void tnsEvaluateEmptyObject(tnsObject* o, tnsEvaluateData* ed){
|
|
|
+ if(ed->SceneEvaluateMode){ return; }
|
|
|
tnsAddEvaluatedInstance(ed,o,tnsDrawEmptyObject,TNS_EVAL_LAYER_SOLID,0,0,0);
|
|
|
if(ed->FillOutline && o->Flags&TNS_OBJECT_FLAGS_SELECTED){
|
|
|
tnsAddEvaluatedInstance(ed,o,tnsDrawEmptyOutline,TNS_EVAL_LAYER_OUTLINE,ed->Active==o,0,0);
|
|
@@ -3908,6 +3897,29 @@ eval_inst_cleanup:
|
|
|
ed->OverrideID=origid; ed->FillOutline=origoutline;
|
|
|
}
|
|
|
|
|
|
+void tnsDrawCameraSelectionID(tnsEvaluatedInstance* ei, void* unused){
|
|
|
+ int i=ei->InstanceSelectionID; real color[4]={0,0,0,1}; TNS_ID_TO_COLOR(color,i); tnsColor4dv(color);
|
|
|
+ tnsDrawCamera(ei->Object); tnsFlush();
|
|
|
+}
|
|
|
+void tnsDrawCameraOutline(tnsEvaluatedInstance* ei, void* unused){
|
|
|
+ real* color=(ei->IsActive)?laAccentColor(LA_BT_TEXT):laAccentColor(LA_BT_NORMAL); tnsColor4dv(color); tnsLineWidth(3);
|
|
|
+ tnsDrawCamera(ei->Object); tnsLineWidth(1); tnsFlush();
|
|
|
+}
|
|
|
+void tnsDrawCameraObject(tnsEvaluatedInstance* ei, void* unused){
|
|
|
+ tnsColor4dv(laThemeColor(_LA_THEME_3D_VIEW,LA_BT_BORDER)); tnsLineWidth(3);
|
|
|
+ tnsDrawCamera(ei->Object); tnsLineWidth(1); tnsFlush();
|
|
|
+}
|
|
|
+void tnsEvaluateCameraObject(tnsObject* o, tnsEvaluateData* ed){
|
|
|
+ if(ed->SceneEvaluateMode){ return; }
|
|
|
+ tnsAddEvaluatedInstance(ed,o,tnsDrawCameraObject,TNS_EVAL_LAYER_SOLID,0,0,0);
|
|
|
+ if(ed->FillOutline && o->Flags&TNS_OBJECT_FLAGS_SELECTED){
|
|
|
+ tnsAddEvaluatedInstance(ed,o,tnsDrawCameraOutline,TNS_EVAL_LAYER_OUTLINE,ed->Active==o,0,0);
|
|
|
+ }
|
|
|
+ if(ed->FillSelectionID){
|
|
|
+ tnsAddEvaluatedInstance(ed,o,tnsDrawCameraSelectionID,TNS_EVAL_LAYER_SELECTION,0,1,o->SelectID);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void tnsRunNode(tnsEvaluatedNode* en, int func, tnsObject* root){
|
|
|
T->Runtime.CurrentEN = en;
|
|
|
tnsObject* ob=root; // should be the same as en->Target.
|
|
@@ -3950,7 +3962,7 @@ void tnsEvaluateThisObject(tnsObject *o, tnsEvaluateData* ed){
|
|
|
tnsEvaluateInstancerObject(o,ed);
|
|
|
if(ed->SceneEvaluateMode){ ed->Scene->CurrentParent=CP; ed->Scene->CurrentChild=CC;}
|
|
|
break;
|
|
|
- case TNS_OBJECT_CAMERA: tnsDrawCamera(o); break;
|
|
|
+ case TNS_OBJECT_CAMERA: tnsEvaluateCameraObject(o,ed); break;
|
|
|
case TNS_OBJECT_SHAPE: tnsEvaluateShapeObject(o,ed); break;
|
|
|
default: tnsEvaluateEmptyObject(o,ed); break;
|
|
|
}
|