CameraObject Manual

内容表

关于

A CameraObject represents a camera in Cinema 4D . It is based on BaseObject (见 BaseObject Manual ).

CameraObject objects are an instance of Ocamera .

Access

A CameraObject is typically obtained from a BaseDraw representing a viewport window. This BaseDraw is obtained from the a BaseDocument .

另请参阅 BaseDocument Editor Windows .

// This example gets the currently used camera.
BaseDraw * const bd = doc-> GetActiveBaseDraw (); if (bd == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
BaseObject * camera = bd-> GetSceneCamera (doc); if (camera == nullptr ) camera = bd-> GetEditorCamera (); if (camera == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Camera name: @" , maxon::String { camera-> GetName () });
注意
Cinema 4D can use any object as a "camera" so the returned BaseObject may or may not be a CameraObject . One can check if it is a CameraObject with C4DAtom::IsInstanceOf() .

Also a generator can contain a CameraObject . To get the real camera from that generator a message has to be sent to that generator:

// This example tries to get the internal camera from a generator. // Typically used with the Alembic Generator camera. GetRealCameraData data;

// send the message to the object to get the "real camera" // and check the result if (obj-> 消息 ( MSG_GETREALCAMERADATA , &data) && data. res ) obj = data. res ; ApplicationOutput ( "Camera: @" , maxon::String { obj-> GetName () });

Allocation/Deallocation

CameraObject objects are created with the usual tools:

A new or existing camera can be set as the active scene camera:

// This example creates a new camera object and uses it as the scene camera. CameraObject * const camera = CameraObject::Alloc (); if (camera == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); doc-> InsertObject (camera, nullptr , nullptr ); camera-> SetName ( "The new camera" _s); const 矩阵 mg = MatrixMove ( 向量 (0, 0, -500)); camera-> SetMg (mg); BaseDraw * const bd = doc-> GetActiveBaseDraw (); if (bd) bd-> SetSceneCamera (camera);

特性

The parameters of a CameraObject are edited as usual with C4DAtom::GetParameter() and C4DAtom::SetParameter() . The parameter IDs are defined in Ocamera.h .

警告
Some parameters of the camera are "virtual" ( CAMERAOBJECT_FOV and CAMERAOBJECT_FOV_VERTICAL ) and cannot be accessed in any situation.

For some parameters dedicated functions exist.

Projection

These functions access the camera projection setting:

// This example sets the projection of the selected camera object to "Parallel". BaseObject * const obj = doc-> GetActiveObject ();

// the function needs a selected camera to get executed if (obj == nullptr || !obj-> IsInstanceOf ( Ocamera )) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION ); CameraObject * const camera = static_cast< CameraObject * > (obj); camera-> SetProjection ( Pparallel );

缩放

These functions set the camera zoom value:

偏移

These functions set the camera position. This is the midpoint for orthogonal projections (Front/Back/Top/Bottom etc.).

注意
This is the same as setting the position with BaseObject::SetAbsPos() .

Aperture

These functions set the camera aperture value:

Focus

These functions set the camera focus value:

Stereoscopic Camera

A CameraObject can also store information about the stereoscopic cameras it represents.

The stereo camera information is stored in a StereoCameraInfo structure object:

// This example loops through the stereo cameras of the given camera object. CameraObject * const camera = static_cast< CameraObject * > (obj); RenderData * const renderData = doc-> GetActiveRenderData (); BaseDraw * const bd = doc-> GetActiveBaseDraw (); if (bd == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Int32 stereoCount = camera-> StereoGetCameraCount (doc, bd, renderData, 0); for ( Int32 i = 0; i < stereoCount; ++i) { StereoCameraInfo info; camera-> StereoGetCameraInfo (doc, bd, renderData, i, info, 0); ApplicationOutput ( "Stereo Camera name: @" , maxon::String { info. strName }); }

延伸阅读

GetRealCameraData::res
BaseObject * res
Set a camera object to provide a real camera for a generator.
定义: c4d_baselist.h:851
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
CameraObject
定义: c4d_baseobject.h:1232
BaseObject
定义: c4d_baseobject.h:224
maxon::Mat3< maxon::Vector64 >
StereoCameraInfo
Stereoscopic camera information.
定义: c4d_videopostdata.h:309
maxon::String
定义: string.h:1197
BaseObject::SetMg
void SetMg(const Matrix &m)
定义: c4d_baseobject.h:488
MSG_GETREALCAMERADATA
#define MSG_GETREALCAMERADATA
Sent to get a real camera object from a generator. The corresponding data is GetRealCameraData.
定义: c4d_baselist.h:531
CameraObject::StereoGetCameraInfo
Bool StereoGetCameraInfo(BaseDocument *doc, BaseDraw *bd, RenderData *rd, Int32 n, StereoCameraInfo &info, Int32 flags) const
BaseDraw::GetSceneCamera
BaseObject * GetSceneCamera(const BaseDocument *doc)
定义: c4d_basedraw.h:829
CameraObject::SetProjection
Bool SetProjection(Int32 projection)
StereoCameraInfo::strName
String strName
Name of the stereoscopic camera.
定义: c4d_videopostdata.h:320
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
Ocamera
#define Ocamera
Camera - CameraObject.
定义: ge_prepass.h:978
Pparallel
@ Pparallel
定义: ocamera.h:10
BaseDocument::GetActiveBaseDraw
BaseDraw * GetActiveBaseDraw(void)
BaseDraw
定义: c4d_basedraw.h:747
BaseDraw::GetEditorCamera
BaseObject * GetEditorCamera(void)
定义: c4d_basedraw.h:868
BaseList2D::SetName
void SetName(const maxon::String &name)
定义: c4d_baselist.h:2324
CameraObject::Alloc
static CameraObject * Alloc()
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
C4DAtom::Message
Bool Message(Int32 type, void *data=nullptr)
定义: c4d_baselist.h:1394
MatrixMove
Matrix MatrixMove(const Vector &t)
BaseDraw::SetSceneCamera
void SetSceneCamera(BaseObject *op, Bool animate=false)
定义: c4d_basedraw.h:836
向量
maxon::Vec3< maxon::Float64, 1 > Vector
定义: ge_math.h:145
BaseDocument::GetActiveRenderData
RenderData * GetActiveRenderData(void)
CameraObject::StereoGetCameraCount
Int32 StereoGetCameraCount(BaseDocument *doc, BaseDraw *bd, RenderData *rd, Int32 flags) const
RenderData
定义: c4d_basedocument.h:136
BaseDocument::GetActiveObject
BaseObject * GetActiveObject(void)
C4DAtom::IsInstanceOf
Bool IsInstanceOf(Int32 id) const
定义: c4d_baselist.h:1373
GetRealCameraData
Message struct for the MSG_GETREALCAMERADATA message.
定义: c4d_baselist.h:844
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1