-
首页
-
C4D R23.110 C++ SDK
#include <c4d_basedraw.h>
详细描述
Represents an editor view. Cannot be instantiated. In most cases the sub-class
BaseDraw
is used. It adds functions for drawing into the view. See the
dbasedraw.h
description file for container IDs.
Additional Inherited Members
|
const
Char
*
|
GetViewportRenderId
(
VIEWPORT_RENDER_ID
typeId) const
|
BaseList2D
*
|
GetNext
()
|
BaseList2D
*
|
GetPred
()
|
void
|
SetBit
(
Int32
mask)
|
Bool
|
GetBit
(
Int32
mask) const
|
void
|
DelBit
(
Int32
mask)
|
void
|
ToggleBit
(
Int32
mask)
|
Int32
|
GetAllBits
() const
|
void
|
SetAllBits
(
Int32
bits)
|
void
|
SetBitEx
(
Int32
mask,
Int32
flags)
|
BaseContainer
|
GetData
()
|
void
|
SetData
(const
BaseContainer
&bc,
Bool
add=true)
|
const
BaseContainer
*
|
GetDataInstance
() const
|
BaseContainer
*
|
GetDataInstance
()
|
const
BaseContainer
&
|
GetDataInstanceRef
() const
|
BaseContainer
&
|
GetDataInstanceRef
()
|
String
|
GetName
() const
|
void
|
SetName
(const
maxon::String
&name)
|
String
|
GetBubbleHelp
()
|
Bool
|
TransferGoal
(
BaseList2D
*dst,
Bool
undolink)
|
Bool
|
TransferMarker
(
BaseList2D
*dst) const
|
Bool
|
比例
(
Float
scale)
|
Bool
|
编辑
()
|
void
|
GetIcon
(
IconData
*dat)
|
GeListHead
*
|
GetNLARoot
()
|
BaseList2D
*
|
AnimationLayerRemap
(
BaseObject
**layer=nullptr)
|
String
|
GetTypeName
()
|
BaseList2D
*
|
GetMain
() const
|
void
|
InsertTrackSorted
(
CTrack
*track)
|
Bool
|
AddEventNotification
(
BaseList2D
*bl,
NOTIFY_EVENT
eventid,
NOTIFY_EVENT_FLAG
flags, const
BaseContainer
*data)
|
Bool
|
RemoveEventNotification
(
BaseDocument
*doc,
BaseList2D
*bl,
NOTIFY_EVENT
eventid)
|
Bool
|
FindEventNotification
(
BaseDocument
*doc,
BaseList2D
*bl,
NOTIFY_EVENT
eventid)
|
Bool
|
SetDescIDState
(const
DescID
&id,
DESCIDSTATE
descidstate)
|
DESCIDSTATE
|
GetDescIDState
(const
DescID
&id,
Bool
tolerant) const
|
GeListHead
*
|
GetOverrideRoot
()
|
BaseOverride
*
|
GetFirstOverride
()
|
GeListHead
*
|
GetShaderRepositoryRoot
()
|
GeListHead
*
|
GetHiddenShaderRoot
()
|
maxon::NimbusInterface *
|
GetNimbusRef
(const
maxon::Id
&spaceId) const
|
maxon::Result
< maxon::NimbusInterface * >
|
GetOrCreateNimbusRef
(const
maxon::Id
&spaceId)
|
void
|
RemoveNimbusRef
(const
maxon::Id
&spaceId)
|
maxon::Result
<
maxon::HashMap
<
maxon::Id
,
maxon::ForwardRef
< maxon::NimbusRef > > >
|
GetAllNimbusRefs
() const
|
Bool
|
IsNodeBased
() const
|
void
|
GetMarkerStampEx
(
UInt32
*l1,
UInt32
*l2)
|
const
GeMarker
&
|
GetMarker
() const
|
void
|
SetMarker
(const
GeMarker
&m)
|
Bool
|
AddUniqueID
(
Int32
appid, const
Char
*const mem,
Int
bytes)
|
Bool
|
FindUniqueID
(
Int32
appid, const
Char
*&mem,
Int
&bytes) const
|
Int32
|
GetUniqueIDCount
() const
|
Bool
|
GetUniqueIDIndex
(
Int32
idx,
Int32
&id, const
Char
*&mem,
Int
&bytes) const
|
Bool
|
SetAnimatedParameter
(
CTrack
*track, const
DescID
&id, const
GeData
&t_data1, const
GeData
&t_data2,
Float
mix,
DESCFLAGS_SET
flags)
|
Bool
|
GetAnimatedParameter
(const
DescID
&id,
GeData
&t_data1,
GeData
&t_data2,
Float
&mix,
DESCFLAGS_GET
flags)
|
BaseShader
*
|
GetFirstShader
() const
|
void
|
InsertShader
(
BaseShader
*shader,
BaseShader
*pred=nullptr)
|
void
|
ClearKeyframeSelection
()
|
Bool
|
FindKeyframeSelection
(const
DescID
&id)
|
Bool
|
SetKeyframeSelection
(const
DescID
&id,
Bool
selection)
|
Bool
|
KeyframeSelectionContent
()
|
LayerObject
*
|
GetLayerObject
(
BaseDocument
*doc)
|
Bool
|
SetLayerObject
(
LayerObject
*layer)
|
const
LayerData
*
|
GetLayerData
(
BaseDocument
*doc,
Bool
rawdata=false)
|
Bool
|
SetLayerData
(
BaseDocument
*doc, const
LayerData
&data)
|
GeListHead
*
|
GetCTrackRoot
()
|
CTrack
*
|
GetFirstCTrack
()
|
CTrack
*
|
FindCTrack
(const
DescID
&id)
|
GeListNode
*
|
GetNext
()
|
GeListNode
*
|
GetPred
()
|
GeListNode
*
|
GetDown
()
|
GeListNode
*
|
GetUp
()
|
GeListNode
*
|
GetDownLast
()
|
void
|
InsertBefore
(
GeListNode
*bl)
|
void
|
InsertAfter
(
GeListNode
*bl)
|
void
|
InsertUnder
(
GeListNode
*bl)
|
void
|
InsertUnderLast
(
GeListNode
*bl)
|
void
|
移除
()
|
GeListHead
*
|
GetListHead
()
|
Int32
|
GetNodeID
(
Int32
index=0) const
|
template<typename CAST >
|
const CAST *
|
GetNodeData
(
Int32
index=0) const
|
template<typename CAST >
|
CAST *
|
GetNodeData
(
Int32
index=0)
|
void
|
SetCustomData
(
GeListNode
*node)
|
GeListNode
*
|
GetCustomData
()
|
BaseDocument
*
|
GetDocument
()
|
Int32
|
GetBranchInfo
(
BranchInfo
*info,
Int32
max,
GETBRANCHINFO
flags)
|
Bool
|
IsDocumentRelated
()
|
Int32
|
GetInfo
()
|
Bool
|
GetNBit
(
NBIT
bit) const
|
UInt32
|
GetNBitMask
(
Int32
index) const
|
Bool
|
ChangeNBit
(
NBIT
bit,
NBITCONTROL
bitmode)
|
Int32
|
GetType
() const
|
Int32
|
GetRealType
() const
|
Int32
|
GetDiskType
() const
|
Bool
|
IsInstanceOf
(
Int32
id) const
|
Int32
|
GetClassification
() const
|
Bool
|
消息
(
Int32
type, void *data=nullptr)
|
Bool
|
MultiMessage
(
MULTIMSG_ROUTE
flags,
Int32
type, void *data)
|
C4DAtom
*
|
GetClone
(
COPYFLAGS
flags,
AliasTrans
*trn)
|
Bool
|
CopyTo
(
C4DAtom
*dst,
COPYFLAGS
flags,
AliasTrans
*trn)
|
Bool
|
读取
(
HyperFile
*hf,
Int32
id,
Int32
level)
|
Bool
|
Write
(
HyperFile
*hf)
|
Bool
|
ReadObject
(
HyperFile
*hf,
Bool
readheader)
|
Bool
|
WriteObject
(
HyperFile
*hf)
|
Bool
|
GetDescription
(
描述
*description,
DESCFLAGS_DESC
flags)
|
Bool
|
GetParameter
(const
DescID
&id,
GeData
&t_data,
DESCFLAGS_GET
flags)
|
Bool
|
SetParameter
(const
DescID
&id, const
GeData
&t_data,
DESCFLAGS_SET
flags)
|
DynamicDescription
*
|
GetDynamicDescription
()
|
Bool
|
GetEnabling
(const
DescID
&id, const
GeData
&t_data,
DESCFLAGS_ENABLE
flags, const
BaseContainer
*itemdesc)
|
Bool
|
TranslateDescID
(const
DescID
&id,
DescID
&res_id,
C4DAtom
*&res_at)
|
UInt32
|
GetDirty
(
DIRTYFLAGS
flags) const
|
void
|
SetDirty
(
DIRTYFLAGS
flags)
|
UInt32
|
GetHDirty
(
HDIRTYFLAGS
mask) const
|
void
|
SetHDirty
(
HDIRTYFLAGS
mask)
|
static
BaseList2D
*
|
Alloc
(
Int32
type)
|
static void
|
Free
(
BaseList2D
*&bl)
|
static const
Int32
|
SETBIT_FLAG_NODIRTY
|
static const
Int32
|
SETBIT_FLAG_REMOVE
|
构造函数 & 析构函数文档编制
◆
BaseView()
◆
~BaseView()
成员函数文档编制
◆
GetFrame()
Assigns the dimension in pixels of the view window. The coordinates are relative to the upper left corner of the view, and specify visible pixels (i.e. the border is not included).
-
参数
-
[out]
|
cl
|
Is assigned the first visible left pixel position.
|
[out]
|
ct
|
Is assigned the first visible top pixel position.
|
[out]
|
cr
|
Is assigned the first visible right pixel position.
|
[out]
|
cb
|
Is assigned the first visible bottom pixel position.
|
◆
GetSafeFrame()
Assigns the dimension in pixels of the safe frame (the frame which is rendered) to the passed pointers. The coordinates are relative to the upper left corner of the view.
-
参数
-
[out]
|
cl
|
Is assigned the first visible left pixel position.
|
[out]
|
ct
|
Is assigned the first visible top pixel position.
|
[out]
|
cr
|
Is assigned the first visible right pixel position.
|
[out]
|
cb
|
Is assigned the first visible bottom pixel position.
|
◆
GetMg()
Gets the camera matrix, i.e. the global object matrix of the current camera object.
-
返回
-
The camera matrix.
◆
GetMi()
Gets the inverse of the camera matrix. Equivalent to !
GetMg()
, but faster.
-
返回
-
The inverted camera matrix.
◆
GetBaseMatrix()
const
矩阵
& GetBaseMatrix
|
(
|
|
)
|
const
|
Gets the base matrix.
-
注意
-
The base matrix is multiplied with the camera matrix so that it is possible to have e.g. a frontal view into another direction than
+Z
.
-
返回
-
The base matrix.
◆
SetBaseMatrix()
void SetBaseMatrix
|
(
|
const
矩阵
&
|
m
|
)
|
|
Sets the base matrix.
-
注意
-
The base matrix is multiplied with the camera matrix so that it is possible to have e.g. a frontal view into another direction than
+Z
.
-
参数
-
[in]
|
m
|
The new base matrix.
|
◆
GetPlanarRotation()
Float
GetPlanarRotation
|
(
|
|
)
|
const
|
Gets the rotation of the planar views.
-
返回
-
The planar rotation.
◆
SetPlanarRotation()
void SetPlanarRotation
|
(
|
Float
|
r
|
)
|
|
Sets the rotation of the planar views.
-
参数
-
[in]
|
r
|
The new planar rotation.
|
◆
TestPoint()
Tests if the point is within the boundary returned by
GetFrame()
. The point coordinates must be in screen space.
-
参数
-
[in]
|
x
|
The X coordinate of the point to check.
|
[in]
|
y
|
The Y coordinate of the point to check.
|
-
返回
-
true
if the point is inside the frame, otherwise
false
.
◆
TestPointZ()
Bool
TestPointZ
|
(
|
const
向量
&
|
p
|
)
|
|
Tests if the point is visible within the near and far clipping planes defined in the view according to the current projection. The point must be in camera space.
-
参数
-
[in]
|
p
|
The point to check.
|
-
返回
-
true
if the point is visible in the view, otherwise
false
.
◆
TestClipping3D()
Bool
TestClipping3D
|
(
|
const
向量
&
|
mp
,
|
|
|
const
向量
&
|
rad
,
|
|
|
const
矩阵
&
|
mg
,
|
|
|
Bool
*
|
clip2d
,
|
|
|
Bool
*
|
clipz
|
|
)
|
|
|
Tests if a bounding box is visible in the view according to the current projection. The box is defined by these eight corner coordinates:
p[0] =
向量
(mp.x + rad.
x
, mp.y + rad.
y
, mp.z + rad.
z
) * mg;
p[1] =
向量
(mp.x + rad.
x
, mp.y + rad.
y
, mp.z - rad.
z
) * mg;
p[2] =
向量
(mp.x + rad.
x
, mp.y - rad.
y
, mp.z + rad.
z
) * mg;
p[3] =
向量
(mp.x + rad.
x
, mp.y - rad.
y
, mp.z - rad.
z
) * mg;
p[4] =
向量
(mp.x - rad.
x
, mp.y + rad.
y
, mp.z + rad.
z
) * mg;
p[5] =
向量
(mp.x - rad.
x
, mp.y + rad.
y
, mp.z - rad.
z
) * mg;
p[6] =
向量
(mp.x - rad.
x
, mp.y - rad.
y
, mp.z + rad.
z
) * mg;
p[7] =
向量
(mp.x - rad.
x
, mp.y - rad.
y
, mp.z - rad.
z
) * mg;
-
参数
-
[in]
|
mp
|
The center of the box.
|
[in]
|
rad
|
The radius of the box.
|
[in]
|
mg
|
The transformation to world space from
mp
/
rad
space.
|
[out]
|
clip2d
|
Is assigned
true
if the box needs
2D
clipping, i.e. if any part of it is outside of the view boundaries. Otherwise
false
.
|
[in]
|
clipz
|
Is assigned
true
if the box needs
Z
clipping, i.e. if any part of it is too close to or behind the camera. Otherwise
false
.
|
-
返回
-
true
if the box is visible, otherwise
false
.
◆
ClipLine2D()
Clips the line defined by
p1
and
p2
so that it fits within the view boundary. The new values are stored directly in the passed vectors. The points are in screen space.
When combined with
ClipLineZ()
,
Z
clipping must be done first and then the
2D
clipping.
-
注意
-
When combined with
ClipLineZ()
,
Z
clipping must be done first and then the
2D
clipping.
-
参数
-
[in,out]
|
p1
|
The start of the line. Is assigned the clipped start point.
|
[in,out]
|
p2
|
The end of the line. Is assigned the clipped end point.
|
-
返回
-
true
if any part of the line was within the view boundary, otherwise
false
.
◆
ClipLineZ()
Clips the line defined by
p1
and
p2
so that it does not come too close to or behind the camera (i.e. it assures that, for those projections that have
Z
clipping, no values are negative or goes through the camera's zero plane).
The new values are stored directly in the passed vectors. The points must be in camera space.
-
注意
-
When combined with
ClipLine2D()
,
Z
clipping must be done first and then the
2D
clipping.
-
参数
-
[in,out]
|
p1
|
The start of the line. Is assigned the clipped start point.
|
[in,out]
|
p2
|
The end of the line. Is assigned the clipped end point.
|
-
返回
-
true
if any part of the line was within the camera boundary, otherwise
false
.
◆
WS()
向量
WS
|
(
|
const
向量
&
|
p
|
)
|
const
|
World to screen conversion. Converts
p
from world space to screen space (pixels relative to the view), and returns the conversion.
The orthogonal distance to the world point is stored in world units in the Z axis of the result.
-
参数
-
[in]
|
p
|
A point in world space.
|
-
返回
-
The point in screen space.
◆
SW()
向量
SW
|
(
|
const
向量
&
|
p
|
)
|
const
|
Screen to world conversion. Converts
p
from screen space (pixels relative to the view) to world space.
The X and Y coordinates of the point are given in screen space, the Z coordinate is the orthogonal distance in world units to the point from the view plane.
-
参数
-
[in]
|
p
|
A point in screen space.
|
-
返回
-
The point in world space.
◆
SW_Reference()
Screen to world conversion. Converts the point given by
x
and
y
in screen space (pixels relative to the view) to world space.
The Z coordinate is taken from the orthogonal distance in world units to
wp
from the view plane.
-
参数
-
[in]
|
x
|
The X coordinate in screen space.
|
[in]
|
y
|
The Y coordinate in screen space.
|
[in]
|
wp
|
The reference point in world space.
|
-
返回
-
The point in world space.
◆
WC()
向量
WC
|
(
|
const
向量
&
|
p
|
)
|
const
|
World to camera conversion. Converts
p
from world to camera space.
-
参数
-
[in]
|
p
|
A point in world space.
|
-
返回
-
The point in camera space.
◆
CW()
向量
CW
|
(
|
const
向量
&
|
p
|
)
|
const
|
Camera to world conversion. Converts
p
from camera to world space.
-
参数
-
[in]
|
p
|
A point in camera space.
|
-
返回
-
The point in world space.
◆
SC()
向量
SC
|
(
|
const
向量
&
|
p
|
)
|
const
|
Screen to camera conversion. Converts
p
from screen (pixels relative to the view) to camera space.
The X and Y coordinates of the point are given in screen space, the Z coordinate is the orthogonal distance in world units to the point from the view plane.
-
参数
-
[in]
|
p
|
A point in screen space.
|
-
返回
-
The point in camera space.
◆
CS()
向量
CS
|
(
|
const
向量
&
|
p
,
|
|
|
Bool
|
z_inverse
|
|
)
|
|
const
|
Camera to screen conversion. Converts
p
from camera to screen space (pixels relative to the view).
-
参数
-
[in]
|
p
|
A point in camera space.
|
[in]
|
z_inverse
|
若
true
if true, otherwise
false
. the Z coordinate of the converted point is inverted. This is used by the Z-buffer.
|
-
返回
-
The point in screen space.
◆
WC_V()
向量
WC_V
|
(
|
const
向量
&
|
v
|
)
|
const
|
World to camera vector conversion. Converts the world vector
v
to camera space.
-
参数
-
[in]
|
v
|
A vector in world space.
|
-
返回
-
The vector in camera space.
◆
CW_V()
向量
CW_V
|
(
|
const
向量
&
|
v
|
)
|
const
|
Camera to world vector conversion. Converts the camera vector
v
to world space.
-
参数
-
[in]
|
v
|
A vector in camera space.
|
-
返回
-
The vector in world space.
◆
WS_V()
向量
WS_V
|
(
|
const
向量
&
|
v
,
|
|
|
const
向量
&
|
p
|
|
)
|
|
const
|
World to screen vector conversion. Converts
v
from world space to screen space (pixels relative to the view), and returns the conversion.
The orthogonal distance to the world point is stored in world units in the Z axis of the result.
-
参数
-
[in]
|
v
|
A vector in world space.
|
[in]
|
p
|
A reference point in world space.
|
-
返回
-
The vector in screen space.
◆
SW_V()
向量
SW_V
|
(
|
const
向量
&
|
v
,
|
|
|
const
向量
&
|
p
|
|
)
|
|
const
|
Screen to world vector conversion. Converts
v
from screen space (pixels relative to the view) to world space.
The X and Y coordinates of the point are given in screen space, the Z coordinate is the orthogonal distance in world units to the point from the view plane.
-
参数
-
[in]
|
v
|
A vector in screen space.
|
[in]
|
p
|
A reference point in screen space.
|
-
返回
-
The vector in world space.
◆
PW_S()
Gets the size in world units for a single pixel at the given Z-depth
z
.
-
参数
-
[in]
|
z
|
The Z-depth.
|
[in]
|
horizontal
|
true
if the size is measured horizontally,
false
for vertically measurement. This is useful for non-square pixel aspect ratios.
|
-
返回
-
The size in world units.
◆
WP_S()
Gets the size in pixels for a single world unit at the given Z-depth
z
.
-
参数
-
[in]
|
z
|
The Z-depth.
|
[in]
|
horizontal
|
true
if the size is measured horizontally,
false
for vertically measurement. This is useful for non-square pixel aspect ratios.
|
-
返回
-
The size in pixels.
◆
PW_W()
Gets the size in world units for a single pixel at screen space vector
p
.
-
参数
-
[in]
|
p
|
The pixel in screen space.
|
[in]
|
horizontal
|
true
if the size is measured horizontally,
false
for vertically measurement. This is useful for non-square pixel aspect ratios.
|
-
返回
-
The size in world units.
◆
WP_W()
Gets the size in screen space pixels for a single world unit at world position
p
.
-
参数
-
[in]
|
p
|
The point in world space.
|
[in]
|
horizontal
|
true
if the size is measured horizontally,
false
for vertically measurement. This is useful for non-square pixel aspect ratios.
|
-
返回
-
The size in screen space pixels.
◆
ZSensitiveNear()
Bool
ZSensitiveNear
|
(
|
void
|
|
)
|
const
|
Indicates if the view has
Z
near-clipping.
-
返回
-
true
if the view has Z near-clipping, otherwise
false
.
◆
ZSensitiveNearClipping()
Float
ZSensitiveNearClipping
|
(
|
void
|
|
)
|
const
|
Gets the near-clipping of
Z
sensitive view.
-
返回
-
The Z near-clipping distance.
◆
ZSensitiveFar()
Bool
ZSensitiveFar
|
(
|
void
|
|
)
|
const
|
Indicates if the view is
Z
far-clipping sensitive.
-
返回
-
true
if the view has Z far-clipping, otherwise
false
.
◆
ZSensitiveFarClipping()
Float
ZSensitiveFarClipping
|
(
|
void
|
|
)
|
const
|
Gets the far-clipping of
Z
sensitive view.
-
返回
-
The Z far-clipping distance.
◆
ProjectPointOnLine()
向量
ProjectPointOnLine
|
(
|
const
向量
&
|
p
,
|
|
|
const
向量
&
|
v
,
|
|
|
Float
|
mouse_x
,
|
|
|
Float
|
mouse_y
,
|
|
|
Float
*
|
offset
=
nullptr
,
|
|
|
Int32
*
|
err
=
nullptr
|
|
)
|
|
|
Gets the nearest point on the line defined by
p
and
v
for a given mouse coordinate.
-
参数
-
[in]
|
p
|
The start position of the line in world space.
|
[in]
|
v
|
The direction of the line. The length of this vector determines the scaling of
offset
.
|
[in]
|
mouse_x
|
The mouse X-coordinate.
|
[in]
|
mouse_y
|
The mouse Y-coordinate.
|
[out]
|
offset
|
Assigned the distance from
p
scaled by the length of
v
. offset = distance to p / length of v.
|
[out]
|
err
|
Assigned an error code:
-
1
= Failed to find nearest point correctly, lines may be beyond horizon, behind camera, or ray line and line may be parallel.
-
2
= The point
p
is either beyond the start or end of the described segment (but a point will still be returned for the line/ray).
|
-
返回
-
The nearest point on the line.
◆
ProjectPointOnPlane()
向量
ProjectPointOnPlane
|
(
|
const
向量
&
|
p
,
|
|
|
const
向量
&
|
v
,
|
|
|
Float
|
mouse_x
,
|
|
|
Float
|
mouse_y
,
|
|
|
Int32
*
|
err
=
nullptr
|
|
)
|
|
|
Gets the nearest point on the plane defined by
p
and
v
for a given mouse coordinate.
-
参数
-
[in]
|
p
|
The plane's position in world space.
|
[in]
|
v
|
The plane's normal in world space.
|
[in]
|
mouse_x
|
The mouse X-coordinate.
|
[in]
|
mouse_y
|
The mouse Y-coordinate.
|
[out]
|
err
|
Assigned an error code:
-
1
= No intersection with plane possible, e.g. plane perpendicular to viewport so ray from view can never hit plane.
-
2
= Out of range error, the calculation will be inaccurate, e.g. can be caused by point being over the horizon.
-
3
= Hit point is behind the clipping plane of the camera, could sometimes result in an incorrect hit value.
|
-
返回
-
The nearest point on the plane.
◆
BackfaceCulling()
Bool
BackfaceCulling
|
(
|
const
向量
&
|
n
,
|
|
|
const
向量
&
|
p
|
|
)
|
|
|
Tests the face with normal
n
and center
p
for backface culling.
-
参数
-
[in]
|
n
|
The face normal in camera space.
|
[in]
|
p
|
The face center in camera space.
|
-
返回
-
true
if the face is not visible, otherwise
false
.
◆
GetProjection()
Int32
GetProjection
|
(
|
void
|
|
)
|
|
Gets the projection used by the view. See
Ocamera.h
for projection types values.
-
返回
-
The projection type.
◆
GetStereoInfo()
Gets the stereoscopic camera information data.
-
返回
-
The stereoscopic camera data.
Cinema 4D
owns the pointed
StereoCameraInfo
.
◆
GetViewParameter()
void GetViewParameter
|
(
|
向量
*
|
offset
,
|
|
|
向量
*
|
scale
,
|
|
|
向量
*
|
scale_z
|
|
)
|
|
const
|
Retrieves the parameters for the current projection. See
Ocamera.h
for projection types.
The following is the code used internally to project points:
#define CAMDIST 0.05
向量
WorldToCamera(
const
向量
&p)
{
return
p*inverse_camera_matrix;
}
向量
CameraToWorld(
const
向量
&p)
{
return
p*camera_matrix;
}
向量
CameraToScreen(
const
向量
&pp)
{
向量
p = pp;
if
(projection==
Pperspective
)
{
Float
nz = p.
z
<=0.0 ? 1.0/CAMDIST : 1.0/(p.
z
+ CAMDIST);
p.
x
= p.
x
*scale.x*nz+off.x;
p.
y
= p.
y
*scale.y*nz+off.y;
return
p;
}
p.
x
= (p.
x
*scale.x)+off.x;
p.
y
= (p.
y
*scale.y)+off.y;
switch
(projection)
{
case
Pmilitary
:
case
Pfrog
:
case
Pbird
:
case
Pgentleman
:
p.
x
+= p.
z
*scale.x*scalez.x;
p.
y
-= p.
z
*scale.y*scalez.y;
break
;
}
return
p;
}
向量
ScreenToCamera(
const
向量
&pp)
{
向量
p = pp;
switch
(projection)
{
case
Pmilitary
:
case
Pfrog
:
case
Pbird
:
case
Pgentleman
:
p.
x
-= p.
z
*scale.x*scalez.x;
p.
y
+= p.
z
*scale.y*scalez.y;
break
;
}
p.
x
= (p.
x
-off.x)/scale.x;
p.
y
= (p.
y
-off.y)/scale.y;
if
(projection==
Pperspective
)
{
Float
nz = p.
z
+ CAMDIST;
p.
x
*= nz;
p.
y
*= nz;
}
return
p;
}
For non-axonometric projection here is the code to calculate offset/scale:
void
InitView(
BaseObject
*camera,
Float
xres,
Float
yres,
Float
pix_x,
Float
pix_y)
{
// xres/yres are the resolution
// pix_x/pix_y are the pixel aspect ratio (normally 1:1)
矩阵
opm = camera->
GetMg
();
Float
ap;
BaseContainer
data = camera->
GetDataInstance
();
projection=data.
GetInt32
(
CAMERA_PROJECTION
,
Pperspective
);
if
(projection!=
Pperspective
&& projection!=
Pparallel
)
{
opm.v1 =
向量
(1.0,0.0,0.0);
opm.v2 =
向量
(0.0,1.0,0.0);
opm.v3 =
向量
(0.0,0.0,1.0);
}
off.x = xres*0.5;
off.y = yres*0.5;
if
(b_ab==
Pperspective
)
{
ap=data.
GetFloat
(
CAMERAOBJECT_APERTURE
,36.0);
scale.x = data.
GetFloat
(
CAMERA_FOCUS
,36.0) / ap * xres;
}
else
scale.x = xres/1024.0*data.
GetFloat
(
CAMERA_ZOOM
,1.0);
scale.y = -scale.x*pix_x/pix_y;
}
-
参数
-
[out]
|
offset
|
Assigned the center of the view in screen space.
|
[out]
|
scale
|
Depends on the projection mode:
-
For perspective mode: Assigned the size of the view plane in pixels.
-
For axonometric modes: Assigned the number of pixels per meter.
|
[out]
|
scale_z
|
Assigned the different Z scale for the X and Y axes in axonometric projections.
|
const BaseContainer * GetDataInstance() const
定义:
c4d_baselist.h:2283
maxon::Float Float
定义:
ge_sys_math.h:64
@ Pmilitary
定义:
ocamera.h:17
Matrix GetMg() const
定义:
c4d_baseobject.h:482
@ Pperspective
定义:
ocamera.h:9
Float GetFloat(Int32 id, Float preset=0.0) const
定义:
c4d_basecontainer.h:335
@ Pparallel
定义:
ocamera.h:10
@ CAMERA_FOCUS
定义:
ocamera.h:6
@ CAMERA_ZOOM
定义:
ocamera.h:7
@ CAMERA_PROJECTION
定义:
ocamera.h:8
@ Pgentleman
定义:
ocamera.h:20
maxon::Vec3< maxon::Float64, 1 > Vector
定义:
ge_math.h:145
@ CAMERAOBJECT_APERTURE
定义:
ocamera.h:42
Int32 GetInt32(Int32 id, Int32 preset=0) const
定义:
c4d_basecontainer.h:303
定义:
c4d_basecontainer.h:46